mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk.kim@samsung.com>
To: Namjae Jeon <linkinjeon@gmail.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [PATCH 2/2] f2fs: fix the inconsistent state of data pages
Date: Wed, 15 May 2013 13:41:35 +0900	[thread overview]
Message-ID: <1368592895.11843.13.camel@kjgkr> (raw)
In-Reply-To: <CAKYAXd__Vy0g-w1wu9csq4P_NEcDDL7+A56K=ZtYtv0oKs9_qw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2749 bytes --]

2013-05-15 (수), 13:04 +0900, Namjae Jeon:
> 2013/5/15, Jaegeuk Kim <jaegeuk.kim@samsung.com>:
> > In get_lock_data_page, if there is a data race between get_dnode_of_data
> > for
> > node and grab_cache_page for data, f2fs is able to face with the following
> > BUG_ON(dn.data_blkaddr == NEW_ADDR).
> >
> > kernel BUG at /home/zeus/f2fs_test/src/fs/f2fs/data.c:251!
> >  [<ffffffffa044966c>] get_lock_data_page+0x1ec/0x210 [f2fs]
> > Call Trace:
> >  [<ffffffffa043b089>] f2fs_readdir+0x89/0x210 [f2fs]
> >  [<ffffffff811a0920>] ? fillonedir+0x100/0x100
> >  [<ffffffff811a0920>] ? fillonedir+0x100/0x100
> >  [<ffffffff811a07f8>] vfs_readdir+0xb8/0xe0
> >  [<ffffffff811a0b4f>] sys_getdents+0x8f/0x110
> >  [<ffffffff816d7999>] system_call_fastpath+0x16/0x1b
> >
> > This bug is able to be occurred when the block address of the data block is
> > changed after f2fs_put_dnode().
> > In order to avoid that, this patch fixes the lock order of node and data
> > blocks in which the node block lock is covered by the data block lock.
> >
> > Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
> > ---
> >  fs/f2fs/data.c | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> > index 91ff93b..05fb5c6 100644
> > --- a/fs/f2fs/data.c
> > +++ b/fs/f2fs/data.c
> > @@ -233,18 +233,23 @@ struct page *get_lock_data_page(struct inode *inode,
> > pgoff_t index)
> >  	struct page *page;
> >  	int err;
> >
> > +repeat:
> > +	page = grab_cache_page(mapping, index);
> > +	if (!page)
> > +		return ERR_PTR(-ENOMEM);
> > +
> >  	set_new_dnode(&dn, inode, NULL, NULL, 0);
> >  	err = get_dnode_of_data(&dn, index, LOOKUP_NODE);
> > -	if (err)
> > +	if (err) {
> > +		f2fs_put_page(page, 1);
> >  		return ERR_PTR(err);
> > +	}
> >  	f2fs_put_dnode(&dn);
> >
> > -	if (dn.data_blkaddr == NULL_ADDR)
> > +	if (dn.data_blkaddr == NULL_ADDR) {
> > +		f2fs_put_page(page, 1);
> >  		return ERR_PTR(-ENOENT);
> > -repeat:
> > -	page = grab_cache_page(mapping, index);
> > -	if (!page)
> > -		return ERR_PTR(-ENOMEM);
> > +	}
> >
> >  	if (PageUptodate(page))
> >  		return page;
> Is there no need to move PageUptodate condition checking to
> grab_cache_page next ?

For the data consistency, I'd like to check index in its node block
prior to this.
Thanks,

> 
> Thanks.
> > --
> > 1.8.1.3.566.gaa39828
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> >

-- 
Jaegeuk Kim
Samsung

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2013-05-15  4:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 23:59 [PATCH 1/2] f2fs: fix inconsistency of block count during recovery Jaegeuk Kim
2013-05-14 23:59 ` [PATCH 2/2] f2fs: fix the inconsistent state of data pages Jaegeuk Kim
2013-05-15  4:04   ` Namjae Jeon
2013-05-15  4:41     ` Jaegeuk Kim [this message]
2013-05-15  3:47 ` [PATCH 1/2] f2fs: fix inconsistency of block count during recovery Namjae Jeon
2013-05-15  4:38   ` Jaegeuk Kim

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=1368592895.11843.13.camel@kjgkr \
    --to=jaegeuk.kim@samsung.com \
    --cc=linkinjeon@gmail.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®