From: Eric Biggers <ebiggers@kernel.org>
To: Gao Xiang <hsiangkao@gmx.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
kernel-team@android.com, linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: get parent inode when recovering pino
Date: Wed, 6 May 2020 12:16:13 -0700 [thread overview]
Message-ID: <20200506191613.GB842@sol.localdomain> (raw)
In-Reply-To: <20200506064709.GA25482@hsiangkao-HP-ZHAN-66-Pro-G1>
On Wed, May 06, 2020 at 02:47:19PM +0800, Gao Xiang wrote:
> On Wed, May 06, 2020 at 09:58:22AM +0800, Gao Xiang wrote:
> > On Tue, May 05, 2020 at 06:24:28PM -0700, Eric Biggers wrote:
> > > On Wed, May 06, 2020 at 08:14:07AM +0800, Gao Xiang wrote:
> > > > >
> > > > > Actually, I think this is wrong because the fsync can be done via a file
> > > > > descriptor that was opened to a now-deleted link to the file.
> > > >
> > > > I'm still confused about this...
> > > >
> > > > I don't know what's wrong with this version from my limited knowledge?
> > > > inode itself is locked when fsyncing, so
> > > >
> > > > if the fsync inode->i_nlink == 1, this inode has only one hard link
> > > > (not deleted yet) and should belong to a single directory; and
> > > >
> > > > the only one parent directory would not go away (not deleted as well)
> > > > since there are some dirents in it (not empty).
> > > >
> > > > Could kindly explain more so I would learn more about this scenario?
> > > > Thanks a lot!
> > >
> > > i_nlink == 1 just means that there is one non-deleted link. There can be links
> > > that have since been deleted, and file descriptors can still be open to them.
> >
> > Thanks for your inspiration. You are right, thanks.
> >
> > Correct my words... I didn't check f2fs code just now, it seems f2fs doesn't
> > take inode_lock as some other fs like __generic_file_fsync or ubifs_fsync.
> >
> > And i_sem locks nlink / try_to_fix_pino similarly in some extent. It seems
> > no race by using d_find_alias here. Thanks again.
> >
>
> (think more little bit just now...)
>
> Thread 1: Thread 2 (fsync):
> vfs_unlink try_to_fix_pino
> f2fs_unlink
> f2fs_delete_entry
> f2fs_drop_nlink (i_sem, inode->i_nlink = 1)
>
> (... but this dentry still hashed) i_sem, check inode->i_nlink = 1
> i_sem d_find_alias
>
> d_delete
>
> I'm not sure if fsync could still use some wrong alias by chance..
> completely untested, maybe just noise...
>
Right, good observation. My patch makes it better, but it's still broken.
I don't know how to fix it. If we see i_nlink == 1 and multiple hashed
dentries, there doesn't appear to be a way to distingush which one corresponds
to the remaining link on-disk (if any; it may not even be in the dcache), and
which correspond to links that vfs_unlink() has deleted from disk but hasn't yet
done d_delete() on.
One idea would be choose one, then take inode_lock_shared(dir) and do
__f2fs_find_entry() to check if the dentry is really still on-disk. That's
heavyweight and error-prone though, and the locking could cause problems.
I'm wondering though, does f2fs really need try_to_fix_pino() at all, and did it
ever really work? It never actually updates the f2fs_inode::i_name to match the
new directory. So independently of this bug with deleted links, I don't see how
it can possibly work as intended.
- Eric
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
next prev parent reply other threads:[~2020-05-06 19:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-05 15:31 [f2fs-dev] [PATCH] f2fs: get parent inode when recovering pino Jaegeuk Kim
2020-05-05 16:58 ` Eric Biggers
2020-05-05 17:59 ` Eric Biggers
2020-05-05 18:20 ` Jaegeuk Kim
2020-05-05 18:13 ` Jaegeuk Kim
2020-05-05 18:19 ` Eric Biggers
2020-05-05 18:49 ` Jaegeuk Kim
2020-05-05 19:01 ` Eric Biggers
2020-05-05 19:08 ` Jaegeuk Kim
2020-05-06 0:14 ` Gao Xiang
2020-05-06 1:24 ` Eric Biggers
2020-05-06 1:58 ` Gao Xiang via Linux-f2fs-devel
2020-05-06 6:47 ` Gao Xiang
2020-05-06 19:16 ` Eric Biggers [this message]
2020-05-06 22:36 ` Gao Xiang
2020-05-07 6:38 ` Chao Yu
2020-05-07 7:23 ` Gao Xiang
2020-05-06 6:55 ` Chao Yu
2020-05-07 6:30 ` 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=20200506191613.GB842@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=hsiangkao@gmx.com \
--cc=jaegeuk@kernel.org \
--cc=kernel-team@android.com \
--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;
as well as URLs for NNTP newsgroup(s).