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);
|