aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs
diff options
context:
space:
mode:
authorAllison Henderson <allison.henderson@oracle.com>2018-10-18 02:20:50 -0400
committerDave Chinner <david@fromorbit.com>2018-10-18 02:20:50 -0400
commit4c74a56b9de76bb6b581274b76b52535ad77c2a7 (patch)
tree48abd647a36ae8326880720ba93f7a767e1aed11 /fs/xfs/libxfs
parente2421f0b5ff3ce279573036f5cfcb0ce28b422a9 (diff)
xfs: Add helper function xfs_attr_try_sf_addname
This patch adds a subroutine xfs_attr_try_sf_addname used by xfs_attr_set. This subrotine will attempt to add the attribute name specified in args in shortform, as well and perform error handling previously done in xfs_attr_set. This patch helps to pre-simplify xfs_attr_set for reviewing purposes and reduce indentation. New function will be added in the next patch. [dgc: moved commit to helper function, too.] Signed-off-by: Allison Henderson <allison.henderson@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r--fs/xfs/libxfs/xfs_attr.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index c6299f82a6e4..c15a1debec90 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -191,6 +191,33 @@ xfs_attr_calc_size(
191 return nblks; 191 return nblks;
192} 192}
193 193
194STATIC int
195xfs_attr_try_sf_addname(
196 struct xfs_inode *dp,
197 struct xfs_da_args *args)
198{
199
200 struct xfs_mount *mp = dp->i_mount;
201 int error, error2;
202
203 error = xfs_attr_shortform_addname(args);
204 if (error == -ENOSPC)
205 return error;
206
207 /*
208 * Commit the shortform mods, and we're done.
209 * NOTE: this is also the error path (EEXIST, etc).
210 */
211 if (!error && (args->flags & ATTR_KERNOTIME) == 0)
212 xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG);
213
214 if (mp->m_flags & XFS_MOUNT_WSYNC)
215 xfs_trans_set_sync(args->trans);
216
217 error2 = xfs_trans_commit(args->trans);
218 return error ? error : error2;
219}
220
194int 221int
195xfs_attr_set( 222xfs_attr_set(
196 struct xfs_inode *dp, 223 struct xfs_inode *dp,
@@ -204,7 +231,7 @@ xfs_attr_set(
204 struct xfs_da_args args; 231 struct xfs_da_args args;
205 struct xfs_trans_res tres; 232 struct xfs_trans_res tres;
206 int rsvd = (flags & ATTR_ROOT) != 0; 233 int rsvd = (flags & ATTR_ROOT) != 0;
207 int error, err2, local; 234 int error, local;
208 235
209 XFS_STATS_INC(mp, xs_attr_set); 236 XFS_STATS_INC(mp, xs_attr_set);
210 237
@@ -281,30 +308,10 @@ xfs_attr_set(
281 * Try to add the attr to the attribute list in 308 * Try to add the attr to the attribute list in
282 * the inode. 309 * the inode.
283 */ 310 */
284 error = xfs_attr_shortform_addname(&args); 311 error = xfs_attr_try_sf_addname(dp, &args);
285 if (error != -ENOSPC) { 312 if (error != -ENOSPC) {
286 /*
287 * Commit the shortform mods, and we're done.
288 * NOTE: this is also the error path (EEXIST, etc).
289 */
290 ASSERT(args.trans != NULL);
291
292 /*
293 * If this is a synchronous mount, make sure that
294 * the transaction goes to disk before returning
295 * to the user.
296 */
297 if (mp->m_flags & XFS_MOUNT_WSYNC)
298 xfs_trans_set_sync(args.trans);
299
300 if (!error && (flags & ATTR_KERNOTIME) == 0) {
301 xfs_trans_ichgtime(args.trans, dp,
302 XFS_ICHGTIME_CHG);
303 }
304 err2 = xfs_trans_commit(args.trans);
305 xfs_iunlock(dp, XFS_ILOCK_EXCL); 313 xfs_iunlock(dp, XFS_ILOCK_EXCL);
306 314 return error;
307 return error ? error : err2;
308 } 315 }
309 316
310 /* 317 /*