aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/xfs/xfs_attr.c11
-rw-r--r--fs/xfs/xfs_attr_leaf.c20
-rw-r--r--fs/xfs/xfs_da_btree.c2
-rw-r--r--fs/xfs/xfs_da_btree.h13
-rw-r--r--fs/xfs/xfs_dir2.c14
-rw-r--r--fs/xfs/xfs_dir2_block.c10
-rw-r--r--fs/xfs/xfs_dir2_leaf.c15
-rw-r--r--fs/xfs/xfs_dir2_node.c16
-rw-r--r--fs/xfs/xfs_dir2_sf.c8
-rw-r--r--fs/xfs/xfs_dir2_trace.c20
10 files changed, 71 insertions, 58 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 5e5dbe62b194..557dad611de0 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -241,8 +241,7 @@ xfs_attr_set_int(xfs_inode_t *dp, struct xfs_name *name,
241 args.firstblock = &firstblock; 241 args.firstblock = &firstblock;
242 args.flist = &flist; 242 args.flist = &flist;
243 args.whichfork = XFS_ATTR_FORK; 243 args.whichfork = XFS_ATTR_FORK;
244 args.addname = 1; 244 args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
245 args.oknoent = 1;
246 245
247 /* 246 /*
248 * Determine space new attribute will use, and if it would be 247 * Determine space new attribute will use, and if it would be
@@ -974,7 +973,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
974 xfs_da_brelse(args->trans, bp); 973 xfs_da_brelse(args->trans, bp);
975 return(retval); 974 return(retval);
976 } 975 }
977 args->rename = 1; /* an atomic rename */ 976 args->op_flags |= XFS_DA_OP_RENAME; /* an atomic rename */
978 args->blkno2 = args->blkno; /* set 2nd entry info*/ 977 args->blkno2 = args->blkno; /* set 2nd entry info*/
979 args->index2 = args->index; 978 args->index2 = args->index;
980 args->rmtblkno2 = args->rmtblkno; 979 args->rmtblkno2 = args->rmtblkno;
@@ -1054,7 +1053,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
1054 * so that one disappears and one appears atomically. Then we 1053 * so that one disappears and one appears atomically. Then we
1055 * must remove the "old" attribute/value pair. 1054 * must remove the "old" attribute/value pair.
1056 */ 1055 */
1057 if (args->rename) { 1056 if (args->op_flags & XFS_DA_OP_RENAME) {
1058 /* 1057 /*
1059 * In a separate transaction, set the incomplete flag on the 1058 * In a separate transaction, set the incomplete flag on the
1060 * "old" attr and clear the incomplete flag on the "new" attr. 1059 * "old" attr and clear the incomplete flag on the "new" attr.
@@ -1307,7 +1306,7 @@ restart:
1307 } else if (retval == EEXIST) { 1306 } else if (retval == EEXIST) {
1308 if (args->flags & ATTR_CREATE) 1307 if (args->flags & ATTR_CREATE)
1309 goto out; 1308 goto out;
1310 args->rename = 1; /* atomic rename op */ 1309 args->op_flags |= XFS_DA_OP_RENAME; /* atomic rename op */
1311 args->blkno2 = args->blkno; /* set 2nd entry info*/ 1310 args->blkno2 = args->blkno; /* set 2nd entry info*/
1312 args->index2 = args->index; 1311 args->index2 = args->index;
1313 args->rmtblkno2 = args->rmtblkno; 1312 args->rmtblkno2 = args->rmtblkno;
@@ -1425,7 +1424,7 @@ restart:
1425 * so that one disappears and one appears atomically. Then we 1424 * so that one disappears and one appears atomically. Then we
1426 * must remove the "old" attribute/value pair. 1425 * must remove the "old" attribute/value pair.
1427 */ 1426 */
1428 if (args->rename) { 1427 if (args->op_flags & XFS_DA_OP_RENAME) {
1429 /* 1428 /*
1430 * In a separate transaction, set the incomplete flag on the 1429 * In a separate transaction, set the incomplete flag on the
1431 * "old" attr and clear the incomplete flag on the "new" attr. 1430 * "old" attr and clear the incomplete flag on the "new" attr.
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index a85e9caf0156..cb345e6e4850 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -369,9 +369,10 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
369 * Fix up the start offset of the attribute fork 369 * Fix up the start offset of the attribute fork
370 */ 370 */
371 totsize -= size; 371 totsize -= size;
372 if (totsize == sizeof(xfs_attr_sf_hdr_t) && !args->addname && 372 if (totsize == sizeof(xfs_attr_sf_hdr_t) &&
373 (mp->m_flags & XFS_MOUNT_ATTR2) && 373 !(args->op_flags & XFS_DA_OP_ADDNAME) &&
374 (dp->i_d.di_format != XFS_DINODE_FMT_BTREE)) { 374 (mp->m_flags & XFS_MOUNT_ATTR2) &&
375 (dp->i_d.di_format != XFS_DINODE_FMT_BTREE)) {
375 /* 376 /*
376 * Last attribute now removed, revert to original 377 * Last attribute now removed, revert to original
377 * inode format making all literal area available 378 * inode format making all literal area available
@@ -389,9 +390,10 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
389 xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); 390 xfs_idata_realloc(dp, -size, XFS_ATTR_FORK);
390 dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); 391 dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize);
391 ASSERT(dp->i_d.di_forkoff); 392 ASSERT(dp->i_d.di_forkoff);
392 ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) || args->addname || 393 ASSERT(totsize > sizeof(xfs_attr_sf_hdr_t) ||
393 !(mp->m_flags & XFS_MOUNT_ATTR2) || 394 (args->op_flags & XFS_DA_OP_ADDNAME) ||
394 dp->i_d.di_format == XFS_DINODE_FMT_BTREE); 395 !(mp->m_flags & XFS_MOUNT_ATTR2) ||
396 dp->i_d.di_format == XFS_DINODE_FMT_BTREE);
395 dp->i_afp->if_ext_max = 397 dp->i_afp->if_ext_max =
396 XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t); 398 XFS_IFORK_ASIZE(dp) / (uint)sizeof(xfs_bmbt_rec_t);
397 dp->i_df.if_ext_max = 399 dp->i_df.if_ext_max =
@@ -531,7 +533,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
531 nargs.total = args->total; 533 nargs.total = args->total;
532 nargs.whichfork = XFS_ATTR_FORK; 534 nargs.whichfork = XFS_ATTR_FORK;
533 nargs.trans = args->trans; 535 nargs.trans = args->trans;
534 nargs.oknoent = 1; 536 nargs.op_flags = XFS_DA_OP_OKNOENT;
535 537
536 sfe = &sf->list[0]; 538 sfe = &sf->list[0];
537 for (i = 0; i < sf->hdr.count; i++) { 539 for (i = 0; i < sf->hdr.count; i++) {
@@ -853,7 +855,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
853 nargs.total = args->total; 855 nargs.total = args->total;
854 nargs.whichfork = XFS_ATTR_FORK; 856 nargs.whichfork = XFS_ATTR_FORK;
855 nargs.trans = args->trans; 857 nargs.trans = args->trans;
856 nargs.oknoent = 1; 858 nargs.op_flags = XFS_DA_OP_OKNOENT;
857 entry = &leaf->entries[0]; 859 entry = &leaf->entries[0];
858 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { 860 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
859 if (entry->flags & XFS_ATTR_INCOMPLETE) 861 if (entry->flags & XFS_ATTR_INCOMPLETE)
@@ -1155,7 +1157,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1155 entry->hashval = cpu_to_be32(args->hashval); 1157 entry->hashval = cpu_to_be32(args->hashval);
1156 entry->flags = tmp ? XFS_ATTR_LOCAL : 0; 1158 entry->flags = tmp ? XFS_ATTR_LOCAL : 0;
1157 entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags); 1159 entry->flags |= XFS_ATTR_NSP_ARGS_TO_ONDISK(args->flags);
1158 if (args->rename) { 1160 if (args->op_flags & XFS_DA_OP_RENAME) {
1159 entry->flags |= XFS_ATTR_INCOMPLETE; 1161 entry->flags |= XFS_ATTR_INCOMPLETE;
1160 if ((args->blkno2 == args->blkno) && 1162 if ((args->blkno2 == args->blkno) &&
1161 (args->index2 <= args->index)) { 1163 (args->index2 <= args->index)) {
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index ae4b18c7726b..edc0aef4e51e 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -1431,7 +1431,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
1431 } 1431 }
1432 if (level < 0) { 1432 if (level < 0) {
1433 *result = XFS_ERROR(ENOENT); /* we're out of our tree */ 1433 *result = XFS_ERROR(ENOENT); /* we're out of our tree */
1434 ASSERT(args->oknoent); 1434 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
1435 return(0); 1435 return(0);
1436 } 1436 }
1437 1437
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index e64c6924996f..8face64c11fb 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -132,14 +132,19 @@ typedef struct xfs_da_args {
132 int index2; /* index of 2nd attr in blk */ 132 int index2; /* index of 2nd attr in blk */
133 xfs_dablk_t rmtblkno2; /* remote attr value starting blkno */ 133 xfs_dablk_t rmtblkno2; /* remote attr value starting blkno */
134 int rmtblkcnt2; /* remote attr value block count */ 134 int rmtblkcnt2; /* remote attr value block count */
135 unsigned char justcheck; /* T/F: check for ok with no space */ 135 int op_flags; /* operation flags */
136 unsigned char rename; /* T/F: this is an atomic rename op */
137 unsigned char addname; /* T/F: this is an add operation */
138 unsigned char oknoent; /* T/F: ok to return ENOENT, else die */
139 enum xfs_dacmp cmpresult; /* name compare result for lookups */ 136 enum xfs_dacmp cmpresult; /* name compare result for lookups */
140} xfs_da_args_t; 137} xfs_da_args_t;
141 138
142/* 139/*
140 * Operation flags:
141 */
142#define XFS_DA_OP_JUSTCHECK 0x0001 /* check for ok with no space */
143#define XFS_DA_OP_RENAME 0x0002 /* this is an atomic rename op */
144#define XFS_DA_OP_ADDNAME 0x0004 /* this is an add operation */
145#define XFS_DA_OP_OKNOENT 0x0008 /* lookup/add op, ENOENT ok, else die */
146
147/*
143 * Structure to describe buffer(s) for a block. 148 * Structure to describe buffer(s) for a block.
144 * This is needed in the directory version 2 format case, when 149 * This is needed in the directory version 2 format case, when
145 * multiple non-contiguous fsblocks might be needed to cover one 150 * multiple non-contiguous fsblocks might be needed to cover one
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 675899bb7048..3387acd3e471 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -46,6 +46,8 @@
46 46
47struct xfs_name xfs_name_dotdot = {"..", 2}; 47struct xfs_name xfs_name_dotdot = {"..", 2};
48 48
49extern const struct xfs_nameops xfs_default_nameops;
50
49void 51void
50xfs_dir_mount( 52xfs_dir_mount(
51 xfs_mount_t *mp) 53 xfs_mount_t *mp)
@@ -173,8 +175,7 @@ xfs_dir_createname(
173 args.total = total; 175 args.total = total;
174 args.whichfork = XFS_DATA_FORK; 176 args.whichfork = XFS_DATA_FORK;
175 args.trans = tp; 177 args.trans = tp;
176 args.justcheck = 0; 178 args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
177 args.addname = args.oknoent = 1;
178 179
179 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 180 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
180 rval = xfs_dir2_sf_addname(&args); 181 rval = xfs_dir2_sf_addname(&args);
@@ -215,7 +216,7 @@ xfs_dir_lookup(
215 args.dp = dp; 216 args.dp = dp;
216 args.whichfork = XFS_DATA_FORK; 217 args.whichfork = XFS_DATA_FORK;
217 args.trans = tp; 218 args.trans = tp;
218 args.oknoent = 1; 219 args.op_flags = XFS_DA_OP_OKNOENT;
219 args.cmpresult = XFS_CMP_DIFFERENT; 220 args.cmpresult = XFS_CMP_DIFFERENT;
220 221
221 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 222 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
@@ -267,7 +268,7 @@ xfs_dir_removename(
267 args.total = total; 268 args.total = total;
268 args.whichfork = XFS_DATA_FORK; 269 args.whichfork = XFS_DATA_FORK;
269 args.trans = tp; 270 args.trans = tp;
270 args.justcheck = args.addname = args.oknoent = 0; 271 args.op_flags = 0;
271 272
272 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 273 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
273 rval = xfs_dir2_sf_removename(&args); 274 rval = xfs_dir2_sf_removename(&args);
@@ -350,7 +351,7 @@ xfs_dir_replace(
350 args.total = total; 351 args.total = total;
351 args.whichfork = XFS_DATA_FORK; 352 args.whichfork = XFS_DATA_FORK;
352 args.trans = tp; 353 args.trans = tp;
353 args.justcheck = args.addname = args.oknoent = 0; 354 args.op_flags = 0;
354 355
355 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 356 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
356 rval = xfs_dir2_sf_replace(&args); 357 rval = xfs_dir2_sf_replace(&args);
@@ -394,7 +395,8 @@ xfs_dir_canenter(
394 args.dp = dp; 395 args.dp = dp;
395 args.whichfork = XFS_DATA_FORK; 396 args.whichfork = XFS_DATA_FORK;
396 args.trans = tp; 397 args.trans = tp;
397 args.justcheck = args.addname = args.oknoent = 1; 398 args.op_flags = XFS_DA_OP_JUSTCHECK | XFS_DA_OP_ADDNAME |
399 XFS_DA_OP_OKNOENT;
398 400
399 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 401 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
400 rval = xfs_dir2_sf_addname(&args); 402 rval = xfs_dir2_sf_addname(&args);
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index 98588491cb0e..dee225918db2 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -215,7 +215,7 @@ xfs_dir2_block_addname(
215 /* 215 /*
216 * If this isn't a real add, we're done with the buffer. 216 * If this isn't a real add, we're done with the buffer.
217 */ 217 */
218 if (args->justcheck) 218 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
219 xfs_da_brelse(tp, bp); 219 xfs_da_brelse(tp, bp);
220 /* 220 /*
221 * If we don't have space for the new entry & leaf ... 221 * If we don't have space for the new entry & leaf ...
@@ -225,7 +225,7 @@ xfs_dir2_block_addname(
225 * Not trying to actually do anything, or don't have 225 * Not trying to actually do anything, or don't have
226 * a space reservation: return no-space. 226 * a space reservation: return no-space.
227 */ 227 */
228 if (args->justcheck || args->total == 0) 228 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
229 return XFS_ERROR(ENOSPC); 229 return XFS_ERROR(ENOSPC);
230 /* 230 /*
231 * Convert to the next larger format. 231 * Convert to the next larger format.
@@ -240,7 +240,7 @@ xfs_dir2_block_addname(
240 /* 240 /*
241 * Just checking, and it would work, so say so. 241 * Just checking, and it would work, so say so.
242 */ 242 */
243 if (args->justcheck) 243 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
244 return 0; 244 return 0;
245 needlog = needscan = 0; 245 needlog = needscan = 0;
246 /* 246 /*
@@ -674,7 +674,7 @@ xfs_dir2_block_lookup_int(
674 else 674 else
675 high = mid - 1; 675 high = mid - 1;
676 if (low > high) { 676 if (low > high) {
677 ASSERT(args->oknoent); 677 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
678 xfs_da_brelse(tp, bp); 678 xfs_da_brelse(tp, bp);
679 return XFS_ERROR(ENOENT); 679 return XFS_ERROR(ENOENT);
680 } 680 }
@@ -713,7 +713,7 @@ xfs_dir2_block_lookup_int(
713 } while (++mid < be32_to_cpu(btp->count) && 713 } while (++mid < be32_to_cpu(btp->count) &&
714 be32_to_cpu(blp[mid].hashval) == hash); 714 be32_to_cpu(blp[mid].hashval) == hash);
715 715
716 ASSERT(args->oknoent); 716 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
717 /* 717 /*
718 * Here, we can only be doing a lookup (not a rename or replace). 718 * Here, we can only be doing a lookup (not a rename or replace).
719 * If a case-insensitive match was found earlier, return success. 719 * If a case-insensitive match was found earlier, return success.
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index b52903bc0b14..2ebbed4f1b0d 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -263,20 +263,21 @@ xfs_dir2_leaf_addname(
263 * If we don't have enough free bytes but we can make enough 263 * If we don't have enough free bytes but we can make enough
264 * by compacting out stale entries, we'll do that. 264 * by compacting out stale entries, we'll do that.
265 */ 265 */
266 if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes && 266 if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <
267 be16_to_cpu(leaf->hdr.stale) > 1) { 267 needbytes && be16_to_cpu(leaf->hdr.stale) > 1) {
268 compact = 1; 268 compact = 1;
269 } 269 }
270 /* 270 /*
271 * Otherwise if we don't have enough free bytes we need to 271 * Otherwise if we don't have enough free bytes we need to
272 * convert to node form. 272 * convert to node form.
273 */ 273 */
274 else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < 274 else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(
275 needbytes) { 275 leaf->hdr.count)] < needbytes) {
276 /* 276 /*
277 * Just checking or no space reservation, give up. 277 * Just checking or no space reservation, give up.
278 */ 278 */
279 if (args->justcheck || args->total == 0) { 279 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) ||
280 args->total == 0) {
280 xfs_da_brelse(tp, lbp); 281 xfs_da_brelse(tp, lbp);
281 return XFS_ERROR(ENOSPC); 282 return XFS_ERROR(ENOSPC);
282 } 283 }
@@ -301,7 +302,7 @@ xfs_dir2_leaf_addname(
301 * If just checking, then it will fit unless we needed to allocate 302 * If just checking, then it will fit unless we needed to allocate
302 * a new data block. 303 * a new data block.
303 */ 304 */
304 if (args->justcheck) { 305 if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
305 xfs_da_brelse(tp, lbp); 306 xfs_da_brelse(tp, lbp);
306 return use_block == -1 ? XFS_ERROR(ENOSPC) : 0; 307 return use_block == -1 ? XFS_ERROR(ENOSPC) : 0;
307 } 308 }
@@ -1414,7 +1415,7 @@ xfs_dir2_leaf_lookup_int(
1414 cbp = dbp; 1415 cbp = dbp;
1415 } 1416 }
1416 } 1417 }
1417 ASSERT(args->oknoent); 1418 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
1418 /* 1419 /*
1419 * Here, we can only be doing a lookup (not a rename or replace). 1420 * Here, we can only be doing a lookup (not a rename or replace).
1420 * If a case-insensitive match was found earlier, release the current 1421 * If a case-insensitive match was found earlier, release the current
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index fedf8f976a10..c71cff85950c 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -226,7 +226,7 @@ xfs_dir2_leafn_add(
226 ASSERT(index == be16_to_cpu(leaf->hdr.count) || 226 ASSERT(index == be16_to_cpu(leaf->hdr.count) ||
227 be32_to_cpu(leaf->ents[index].hashval) >= args->hashval); 227 be32_to_cpu(leaf->ents[index].hashval) >= args->hashval);
228 228
229 if (args->justcheck) 229 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
230 return 0; 230 return 0;
231 231
232 /* 232 /*
@@ -515,7 +515,7 @@ xfs_dir2_leafn_lookup_for_addname(
515 /* Didn't find any space */ 515 /* Didn't find any space */
516 fi = -1; 516 fi = -1;
517out: 517out:
518 ASSERT(args->oknoent); 518 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
519 if (curbp) { 519 if (curbp) {
520 /* Giving back a free block. */ 520 /* Giving back a free block. */
521 state->extravalid = 1; 521 state->extravalid = 1;
@@ -638,7 +638,8 @@ xfs_dir2_leafn_lookup_for_entry(
638 /* Didn't find an exact match. */ 638 /* Didn't find an exact match. */
639 error = ENOENT; 639 error = ENOENT;
640 di = -1; 640 di = -1;
641 ASSERT(index == be16_to_cpu(leaf->hdr.count) || args->oknoent); 641 ASSERT(index == be16_to_cpu(leaf->hdr.count) ||
642 (args->op_flags & XFS_DA_OP_OKNOENT));
642out: 643out:
643 if (curbp) { 644 if (curbp) {
644 /* Giving back a data block. */ 645 /* Giving back a data block. */
@@ -669,7 +670,7 @@ xfs_dir2_leafn_lookup_int(
669 int *indexp, /* out: leaf entry index */ 670 int *indexp, /* out: leaf entry index */
670 xfs_da_state_t *state) /* state to fill in */ 671 xfs_da_state_t *state) /* state to fill in */
671{ 672{
672 if (args->addname) 673 if (args->op_flags & XFS_DA_OP_ADDNAME)
673 return xfs_dir2_leafn_lookup_for_addname(bp, args, indexp, 674 return xfs_dir2_leafn_lookup_for_addname(bp, args, indexp,
674 state); 675 state);
675 return xfs_dir2_leafn_lookup_for_entry(bp, args, indexp, state); 676 return xfs_dir2_leafn_lookup_for_entry(bp, args, indexp, state);
@@ -1383,7 +1384,7 @@ xfs_dir2_node_addname(
1383 /* 1384 /*
1384 * It worked, fix the hash values up the btree. 1385 * It worked, fix the hash values up the btree.
1385 */ 1386 */
1386 if (!args->justcheck) 1387 if (!(args->op_flags & XFS_DA_OP_JUSTCHECK))
1387 xfs_da_fixhashpath(state, &state->path); 1388 xfs_da_fixhashpath(state, &state->path);
1388 } else { 1389 } else {
1389 /* 1390 /*
@@ -1566,7 +1567,8 @@ xfs_dir2_node_addname_int(
1566 /* 1567 /*
1567 * Not allowed to allocate, return failure. 1568 * Not allowed to allocate, return failure.
1568 */ 1569 */
1569 if (args->justcheck || args->total == 0) { 1570 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) ||
1571 args->total == 0) {
1570 /* 1572 /*
1571 * Drop the freespace buffer unless it came from our 1573 * Drop the freespace buffer unless it came from our
1572 * caller. 1574 * caller.
@@ -1712,7 +1714,7 @@ xfs_dir2_node_addname_int(
1712 /* 1714 /*
1713 * If just checking, we succeeded. 1715 * If just checking, we succeeded.
1714 */ 1716 */
1715 if (args->justcheck) { 1717 if (args->op_flags & XFS_DA_OP_JUSTCHECK) {
1716 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL) 1718 if ((fblk == NULL || fblk->bp == NULL) && fbp != NULL)
1717 xfs_da_buf_done(fbp); 1719 xfs_da_buf_done(fbp);
1718 return 0; 1720 return 0;
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index dcd09cada43f..9409fd3e565f 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -332,7 +332,7 @@ xfs_dir2_sf_addname(
332 /* 332 /*
333 * Just checking or no space reservation, it doesn't fit. 333 * Just checking or no space reservation, it doesn't fit.
334 */ 334 */
335 if (args->justcheck || args->total == 0) 335 if ((args->op_flags & XFS_DA_OP_JUSTCHECK) || args->total == 0)
336 return XFS_ERROR(ENOSPC); 336 return XFS_ERROR(ENOSPC);
337 /* 337 /*
338 * Convert to block form then add the name. 338 * Convert to block form then add the name.
@@ -345,7 +345,7 @@ xfs_dir2_sf_addname(
345 /* 345 /*
346 * Just checking, it fits. 346 * Just checking, it fits.
347 */ 347 */
348 if (args->justcheck) 348 if (args->op_flags & XFS_DA_OP_JUSTCHECK)
349 return 0; 349 return 0;
350 /* 350 /*
351 * Do it the easy way - just add it at the end. 351 * Do it the easy way - just add it at the end.
@@ -869,7 +869,7 @@ xfs_dir2_sf_lookup(
869 return XFS_ERROR(EEXIST); 869 return XFS_ERROR(EEXIST);
870 } 870 }
871 } 871 }
872 ASSERT(args->oknoent); 872 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
873 /* 873 /*
874 * Here, we can only be doing a lookup (not a rename or replace). 874 * Here, we can only be doing a lookup (not a rename or replace).
875 * If a case-insensitive match was found earlier, return "found". 875 * If a case-insensitive match was found earlier, return "found".
@@ -1071,7 +1071,7 @@ xfs_dir2_sf_replace(
1071 * Didn't find it. 1071 * Didn't find it.
1072 */ 1072 */
1073 if (i == sfp->hdr.count) { 1073 if (i == sfp->hdr.count) {
1074 ASSERT(args->oknoent); 1074 ASSERT(args->op_flags & XFS_DA_OP_OKNOENT);
1075#if XFS_BIG_INUMS 1075#if XFS_BIG_INUMS
1076 if (i8elevated) 1076 if (i8elevated)
1077 xfs_dir2_sf_toino4(args); 1077 xfs_dir2_sf_toino4(args);
diff --git a/fs/xfs/xfs_dir2_trace.c b/fs/xfs/xfs_dir2_trace.c
index f3fb2ffd6f5c..6cc7c0c681ac 100644
--- a/fs/xfs/xfs_dir2_trace.c
+++ b/fs/xfs/xfs_dir2_trace.c
@@ -85,7 +85,8 @@ xfs_dir2_trace_args(
85 (void *)((unsigned long)(args->inumber >> 32)), 85 (void *)((unsigned long)(args->inumber >> 32)),
86 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), 86 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
87 (void *)args->dp, (void *)args->trans, 87 (void *)args->dp, (void *)args->trans,
88 (void *)(unsigned long)args->justcheck, NULL, NULL); 88 (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
89 NULL, NULL);
89} 90}
90 91
91void 92void
@@ -100,7 +101,7 @@ xfs_dir2_trace_args_b(
100 (void *)((unsigned long)(args->inumber >> 32)), 101 (void *)((unsigned long)(args->inumber >> 32)),
101 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), 102 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
102 (void *)args->dp, (void *)args->trans, 103 (void *)args->dp, (void *)args->trans,
103 (void *)(unsigned long)args->justcheck, 104 (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
104 (void *)(bp ? bp->bps[0] : NULL), NULL); 105 (void *)(bp ? bp->bps[0] : NULL), NULL);
105} 106}
106 107
@@ -117,7 +118,7 @@ xfs_dir2_trace_args_bb(
117 (void *)((unsigned long)(args->inumber >> 32)), 118 (void *)((unsigned long)(args->inumber >> 32)),
118 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), 119 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
119 (void *)args->dp, (void *)args->trans, 120 (void *)args->dp, (void *)args->trans,
120 (void *)(unsigned long)args->justcheck, 121 (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
121 (void *)(lbp ? lbp->bps[0] : NULL), 122 (void *)(lbp ? lbp->bps[0] : NULL),
122 (void *)(dbp ? dbp->bps[0] : NULL)); 123 (void *)(dbp ? dbp->bps[0] : NULL));
123} 124}
@@ -157,8 +158,8 @@ xfs_dir2_trace_args_db(
157 (void *)((unsigned long)(args->inumber >> 32)), 158 (void *)((unsigned long)(args->inumber >> 32)),
158 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), 159 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
159 (void *)args->dp, (void *)args->trans, 160 (void *)args->dp, (void *)args->trans,
160 (void *)(unsigned long)args->justcheck, (void *)(long)db, 161 (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
161 (void *)dbp); 162 (void *)(long)db, (void *)dbp);
162} 163}
163 164
164void 165void
@@ -173,7 +174,7 @@ xfs_dir2_trace_args_i(
173 (void *)((unsigned long)(args->inumber >> 32)), 174 (void *)((unsigned long)(args->inumber >> 32)),
174 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), 175 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
175 (void *)args->dp, (void *)args->trans, 176 (void *)args->dp, (void *)args->trans,
176 (void *)(unsigned long)args->justcheck, 177 (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
177 (void *)((unsigned long)(i >> 32)), 178 (void *)((unsigned long)(i >> 32)),
178 (void *)((unsigned long)(i & 0xFFFFFFFF))); 179 (void *)((unsigned long)(i & 0xFFFFFFFF)));
179} 180}
@@ -190,7 +191,8 @@ xfs_dir2_trace_args_s(
190 (void *)((unsigned long)(args->inumber >> 32)), 191 (void *)((unsigned long)(args->inumber >> 32)),
191 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), 192 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
192 (void *)args->dp, (void *)args->trans, 193 (void *)args->dp, (void *)args->trans,
193 (void *)(unsigned long)args->justcheck, (void *)(long)s, NULL); 194 (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
195 (void *)(long)s, NULL);
194} 196}
195 197
196void 198void
@@ -208,7 +210,7 @@ xfs_dir2_trace_args_sb(
208 (void *)((unsigned long)(args->inumber >> 32)), 210 (void *)((unsigned long)(args->inumber >> 32)),
209 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)), 211 (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
210 (void *)args->dp, (void *)args->trans, 212 (void *)args->dp, (void *)args->trans,
211 (void *)(unsigned long)args->justcheck, (void *)(long)s, 213 (void *)(unsigned long)(args->op_flags & XFS_DA_OP_JUSTCHECK),
212 (void *)dbp); 214 (void *)(long)s, (void *)dbp);
213} 215}
214#endif /* XFS_DIR2_TRACE */ 216#endif /* XFS_DIR2_TRACE */