[Ocfs2-devel] [patch 04/11] ocfs2: fix a tiny race when running dirop_fileop_racer

Mark Fasheh mfasheh at suse.de
Wed Feb 12 15:12:21 PST 2014


On Tue, Feb 11, 2014 at 08:42:07PM +0800, Xue jiufei wrote:
> > I am confused as to how this race happens.
> > 
> > Something like "ls /race/16' shouldn't hold locks on 'race' and '16' at the
> > same time. It should look more like:
> > 
> > <userspace does readdir /race/16>
> > PR race
> > <kernel looks up '16' in 'race'>
> > Unlock PR race
> > PR 16
> > <get dirents from '16'>
> > Unlock PR 16
> > <return dirents to userspace>
> > 
> > Can you please explain where I may be going wrong? Also an strace of the
> > locked up 'ls' as well as the output of sysrq-t when it's deadlocked would
> > help show what's going on.
> > 	--Mark
> > 
> when doing 'ls /race/16', it calls vfs_fstatat->..->d_alloc()->ocfs2_lookup()
> after readdir(). ocfs2_lookup() first get PR lock of race, and then get PR
> lock of 16 in ocfs2_iget() without unlocking PR race.

Ok I see how that can happen now, thanks! Another solution might be to
trylock in ocfs2_read_locked_inode() but I think this is a better approach
as we'll leave the potential impact in rename. I will give the patch another
look and send my review shortly, thanks!
	--Mark

--
Mark Fasheh



More information about the Ocfs2-devel mailing list