[Ocfs2-devel] [patch 09/15] ocfs2: add functions to add and remove inode in orphan dir

Mark Fasheh mfasheh at suse.de
Thu Dec 18 15:18:59 PST 2014


Thanks once again for all of this by the way.

On Mon, Dec 15, 2014 at 02:51:14PM -0800, Andrew Morton wrote:
> From: Weiwei Wang <wangww631 at huawei.com>
> Subject: ocfs2: add functions to add and remove inode in orphan dir
> 
> Add functions to add inode to orphan dir and remove inode in orphan dir. 
> Here we do not call ocfs2_prepare_orphan_dir and ocfs2_orphan_add
> directly.  Because append O_DIRECT will add inode to orphan two and may
> result in more than one orphan entry for the same inode.

Just so I understand -  your problem is that ocfs2_prepare_orphan_dir() will
EEXIST when it finds the inode already there.

The solution you have below has a couple problems, stemming from the fact
that it uses the same name for an inode that is orphaned because of
nlink == 0 as that of one that is orphaned because it is undergoing direct
IO.

Having identical names in a directory is always considered an error, even
for system directories like the orphan dir. In my honest opinion we should
not do that here either.

Instead you could use a prefix for those entries - something like "dio-".

If you modify ocfs2_prepare_orphan_dir() and __ocfs2_prepare_orphan_dir()
to pass down an optional prefix which is prepended to the name you don't need a
special dio prepare function. Then we don't need ocfs2_dio_prepare_orphan_dir()
any more.

In fact, the EEXIST check now becomes valid again and you don't need to
do all that extra work in ocfs2_dio_orphan_add() to figure out whether the
name is there because of nlink == 0 or we're doing dio (or both!).

Actually, it really becomes trivial to special case dio in
ocfs2_orphan_add() so I would suggest just adding a boolean argument and
doing the bits for dio there, thus allowing us to drop
ocfs2_dio_orphan_add() too.


I hope this all helps.
	--Mark

--
Mark Fasheh



More information about the Ocfs2-devel mailing list