xfs: Factor out xfs_attr_rmtval_invalidate
authorAllison Collins <allison.henderson@oracle.com>
Tue, 21 Jul 2020 04:47:25 +0000 (21:47 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 29 Jul 2020 03:28:11 +0000 (20:28 -0700)
Because new delayed attribute routines cannot roll transactions, we
carve off the parts of xfs_attr_rmtval_remove that we can use.  This
will help to reduce repetitive code later when we introduce delayed
attributes.

Signed-off-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Chandan Rajendra <chandanrlinux@gmail.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Dave Chinner <dchinner@redhat.com>
fs/xfs/libxfs/xfs_attr_remote.c
fs/xfs/libxfs/xfs_attr_remote.h

index f825eedc04b8ce794620116bd938c093b0c0ab2c..4d519691daafcb7c0d1595fc08fb3caeadaa380b 100644 (file)
@@ -634,15 +634,12 @@ xfs_attr_rmtval_set(
  * out-of-line buffer that it is stored on.
  */
 int
-xfs_attr_rmtval_remove(
+xfs_attr_rmtval_invalidate(
        struct xfs_da_args      *args)
 {
        xfs_dablk_t             lblkno;
        int                     blkcnt;
        int                     error;
-       int                     done;
-
-       trace_xfs_attr_rmtval_remove(args);
 
        /*
         * Roll through the "value", invalidating the attribute value's blocks.
@@ -670,13 +667,32 @@ xfs_attr_rmtval_remove(
                lblkno += map.br_blockcount;
                blkcnt -= map.br_blockcount;
        }
+       return 0;
+}
 
+/*
+ * Remove the value associated with an attribute by deleting the
+ * out-of-line buffer that it is stored on.
+ */
+int
+xfs_attr_rmtval_remove(
+       struct xfs_da_args      *args)
+{
+       xfs_dablk_t             lblkno;
+       int                     blkcnt;
+       int                     error = 0;
+       int                     done = 0;
+
+       trace_xfs_attr_rmtval_remove(args);
+
+       error = xfs_attr_rmtval_invalidate(args);
+       if (error)
+               return error;
        /*
         * Keep de-allocating extents until the remote-value region is gone.
         */
        lblkno = args->rmtblkno;
        blkcnt = args->rmtblkcnt;
-       done = 0;
        while (!done) {
                error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
                                    XFS_BMAPI_ATTRFORK, 1, &done);
index e1144f22b00520ab1b0270b9f6ba8e1b12b6a545..3616e888f7948df060372a8b00518bfb8dea6182 100644 (file)
@@ -13,5 +13,5 @@ int xfs_attr_rmtval_set(struct xfs_da_args *args);
 int xfs_attr_rmtval_remove(struct xfs_da_args *args);
 int xfs_attr_rmtval_stale(struct xfs_inode *ip, struct xfs_bmbt_irec *map,
                xfs_buf_flags_t incore_flags);
-
+int xfs_attr_rmtval_invalidate(struct xfs_da_args *args);
 #endif /* __XFS_ATTR_REMOTE_H__ */