Re: [f2fs-dev] [PATCH] f2fs: fix multiple f2fs_add_link() calls having same name

From: Jaegeuk Kim
Date: Wed Feb 15 2017 - 20:16:12 EST

On 02/14, Jaegeuk Kim wrote:
> On 02/15, Chao Yu wrote:
> > On 2017/2/15 2:03, Jaegeuk Kim wrote:
> > > VFS uses f2fs_lookup() to decide f2fs_add_link() call during file creation.
> > > But, if there is a race condition, f2fs_add_link() can be called multiple
> > > times, resulting in multiple dentries with a same name. This patches fixes
> > > it by adding __f2fs_find_entry() in f2fs_add_link() path.
> >
> > As during ->lookup, i_mutex will be held all the time, so there is no race
> > condition in between different file creators?
> Hehe, yup.
> I dropped this patch.

It turns out sdcardfs has a race condition between lookup and create, and it
calls vfs_create() twice. Workaround by f2fs would be needed for whole AOSP as
well. And I added to check current to avoid performance regression.