Skip to content

Commit 6cc5b5f

Browse files
allisonhendersondjwong
authored andcommitted
xfs: Refactor xfs_attr_try_sf_addname
To help pre-simplify xfs_attr_set_args, we need to hoist transaction handling up, while modularizing the adjacent code down into helpers. In this patch, hoist the commit in xfs_attr_try_sf_addname up into the calling function, and also pull the attr list creation down. Signed-off-by: Allison Collins <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Reviewed-by: Amir Goldstein <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Chandan Rajendra <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]> Acked-by: Dave Chinner <[email protected]>
1 parent 7c93d4a commit 6cc5b5f

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

fs/xfs/libxfs/xfs_attr.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,13 @@ xfs_attr_try_sf_addname(
178178
struct xfs_da_args *args)
179179
{
180180

181-
struct xfs_mount *mp = dp->i_mount;
182-
int error, error2;
181+
int error;
182+
183+
/*
184+
* Build initial attribute list (if required).
185+
*/
186+
if (dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS)
187+
xfs_attr_shortform_create(args);
183188

184189
error = xfs_attr_shortform_addname(args);
185190
if (error == -ENOSPC)
@@ -192,12 +197,10 @@ xfs_attr_try_sf_addname(
192197
if (!error && !(args->op_flags & XFS_DA_OP_NOTIME))
193198
xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG);
194199

195-
if (mp->m_flags & XFS_MOUNT_WSYNC)
200+
if (dp->i_mount->m_flags & XFS_MOUNT_WSYNC)
196201
xfs_trans_set_sync(args->trans);
197202

198-
error2 = xfs_trans_commit(args->trans);
199-
args->trans = NULL;
200-
return error ? error : error2;
203+
return error;
201204
}
202205

203206
/*
@@ -209,7 +212,7 @@ xfs_attr_set_args(
209212
{
210213
struct xfs_inode *dp = args->dp;
211214
struct xfs_buf *leaf_bp = NULL;
212-
int error;
215+
int error, error2 = 0;
213216

214217
/*
215218
* If the attribute list is non-existent or a shortform list,
@@ -219,18 +222,15 @@ xfs_attr_set_args(
219222
(dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS &&
220223
dp->i_afp->if_nextents == 0)) {
221224

222-
/*
223-
* Build initial attribute list (if required).
224-
*/
225-
if (dp->i_afp->if_format == XFS_DINODE_FMT_EXTENTS)
226-
xfs_attr_shortform_create(args);
227-
228225
/*
229226
* Try to add the attr to the attribute list in the inode.
230227
*/
231228
error = xfs_attr_try_sf_addname(dp, args);
232-
if (error != -ENOSPC)
233-
return error;
229+
if (error != -ENOSPC) {
230+
error2 = xfs_trans_commit(args->trans);
231+
args->trans = NULL;
232+
return error ? error : error2;
233+
}
234234

235235
/*
236236
* It won't fit in the shortform, transform to a leaf block.

0 commit comments

Comments
 (0)