Skip to content

Commit 8b8e0cc

Browse files
allisonhendersondjwong
authored andcommitted
xfs: Refactor xfs_attr_rmtval_remove
Refactor xfs_attr_rmtval_remove to add helper function __xfs_attr_rmtval_remove. We will use this later when we introduce delayed attributes. This function will eventually replace xfs_attr_rmtval_remove Signed-off-by: Allison Collins <[email protected]> Reviewed-by: Chandan Rajendra <[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 1fc618d commit 8b8e0cc

File tree

2 files changed

+38
-15
lines changed

2 files changed

+38
-15
lines changed

fs/xfs/libxfs/xfs_attr_remote.c

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,8 @@ int
678678
xfs_attr_rmtval_remove(
679679
struct xfs_da_args *args)
680680
{
681-
xfs_dablk_t lblkno;
682-
int blkcnt;
683-
int error = 0;
684-
int done = 0;
681+
int error;
682+
int retval;
685683

686684
trace_xfs_attr_rmtval_remove(args);
687685

@@ -691,23 +689,47 @@ xfs_attr_rmtval_remove(
691689
/*
692690
* Keep de-allocating extents until the remote-value region is gone.
693691
*/
694-
lblkno = args->rmtblkno;
695-
blkcnt = args->rmtblkcnt;
696-
while (!done) {
697-
error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
698-
XFS_BMAPI_ATTRFORK, 1, &done);
699-
if (error)
700-
return error;
701-
error = xfs_defer_finish(&args->trans);
702-
if (error)
703-
return error;
692+
do {
693+
retval = __xfs_attr_rmtval_remove(args);
694+
if (retval && retval != -EAGAIN)
695+
return retval;
704696

705697
/*
706698
* Close out trans and start the next one in the chain.
707699
*/
708700
error = xfs_trans_roll_inode(&args->trans, args->dp);
709701
if (error)
710702
return error;
711-
}
703+
} while (retval == -EAGAIN);
704+
712705
return 0;
713706
}
707+
708+
/*
709+
* Remove the value associated with an attribute by deleting the out-of-line
710+
* buffer that it is stored on. Returns EAGAIN for the caller to refresh the
711+
* transaction and re-call the function
712+
*/
713+
int
714+
__xfs_attr_rmtval_remove(
715+
struct xfs_da_args *args)
716+
{
717+
int error, done;
718+
719+
/*
720+
* Unmap value blocks for this attr.
721+
*/
722+
error = xfs_bunmapi(args->trans, args->dp, args->rmtblkno,
723+
args->rmtblkcnt, XFS_BMAPI_ATTRFORK, 1, &done);
724+
if (error)
725+
return error;
726+
727+
error = xfs_defer_finish(&args->trans);
728+
if (error)
729+
return error;
730+
731+
if (!done)
732+
return -EAGAIN;
733+
734+
return error;
735+
}

fs/xfs/libxfs/xfs_attr_remote.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ int xfs_attr_rmtval_remove(struct xfs_da_args *args);
1414
int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map,
1515
xfs_buf_flags_t incore_flags);
1616
int xfs_attr_rmtval_invalidate(struct xfs_da_args *args);
17+
int __xfs_attr_rmtval_remove(struct xfs_da_args *args);
1718
#endif /* __XFS_ATTR_REMOTE_H__ */

0 commit comments

Comments
 (0)