aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-05-13 02:34:14 -0400
committerDave Chinner <david@fromorbit.com>2014-05-13 02:34:14 -0400
commitc5b4ac39a4cb6a9a79025106a471f0738b3cb525 (patch)
tree010f30d45ef4b82bab147b689b3256d0c112f7c5 /fs/xfs
parentc9eaa447e77efe77b7fa4c953bd62de8297fd6c5 (diff)
xfs: fold xfs_attr_set_int into xfs_attr_set
Plus various minor style fixes to the new xfs_attr_set. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_attr.c110
1 files changed, 44 insertions, 66 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 01b6a0102fbd..eb3ae8fcaf74 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -221,26 +221,32 @@ xfs_attr_calc_size(
221 return nblks; 221 return nblks;
222} 222}
223 223
224STATIC int 224int
225xfs_attr_set_int( 225xfs_attr_set(
226 struct xfs_inode *dp, 226 struct xfs_inode *dp,
227 struct xfs_name *name, 227 const unsigned char *name,
228 unsigned char *value, 228 unsigned char *value,
229 int valuelen, 229 int valuelen,
230 int flags) 230 int flags)
231{ 231{
232 xfs_da_args_t args;
233 xfs_fsblock_t firstblock;
234 xfs_bmap_free_t flist;
235 int error, err2, committed;
236 struct xfs_mount *mp = dp->i_mount; 232 struct xfs_mount *mp = dp->i_mount;
233 struct xfs_da_args args;
234 struct xfs_bmap_free flist;
237 struct xfs_trans_res tres; 235 struct xfs_trans_res tres;
236 struct xfs_name xname;
237 xfs_fsblock_t firstblock;
238 int rsvd = (flags & ATTR_ROOT) != 0; 238 int rsvd = (flags & ATTR_ROOT) != 0;
239 int local; 239 int error, err2, committed, local;
240
241 XFS_STATS_INC(xs_attr_set);
242
243 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
244 return EIO;
245
246 error = xfs_attr_name_to_xname(&xname, name);
247 if (error)
248 return error;
240 249
241 /*
242 * Attach the dquots to the inode.
243 */
244 error = xfs_qm_dqattach(dp, 0); 250 error = xfs_qm_dqattach(dp, 0);
245 if (error) 251 if (error)
246 return error; 252 return error;
@@ -251,18 +257,16 @@ xfs_attr_set_int(
251 */ 257 */
252 if (XFS_IFORK_Q(dp) == 0) { 258 if (XFS_IFORK_Q(dp) == 0) {
253 int sf_size = sizeof(xfs_attr_sf_hdr_t) + 259 int sf_size = sizeof(xfs_attr_sf_hdr_t) +
254 XFS_ATTR_SF_ENTSIZE_BYNAME(name->len, valuelen); 260 XFS_ATTR_SF_ENTSIZE_BYNAME(xname.len, valuelen);
255 261
256 if ((error = xfs_bmap_add_attrfork(dp, sf_size, rsvd))) 262 error = xfs_bmap_add_attrfork(dp, sf_size, rsvd);
257 return(error); 263 if (error)
264 return error;
258 } 265 }
259 266
260 /* 267 memset(&args, 0, sizeof(args));
261 * Fill in the arg structure for this request. 268 args.name = xname.name;
262 */ 269 args.namelen = xname.len;
263 memset((char *)&args, 0, sizeof(args));
264 args.name = name->name;
265 args.namelen = name->len;
266 args.value = value; 270 args.value = value;
267 args.valuelen = valuelen; 271 args.valuelen = valuelen;
268 args.flags = flags; 272 args.flags = flags;
@@ -274,7 +278,7 @@ xfs_attr_set_int(
274 args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT; 278 args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
275 279
276 /* Size is now blocks for attribute data */ 280 /* Size is now blocks for attribute data */
277 args.total = xfs_attr_calc_size(dp, name->len, valuelen, &local); 281 args.total = xfs_attr_calc_size(dp, xname.len, valuelen, &local);
278 282
279 /* 283 /*
280 * Start our first transaction of the day. 284 * Start our first transaction of the day.
@@ -303,7 +307,7 @@ xfs_attr_set_int(
303 error = xfs_trans_reserve(args.trans, &tres, args.total, 0); 307 error = xfs_trans_reserve(args.trans, &tres, args.total, 0);
304 if (error) { 308 if (error) {
305 xfs_trans_cancel(args.trans, 0); 309 xfs_trans_cancel(args.trans, 0);
306 return(error); 310 return error;
307 } 311 }
308 xfs_ilock(dp, XFS_ILOCK_EXCL); 312 xfs_ilock(dp, XFS_ILOCK_EXCL);
309 313
@@ -313,7 +317,7 @@ xfs_attr_set_int(
313 if (error) { 317 if (error) {
314 xfs_iunlock(dp, XFS_ILOCK_EXCL); 318 xfs_iunlock(dp, XFS_ILOCK_EXCL);
315 xfs_trans_cancel(args.trans, XFS_TRANS_RELEASE_LOG_RES); 319 xfs_trans_cancel(args.trans, XFS_TRANS_RELEASE_LOG_RES);
316 return (error); 320 return error;
317 } 321 }
318 322
319 xfs_trans_ijoin(args.trans, dp, 0); 323 xfs_trans_ijoin(args.trans, dp, 0);
@@ -322,9 +326,9 @@ xfs_attr_set_int(
322 * If the attribute list is non-existent or a shortform list, 326 * If the attribute list is non-existent or a shortform list,
323 * upgrade it to a single-leaf-block attribute list. 327 * upgrade it to a single-leaf-block attribute list.
324 */ 328 */
325 if ((dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) || 329 if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL ||
326 ((dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) && 330 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
327 (dp->i_d.di_anextents == 0))) { 331 dp->i_d.di_anextents == 0)) {
328 332
329 /* 333 /*
330 * Build initial attribute list (if required). 334 * Build initial attribute list (if required).
@@ -349,9 +353,8 @@ xfs_attr_set_int(
349 * the transaction goes to disk before returning 353 * the transaction goes to disk before returning
350 * to the user. 354 * to the user.
351 */ 355 */
352 if (mp->m_flags & XFS_MOUNT_WSYNC) { 356 if (mp->m_flags & XFS_MOUNT_WSYNC)
353 xfs_trans_set_sync(args.trans); 357 xfs_trans_set_sync(args.trans);
354 }
355 358
356 if (!error && (flags & ATTR_KERNOTIME) == 0) { 359 if (!error && (flags & ATTR_KERNOTIME) == 0) {
357 xfs_trans_ichgtime(args.trans, dp, 360 xfs_trans_ichgtime(args.trans, dp,
@@ -361,7 +364,7 @@ xfs_attr_set_int(
361 XFS_TRANS_RELEASE_LOG_RES); 364 XFS_TRANS_RELEASE_LOG_RES);
362 xfs_iunlock(dp, XFS_ILOCK_EXCL); 365 xfs_iunlock(dp, XFS_ILOCK_EXCL);
363 366
364 return(error == 0 ? err2 : error); 367 return error ? error : err2;
365 } 368 }
366 369
367 /* 370 /*
@@ -399,22 +402,19 @@ xfs_attr_set_int(
399 402
400 } 403 }
401 404
402 if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) { 405 if (xfs_bmap_one_block(dp, XFS_ATTR_FORK))
403 error = xfs_attr_leaf_addname(&args); 406 error = xfs_attr_leaf_addname(&args);
404 } else { 407 else
405 error = xfs_attr_node_addname(&args); 408 error = xfs_attr_node_addname(&args);
406 } 409 if (error)
407 if (error) {
408 goto out; 410 goto out;
409 }
410 411
411 /* 412 /*
412 * If this is a synchronous mount, make sure that the 413 * If this is a synchronous mount, make sure that the
413 * transaction goes to disk before returning to the user. 414 * transaction goes to disk before returning to the user.
414 */ 415 */
415 if (mp->m_flags & XFS_MOUNT_WSYNC) { 416 if (mp->m_flags & XFS_MOUNT_WSYNC)
416 xfs_trans_set_sync(args.trans); 417 xfs_trans_set_sync(args.trans);
417 }
418 418
419 if ((flags & ATTR_KERNOTIME) == 0) 419 if ((flags & ATTR_KERNOTIME) == 0)
420 xfs_trans_ichgtime(args.trans, dp, XFS_ICHGTIME_CHG); 420 xfs_trans_ichgtime(args.trans, dp, XFS_ICHGTIME_CHG);
@@ -426,37 +426,15 @@ xfs_attr_set_int(
426 error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES); 426 error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES);
427 xfs_iunlock(dp, XFS_ILOCK_EXCL); 427 xfs_iunlock(dp, XFS_ILOCK_EXCL);
428 428
429 return(error); 429 return error;
430 430
431out: 431out:
432 if (args.trans) 432 if (args.trans) {
433 xfs_trans_cancel(args.trans, 433 xfs_trans_cancel(args.trans,
434 XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); 434 XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
435 }
435 xfs_iunlock(dp, XFS_ILOCK_EXCL); 436 xfs_iunlock(dp, XFS_ILOCK_EXCL);
436 return(error); 437 return error;
437}
438
439int
440xfs_attr_set(
441 xfs_inode_t *dp,
442 const unsigned char *name,
443 unsigned char *value,
444 int valuelen,
445 int flags)
446{
447 int error;
448 struct xfs_name xname;
449
450 XFS_STATS_INC(xs_attr_set);
451
452 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
453 return (EIO);
454
455 error = xfs_attr_name_to_xname(&xname, name);
456 if (error)
457 return error;
458
459 return xfs_attr_set_int(dp, &xname, value, valuelen, flags);
460} 438}
461 439
462/* 440/*