]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
ocfs2: Fix orphan add in ocfs2_create_inode_in_orphan
authorMark Fasheh <mfasheh@suse.com>
Fri, 13 Aug 2010 22:15:19 +0000 (15:15 -0700)
committerTao Ma <tao.ma@oracle.com>
Wed, 8 Sep 2010 06:26:00 +0000 (14:26 +0800)
commit97b8f4a9dfd932997677136e11980eb2fafea91d
tree63f1a6555c61f4ce421c7b9d7358a34a6e919c6a
parentdd43bcde23c527f64897eef41aa1fed2c9905ea9
ocfs2: Fix orphan add in ocfs2_create_inode_in_orphan

ocfs2_create_inode_in_orphan() is used by reflink to create the newly
reflinked inode simultaneously in the orphan dir. This allows us to easily
handle partially-reflinked files during recovery cleanup.

We have a problem though - the orphan dir stringifies inode # to determine
a unique name under which the orphan entry dirent can be created. Since
ocfs2_create_inode_in_orphan() needs the space allocated in the orphan dir
before it can allocate the inode, we currently call into the orphan code:

       /*
        * We give the orphan dir the root blkno to fake an orphan name,
        * and allocate enough space for our insertion.
        */
       status = ocfs2_prepare_orphan_dir(osb, &orphan_dir,
                                         osb->root_blkno,
                                         orphan_name, &orphan_insert);

Using osb->root_blkno might work fine on unindexed directories, but the
orphan dir can have an index.  When it has that index, the above code fails
to allocate the proper index entry.  Later, when we try to remove the file
from the orphan dir (using the actual inode #), the reflink operation will
fail.

To fix this, I created a function ocfs2_alloc_orphaned_file() which uses the
newly split out orphan and inode alloc code to figure out what the inode
block number will be (once allocated) and then prepare the orphan dir from
that data.

Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Tao Ma <tao.ma@oracle.com>
fs/ocfs2/namei.c