mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Bo Ye (叶波)" <Bo.Ye@mediatek.com>
To: "jaegeuk@kernel.org" <jaegeuk@kernel.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"xiongping1@xiaomi.com" <xiongping1@xiaomi.com>,
	"angelogioacchino.delregno@collabora.com" 
	<angelogioacchino.delregno@collabora.com>,
	"chao@kernel.org" <chao@kernel.org>,
	"qixiaoyu1@xiaomi.com" <qixiaoyu1@xiaomi.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Browse Zhang (张磊)" <Browse.Zhang@mediatek.com>,
	"Peng Zhou (周鹏)" <Peng.Zhou@mediatek.com>,
	"Light Hsieh (謝明燈)" <Light.Hsieh@mediatek.com>,
	"Yongdong Zhang (张永东)" <Yongdong.Zhang@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"Qilin Tan (谭麒麟)" <Qilin.Tan@mediatek.com>,
	"linux-f2fs-devel@lists.sourceforge.net"
	<linux-f2fs-devel@lists.sourceforge.net>
Subject: Re: [PATCH 2/2] f2fs: add __pack attribute for extent_info
Date: Fri, 7 Apr 2023 09:38:06 +0000	[thread overview]
Message-ID: <e9afd9e1901b4ae7cff4cb4a14483125d05163c9.camel@mediatek.com> (raw)
In-Reply-To: <ec3f83d3-c00c-17d5-c967-2e3e7a4798c7@kernel.org>

On Sat, 2023-04-01 at 09:00 +0800, Chao Yu wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> On 2023/3/31 17:26, Bo Ye wrote:
> > From: Qilin Tan <qilin.tan@mediatek.com>
> > 
> > Need add __pack for struct extent_info to align to memory
> > layout of struct rb_entry.
> 
> Jaegeuk has fixed this bug w/ below patchset, please check it:
> 
> 
https://lore.kernel.org/linux-f2fs-devel/20230313201216.924234-1-jaegeuk@kernel.org/
> 
> Thanks,
> 
  OK, under verifying, I will reply with test result. 
  Thanks a lot!
> > 
> > struct rb_entry {
> >      struct rb_node rb_node;     /* rb node located in rb-tree */
> >      union {
> >          struct {
> >              unsigned int ofs;   /* start offset of the entry */
> >              unsigned int len;   /* length of the entry */
> >          };
> >          unsigned long long key;     /* 64-bits key */
> >      } __packed;
> > };
> > 
> > struct extent_info {
> >      unsigned int fofs;      /* start offset in a file */
> >      unsigned int len;       /* length of the extent */
> >      union {
> >          ...
> >          /* block age extent_cache */
> >          struct {
> >              /* block age of the extent */
> >              unsigned long long age;
> >              /* last total blocks allocated */
> >              unsigned long long last_blocks;
> >          };
> > };
> > 
> > The new fields(age, last_blocks) are u64 in change 71644dff4811, it
> > cause the memory alignment based on 8 bytes in some complier. So
> > the
> > field fofs and len are alloced with 8 bytes and using the last 4
> > byts.
> > Its memory is not aligned with struct rb_entry. the ofs of rb_entry
> > pointer to a invalid value and cause writing file failed.
> > 
> > struct extent_info's offset should be 12 rather than 16 from the
> > beginning of struct rb_entry.
> > 
> > The offset dump for the bad case as:
> > kworker/u16:6:
> > [name:f2fs&]f2fs_lookup_rb_tree_for_insert:MTK_DEBUG: ino=1629
> > re=0xc675dc08 ofs=0 re->ofs=0, re->len=68 ei=0xc675dc18 ei.fofs=68
> > ei.len=277
> > 
> > Fixes: 71644dff4811 ("f2fs: add block_age-based extent cache")
> > Signed-off-by: Bo Ye <bo.ye@mediatek.com>
> > Signed-off-by: Qilin Tan <qilin.tan@mediatek.com>
> > ---
> >   fs/f2fs/f2fs.h | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> > index b0ab2062038a..7c690667a42f 100644
> > --- a/fs/f2fs/f2fs.h
> > +++ b/fs/f2fs/f2fs.h
> > @@ -660,7 +660,7 @@ struct extent_info {
> >                       unsigned long long last_blocks;
> >               };
> >       };
> > -};
> > +} __packed;
> > 
> >   struct extent_node {
> >       struct rb_node rb_node;         /* rb node located in rb-tree 
> > */

  reply	other threads:[~2023-04-07  9:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  9:26 [PATCH 1/2] f2fs: fix iostat lock protection Bo Ye
2023-03-31  9:26 ` [PATCH 2/2] f2fs: add __pack attribute for extent_info Bo Ye
2023-04-01  1:00   ` Chao Yu
2023-04-07  9:38     ` Bo Ye (叶波) [this message]
2023-04-01  0:53 ` [PATCH 1/2] f2fs: fix iostat lock protection Chao Yu
2023-04-03 18:30 ` [f2fs-dev] " patchwork-bot+f2fs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9afd9e1901b4ae7cff4cb4a14483125d05163c9.camel@mediatek.com \
    --to=bo.ye@mediatek.com \
    --cc=Browse.Zhang@mediatek.com \
    --cc=Light.Hsieh@mediatek.com \
    --cc=Peng.Zhou@mediatek.com \
    --cc=Qilin.Tan@mediatek.com \
    --cc=Yongdong.Zhang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=qixiaoyu1@xiaomi.com \
    --cc=xiongping1@xiaomi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®