Skip to content

Commit 410c198

Browse files
allisonhendersondjwong
authored andcommitted
xfs: Add remote block helper functions
This patch adds two new helper functions xfs_attr_store_rmt_blk and xfs_attr_restore_rmt_blk. These two helpers assist to remove redundant code associated with storing and retrieving remote blocks during the attr set operations. Signed-off-by: Allison Collins <[email protected]> Reviewed-by: Chandan Rajendra <[email protected]> Reviewed-by: Amir Goldstein <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Acked-by: Dave Chinner <[email protected]>
1 parent f44df68 commit 410c198

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,30 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
564564
* External routines when attribute list is one block
565565
*========================================================================*/
566566

567+
/* Store info about a remote block */
568+
STATIC void
569+
xfs_attr_save_rmt_blk(
570+
struct xfs_da_args *args)
571+
{
572+
args->blkno2 = args->blkno;
573+
args->index2 = args->index;
574+
args->rmtblkno2 = args->rmtblkno;
575+
args->rmtblkcnt2 = args->rmtblkcnt;
576+
args->rmtvaluelen2 = args->rmtvaluelen;
577+
}
578+
579+
/* Set stored info about a remote block */
580+
STATIC void
581+
xfs_attr_restore_rmt_blk(
582+
struct xfs_da_args *args)
583+
{
584+
args->blkno = args->blkno2;
585+
args->index = args->index2;
586+
args->rmtblkno = args->rmtblkno2;
587+
args->rmtblkcnt = args->rmtblkcnt2;
588+
args->rmtvaluelen = args->rmtvaluelen2;
589+
}
590+
567591
/*
568592
* Tries to add an attribute to an inode in leaf form
569593
*
@@ -598,11 +622,7 @@ xfs_attr_leaf_try_add(
598622

599623
/* save the attribute state for later removal*/
600624
args->op_flags |= XFS_DA_OP_RENAME; /* an atomic rename */
601-
args->blkno2 = args->blkno; /* set 2nd entry info*/
602-
args->index2 = args->index;
603-
args->rmtblkno2 = args->rmtblkno;
604-
args->rmtblkcnt2 = args->rmtblkcnt;
605-
args->rmtvaluelen2 = args->rmtvaluelen;
625+
xfs_attr_save_rmt_blk(args);
606626

607627
/*
608628
* clear the remote attr state now that it is saved so that the
@@ -701,11 +721,8 @@ xfs_attr_leaf_addname(
701721
* Dismantle the "old" attribute/value pair by removing
702722
* a "remote" value (if it exists).
703723
*/
704-
args->index = args->index2;
705-
args->blkno = args->blkno2;
706-
args->rmtblkno = args->rmtblkno2;
707-
args->rmtblkcnt = args->rmtblkcnt2;
708-
args->rmtvaluelen = args->rmtvaluelen2;
724+
xfs_attr_restore_rmt_blk(args);
725+
709726
if (args->rmtblkno) {
710727
error = xfs_attr_rmtval_invalidate(args);
711728
if (error)
@@ -919,11 +936,7 @@ xfs_attr_node_addname(
919936

920937
/* save the attribute state for later removal*/
921938
args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op */
922-
args->blkno2 = args->blkno; /* set 2nd entry info*/
923-
args->index2 = args->index;
924-
args->rmtblkno2 = args->rmtblkno;
925-
args->rmtblkcnt2 = args->rmtblkcnt;
926-
args->rmtvaluelen2 = args->rmtvaluelen;
939+
xfs_attr_save_rmt_blk(args);
927940

928941
/*
929942
* clear the remote attr state now that it is saved so that the
@@ -1035,11 +1048,8 @@ xfs_attr_node_addname(
10351048
* Dismantle the "old" attribute/value pair by removing
10361049
* a "remote" value (if it exists).
10371050
*/
1038-
args->index = args->index2;
1039-
args->blkno = args->blkno2;
1040-
args->rmtblkno = args->rmtblkno2;
1041-
args->rmtblkcnt = args->rmtblkcnt2;
1042-
args->rmtvaluelen = args->rmtvaluelen2;
1051+
xfs_attr_restore_rmt_blk(args);
1052+
10431053
if (args->rmtblkno) {
10441054
error = xfs_attr_rmtval_invalidate(args);
10451055
if (error)

0 commit comments

Comments
 (0)