xfs
[Top] [All Lists]

[RFC 07/17] xfs: (parent ptr) add parent pointer support to xfs_create

To: xfs@xxxxxxxxxxx
Subject: [RFC 07/17] xfs: (parent ptr) add parent pointer support to xfs_create
From: Mark Tinguely <tinguely@xxxxxxx>
Date: Wed, 15 Jan 2014 16:00:19 -0600
Delivered-to: xfs@xxxxxxxxxxx
References: <20140115220012.624438534@xxxxxxx>
User-agent: quilt/0.51-1
Add the parent inode / entry offset into the parent inode entries
when creating a new file or directory. The first entry will always
go into the inode.

---
 fs/xfs/xfs_inode.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Index: b/fs/xfs/xfs_inode.c
===================================================================
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1163,6 +1163,7 @@ xfs_create(
        struct xfs_dquot        *pdqp = NULL;
        struct xfs_trans_res    tres;
        uint                    resblks;
+       uint                    offset;
 
        trace_xfs_create(dp, name);
 
@@ -1265,11 +1266,17 @@ xfs_create(
        error = xfs_dir_createname(tp, dp, name, ip->i_ino,
                                        &first_block, &free_list, resblks ?
                                        resblks - XFS_IALLOC_SPACE_RES(mp) : 0,
-                                       NULL);
+                                       &offset);
        if (error) {
                ASSERT(error != ENOSPC);
                goto out_trans_abort;
        }
+
+       if (xfs_sb_version_hasparent(&mp->m_sb)) {
+               /* set the parent pointer and offset to the inode core fields */
+               ip->i_d.di_parent = cpu_to_be64(dp->i_ino);
+               ip->i_d.di_poffset = cpu_to_be32(offset);
+       }
        xfs_trans_ichgtime(tp, dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
        xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
 


<Prev in Thread] Current Thread [Next in Thread>