aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_dir2_node.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_dir2_node.c')
-rw-r--r--fs/xfs/xfs_dir2_node.c190
1 files changed, 96 insertions, 94 deletions
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index cb434d732681..da43d304fca2 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -195,17 +195,18 @@ xfs_dir2_free_try_read(
195 195
196static int 196static int
197xfs_dir3_free_get_buf( 197xfs_dir3_free_get_buf(
198 struct xfs_trans *tp, 198 xfs_da_args_t *args,
199 struct xfs_inode *dp,
200 xfs_dir2_db_t fbno, 199 xfs_dir2_db_t fbno,
201 struct xfs_buf **bpp) 200 struct xfs_buf **bpp)
202{ 201{
202 struct xfs_trans *tp = args->trans;
203 struct xfs_inode *dp = args->dp;
203 struct xfs_mount *mp = dp->i_mount; 204 struct xfs_mount *mp = dp->i_mount;
204 struct xfs_buf *bp; 205 struct xfs_buf *bp;
205 int error; 206 int error;
206 struct xfs_dir3_icfree_hdr hdr; 207 struct xfs_dir3_icfree_hdr hdr;
207 208
208 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, fbno), 209 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, fbno),
209 -1, &bp, XFS_DATA_FORK); 210 -1, &bp, XFS_DATA_FORK);
210 if (error) 211 if (error)
211 return error; 212 return error;
@@ -240,8 +241,7 @@ xfs_dir3_free_get_buf(
240 */ 241 */
241STATIC void 242STATIC void
242xfs_dir2_free_log_bests( 243xfs_dir2_free_log_bests(
243 struct xfs_trans *tp, 244 struct xfs_da_args *args,
244 struct xfs_inode *dp,
245 struct xfs_buf *bp, 245 struct xfs_buf *bp,
246 int first, /* first entry to log */ 246 int first, /* first entry to log */
247 int last) /* last entry to log */ 247 int last) /* last entry to log */
@@ -250,10 +250,10 @@ xfs_dir2_free_log_bests(
250 __be16 *bests; 250 __be16 *bests;
251 251
252 free = bp->b_addr; 252 free = bp->b_addr;
253 bests = dp->d_ops->free_bests_p(free); 253 bests = args->dp->d_ops->free_bests_p(free);
254 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || 254 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
255 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); 255 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
256 xfs_trans_log_buf(tp, bp, 256 xfs_trans_log_buf(args->trans, bp,
257 (uint)((char *)&bests[first] - (char *)free), 257 (uint)((char *)&bests[first] - (char *)free),
258 (uint)((char *)&bests[last] - (char *)free + 258 (uint)((char *)&bests[last] - (char *)free +
259 sizeof(bests[0]) - 1)); 259 sizeof(bests[0]) - 1));
@@ -264,8 +264,7 @@ xfs_dir2_free_log_bests(
264 */ 264 */
265static void 265static void
266xfs_dir2_free_log_header( 266xfs_dir2_free_log_header(
267 struct xfs_trans *tp, 267 struct xfs_da_args *args,
268 struct xfs_inode *dp,
269 struct xfs_buf *bp) 268 struct xfs_buf *bp)
270{ 269{
271#ifdef DEBUG 270#ifdef DEBUG
@@ -275,7 +274,8 @@ xfs_dir2_free_log_header(
275 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || 274 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
276 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); 275 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
277#endif 276#endif
278 xfs_trans_log_buf(tp, bp, 0, dp->d_ops->free_hdr_size - 1); 277 xfs_trans_log_buf(args->trans, bp, 0,
278 args->dp->d_ops->free_hdr_size - 1);
279} 279}
280 280
281/* 281/*
@@ -315,20 +315,20 @@ xfs_dir2_leaf_to_node(
315 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_FREE_SPACE, &fdb))) { 315 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_FREE_SPACE, &fdb))) {
316 return error; 316 return error;
317 } 317 }
318 ASSERT(fdb == XFS_DIR2_FREE_FIRSTDB(mp)); 318 ASSERT(fdb == xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET));
319 /* 319 /*
320 * Get the buffer for the new freespace block. 320 * Get the buffer for the new freespace block.
321 */ 321 */
322 error = xfs_dir3_free_get_buf(tp, dp, fdb, &fbp); 322 error = xfs_dir3_free_get_buf(args, fdb, &fbp);
323 if (error) 323 if (error)
324 return error; 324 return error;
325 325
326 free = fbp->b_addr; 326 free = fbp->b_addr;
327 dp->d_ops->free_hdr_from_disk(&freehdr, free); 327 dp->d_ops->free_hdr_from_disk(&freehdr, free);
328 leaf = lbp->b_addr; 328 leaf = lbp->b_addr;
329 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 329 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
330 ASSERT(be32_to_cpu(ltp->bestcount) <= 330 ASSERT(be32_to_cpu(ltp->bestcount) <=
331 (uint)dp->i_d.di_size / mp->m_dirblksize); 331 (uint)dp->i_d.di_size / args->geo->blksize);
332 332
333 /* 333 /*
334 * Copy freespace entries from the leaf block to the new block. 334 * Copy freespace entries from the leaf block to the new block.
@@ -349,8 +349,8 @@ xfs_dir2_leaf_to_node(
349 freehdr.nvalid = be32_to_cpu(ltp->bestcount); 349 freehdr.nvalid = be32_to_cpu(ltp->bestcount);
350 350
351 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr); 351 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
352 xfs_dir2_free_log_bests(tp, dp, fbp, 0, freehdr.nvalid - 1); 352 xfs_dir2_free_log_bests(args, fbp, 0, freehdr.nvalid - 1);
353 xfs_dir2_free_log_header(tp, dp, fbp); 353 xfs_dir2_free_log_header(args, fbp);
354 354
355 /* 355 /*
356 * Converting the leaf to a leafnode is just a matter of changing the 356 * Converting the leaf to a leafnode is just a matter of changing the
@@ -364,7 +364,7 @@ xfs_dir2_leaf_to_node(
364 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC); 364 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC);
365 lbp->b_ops = &xfs_dir3_leafn_buf_ops; 365 lbp->b_ops = &xfs_dir3_leafn_buf_ops;
366 xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF); 366 xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF);
367 xfs_dir3_leaf_log_header(tp, dp, lbp); 367 xfs_dir3_leaf_log_header(args, lbp);
368 xfs_dir3_leaf_check(dp, lbp); 368 xfs_dir3_leaf_check(dp, lbp);
369 return 0; 369 return 0;
370} 370}
@@ -415,7 +415,7 @@ xfs_dir2_leafn_add(
415 * a compact. 415 * a compact.
416 */ 416 */
417 417
418 if (leafhdr.count == dp->d_ops->leaf_max_ents(mp)) { 418 if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) {
419 if (!leafhdr.stale) 419 if (!leafhdr.stale)
420 return XFS_ERROR(ENOSPC); 420 return XFS_ERROR(ENOSPC);
421 compact = leafhdr.stale > 1; 421 compact = leafhdr.stale > 1;
@@ -450,12 +450,12 @@ xfs_dir2_leafn_add(
450 highstale, &lfloglow, &lfloghigh); 450 highstale, &lfloglow, &lfloghigh);
451 451
452 lep->hashval = cpu_to_be32(args->hashval); 452 lep->hashval = cpu_to_be32(args->hashval);
453 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, 453 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(args->geo,
454 args->blkno, args->index)); 454 args->blkno, args->index));
455 455
456 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 456 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
457 xfs_dir3_leaf_log_header(tp, dp, bp); 457 xfs_dir3_leaf_log_header(args, bp);
458 xfs_dir3_leaf_log_ents(tp, dp, bp, lfloglow, lfloghigh); 458 xfs_dir3_leaf_log_ents(args, bp, lfloglow, lfloghigh);
459 xfs_dir3_leaf_check(dp, bp); 459 xfs_dir3_leaf_check(dp, bp);
460 return 0; 460 return 0;
461} 461}
@@ -471,7 +471,8 @@ xfs_dir2_free_hdr_check(
471 471
472 dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr); 472 dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr);
473 473
474 ASSERT((hdr.firstdb % dp->d_ops->free_max_bests(dp->i_mount)) == 0); 474 ASSERT((hdr.firstdb %
475 dp->d_ops->free_max_bests(dp->i_mount->m_dir_geo)) == 0);
475 ASSERT(hdr.firstdb <= db); 476 ASSERT(hdr.firstdb <= db);
476 ASSERT(db < hdr.firstdb + hdr.nvalid); 477 ASSERT(db < hdr.firstdb + hdr.nvalid);
477} 478}
@@ -576,7 +577,8 @@ xfs_dir2_leafn_lookup_for_addname(
576 /* 577 /*
577 * Pull the data block number from the entry. 578 * Pull the data block number from the entry.
578 */ 579 */
579 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 580 newdb = xfs_dir2_dataptr_to_db(args->geo,
581 be32_to_cpu(lep->address));
580 /* 582 /*
581 * For addname, we're looking for a place to put the new entry. 583 * For addname, we're looking for a place to put the new entry.
582 * We want to use a data block with an entry of equal 584 * We want to use a data block with an entry of equal
@@ -593,7 +595,7 @@ xfs_dir2_leafn_lookup_for_addname(
593 * Convert the data block to the free block 595 * Convert the data block to the free block
594 * holding its freespace information. 596 * holding its freespace information.
595 */ 597 */
596 newfdb = dp->d_ops->db_to_fdb(mp, newdb); 598 newfdb = dp->d_ops->db_to_fdb(args->geo, newdb);
597 /* 599 /*
598 * If it's not the one we have in hand, read it in. 600 * If it's not the one we have in hand, read it in.
599 */ 601 */
@@ -605,7 +607,8 @@ xfs_dir2_leafn_lookup_for_addname(
605 xfs_trans_brelse(tp, curbp); 607 xfs_trans_brelse(tp, curbp);
606 608
607 error = xfs_dir2_free_read(tp, dp, 609 error = xfs_dir2_free_read(tp, dp,
608 xfs_dir2_db_to_da(mp, newfdb), 610 xfs_dir2_db_to_da(args->geo,
611 newfdb),
609 &curbp); 612 &curbp);
610 if (error) 613 if (error)
611 return error; 614 return error;
@@ -616,7 +619,7 @@ xfs_dir2_leafn_lookup_for_addname(
616 /* 619 /*
617 * Get the index for our entry. 620 * Get the index for our entry.
618 */ 621 */
619 fi = dp->d_ops->db_to_fdindex(mp, curdb); 622 fi = dp->d_ops->db_to_fdindex(args->geo, curdb);
620 /* 623 /*
621 * If it has room, return it. 624 * If it has room, return it.
622 */ 625 */
@@ -721,7 +724,8 @@ xfs_dir2_leafn_lookup_for_entry(
721 /* 724 /*
722 * Pull the data block number from the entry. 725 * Pull the data block number from the entry.
723 */ 726 */
724 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 727 newdb = xfs_dir2_dataptr_to_db(args->geo,
728 be32_to_cpu(lep->address));
725 /* 729 /*
726 * Not adding a new entry, so we really want to find 730 * Not adding a new entry, so we really want to find
727 * the name given to us. 731 * the name given to us.
@@ -746,7 +750,8 @@ xfs_dir2_leafn_lookup_for_entry(
746 curbp = state->extrablk.bp; 750 curbp = state->extrablk.bp;
747 } else { 751 } else {
748 error = xfs_dir3_data_read(tp, dp, 752 error = xfs_dir3_data_read(tp, dp,
749 xfs_dir2_db_to_da(mp, newdb), 753 xfs_dir2_db_to_da(args->geo,
754 newdb),
750 -1, &curbp); 755 -1, &curbp);
751 if (error) 756 if (error)
752 return error; 757 return error;
@@ -758,7 +763,8 @@ xfs_dir2_leafn_lookup_for_entry(
758 * Point to the data entry. 763 * Point to the data entry.
759 */ 764 */
760 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr + 765 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr +
761 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 766 xfs_dir2_dataptr_to_off(args->geo,
767 be32_to_cpu(lep->address)));
762 /* 768 /*
763 * Compare the entry and if it's an exact match, return 769 * Compare the entry and if it's an exact match, return
764 * EEXIST immediately. If it's the first case-insensitive 770 * EEXIST immediately. If it's the first case-insensitive
@@ -844,7 +850,6 @@ xfs_dir3_leafn_moveents(
844 int start_d,/* destination leaf index */ 850 int start_d,/* destination leaf index */
845 int count) /* count of leaves to copy */ 851 int count) /* count of leaves to copy */
846{ 852{
847 struct xfs_trans *tp = args->trans;
848 int stale; /* count stale leaves copied */ 853 int stale; /* count stale leaves copied */
849 854
850 trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count); 855 trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count);
@@ -863,7 +868,7 @@ xfs_dir3_leafn_moveents(
863 if (start_d < dhdr->count) { 868 if (start_d < dhdr->count) {
864 memmove(&dents[start_d + count], &dents[start_d], 869 memmove(&dents[start_d + count], &dents[start_d],
865 (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t)); 870 (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t));
866 xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, start_d + count, 871 xfs_dir3_leaf_log_ents(args, bp_d, start_d + count,
867 count + dhdr->count - 1); 872 count + dhdr->count - 1);
868 } 873 }
869 /* 874 /*
@@ -885,8 +890,7 @@ xfs_dir3_leafn_moveents(
885 */ 890 */
886 memcpy(&dents[start_d], &sents[start_s], 891 memcpy(&dents[start_d], &sents[start_s],
887 count * sizeof(xfs_dir2_leaf_entry_t)); 892 count * sizeof(xfs_dir2_leaf_entry_t));
888 xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, 893 xfs_dir3_leaf_log_ents(args, bp_d, start_d, start_d + count - 1);
889 start_d, start_d + count - 1);
890 894
891 /* 895 /*
892 * If there are source entries after the ones we copied, 896 * If there are source entries after the ones we copied,
@@ -895,8 +899,7 @@ xfs_dir3_leafn_moveents(
895 if (start_s + count < shdr->count) { 899 if (start_s + count < shdr->count) {
896 memmove(&sents[start_s], &sents[start_s + count], 900 memmove(&sents[start_s], &sents[start_s + count],
897 count * sizeof(xfs_dir2_leaf_entry_t)); 901 count * sizeof(xfs_dir2_leaf_entry_t));
898 xfs_dir3_leaf_log_ents(tp, args->dp, bp_s, 902 xfs_dir3_leaf_log_ents(args, bp_s, start_s, start_s + count - 1);
899 start_s, start_s + count - 1);
900 } 903 }
901 904
902 /* 905 /*
@@ -1032,8 +1035,8 @@ xfs_dir2_leafn_rebalance(
1032 /* log the changes made when moving the entries */ 1035 /* log the changes made when moving the entries */
1033 dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1); 1036 dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1);
1034 dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2); 1037 dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2);
1035 xfs_dir3_leaf_log_header(args->trans, dp, blk1->bp); 1038 xfs_dir3_leaf_log_header(args, blk1->bp);
1036 xfs_dir3_leaf_log_header(args->trans, dp, blk2->bp); 1039 xfs_dir3_leaf_log_header(args, blk2->bp);
1037 1040
1038 xfs_dir3_leaf_check(dp, blk1->bp); 1041 xfs_dir3_leaf_check(dp, blk1->bp);
1039 xfs_dir3_leaf_check(dp, blk2->bp); 1042 xfs_dir3_leaf_check(dp, blk2->bp);
@@ -1076,7 +1079,6 @@ xfs_dir3_data_block_free(
1076 struct xfs_buf *fbp, 1079 struct xfs_buf *fbp,
1077 int longest) 1080 int longest)
1078{ 1081{
1079 struct xfs_trans *tp = args->trans;
1080 int logfree = 0; 1082 int logfree = 0;
1081 __be16 *bests; 1083 __be16 *bests;
1082 struct xfs_dir3_icfree_hdr freehdr; 1084 struct xfs_dir3_icfree_hdr freehdr;
@@ -1090,7 +1092,7 @@ xfs_dir3_data_block_free(
1090 * value. 1092 * value.
1091 */ 1093 */
1092 bests[findex] = cpu_to_be16(longest); 1094 bests[findex] = cpu_to_be16(longest);
1093 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 1095 xfs_dir2_free_log_bests(args, fbp, findex, findex);
1094 return 0; 1096 return 0;
1095 } 1097 }
1096 1098
@@ -1118,7 +1120,7 @@ xfs_dir3_data_block_free(
1118 } 1120 }
1119 1121
1120 dp->d_ops->free_hdr_to_disk(free, &freehdr); 1122 dp->d_ops->free_hdr_to_disk(free, &freehdr);
1121 xfs_dir2_free_log_header(tp, dp, fbp); 1123 xfs_dir2_free_log_header(args, fbp);
1122 1124
1123 /* 1125 /*
1124 * If there are no useful entries left in the block, get rid of the 1126 * If there are no useful entries left in the block, get rid of the
@@ -1142,7 +1144,7 @@ xfs_dir3_data_block_free(
1142 1144
1143 /* Log the free entry that changed, unless we got rid of it. */ 1145 /* Log the free entry that changed, unless we got rid of it. */
1144 if (logfree) 1146 if (logfree)
1145 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 1147 xfs_dir2_free_log_bests(args, fbp, findex, findex);
1146 return 0; 1148 return 0;
1147} 1149}
1148 1150
@@ -1193,9 +1195,9 @@ xfs_dir2_leafn_remove(
1193 /* 1195 /*
1194 * Extract the data block and offset from the entry. 1196 * Extract the data block and offset from the entry.
1195 */ 1197 */
1196 db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 1198 db = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
1197 ASSERT(dblk->blkno == db); 1199 ASSERT(dblk->blkno == db);
1198 off = xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)); 1200 off = xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address));
1199 ASSERT(dblk->index == off); 1201 ASSERT(dblk->index == off);
1200 1202
1201 /* 1203 /*
@@ -1204,10 +1206,10 @@ xfs_dir2_leafn_remove(
1204 */ 1206 */
1205 leafhdr.stale++; 1207 leafhdr.stale++;
1206 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 1208 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1207 xfs_dir3_leaf_log_header(tp, dp, bp); 1209 xfs_dir3_leaf_log_header(args, bp);
1208 1210
1209 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); 1211 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
1210 xfs_dir3_leaf_log_ents(tp, dp, bp, index, index); 1212 xfs_dir3_leaf_log_ents(args, bp, index, index);
1211 1213
1212 /* 1214 /*
1213 * Make the data entry free. Keep track of the longest freespace 1215 * Make the data entry free. Keep track of the longest freespace
@@ -1219,7 +1221,7 @@ xfs_dir2_leafn_remove(
1219 bf = dp->d_ops->data_bestfree_p(hdr); 1221 bf = dp->d_ops->data_bestfree_p(hdr);
1220 longest = be16_to_cpu(bf[0].length); 1222 longest = be16_to_cpu(bf[0].length);
1221 needlog = needscan = 0; 1223 needlog = needscan = 0;
1222 xfs_dir2_data_make_free(tp, dp, dbp, off, 1224 xfs_dir2_data_make_free(args, dbp, off,
1223 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); 1225 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
1224 /* 1226 /*
1225 * Rescan the data block freespaces for bestfree. 1227 * Rescan the data block freespaces for bestfree.
@@ -1228,7 +1230,7 @@ xfs_dir2_leafn_remove(
1228 if (needscan) 1230 if (needscan)
1229 xfs_dir2_data_freescan(dp, hdr, &needlog); 1231 xfs_dir2_data_freescan(dp, hdr, &needlog);
1230 if (needlog) 1232 if (needlog)
1231 xfs_dir2_data_log_header(tp, dp, dbp); 1233 xfs_dir2_data_log_header(args, dbp);
1232 xfs_dir3_data_check(dp, dbp); 1234 xfs_dir3_data_check(dp, dbp);
1233 /* 1235 /*
1234 * If the longest data block freespace changes, need to update 1236 * If the longest data block freespace changes, need to update
@@ -1245,8 +1247,9 @@ xfs_dir2_leafn_remove(
1245 * Convert the data block number to a free block, 1247 * Convert the data block number to a free block,
1246 * read in the free block. 1248 * read in the free block.
1247 */ 1249 */
1248 fdb = dp->d_ops->db_to_fdb(mp, db); 1250 fdb = dp->d_ops->db_to_fdb(args->geo, db);
1249 error = xfs_dir2_free_read(tp, dp, xfs_dir2_db_to_da(mp, fdb), 1251 error = xfs_dir2_free_read(tp, dp,
1252 xfs_dir2_db_to_da(args->geo, fdb),
1250 &fbp); 1253 &fbp);
1251 if (error) 1254 if (error)
1252 return error; 1255 return error;
@@ -1255,20 +1258,21 @@ xfs_dir2_leafn_remove(
1255 { 1258 {
1256 struct xfs_dir3_icfree_hdr freehdr; 1259 struct xfs_dir3_icfree_hdr freehdr;
1257 dp->d_ops->free_hdr_from_disk(&freehdr, free); 1260 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1258 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(mp) * 1261 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(args->geo) *
1259 (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); 1262 (fdb - xfs_dir2_byte_to_db(args->geo,
1263 XFS_DIR2_FREE_OFFSET)));
1260 } 1264 }
1261#endif 1265#endif
1262 /* 1266 /*
1263 * Calculate which entry we need to fix. 1267 * Calculate which entry we need to fix.
1264 */ 1268 */
1265 findex = dp->d_ops->db_to_fdindex(mp, db); 1269 findex = dp->d_ops->db_to_fdindex(args->geo, db);
1266 longest = be16_to_cpu(bf[0].length); 1270 longest = be16_to_cpu(bf[0].length);
1267 /* 1271 /*
1268 * If the data block is now empty we can get rid of it 1272 * If the data block is now empty we can get rid of it
1269 * (usually). 1273 * (usually).
1270 */ 1274 */
1271 if (longest == mp->m_dirblksize - 1275 if (longest == args->geo->blksize -
1272 dp->d_ops->data_entry_offset) { 1276 dp->d_ops->data_entry_offset) {
1273 /* 1277 /*
1274 * Try to punch out the data block. 1278 * Try to punch out the data block.
@@ -1303,7 +1307,7 @@ xfs_dir2_leafn_remove(
1303 */ 1307 */
1304 *rval = (dp->d_ops->leaf_hdr_size + 1308 *rval = (dp->d_ops->leaf_hdr_size +
1305 (uint)sizeof(ents[0]) * (leafhdr.count - leafhdr.stale)) < 1309 (uint)sizeof(ents[0]) * (leafhdr.count - leafhdr.stale)) <
1306 mp->m_dir_magicpct; 1310 args->geo->magicpct;
1307 return 0; 1311 return 0;
1308} 1312}
1309 1313
@@ -1336,7 +1340,7 @@ xfs_dir2_leafn_split(
1336 /* 1340 /*
1337 * Initialize the new leaf block. 1341 * Initialize the new leaf block.
1338 */ 1342 */
1339 error = xfs_dir3_leaf_get_buf(args, xfs_dir2_da_to_db(mp, blkno), 1343 error = xfs_dir3_leaf_get_buf(args, xfs_dir2_da_to_db(args->geo, blkno),
1340 &newblk->bp, XFS_DIR2_LEAFN_MAGIC); 1344 &newblk->bp, XFS_DIR2_LEAFN_MAGIC);
1341 if (error) 1345 if (error)
1342 return error; 1346 return error;
@@ -1410,7 +1414,7 @@ xfs_dir2_leafn_toosmall(
1410 1414
1411 count = leafhdr.count - leafhdr.stale; 1415 count = leafhdr.count - leafhdr.stale;
1412 bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]); 1416 bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]);
1413 if (bytes > (state->blocksize >> 1)) { 1417 if (bytes > (state->args->geo->blksize >> 1)) {
1414 /* 1418 /*
1415 * Blk over 50%, don't try to join. 1419 * Blk over 50%, don't try to join.
1416 */ 1420 */
@@ -1463,7 +1467,8 @@ xfs_dir2_leafn_toosmall(
1463 * Count bytes in the two blocks combined. 1467 * Count bytes in the two blocks combined.
1464 */ 1468 */
1465 count = leafhdr.count - leafhdr.stale; 1469 count = leafhdr.count - leafhdr.stale;
1466 bytes = state->blocksize - (state->blocksize >> 2); 1470 bytes = state->args->geo->blksize -
1471 (state->args->geo->blksize >> 2);
1467 1472
1468 leaf = bp->b_addr; 1473 leaf = bp->b_addr;
1469 dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf); 1474 dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf);
@@ -1560,8 +1565,8 @@ xfs_dir2_leafn_unbalance(
1560 /* log the changes made when moving the entries */ 1565 /* log the changes made when moving the entries */
1561 dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr); 1566 dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr);
1562 dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr); 1567 dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr);
1563 xfs_dir3_leaf_log_header(args->trans, dp, save_blk->bp); 1568 xfs_dir3_leaf_log_header(args, save_blk->bp);
1564 xfs_dir3_leaf_log_header(args->trans, dp, drop_blk->bp); 1569 xfs_dir3_leaf_log_header(args, drop_blk->bp);
1565 1570
1566 xfs_dir3_leaf_check(dp, save_blk->bp); 1571 xfs_dir3_leaf_check(dp, save_blk->bp);
1567 xfs_dir3_leaf_check(dp, drop_blk->bp); 1572 xfs_dir3_leaf_check(dp, drop_blk->bp);
@@ -1587,8 +1592,6 @@ xfs_dir2_node_addname(
1587 state = xfs_da_state_alloc(); 1592 state = xfs_da_state_alloc();
1588 state->args = args; 1593 state->args = args;
1589 state->mp = args->dp->i_mount; 1594 state->mp = args->dp->i_mount;
1590 state->blocksize = state->mp->m_dirblksize;
1591 state->node_ents = state->mp->m_dir_node_ents;
1592 /* 1595 /*
1593 * Look up the name. We're not supposed to find it, but 1596 * Look up the name. We're not supposed to find it, but
1594 * this gives us the insertion point. 1597 * this gives us the insertion point.
@@ -1727,9 +1730,9 @@ xfs_dir2_node_addname_int(
1727 if (dbno == -1) { 1730 if (dbno == -1) {
1728 xfs_fileoff_t fo; /* freespace block number */ 1731 xfs_fileoff_t fo; /* freespace block number */
1729 1732
1730 if ((error = xfs_bmap_last_offset(tp, dp, &fo, XFS_DATA_FORK))) 1733 if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK)))
1731 return error; 1734 return error;
1732 lastfbno = xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo); 1735 lastfbno = xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)fo);
1733 fbno = ifbno; 1736 fbno = ifbno;
1734 } 1737 }
1735 /* 1738 /*
@@ -1747,7 +1750,8 @@ xfs_dir2_node_addname_int(
1747 * us a freespace block to start with. 1750 * us a freespace block to start with.
1748 */ 1751 */
1749 if (++fbno == 0) 1752 if (++fbno == 0)
1750 fbno = XFS_DIR2_FREE_FIRSTDB(mp); 1753 fbno = xfs_dir2_byte_to_db(args->geo,
1754 XFS_DIR2_FREE_OFFSET);
1751 /* 1755 /*
1752 * If it's ifbno we already looked at it. 1756 * If it's ifbno we already looked at it.
1753 */ 1757 */
@@ -1765,8 +1769,8 @@ xfs_dir2_node_addname_int(
1765 * to avoid it. 1769 * to avoid it.
1766 */ 1770 */
1767 error = xfs_dir2_free_try_read(tp, dp, 1771 error = xfs_dir2_free_try_read(tp, dp,
1768 xfs_dir2_db_to_da(mp, fbno), 1772 xfs_dir2_db_to_da(args->geo, fbno),
1769 &fbp); 1773 &fbp);
1770 if (error) 1774 if (error)
1771 return error; 1775 return error;
1772 if (!fbp) 1776 if (!fbp)
@@ -1834,10 +1838,10 @@ xfs_dir2_node_addname_int(
1834 * Get the freespace block corresponding to the data block 1838 * Get the freespace block corresponding to the data block
1835 * that was just allocated. 1839 * that was just allocated.
1836 */ 1840 */
1837 fbno = dp->d_ops->db_to_fdb(mp, dbno); 1841 fbno = dp->d_ops->db_to_fdb(args->geo, dbno);
1838 error = xfs_dir2_free_try_read(tp, dp, 1842 error = xfs_dir2_free_try_read(tp, dp,
1839 xfs_dir2_db_to_da(mp, fbno), 1843 xfs_dir2_db_to_da(args->geo, fbno),
1840 &fbp); 1844 &fbp);
1841 if (error) 1845 if (error)
1842 return error; 1846 return error;
1843 1847
@@ -1851,12 +1855,13 @@ xfs_dir2_node_addname_int(
1851 if (error) 1855 if (error)
1852 return error; 1856 return error;
1853 1857
1854 if (unlikely(dp->d_ops->db_to_fdb(mp, dbno) != fbno)) { 1858 if (dp->d_ops->db_to_fdb(args->geo, dbno) != fbno) {
1855 xfs_alert(mp, 1859 xfs_alert(mp,
1856 "%s: dir ino %llu needed freesp block %lld for\n" 1860 "%s: dir ino %llu needed freesp block %lld for\n"
1857 " data block %lld, got %lld ifbno %llu lastfbno %d", 1861 " data block %lld, got %lld ifbno %llu lastfbno %d",
1858 __func__, (unsigned long long)dp->i_ino, 1862 __func__, (unsigned long long)dp->i_ino,
1859 (long long)dp->d_ops->db_to_fdb(mp, dbno), 1863 (long long)dp->d_ops->db_to_fdb(
1864 args->geo, dbno),
1860 (long long)dbno, (long long)fbno, 1865 (long long)dbno, (long long)fbno,
1861 (unsigned long long)ifbno, lastfbno); 1866 (unsigned long long)ifbno, lastfbno);
1862 if (fblk) { 1867 if (fblk) {
@@ -1877,7 +1882,7 @@ xfs_dir2_node_addname_int(
1877 /* 1882 /*
1878 * Get a buffer for the new block. 1883 * Get a buffer for the new block.
1879 */ 1884 */
1880 error = xfs_dir3_free_get_buf(tp, dp, fbno, &fbp); 1885 error = xfs_dir3_free_get_buf(args, fbno, &fbp);
1881 if (error) 1886 if (error)
1882 return error; 1887 return error;
1883 free = fbp->b_addr; 1888 free = fbp->b_addr;
@@ -1887,8 +1892,10 @@ xfs_dir2_node_addname_int(
1887 /* 1892 /*
1888 * Remember the first slot as our empty slot. 1893 * Remember the first slot as our empty slot.
1889 */ 1894 */
1890 freehdr.firstdb = (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * 1895 freehdr.firstdb =
1891 dp->d_ops->free_max_bests(mp); 1896 (fbno - xfs_dir2_byte_to_db(args->geo,
1897 XFS_DIR2_FREE_OFFSET)) *
1898 dp->d_ops->free_max_bests(args->geo);
1892 } else { 1899 } else {
1893 free = fbp->b_addr; 1900 free = fbp->b_addr;
1894 bests = dp->d_ops->free_bests_p(free); 1901 bests = dp->d_ops->free_bests_p(free);
@@ -1898,13 +1905,13 @@ xfs_dir2_node_addname_int(
1898 /* 1905 /*
1899 * Set the freespace block index from the data block number. 1906 * Set the freespace block index from the data block number.
1900 */ 1907 */
1901 findex = dp->d_ops->db_to_fdindex(mp, dbno); 1908 findex = dp->d_ops->db_to_fdindex(args->geo, dbno);
1902 /* 1909 /*
1903 * If it's after the end of the current entries in the 1910 * If it's after the end of the current entries in the
1904 * freespace block, extend that table. 1911 * freespace block, extend that table.
1905 */ 1912 */
1906 if (findex >= freehdr.nvalid) { 1913 if (findex >= freehdr.nvalid) {
1907 ASSERT(findex < dp->d_ops->free_max_bests(mp)); 1914 ASSERT(findex < dp->d_ops->free_max_bests(args->geo));
1908 freehdr.nvalid = findex + 1; 1915 freehdr.nvalid = findex + 1;
1909 /* 1916 /*
1910 * Tag new entry so nused will go up. 1917 * Tag new entry so nused will go up.
@@ -1918,7 +1925,7 @@ xfs_dir2_node_addname_int(
1918 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) { 1925 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) {
1919 freehdr.nused++; 1926 freehdr.nused++;
1920 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr); 1927 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
1921 xfs_dir2_free_log_header(tp, dp, fbp); 1928 xfs_dir2_free_log_header(args, fbp);
1922 } 1929 }
1923 /* 1930 /*
1924 * Update the real value in the table. 1931 * Update the real value in the table.
@@ -1943,7 +1950,8 @@ xfs_dir2_node_addname_int(
1943 /* 1950 /*
1944 * Read the data block in. 1951 * Read the data block in.
1945 */ 1952 */
1946 error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(mp, dbno), 1953 error = xfs_dir3_data_read(tp, dp,
1954 xfs_dir2_db_to_da(args->geo, dbno),
1947 -1, &dbp); 1955 -1, &dbp);
1948 if (error) 1956 if (error)
1949 return error; 1957 return error;
@@ -1961,7 +1969,7 @@ xfs_dir2_node_addname_int(
1961 /* 1969 /*
1962 * Mark the first part of the unused space, inuse for us. 1970 * Mark the first part of the unused space, inuse for us.
1963 */ 1971 */
1964 xfs_dir2_data_use_free(tp, dp, dbp, dup, 1972 xfs_dir2_data_use_free(args, dbp, dup,
1965 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, 1973 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
1966 &needlog, &needscan); 1974 &needlog, &needscan);
1967 /* 1975 /*
@@ -1974,7 +1982,7 @@ xfs_dir2_node_addname_int(
1974 dp->d_ops->data_put_ftype(dep, args->filetype); 1982 dp->d_ops->data_put_ftype(dep, args->filetype);
1975 tagp = dp->d_ops->data_entry_tag_p(dep); 1983 tagp = dp->d_ops->data_entry_tag_p(dep);
1976 *tagp = cpu_to_be16((char *)dep - (char *)hdr); 1984 *tagp = cpu_to_be16((char *)dep - (char *)hdr);
1977 xfs_dir2_data_log_entry(tp, dp, dbp, dep); 1985 xfs_dir2_data_log_entry(args, dbp, dep);
1978 /* 1986 /*
1979 * Rescan the block for bestfree if needed. 1987 * Rescan the block for bestfree if needed.
1980 */ 1988 */
@@ -1984,7 +1992,7 @@ xfs_dir2_node_addname_int(
1984 * Log the data block header if needed. 1992 * Log the data block header if needed.
1985 */ 1993 */
1986 if (needlog) 1994 if (needlog)
1987 xfs_dir2_data_log_header(tp, dp, dbp); 1995 xfs_dir2_data_log_header(args, dbp);
1988 /* 1996 /*
1989 * If the freespace entry is now wrong, update it. 1997 * If the freespace entry is now wrong, update it.
1990 */ 1998 */
@@ -1997,7 +2005,7 @@ xfs_dir2_node_addname_int(
1997 * Log the freespace entry if needed. 2005 * Log the freespace entry if needed.
1998 */ 2006 */
1999 if (logfree) 2007 if (logfree)
2000 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 2008 xfs_dir2_free_log_bests(args, fbp, findex, findex);
2001 /* 2009 /*
2002 * Return the data block and offset in args, then drop the data block. 2010 * Return the data block and offset in args, then drop the data block.
2003 */ 2011 */
@@ -2028,8 +2036,6 @@ xfs_dir2_node_lookup(
2028 state = xfs_da_state_alloc(); 2036 state = xfs_da_state_alloc();
2029 state->args = args; 2037 state->args = args;
2030 state->mp = args->dp->i_mount; 2038 state->mp = args->dp->i_mount;
2031 state->blocksize = state->mp->m_dirblksize;
2032 state->node_ents = state->mp->m_dir_node_ents;
2033 /* 2039 /*
2034 * Fill in the path to the entry in the cursor. 2040 * Fill in the path to the entry in the cursor.
2035 */ 2041 */
@@ -2083,8 +2089,6 @@ xfs_dir2_node_removename(
2083 state = xfs_da_state_alloc(); 2089 state = xfs_da_state_alloc();
2084 state->args = args; 2090 state->args = args;
2085 state->mp = args->dp->i_mount; 2091 state->mp = args->dp->i_mount;
2086 state->blocksize = state->mp->m_dirblksize;
2087 state->node_ents = state->mp->m_dir_node_ents;
2088 2092
2089 /* Look up the entry we're deleting, set up the cursor. */ 2093 /* Look up the entry we're deleting, set up the cursor. */
2090 error = xfs_da3_node_lookup_int(state, &rval); 2094 error = xfs_da3_node_lookup_int(state, &rval);
@@ -2153,8 +2157,6 @@ xfs_dir2_node_replace(
2153 state = xfs_da_state_alloc(); 2157 state = xfs_da_state_alloc();
2154 state->args = args; 2158 state->args = args;
2155 state->mp = args->dp->i_mount; 2159 state->mp = args->dp->i_mount;
2156 state->blocksize = state->mp->m_dirblksize;
2157 state->node_ents = state->mp->m_dir_node_ents;
2158 inum = args->inumber; 2160 inum = args->inumber;
2159 /* 2161 /*
2160 * Lookup the entry to change in the btree. 2162 * Lookup the entry to change in the btree.
@@ -2186,15 +2188,15 @@ xfs_dir2_node_replace(
2186 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); 2188 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
2187 dep = (xfs_dir2_data_entry_t *) 2189 dep = (xfs_dir2_data_entry_t *)
2188 ((char *)hdr + 2190 ((char *)hdr +
2189 xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); 2191 xfs_dir2_dataptr_to_off(args->geo,
2192 be32_to_cpu(lep->address)));
2190 ASSERT(inum != be64_to_cpu(dep->inumber)); 2193 ASSERT(inum != be64_to_cpu(dep->inumber));
2191 /* 2194 /*
2192 * Fill in the new inode number and log the entry. 2195 * Fill in the new inode number and log the entry.
2193 */ 2196 */
2194 dep->inumber = cpu_to_be64(inum); 2197 dep->inumber = cpu_to_be64(inum);
2195 args->dp->d_ops->data_put_ftype(dep, args->filetype); 2198 args->dp->d_ops->data_put_ftype(dep, args->filetype);
2196 xfs_dir2_data_log_entry(args->trans, args->dp, 2199 xfs_dir2_data_log_entry(args, state->extrablk.bp, dep);
2197 state->extrablk.bp, dep);
2198 rval = 0; 2200 rval = 0;
2199 } 2201 }
2200 /* 2202 /*
@@ -2262,9 +2264,9 @@ xfs_dir2_node_trim_free(
2262 /* 2264 /*
2263 * Blow the block away. 2265 * Blow the block away.
2264 */ 2266 */
2265 if ((error = 2267 error = xfs_dir2_shrink_inode(args,
2266 xfs_dir2_shrink_inode(args, xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo), 2268 xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)fo), bp);
2267 bp))) { 2269 if (error) {
2268 /* 2270 /*
2269 * Can't fail with ENOSPC since that only happens with no 2271 * Can't fail with ENOSPC since that only happens with no
2270 * space reservation, when breaking up an extent into two 2272 * space reservation, when breaking up an extent into two