aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr_leaf.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-02-04 03:36:00 -0500
committerChristoph Hellwig <hch@brick.lst.de>2009-02-04 03:36:00 -0500
commite1486dea0bf4bc75a52a983281076f454a894b66 (patch)
tree53679519cd218cae7de7455af92d5005ef28d91a /fs/xfs/xfs_attr_leaf.c
parentc52e9fd8a9d3ac019680ffa315c1a0689d401ce3 (diff)
xfs: factor out attr fork reset handling
We currently duplicate code to reset the attribute fork after the last attribute has been deleted. Factor this out into a small helper. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Felix Blyakher <felixb@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r--fs/xfs/xfs_attr_leaf.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 6c323f8a4cd1..aa001629b596 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -298,6 +298,26 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
298} 298}
299 299
300/* 300/*
301 * After the last attribute is removed revert to original inode format,
302 * making all literal area available to the data fork once more.
303 */
304STATIC void
305xfs_attr_fork_reset(
306 struct xfs_inode *ip,
307 struct xfs_trans *tp)
308{
309 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
310 ip->i_d.di_forkoff = 0;
311 ip->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
312
313 ASSERT(ip->i_d.di_anextents == 0);
314 ASSERT(ip->i_afp == NULL);
315
316 ip->i_df.if_ext_max = XFS_IFORK_DSIZE(ip) / sizeof(xfs_bmbt_rec_t);
317 xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
318}
319
320/*
301 * Remove an attribute from the shortform attribute list structure. 321 * Remove an attribute from the shortform attribute list structure.
302 */ 322 */
303int 323int
@@ -344,22 +364,10 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
344 */ 364 */
345 totsize -= size; 365 totsize -= size;
346 if (totsize == sizeof(xfs_attr_sf_hdr_t) && 366 if (totsize == sizeof(xfs_attr_sf_hdr_t) &&
347 !(args->op_flags & XFS_DA_OP_ADDNAME) && 367 (mp->m_flags & XFS_MOUNT_ATTR2) &&
348 (mp->m_flags & XFS_MOUNT_ATTR2) && 368 (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) &&
349 (dp->i_d.di_format != XFS_DINODE_FMT_BTREE)) { 369 !(args->op_flags & XFS_DA_OP_ADDNAME)) {
350 /* 370 xfs_attr_fork_reset(dp, args->trans);
351 * Last attribute now removed, revert to original
352 * inode format making all literal area available
353 * to the data fork once more.
354 */
355 xfs_idestroy_fork(dp, XFS_ATTR_FORK);
356 dp->i_d.di_forkoff = 0;
357 dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
358 ASSERT(dp->i_d.di_anextents == 0);
359 ASSERT(dp->i_afp == NULL);
360 dp->i_df.if_ext_max =
361 XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
362 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
363 } else { 371 } else {
364 xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); 372 xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
365 dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); 373 dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
@@ -786,20 +794,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
786 if (forkoff == -1) { 794 if (forkoff == -1) {
787 ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2); 795 ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2);
788 ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE); 796 ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE);
789 797 xfs_attr_fork_reset(dp, args->trans);
790 /*
791 * Last attribute was removed, revert to original
792 * inode format making all literal area available
793 * to the data fork once more.
794 */
795 xfs_idestroy_fork(dp, XFS_ATTR_FORK);
796 dp->i_d.di_forkoff = 0;
797 dp->i_d.di_aformat = XFS_DINODE_FMT_EXTENTS;
798 ASSERT(dp->i_d.di_anextents == 0);
799 ASSERT(dp->i_afp == NULL);
800 dp->i_df.if_ext_max =
801 XFS_IFORK_DSIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
802 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
803 goto out; 798 goto out;
804 } 799 }
805 800