Return the directory offset information when removing an entry to the
directory.
This offset will be used as the parent pointer offset in xfs_remove.
---
fs/xfs/xfs_dir2.c | 5 ++++-
fs/xfs/xfs_dir2.h | 3 ++-
fs/xfs/xfs_dir2_block.c | 1 +
fs/xfs/xfs_dir2_leaf.c | 1 +
fs/xfs/xfs_dir2_node.c | 1 +
fs/xfs/xfs_dir2_sf.c | 2 ++
fs/xfs/xfs_inode.c | 4 ++--
7 files changed, 13 insertions(+), 4 deletions(-)
Index: b/fs/xfs/xfs_dir2.c
===================================================================
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -340,7 +340,8 @@ xfs_dir_removename(
xfs_ino_t ino,
xfs_fsblock_t *first, /* bmap's firstblock */
xfs_bmap_free_t *flist, /* bmap's freeblock list */
- xfs_extlen_t total) /* bmap's total block count */
+ xfs_extlen_t total, /* bmap's total block count */
+ __uint32_t *offset) /* out: return entry's dir offset */
{
xfs_da_args_t args;
int rval;
@@ -374,6 +375,8 @@ xfs_dir_removename(
rval = xfs_dir2_leaf_removename(&args);
else
rval = xfs_dir2_node_removename(&args);
+ if (offset)
+ *offset = args.offset;
return rval;
}
Index: b/fs/xfs/xfs_dir2.h
===================================================================
--- a/fs/xfs/xfs_dir2.h
+++ b/fs/xfs/xfs_dir2.h
@@ -127,7 +127,8 @@ extern int xfs_dir_lookup(struct xfs_tra
extern int xfs_dir_removename(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_name *name, xfs_ino_t ino,
xfs_fsblock_t *first,
- struct xfs_bmap_free *flist, xfs_extlen_t tot);
+ struct xfs_bmap_free *flist, xfs_extlen_t tot,
+ __uint32_t *offset);
extern int xfs_dir_replace(struct xfs_trans *tp, struct xfs_inode *dp,
struct xfs_name *name, xfs_ino_t inum,
xfs_fsblock_t *first,
Index: b/fs/xfs/xfs_dir2_block.c
===================================================================
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -796,6 +796,7 @@ xfs_dir2_block_removename(
/*
* Point to the data entry using the leaf entry.
*/
+ args->offset = be32_to_cpu(blp[ent].address);
dep = (xfs_dir2_data_entry_t *)
((char *)hdr + xfs_dir2_dataptr_to_off(mp,
be32_to_cpu(blp[ent].address)));
/*
Index: b/fs/xfs/xfs_dir2_leaf.c
===================================================================
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -1381,6 +1381,7 @@ xfs_dir2_leaf_removename(
* Point to the leaf entry, use that to point to the data entry.
*/
lep = &ents[index];
+ args->offset = be32_to_cpu(lep->address);
db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
dep = (xfs_dir2_data_entry_t *)
((char *)hdr + xfs_dir2_dataptr_to_off(mp,
be32_to_cpu(lep->address)));
Index: b/fs/xfs/xfs_dir2_node.c
===================================================================
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -1192,6 +1192,7 @@ xfs_dir2_leafn_remove(
/*
* Extract the data block and offset from the entry.
*/
+ args->offset = be32_to_cpu(lep->address);
db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
ASSERT(dblk->blkno == db);
off = xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address));
Index: b/fs/xfs/xfs_dir2_sf.c
===================================================================
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -847,6 +847,8 @@ xfs_dir2_sf_removename(
XFS_CMP_EXACT) {
ASSERT(dp->d_ops->sf_get_ino(sfp, sfep) ==
args->inumber);
+ args->offset = xfs_dir2_byte_to_dataptr(dp->i_mount,
+ xfs_dir2_sf_get_offset(sfep));
break;
}
}
Index: b/fs/xfs/xfs_inode.c
===================================================================
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2542,7 +2542,7 @@ xfs_remove(
xfs_bmap_init(&free_list, &first_block);
error = xfs_dir_removename(tp, dp, name, ip->i_ino,
- &first_block, &free_list, resblks);
+ &first_block, &free_list, resblks, NULL);
if (error) {
ASSERT(error != ENOENT);
goto out_bmap_cancel;
@@ -2847,7 +2847,7 @@ xfs_rename(
}
error = xfs_dir_removename(tp, src_dp, src_name, src_ip->i_ino,
- &first_block, &free_list, spaceres);
+ &first_block, &free_list, spaceres, NULL);
if (error)
goto abort_return;
|