From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <chao@kernel.org>
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH 2/2] f2fs: avoid f2fs_bug_on if f2fs_get_meta_page_nofail got EIO
Date: Tue, 18 Sep 2018 10:55:33 -0700 [thread overview]
Message-ID: <20180918175533.GD91945@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <4ac0b893-7437-c5f3-e710-64156df09ced@kernel.org>
On 09/18, Chao Yu wrote:
> On 2018/9/18 10:18, Jaegeuk Kim wrote:
> > This patch avoids BUG_ON when f2fs_get_meta_page_nofail got EIO during
> > xfstests/generic/475.
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/checkpoint.c | 2 +-
> > fs/f2fs/gc.c | 2 ++
> > fs/f2fs/node.c | 12 ++++++++++--
> > fs/f2fs/recovery.c | 2 ++
> > fs/f2fs/segment.c | 3 +++
> > 5 files changed, 18 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
> > index 01e0d8f5bbbe..6ce3cb6502dd 100644
> > --- a/fs/f2fs/checkpoint.c
> > +++ b/fs/f2fs/checkpoint.c
> > @@ -121,7 +121,7 @@ struct page *f2fs_get_meta_page_nofail(struct f2fs_sb_info *sbi, pgoff_t index)
> > goto retry;
> >
> > f2fs_stop_checkpoint(sbi, false);
> > - f2fs_bug_on(sbi, 1);
> > + return NULL;
>
> How about propagate PTR_ERR(page) to caller?
Done.
>
> > }
> >
> > return page;
> > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> > index 4bcc8a59fdef..d049865887cf 100644
> > --- a/fs/f2fs/gc.c
> > +++ b/fs/f2fs/gc.c
> > @@ -1070,6 +1070,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
> > /* reference all summary page */
> > while (segno < end_segno) {
> > sum_page = f2fs_get_sum_page(sbi, segno++);
> > + if (!sum_page)
> > + return -EIO;
>
> Well, for large section, we need to release all referenced sum page by
> f2fs_put_page().
Done.
>
> > unlock_page(sum_page);
> > }
> >
> > diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> > index fa2381c0bc47..b3595522c35b 100644
> > --- a/fs/f2fs/node.c
> > +++ b/fs/f2fs/node.c
> > @@ -126,6 +126,8 @@ static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
> >
> > /* get current nat block page with lock */
> > src_page = get_current_nat_page(sbi, nid);
> > + if (!src_page)
> > + return NULL;
> > dst_page = f2fs_grab_meta_page(sbi, dst_off);
> > f2fs_bug_on(sbi, PageDirty(src_page));
> >
> > @@ -2265,8 +2267,12 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi,
> > nm_i->nat_block_bitmap)) {
> > struct page *page = get_current_nat_page(sbi, nid);
> >
> > - ret = scan_nat_page(sbi, page, nid);
> > - f2fs_put_page(page, 1);
> > + if (page) {
> > + ret = scan_nat_page(sbi, page, nid);
> > + f2fs_put_page(page, 1);
> > + } else {
> > + ret = -EIO;
> > + }
> >
> > if (ret) {
> > up_read(&nm_i->nat_tree_lock);
>
> Should propagate the error to f2fs_alloc_nid()?
Done.
>
> > @@ -2724,6 +2730,8 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
> > down_write(&curseg->journal_rwsem);
> > } else {
> > page = get_next_nat_page(sbi, start_nid);
> > + if (!page)
> > + return;
>
> Ditto, propagate such error to write_checkpoint()?
Done.
>
> > nat_blk = page_address(page);
> > f2fs_bug_on(sbi, !nat_blk);
> > }
> > diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
> > index 56d34193a74b..a3dce16bfd6c 100644
> > --- a/fs/f2fs/recovery.c
> > +++ b/fs/f2fs/recovery.c
> > @@ -355,6 +355,8 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
> > }
> >
> > sum_page = f2fs_get_sum_page(sbi, segno);
> > + if (!sum_page)
> > + return -EIO;
> > sum_node = (struct f2fs_summary_block *)page_address(sum_page);
> > sum = sum_node->entries[blkoff];
> > f2fs_put_page(sum_page, 1);
> > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> > index aa96a371aaf8..cfc9eb492da1 100644
> > --- a/fs/f2fs/segment.c
> > +++ b/fs/f2fs/segment.c
> > @@ -2487,6 +2487,7 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)
> > __next_free_blkoff(sbi, curseg, 0);
> >
> > sum_page = f2fs_get_sum_page(sbi, new_segno);
> > + f2fs_bug_on(sbi, !sum_page);
>
> Well, next time we may panic here...
This is the same as before, and it's almost impossible to hit anyway in
production.
Thanks,
>
> In product, for EIO case, usually we just reboot cell phone directly to avoid
> potential data loss later.
>
> So I just set DEFAULT_RETRY_IO_COUNT to 32 temporarily to pass xfstest IO error
> injection cases.
>
> Thanks,
>
> > sum_node = (struct f2fs_summary_block *)page_address(sum_page);
> > memcpy(curseg->sum_blk, sum_node, SUM_ENTRY_SIZE);
> > f2fs_put_page(sum_page, 1);
> > @@ -3971,6 +3972,8 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
> >
> > se = &sit_i->sentries[start];
> > page = get_current_sit_page(sbi, start);
> > + if (!page)
> > + return err;
> > sit_blk = (struct f2fs_sit_block *)page_address(page);
> > sit = sit_blk->entries[SIT_ENTRY_OFFSET(sit_i, start)];
> > f2fs_put_page(page, 1);
> >
next prev parent reply other threads:[~2018-09-18 17:55 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-18 2:18 [PATCH 1/2] f2fs: report ENOENT correct in f2fs_rename Jaegeuk Kim
2018-09-18 2:18 ` [PATCH 2/2] f2fs: avoid f2fs_bug_on if f2fs_get_meta_page_nofail got EIO Jaegeuk Kim
2018-09-18 13:16 ` [f2fs-dev] " Chao Yu
2018-09-18 17:55 ` Jaegeuk Kim [this message]
2018-09-18 17:56 ` [PATCH 2/2 v2] " Jaegeuk Kim
2018-09-19 1:45 ` [f2fs-dev] " Chao Yu
2018-09-19 22:47 ` Jaegeuk Kim
2018-09-20 6:07 ` Chao Yu
2018-09-20 21:46 ` Jaegeuk Kim
2018-09-21 1:30 ` Chao Yu
2018-09-26 0:18 ` Jaegeuk Kim
2018-09-26 1:10 ` Chao Yu
2018-09-26 8:31 ` Chao Yu
2018-09-26 19:49 ` Jaegeuk Kim
2018-09-27 1:14 ` Chao Yu
2018-09-27 4:58 ` Jaegeuk Kim
2018-09-27 5:45 ` Chao Yu
2018-09-20 21:48 ` [f2fs-dev] [PATCH 2/2 v3] " Jaegeuk Kim
2018-09-27 12:09 ` Chao Yu
2018-09-18 12:47 ` [f2fs-dev] [PATCH 1/2] f2fs: report ENOENT correct in f2fs_rename Chao Yu
2018-09-18 17:59 ` Jaegeuk Kim
2018-09-19 1:48 ` Chao Yu
2018-09-19 0:47 ` Sahitya Tummala
2018-09-19 22:50 ` [PATCH 1/2 v2] " Jaegeuk Kim
2018-09-20 6:14 ` [f2fs-dev] " Chao Yu
2018-09-20 21:35 ` [f2fs-dev] [PATCH 1/2 v3] " Jaegeuk Kim
2018-09-21 1:31 ` Chao Yu
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=20180918175533.GD91945@jaegeuk-macbookpro.roam.corp.google.com \
--to=jaegeuk@kernel.org \
--cc=chao@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome