44 #define xfs_dir2_leafn_check(dp, bp)
47 int start_s,
struct xfs_buf *bp_d,
48 int start_d,
int count);
73 (
uint)((
char *)&free->
bests[first] - (
char *)free),
74 (
uint)((
char *)&free->
bests[last] - (
char *)free +
75 sizeof(free->
bests[0]) - 1));
82 xfs_dir2_free_log_header(
119 trace_xfs_dir2_leaf_to_node(args);
134 if ((error =
xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, fdb), -1, &fbp,
141 ltp = xfs_dir2_leaf_tail_p(mp, leaf);
153 for (i = n = 0, from = xfs_dir2_leaf_bests_p(ltp), to = free->
bests;
165 xfs_dir2_free_log_header(tp, fbp);
192 trace_xfs_dir2_leafn_add(args, index);
232 &lfloglow, &lfloghigh);
246 highstale, &lfloglow, &lfloghigh);
263 struct xfs_inode *dp,
357 length = xfs_dir2_data_entsize(args->
namelen);
381 if (newdb != curdb) {
387 newfdb = xfs_dir2_db_to_fdb(mp, newdb);
391 if (newfdb != curfdb) {
401 xfs_dir2_db_to_da(mp, newfdb),
409 xfs_dir2_free_max_bests(mp)) == 0);
417 fi = xfs_dir2_db_to_fdindex(mp, curdb);
425 if (curfdb != newfdb)
520 if (newdb != curdb) {
538 xfs_dir2_db_to_da(mp, newdb),
556 cmp = mp->m_dirnameops->compname(args, dep->
name, dep->
namelen);
620 xfs_dir2_leafn_moveents(
633 trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count);
663 for (i = start_s, stale = 0; i < start_s +
count; i++) {
688 be16_add_cpu(&leaf_s->
hdr.
count, -(count));
689 be16_add_cpu(&leaf_s->
hdr.
stale, -(stale));
690 be16_add_cpu(&leaf_d->
hdr.
count, count);
691 be16_add_cpu(&leaf_d->
hdr.
stale, stale);
731 xfs_dir2_leafn_rebalance(
759 leaf1 = blk1->
bp->b_addr;
760 leaf2 = blk2->
bp->b_addr;
777 isleft = args->
hashval <= midhash;
792 xfs_dir2_leafn_moveents(args, blk1->
bp,
795 xfs_dir2_leafn_moveents(args, blk2->
bp, 0, blk1->
bp,
819 if(blk2->
index < 0) {
822 xfs_alert(args->
dp->i_mount,
823 "%s: picked the wrong leaf? reverting original leaf: blk1->index %d\n",
824 __func__, blk1->
index);
834 xfs_dir2_leafn_remove(
855 trace_xfs_dir2_leafn_remove(args, index);
889 needlog = needscan = 0;
891 xfs_dir2_data_entsize(dep->
namelen), &needlog, &needscan);
917 fdb = xfs_dir2_db_to_fdb(mp, db);
925 xfs_dir2_free_max_bests(mp) *
930 findex = xfs_dir2_db_to_fdindex(mp, db);
936 if (longest == mp->m_dirblksize - (
uint)
sizeof(*hdr)) {
962 xfs_dir2_free_log_header(tp, fbp);
1050 mp = args->
dp->i_mount;
1065 newblk->
blkno = blkno;
1071 xfs_dir2_leafn_rebalance(state, oldblk, newblk);
1080 error = xfs_dir2_leafn_add(oldblk->
bp, args, oldblk->
index);
1082 error = xfs_dir2_leafn_add(newblk->
bp, args, newblk->
index);
1125 info = blk->
bp->b_addr;
1129 bytes = (
uint)
sizeof(leaf->
hdr) + count * (
uint)
sizeof(leaf->
ents[0]);
1148 forward = (info->
forw != 0);
1154 *action = rval ? 2 : 0;
1165 for (i = 0, bp =
NULL; i < 2; forward = !forward, i++) {
1187 bytes -= count * (
uint)
sizeof(leaf->
ents[0]);
1208 if (blkno < blk->blkno)
1217 *action = rval ? 0 : 1;
1238 drop_leaf = drop_blk->
bp->b_addr;
1239 save_leaf = save_blk->
bp->b_addr;
1255 xfs_dir2_leafn_moveents(args, drop_blk->
bp, 0, save_blk->
bp, 0,
1258 xfs_dir2_leafn_moveents(args, drop_blk->
bp, 0, save_blk->
bp,
1276 trace_xfs_dir2_node_addname(args);
1283 state->
mp = args->
dp->i_mount;
1300 rval = xfs_dir2_node_addname_int(args,
1310 rval = xfs_dir2_leafn_add(blk->
bp, args, blk->
index);
1321 if (args->
total == 0) {
1341 xfs_dir2_node_addname_int(
1369 length = xfs_dir2_data_entsize(args->
namelen);
1380 ifbno = fblk->
blkno;
1383 findex = fblk->
index;
1422 lastfbno = xfs_dir2_da_to_db(mp, (
xfs_dablk_t)fo);
1430 while (dbno == -1) {
1449 if (fbno >= lastfbno)
1458 xfs_dir2_db_to_da(mp, fbno), -2, &fbp,
1485 if (fblk && fblk->
bp)
1515 if (fblk && fblk->
bp)
1522 fbno = xfs_dir2_db_to_fdb(mp, dbno);
1524 xfs_dir2_db_to_da(mp, fbno), -2, &fbp,
1538 if (
unlikely(xfs_dir2_db_to_fdb(mp, dbno) != fbno)) {
1540 "%s: dir ino %llu needed freesp block %lld for\n"
1541 " data block %lld, got %lld ifbno %llu lastfbno %d",
1542 __func__, (
unsigned long long)dp->i_ino,
1543 (
long long)xfs_dir2_db_to_fdb(mp, dbno),
1544 (
long long)dbno, (
long long)fbno,
1545 (
unsigned long long)ifbno, lastfbno);
1548 " fblk 0x%p blkno %llu index %d magic 0x%x",
1550 (
unsigned long long)fblk->
blkno,
1554 xfs_alert(mp,
" ... fblk is NULL");
1565 xfs_dir2_db_to_da(mp, fbno),
1579 xfs_dir2_free_max_bests(mp));
1590 findex = xfs_dir2_db_to_fdindex(mp, dbno);
1596 ASSERT(findex < xfs_dir2_free_max_bests(mp));
1609 xfs_dir2_free_log_header(tp, fbp);
1646 needscan = needlog = 0;
1652 &needlog, &needscan);
1660 tagp = xfs_dir2_data_entry_tag_p(dep);
1707 trace_xfs_dir2_node_lookup(args);
1714 state->
mp = args->
dp->i_mount;
1762 trace_xfs_dir2_node_removename(args);
1769 state->
mp = args->
dp->i_mount;
1792 error = xfs_dir2_leafn_remove(args, blk->
bp, blk->
index,
1832 trace_xfs_dir2_node_replace(args);
1839 state->
mp = args->
dp->i_mount;
1860 leaf = blk->
bp->b_addr;