Message ID | 1709892753-27461-1-git-send-email-zhiguo.niu@unisoc.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [f2fs-dev,1/2] f2fs: fix to remove f2fs_bug_on in add_bio_entry | expand |
On 2024/3/8 18:12, Zhiguo Niu wrote: > add_bio_entry should not trigger system panic when bio_add_page fail, > fix to remove it. > > Fixes: 0b20fcec8651 ("f2fs: cache global IPU bio") > Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com> > --- > fs/f2fs/data.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index d9494b5..f8ae684 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -759,8 +759,10 @@ static void add_bio_entry(struct f2fs_sb_info *sbi, struct bio *bio, > be->bio = bio; > bio_get(bio); > > - if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) > - f2fs_bug_on(sbi, 1); > + if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) { > + bio_put(bio); I didn't get it, why new created bio has no space to store one page? Thanks, > + return; > + } > > f2fs_down_write(&io->bio_list_lock); > list_add_tail(&be->list, &io->bio_list);
On Mon, Mar 11, 2024 at 11:54 AM Chao Yu <chao@kernel.org> wrote: > > On 2024/3/8 18:12, Zhiguo Niu wrote: > > add_bio_entry should not trigger system panic when bio_add_page fail, > > fix to remove it. > > > > Fixes: 0b20fcec8651 ("f2fs: cache global IPU bio") > > Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com> > > --- > > fs/f2fs/data.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > > index d9494b5..f8ae684 100644 > > --- a/fs/f2fs/data.c > > +++ b/fs/f2fs/data.c > > @@ -759,8 +759,10 @@ static void add_bio_entry(struct f2fs_sb_info *sbi, struct bio *bio, > > be->bio = bio; > > bio_get(bio); > > > > - if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) > > - f2fs_bug_on(sbi, 1); > > + if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) { > > + bio_put(bio); > > I didn't get it, why new created bio has no space to store one page? > > Thanks, Dear Chao, I got what you mean. We are doing bio merge optimization in bio_add_page. After looking at all the locations where bio_add_page is called, and think it is unreasonable to panic the system if bio_add_page fails. but it is not impossible to panic in the current flow about bio_add_page. so keeping it as is is a good choice. thanks! > > + return; > > + } > > > > f2fs_down_write(&io->bio_list_lock); > > list_add_tail(&be->list, &io->bio_list);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d9494b5..f8ae684 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -759,8 +759,10 @@ static void add_bio_entry(struct f2fs_sb_info *sbi, struct bio *bio, be->bio = bio; bio_get(bio); - if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) - f2fs_bug_on(sbi, 1); + if (bio_add_page(bio, page, PAGE_SIZE, 0) != PAGE_SIZE) { + bio_put(bio); + return; + } f2fs_down_write(&io->bio_list_lock); list_add_tail(&be->list, &io->bio_list);
add_bio_entry should not trigger system panic when bio_add_page fail, fix to remove it. Fixes: 0b20fcec8651 ("f2fs: cache global IPU bio") Signed-off-by: Zhiguo Niu <zhiguo.niu@unisoc.com> --- fs/f2fs/data.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)