110 trace_xfs_da_node_create(args);
118 node->
hdr.info.forw = 0;
119 node->
hdr.info.back = 0;
121 node->
hdr.info.pad = 0;
144 trace_xfs_da_split(state->
args);
158 for (i = max; (i >= 0) && addblk; state->
path.
active--, i--) {
168 switch (oldblk->
magic) {
171 if ((error != 0) && (error !=
ENOSPC)) {
184 trace_xfs_attr_leaf_split_before(state->
args);
189 trace_xfs_attr_leaf_split_after(state->
args);
245 node = oldblk->
bp->b_addr;
246 if (node->
hdr.info.forw) {
257 sizeof(node->
hdr.info)));
259 node = oldblk->
bp->b_addr;
260 if (node->
hdr.info.back) {
271 sizeof(node->
hdr.info)));
296 trace_xfs_da_root_split(state->
args);
315 oldroot = blk1->
bp->b_addr;
325 memcpy(node, oldroot, size);
348 blk1->
blkno < mp->m_dirfreeblk);
350 blk2->
blkno < mp->m_dirfreeblk);
369 int treelevel,
int *
result)
376 trace_xfs_da_node_split(state->
args);
378 node = oldblk->
bp->b_addr;
385 newcount = 1 + useextra;
402 newblk->
blkno = blkno;
425 node = oldblk->
bp->b_addr;
464 trace_xfs_da_node_rebalance(state->
args);
466 node1 = blk1->
bp->b_addr;
467 node2 = blk2->
bp->b_addr;
495 btree_s = &node2->
btree[0];
497 memmove(btree_d, btree_s, tmp);
504 be16_add_cpu(&node2->
hdr.count, count);
507 btree_d = &node2->
btree[0];
508 memcpy(btree_d, btree_s, tmp);
509 be16_add_cpu(&node1->
hdr.count, -count);
517 btree_s = &node2->
btree[0];
519 memcpy(btree_d, btree_s, tmp);
520 be16_add_cpu(&node1->
hdr.count, count);
530 btree_d = &node2->
btree[0];
531 memmove(btree_d, btree_s, tmp);
532 be16_add_cpu(&node2->
hdr.count, -count);
549 node1 = blk1->
bp->b_addr;
550 node2 = blk2->
bp->b_addr;
574 trace_xfs_da_node_add(state->
args);
576 node = oldblk->
bp->b_addr;
582 newblk->
blkno < state->
mp->m_dirfreeblk);
591 memmove(btree + 1, btree, tmp);
597 be16_add_cpu(&node->
hdr.count, 1);
621 trace_xfs_da_join(state->
args);
634 for ( ; state->
path.
active >= 2; drop_blk--, save_blk--,
642 switch (drop_blk->
magic) {
711 #define xfs_da_blkinfo_onlychild_validate(blkinfo, level)
727 trace_xfs_da_root_join(state->
args);
732 oldroot = root_blk->
bp->b_addr;
788 info = blk->
bp->b_addr;
808 forward = (info->
forw != 0);
831 for (i = 0; i < 2; forward = !forward, i++) {
865 if (blkno < blk->blkno) {
905 switch (blk->
magic) {
922 for (blk--, level--; level >= 0; blk--, level--) {
923 node = blk->
bp->b_addr;
947 trace_xfs_da_node_remove(state->
args);
949 node = drop_blk->
bp->b_addr;
960 memmove(btree, btree + 1, tmp);
968 be16_add_cpu(&node->
hdr.count, -1);
992 trace_xfs_da_node_unbalance(state->
args);
994 drop_node = drop_blk->
bp->b_addr;
995 save_node = save_blk->
bp->b_addr;
1011 btree = &save_node->
btree[0];
1033 sizeof(save_node->
hdr)));
1089 curr = blk->
bp->b_addr;
1099 node = blk->
bp->b_addr;
1106 probe = span = max / 2;
1108 for (btree = &node->
btree[probe]; span > 4;
1109 btree = &node->
btree[probe]) {
1112 if (btreehashval < hashval)
1114 else if (btreehashval > hashval)
1119 ASSERT((probe >= 0) && (probe < max));
1126 while ((probe > 0) && (
be32_to_cpu(btree->hashval) >= hashval)) {
1130 while ((probe < max) && (
be32_to_cpu(btree->hashval) < hashval)) {
1163 &blk->
index, state);
1204 int before=0,
error;
1212 old_info = old_blk->
bp->b_addr;
1213 new_info = new_blk->
bp->b_addr;
1221 switch (old_blk->
magic) {
1240 trace_xfs_da_link_before(args);
1243 if (old_info->
back) {
1261 trace_xfs_da_link_after(args);
1264 if (old_info->
forw) {
1295 node1 = node1_bp->
b_addr;
1296 node2 = node2_bp->
b_addr;
1323 if (!node->
hdr.count)
1345 save_info = save_blk->
bp->b_addr;
1346 drop_info = drop_blk->
bp->b_addr;
1362 trace_xfs_da_unlink_back(args);
1364 if (drop_info->
back) {
1376 sizeof(*tmp_info) - 1);
1379 trace_xfs_da_unlink_forward(args);
1381 if (drop_info->
forw) {
1393 sizeof(*tmp_info) - 1);
1429 level = (path->
active-1) - 1;
1430 for (blk = &path->
blk[level]; level >= 0; blk--, level--) {
1432 node = blk->
bp->b_addr;
1438 }
else if (!forward && (blk->
index > 0)) {
1454 for (blk++, level++; level < path->
active; blk++, level++) {
1471 info = blk->
bp->b_addr;
1487 switch(blk->
magic) {
1525 for (hash = 0; namelen >= 4; namelen -= 4, name += 4)
1526 hash = (name[0] << 21) ^ (name[1] << 14) ^ (name[2] << 7) ^
1527 (name[3] << 0) ^ rol32(hash, 7 * 4);
1534 return (name[0] << 14) ^ (name[1] << 7) ^ (name[2] << 0) ^
1537 return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2);
1539 return (name[0] << 0) ^ rol32(hash, 7 * 1);
1548 const unsigned char *
name,
1556 xfs_default_hashname(
1563 .hashname = xfs_default_hashname,
1573 struct xfs_trans *tp = args->
trans;
1574 struct xfs_inode *
dp = args->
dp;
1578 int nmap,
error, got,
i, mapi;
1603 }
else if (nmap == 0 && count > 1) {
1612 for (b = *bno, mapi = 0; b < *bno +
count; ) {
1614 c = (
int)(*bno + count - b);
1618 &mapp[mapi], &nmap, args->
flist);
1635 for (i = 0, got = 0; i < mapi; i++)
1637 if (got != count || mapp[0].
br_startoff != *bno ||
1645 args->
total -= dp->i_d.di_nblocks - nblks;
1666 trace_xfs_da_grow_inode(args);
1669 bno = args->
dp->i_mount->m_dirleafblk;
1670 count = args->
dp->i_mount->m_dirblkfsbs;
1696 xfs_dablk_t dead_blkno, last_blkno, sib_blkno, par_blkno;
1697 struct xfs_buf *dead_buf, *last_buf, *sib_buf, *par_buf;
1708 trace_xfs_da_swap_lastblock(args);
1710 dead_buf = *dead_bufp;
1711 dead_blkno = *dead_blknop;
1717 lastoff = mp->m_dirfreeblk;
1729 last_blkno = (
xfs_dablk_t)lastoff - mp->m_dirblkfsbs;
1737 dead_info = dead_buf->
b_addr;
1751 sib_buf = par_buf =
NULL;
1758 sib_info = sib_buf->
b_addr;
1770 sizeof(sib_info->
forw)));
1779 sib_info = sib_buf->
b_addr;
1791 sizeof(sib_info->
back)));
1794 par_blkno = mp->m_dirleafblk;
1802 par_node = par_buf->
b_addr;
1805 (level >= 0 && level !=
be16_to_cpu(par_node->
hdr.level) + 1))) {
1824 if (level == dead_level + 1)
1852 par_node = par_buf->
b_addr;
1869 sizeof(par_node->
btree[entno].before)));
1870 *dead_blknop = last_blkno;
1871 *dead_bufp = last_buf;
1896 trace_xfs_da_shrink_inode(args);
1903 count = mp->m_dirblkfsbs;
1911 if ((error =
xfs_bunmapi(tp, dp, dead_blkno, count,
1942 for (i = 0, off = bno; i < nmap; i++) {
1947 if (off != mapp[i].br_startoff) {
1952 return off == bno +
count;
1964 xfs_buf_map_from_irec(
1965 struct xfs_mount *
mp,
1967 unsigned int *nmaps,
1969 unsigned int nirecs)
1986 for (i = 0; i < *nmaps; i++) {
2005 struct xfs_trans *
trans,
2006 struct xfs_inode *
dp,
2008 xfs_daddr_t mappedbno,
2013 struct xfs_mount *mp = dp->i_mount;
2029 if (mappedbno == -1 || mappedbno == -2) {
2038 &nirecs, xfs_bmapi_aflag(whichfork));
2054 xfs_alert(mp,
"%s: bno %lld dir: inode %lld",
2055 __func__, (
long long)bno,
2056 (
long long)dp->i_ino);
2057 for (i = 0; i < *nmaps; i++) {
2059 "[%02d] br_startoff %lld br_startblock %lld br_blockcount %lld br_state %d",
2072 error = xfs_buf_map_from_irec(mp, map, nmaps, irecs, nirecs);
2084 struct xfs_trans *trans,
2085 struct xfs_inode *dp,
2087 xfs_daddr_t mappedbno,
2100 error = xfs_dabuf_map(trans, dp, bno, mappedbno, whichfork,
2131 struct xfs_trans *trans,
2132 struct xfs_inode *dp,
2134 xfs_daddr_t mappedbno,
2147 error = xfs_dabuf_map(trans, dp, bno, mappedbno, whichfork,
2157 dp->i_mount->m_ddev_targp,
2158 mapp, nmap, 0, &bp);
2176 struct xfs_mount *mp = dp->i_mount;
2190 trace_xfs_da_btree_corrupt(bp,
_RET_IP_);
2211 struct xfs_trans *trans,
2212 struct xfs_inode *dp,
2216 xfs_daddr_t mappedbno = -1;
2224 error = xfs_dabuf_map(trans, dp, bno, -1, whichfork,
2233 mappedbno = mapp[0].
bm_bn;
2278 memset((
char *)state, 0,
sizeof(*state));
2280 kmem_zone_free(xfs_da_state_zone, state);