Lines Matching refs:args

41 STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args);
46 STATIC int xfs_attr_leaf_get(xfs_da_args_t *args);
47 STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args);
48 STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args);
49 STATIC int xfs_attr_leaf_hasname(struct xfs_da_args *args, struct xfs_buf **bp);
54 STATIC int xfs_attr_node_get(xfs_da_args_t *args);
55 STATIC int xfs_attr_node_addname(xfs_da_args_t *args);
56 STATIC int xfs_attr_node_removename(xfs_da_args_t *args);
57 STATIC int xfs_attr_node_hasname(xfs_da_args_t *args,
83 struct xfs_da_args *args)
85 ASSERT(xfs_isilocked(args->dp, XFS_ILOCK_SHARED | XFS_ILOCK_EXCL));
87 if (!xfs_inode_hasattr(args->dp))
90 if (args->dp->i_afp->if_format == XFS_DINODE_FMT_LOCAL)
91 return xfs_attr_shortform_getvalue(args);
92 if (xfs_bmap_one_block(args->dp, XFS_ATTR_FORK))
93 return xfs_attr_leaf_get(args);
94 return xfs_attr_node_get(args);
100 * If args->valuelen is zero, then the caller does not want the value, just an
102 * exists. The size is returned in args.valuelen.
104 * If args->value is NULL but args->valuelen is non-zero, allocate the buffer
106 * caller always has to free args->value if it is set, no matter if this
110 * args->valuelen, return -ERANGE with the size of the attribute that was found
111 * in args->valuelen.
115 struct xfs_da_args *args)
120 XFS_STATS_INC(args->dp->i_mount, xs_attr_get);
122 if (XFS_FORCED_SHUTDOWN(args->dp->i_mount))
125 args->geo = args->dp->i_mount->m_attr_geo;
126 args->whichfork = XFS_ATTR_FORK;
127 args->hashval = xfs_da_hashname(args->name, args->namelen);
130 args->op_flags = XFS_DA_OP_OKNOENT;
132 lock_mode = xfs_ilock_attr_map_shared(args->dp);
133 error = xfs_attr_get_ilocked(args);
134 xfs_iunlock(args->dp, lock_mode);
144 struct xfs_da_args *args,
147 struct xfs_mount *mp = args->dp->i_mount;
155 size = xfs_attr_leaf_newentsize(args, local);
158 if (size > (args->geo->blksize / 2)) {
167 uint dblocks = xfs_attr3_rmt_blocks(mp, args->valuelen);
178 struct xfs_da_args *args)
187 xfs_attr_shortform_create(args);
189 error = xfs_attr_shortform_addname(args);
197 if (!error && !(args->op_flags & XFS_DA_OP_NOTIME))
198 xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG);
201 xfs_trans_set_sync(args->trans);
226 struct xfs_da_args *args,
229 struct xfs_inode *dp = args->dp;
235 error = xfs_attr_try_sf_addname(dp, args);
237 error2 = xfs_trans_commit(args->trans);
238 args->trans = NULL;
245 error = xfs_attr_shortform_to_leaf(args, leaf_bp);
255 xfs_trans_bhold(args->trans, *leaf_bp);
256 error = xfs_defer_finish(&args->trans);
257 xfs_trans_bhold_release(args->trans, *leaf_bp);
259 xfs_trans_brelse(args->trans, *leaf_bp);
267 * Set the attribute specified in @args.
271 struct xfs_da_args *args)
273 struct xfs_inode *dp = args->dp;
291 error = xfs_attr_set_shortform(args, &leaf_bp);
292 if (error || !args->trans)
297 error = xfs_attr_leaf_addname(args);
304 error = xfs_attr3_leaf_to_node(args);
314 error = xfs_defer_finish(&args->trans);
322 error = xfs_trans_roll_inode(&args->trans, dp);
327 error = xfs_attr_node_addname(args);
336 struct xfs_da_args *args)
338 struct xfs_inode *dp = args->dp;
347 return xfs_attr_sf_findname(args, NULL, NULL);
351 error = xfs_attr_leaf_hasname(args, &bp);
354 xfs_trans_brelse(args->trans, bp);
359 return xfs_attr_node_hasname(args, NULL);
363 * Remove the attribute specified in @args.
367 struct xfs_da_args *args)
369 struct xfs_inode *dp = args->dp;
376 error = xfs_attr_shortform_remove(args);
378 error = xfs_attr_leaf_removename(args);
380 error = xfs_attr_node_removename(args);
387 * Note: If args->value is NULL the attribute will be removed, just like the
392 struct xfs_da_args *args)
394 struct xfs_inode *dp = args->dp;
397 bool rsvd = (args->attr_filter & XFS_ATTR_ROOT);
408 args->geo = mp->m_attr_geo;
409 args->whichfork = XFS_ATTR_FORK;
410 args->hashval = xfs_da_hashname(args->name, args->namelen);
417 args->op_flags = XFS_DA_OP_OKNOENT;
419 if (args->value) {
422 args->op_flags |= XFS_DA_OP_ADDNAME;
423 args->total = xfs_attr_calc_size(args, &local);
431 xfs_attr_sf_entsize_byname(args->namelen,
432 args->valuelen);
441 args->total;
444 total = args->total;
457 rsvd ? XFS_TRANS_RESERVE : 0, &args->trans);
462 xfs_trans_ijoin(args->trans, dp, 0);
463 if (args->value) {
468 error = xfs_trans_reserve_quota_nblks(args->trans, dp,
469 args->total, 0, quota_flags);
473 error = xfs_has_attr(args);
474 if (error == -EEXIST && (args->attr_flags & XATTR_CREATE))
476 if (error == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
481 error = xfs_attr_set_args(args);
485 if (!args->trans)
488 error = xfs_has_attr(args);
492 error = xfs_attr_remove_args(args);
502 xfs_trans_set_sync(args->trans);
504 if (!(args->op_flags & XFS_DA_OP_NOTIME))
505 xfs_trans_ichgtime(args->trans, dp, XFS_ICHGTIME_CHG);
510 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
511 error = xfs_trans_commit(args->trans);
517 if (args->trans)
518 xfs_trans_cancel(args->trans);
539 xfs_attr_shortform_addname(xfs_da_args_t *args)
543 trace_xfs_attr_sf_addname(args);
545 retval = xfs_attr_shortform_lookup(args);
546 if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
549 if (args->attr_flags & XATTR_CREATE)
551 retval = xfs_attr_shortform_remove(args);
559 args->attr_flags &= ~XATTR_REPLACE;
562 if (args->namelen >= XFS_ATTR_SF_ENTSIZE_MAX ||
563 args->valuelen >= XFS_ATTR_SF_ENTSIZE_MAX)
566 newsize = xfs_attr_sf_totsize(args->dp);
567 newsize += xfs_attr_sf_entsize_byname(args->namelen, args->valuelen);
569 forkoff = xfs_attr_shortform_bytesfit(args->dp, newsize);
573 xfs_attr_shortform_add(args, forkoff);
585 struct xfs_da_args *args)
587 args->blkno2 = args->blkno;
588 args->index2 = args->index;
589 args->rmtblkno2 = args->rmtblkno;
590 args->rmtblkcnt2 = args->rmtblkcnt;
591 args->rmtvaluelen2 = args->rmtvaluelen;
597 struct xfs_da_args *args)
599 args->blkno = args->blkno2;
600 args->index = args->index2;
601 args->rmtblkno = args->rmtblkno2;
602 args->rmtblkcnt = args->rmtblkcnt2;
603 args->rmtvaluelen = args->rmtvaluelen2;
618 struct xfs_da_args *args,
627 retval = xfs_attr_leaf_hasname(args, &bp);
630 if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
633 if (args->attr_flags & XATTR_CREATE)
636 trace_xfs_attr_leaf_replace(args);
639 args->op_flags |= XFS_DA_OP_RENAME; /* an atomic rename */
640 xfs_attr_save_rmt_blk(args);
647 args->rmtblkno = 0;
648 args->rmtblkcnt = 0;
649 args->rmtvaluelen = 0;
655 return xfs_attr3_leaf_add(bp, args);
658 xfs_trans_brelse(args->trans, bp);
671 struct xfs_da_args *args)
675 struct xfs_inode *dp = args->dp;
677 trace_xfs_attr_leaf_addname(args);
679 error = xfs_attr_leaf_try_add(args, bp);
687 error = xfs_trans_roll_inode(&args->trans, dp);
697 if (args->rmtblkno > 0) {
698 error = xfs_attr_rmtval_set(args);
703 if (!(args->op_flags & XFS_DA_OP_RENAME)) {
707 if (args->rmtblkno > 0)
708 error = xfs_attr3_leaf_clearflag(args);
723 error = xfs_attr3_leaf_flipflags(args);
729 error = xfs_trans_roll_inode(&args->trans, args->dp);
737 xfs_attr_restore_rmt_blk(args);
739 if (args->rmtblkno) {
740 error = xfs_attr_rmtval_invalidate(args);
744 error = xfs_attr_rmtval_remove(args);
753 error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno,
758 xfs_attr3_leaf_remove(bp, args);
765 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
776 struct xfs_da_args *args,
781 error = xfs_attr3_leaf_read(args->trans, args->dp, 0, bp);
785 error = xfs_attr3_leaf_lookup_int(*bp, args);
787 xfs_trans_brelse(args->trans, *bp);
800 struct xfs_da_args *args)
806 trace_xfs_attr_leaf_removename(args);
811 dp = args->dp;
813 error = xfs_attr_leaf_hasname(args, &bp);
816 xfs_trans_brelse(args->trans, bp);
821 xfs_attr3_leaf_remove(bp, args);
828 return xfs_attr3_leaf_to_shortform(bp, args, forkoff);
843 xfs_attr_leaf_get(xfs_da_args_t *args)
848 trace_xfs_attr_leaf_get(args);
850 error = xfs_attr_leaf_hasname(args, &bp);
853 xfs_trans_brelse(args->trans, bp);
859 error = xfs_attr3_leaf_getvalue(bp, args);
860 xfs_trans_brelse(args->trans, bp);
871 struct xfs_da_args *args,
877 state = xfs_da_state_alloc(args);
910 struct xfs_da_args *args)
917 trace_xfs_attr_node_addname(args);
922 dp = args->dp;
929 retval = xfs_attr_node_hasname(args, &state);
935 if (retval == -ENOATTR && (args->attr_flags & XATTR_REPLACE))
938 if (args->attr_flags & XATTR_CREATE)
941 trace_xfs_attr_node_replace(args);
944 args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op */
945 xfs_attr_save_rmt_blk(args);
952 args->rmtblkno = 0;
953 args->rmtblkcnt = 0;
954 args->rmtvaluelen = 0;
957 retval = xfs_attr3_leaf_add(blk->bp, state->args);
967 error = xfs_attr3_leaf_to_node(args);
970 error = xfs_defer_finish(&args->trans);
978 error = xfs_trans_roll_inode(&args->trans, dp);
994 error = xfs_defer_finish(&args->trans);
1015 error = xfs_trans_roll_inode(&args->trans, dp);
1025 if (args->rmtblkno > 0) {
1026 error = xfs_attr_rmtval_set(args);
1031 if (!(args->op_flags & XFS_DA_OP_RENAME)) {
1035 if (args->rmtblkno > 0)
1036 error = xfs_attr3_leaf_clearflag(args);
1050 error = xfs_attr3_leaf_flipflags(args);
1056 error = xfs_trans_roll_inode(&args->trans, args->dp);
1064 xfs_attr_restore_rmt_blk(args);
1066 if (args->rmtblkno) {
1067 error = xfs_attr_rmtval_invalidate(args);
1071 error = xfs_attr_rmtval_remove(args);
1080 args->attr_filter |= XFS_ATTR_INCOMPLETE;
1081 state = xfs_da_state_alloc(args);
1092 error = xfs_attr3_leaf_remove(blk->bp, args);
1118 struct xfs_da_args *args,
1121 struct xfs_inode *dp = args->dp;
1132 error = xfs_attr3_leaf_read(args->trans, args->dp, 0, &bp);
1138 error = xfs_attr3_leaf_to_shortform(bp, args, forkoff);
1141 xfs_trans_brelse(args->trans, bp);
1152 struct xfs_da_args *args,
1169 return xfs_attr3_leaf_setflag(args);
1179 struct xfs_da_args *args,
1184 error = xfs_attr_node_hasname(args, state);
1192 if (args->rmtblkno > 0) {
1193 error = xfs_attr_leaf_mark_incomplete(args, *state);
1197 return xfs_attr_rmtval_invalidate(args);
1205 struct xfs_da_args *args,
1210 error = xfs_attr_rmtval_remove(args);
1230 struct xfs_da_args *args)
1235 struct xfs_inode *dp = args->dp;
1237 trace_xfs_attr_node_removename(args);
1239 error = xfs_attr_node_removename_setup(args, &state);
1248 if (args->rmtblkno > 0) {
1249 error = xfs_attr_node_remove_rmt(args, state);
1259 retval = xfs_attr3_leaf_remove(blk->bp, args);
1269 error = xfs_defer_finish(&args->trans);
1275 error = xfs_trans_roll_inode(&args->trans, dp);
1284 error = xfs_attr_node_shrink(args, state);
1305 trace_xfs_attr_fillstate(state->args);
1353 trace_xfs_attr_refillstate(state->args);
1363 error = xfs_da3_node_read_mapped(state->args->trans,
1364 state->args->dp, blk->disk_blkno,
1381 error = xfs_da3_node_read_mapped(state->args->trans,
1382 state->args->dp, blk->disk_blkno,
1405 struct xfs_da_args *args)
1412 trace_xfs_attr_node_get(args);
1417 error = xfs_attr_node_hasname(args, &state);
1425 error = xfs_attr3_leaf_getvalue(blk->bp, args);
1432 xfs_trans_brelse(args->trans, state->path.blk[i].bp);