103 #include <linux/fs.h>
105 #include <linux/slab.h>
124 #define DT_PAGE(IP, MP) BT_PAGE(IP, MP, dtpage_t, i_dtroot)
127 #define DT_GETPAGE(IP, BN, MP, SIZE, P, RC)\
129 BT_GETPAGE(IP, BN, MP, dtpage_t, SIZE, P, RC, i_dtroot)\
132 if (((P)->header.nextindex > (((BN)==0)?DTROOTMAXSLOT:(P)->header.maxslot)) ||\
133 ((BN) && ((P)->header.maxslot > DTPAGEMAXSLOT)))\
136 jfs_error((IP)->i_sb, "DT_GETPAGE: dtree page corrupt");\
144 #define DT_PUTPAGE(MP) BT_PUTPAGE(MP)
146 #define DT_GETSEARCH(IP, LEAF, BN, MP, P, INDEX) \
147 BT_GETSEARCH(IP, LEAF, BN, MP, dtpage_t, P, INDEX, i_dtroot)
171 static int dtReadNext(
struct inode *
ip,
194 static void dtTruncateEntry(
dtpage_t *
p,
int ti,
struct dt_lock ** dtlock);
198 #define ciToUpper(c) UniStrupr((c)->name)
215 rc =
xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
216 if (rc || (xaddr == 0))
234 rc =
xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
235 if (rc || (xaddr == 0))
257 static int maxWarnings = 10;
261 jfs_warn(
"find_entry called with index = %d", index);
268 jfs_warn(
"find_entry called with index >= next_index");
272 if (jfs_dirtable_inline(ip)) {
277 slot = &jfs_ip->i_dirtable[index - 2];
280 page_offset = offset & (
PSIZE - 1);
281 blkno = ((offset + 1) >>
L2PSIZE) <<
282 JFS_SBI(ip->
i_sb)->l2nbperpage;
284 if (*mp && (*lblock != blkno)) {
290 *mp = read_index_page(ip, blkno);
293 jfs_err(
"free_index: error reading directory table");
304 static inline void lock_index(
tid_t tid,
struct inode *ip,
struct metapage * mp,
322 lv->
offset = ((index - 2) & 511) >> 1;
334 static u32 add_index(
tid_t tid,
struct inode *ip,
s64 bn,
int slot)
353 jfs_warn(
"add_index: next_index = %d. Resetting!",
364 ip->
i_size = (loff_t) (index - 1) << 3;
369 dirtab_slot = &jfs_ip->i_dirtable[index-2];
385 if (dquot_alloc_block(ip, sbi->
nbperpage))
396 memcpy(temp_table, &jfs_ip->i_dirtable,
sizeof(temp_table));
408 jfs_warn(
"add_index: xtInsert failed!");
409 memcpy(&jfs_ip->i_dirtable, temp_table,
417 mp = get_index_page(ip, 0);
419 jfs_err(
"add_index: get_metapage failed!");
421 memcpy(&jfs_ip->i_dirtable, temp_table,
434 memcpy(mp->
data, temp_table,
sizeof(temp_table));
446 page_offset = offset & (
PSIZE - 1);
448 if (page_offset == 0) {
454 jfs_warn(
"add_index: xtInsert failed!");
459 if ((mp = get_index_page(ip, blkno)))
464 mp = read_index_page(ip, blkno);
467 jfs_err(
"add_index: get/read_metapage failed!");
471 lock_index(tid, ip, mp, index);
496 static void free_index(
tid_t tid,
struct inode *ip,
u32 index,
u32 next)
502 dirtab_slot = find_index(ip, index, &mp, &lblock);
508 dirtab_slot->
slot = dirtab_slot->
addr1 = 0;
512 lock_index(tid, ip, mp, index);
524 static void modify_index(
tid_t tid,
struct inode *ip,
u32 index,
s64 bn,
529 dirtab_slot = find_index(ip, index, mp, lblock);
538 lock_index(tid, ip, *mp, index);
549 static int read_index(
struct inode *ip,
u32 index,
556 slot = find_index(ip, index, &mp, &lblock);
609 if ((JFS_SBI(sb)->mntflag &
JFS_OS2) == JFS_OS2) {
645 for (base = 0, lim = p->
header.nextindex; lim; lim >>= 1) {
646 index = base + (lim >> 1);
651 ciCompare(&ciKey, p, stbl[index],
652 JFS_SBI(sb)->mntflag);
656 cmp = dtCompare(&ciKey, p, stbl[index]);
768 index = base ? base - 1 : base;
779 jfs_error(sb,
"stack overrun in dtSearch!");
780 BT_STACK_DUMP(btstack);
849 if (JFS_IP(ip)->next_index ==
DIREND) {
860 data.leaf.ino = *fsn;
869 if (n > p->
header.freecnt) {
875 rc = dtSplitUp(tid, ip, &split, btstack);
890 ASSERT(dtlck->index == 0);
898 dtInsertEntry(p, index, name, &data, &dtlck);
902 if (dtlck->index >= dtlck->maxcnt)
904 lv = & dtlck->lv[dtlck->index];
908 ((p->
header.nextindex - 1) >> L2DTSLOTSIZE) - n + 1;
930 static int dtSplitUp(
tid_t tid,
954 int quota_allocation = 0;
984 if (n <= split->nslot)
986 if ((rc =
dbAlloc(ip, 0, (
s64) xlen, &xaddr))) {
997 rc = dtSplitRoot(tid, ip, split, &rmp);
1021 if (xsize <
PSIZE) {
1024 n -= (n + 31) >> L2DTSLOTSIZE;
1026 n = xlen + (xlen << 1);
1031 rc = dquot_alloc_block(ip, n);
1034 quota_allocation +=
n;
1046 if ((rc = dtExtendPage(tid, ip, split, btstack))) {
1048 if (xaddr != nxaddr) {
1078 n = btstack->nsplit;
1079 pxdlist.maxnpxd = pxdlist.npxd = 0;
1081 for (pxd = pxdlist.pxd; n > 0; n--, pxd++) {
1082 if ((rc =
dbAlloc(ip, 0, (
s64) xlen, &xaddr)) == 0) {
1095 split->pxdlist = &pxdlist;
1096 if ((rc = dtSplitPage(tid, ip, split, &rmp, &rp, &rpxd))) {
1104 ip->i_size +=
PSIZE;
1149 skip = parent->
index + 1;
1184 sp->
header.prev != 0 || skip > 1) {
1186 rc = ciGetLeafPrefixKey(lp,
1201 dtGetKey(rp, 0, &key, sbi->
mntflag);
1212 dtGetKey(rp, 0, &key, sbi->
mntflag);
1232 if (n > sp->
header.freecnt) {
1235 split->index =
skip;
1248 dtSplitRoot(tid, ip, split, &rmp) :
1249 dtSplitPage(tid, ip, split, &rmp, &rp, &rpxd);
1267 ASSERT(dtlck->index == 0);
1268 lv = & dtlck->lv[0];
1282 1) >> L2DTSLOTSIZE) - n + 1;
1286 dtInsertEntry(sp, skip, &key, data, &dtlck);
1302 pxd = &pxdlist.pxd[
n];
1303 for (; n < pxdlist.maxnpxd; n++, pxd++)
1310 if (rc && quota_allocation)
1311 dquot_free_block(ip, quota_allocation);
1330 static int dtSplitPage(
tid_t tid,
struct inode *ip,
struct dtsplit * split,
1342 struct pxdlist *pxdlist;
1351 struct dt_lock *sdtlck, *rdtlck;
1354 struct lv *slv, *rlv, *lv;
1364 pxd = &pxdlist->
pxd[pxdlist->
npxd];
1372 rc = dquot_alloc_block(ip,
lengthPXD(pxd));
1378 jfs_info(
"dtSplitPage: ip:0x%p smp:0x%p rmp:0x%p", ip, smp, rmp);
1401 ASSERT(sdtlck->index == 0);
1402 slv = & sdtlck->lv[0];
1421 rp->
header.nextindex = 0;
1422 rp->
header.stblindex = 1;
1426 stblsize = (n + 31) >> L2DTSLOTSIZE;
1429 fsi = rp->
header.stblindex + stblsize;
1430 rp->
header.freelist = fsi;
1446 if (nextbn == 0 && split->
index == sp->
header.nextindex) {
1448 rlv = & rdtlck->lv[rdtlck->index];
1457 for (fsi++; fsi < rp->
header.maxslot; f++, fsi++)
1462 dtInsertEntry(rp, 0, split->
key, split->
data, &rdtlck);
1477 discard_metapage(rmp);
1486 jfs_info(
"dtSplitPage: tlck = 0x%p, ip = 0x%p, mp=0x%p",
1491 lv = & dtlck->lv[dtlck->index];
1504 skip = split->
index;
1515 nextindex = sp->
header.nextindex;
1516 for (nxt = off = 0; nxt < nextindex; ++off) {
1524 ldtentry = (
struct ldtentry *) & sp->
slot[si];
1533 idtentry = (
struct idtentry *) & sp->
slot[si];
1560 rlv = & rdtlck->lv[rdtlck->index];
1565 dtMoveEntry(sp, nxt, rp, &sdtlck, &rdtlck,
DO_INDEX(ip));
1567 sp->
header.nextindex = nxt;
1572 fsi = rp->
header.freelist;
1574 for (fsi++; fsi < rp->
header.maxslot; f++, fsi++)
1586 for (n = 0; n < rp->
header.nextindex; n++) {
1587 ldtentry = (
struct ldtentry *) & rp->
slot[stbl[n]];
1589 rbn,
n, &
mp, &lblock);
1600 dtInsertEntry(sp, skip, split->
key, split->
data, &sdtlck);
1603 if (sdtlck->index >= sdtlck->maxcnt)
1605 slv = & sdtlck->lv[sdtlck->index];
1609 ((sp->
header.nextindex - 1) >> L2DTSLOTSIZE) - n + 1;
1620 dtInsertEntry(rp, skip, split->
key, split->
data, &rdtlck);
1642 static int dtExtendPage(
tid_t tid,
1643 struct inode *ip,
struct dtsplit * split,
struct btstack * btstack)
1649 struct pxdlist *pxdlist;
1652 int newstblindex, newstblsize;
1653 int oldstblindex, oldstblsize;
1664 struct ldtentry *ldtentry;
1672 parent =
BT_POP(btstack);
1681 pxd = &pxdlist->
pxd[pxdlist->
npxd];
1688 if (xaddr == txaddr) {
1699 pxdlock->pxd = sp->
header.self;
1710 for (n = 0; n < sp->
header.nextindex; n++) {
1712 (
struct ldtentry *) & sp->
slot[stbl[n]];
1713 modify_index(tid, ip,
1715 xaddr,
n, &
mp, &lblock);
1727 jfs_info(
"dtExtendPage: ip:0x%p smp:0x%p sp:0x%p", ip, smp, sp);
1735 lv = & dtlck->lv[0];
1739 xsize = xlen << JFS_SBI(sb)->l2bsize;
1744 oldstblindex = sp->
header.stblindex;
1745 oldstblsize = (sp->
header.maxslot + 31) >> L2DTSLOTSIZE;
1746 newstblindex = sp->
header.maxslot;
1748 newstblsize = (n + 31) >> L2DTSLOTSIZE;
1763 lv->
offset = newstblindex;
1764 lv->
length = newstblsize;
1777 sp->
header.stblindex = newstblindex;
1785 last = sp->
header.freelist;
1786 for (n = 0; n < oldstblsize; n++, fsi++, f++) {
1790 sp->
header.freelist = last;
1791 sp->
header.freecnt += oldstblsize;
1797 fsi = n = newstblindex + newstblsize;
1799 for (fsi++; fsi < sp->
header.maxslot; f++, fsi++)
1804 fsi = sp->
header.freelist;
1811 }
while (fsi != -1);
1821 dtInsertEntry(sp, split->
index, split->
key, split->
data, &dtlck);
1828 n = sp->
header.maxslot >> 2;
1829 if (sp->
header.freelist < n)
1830 dtLinelockFreelist(sp, n, &dtlck);
1841 lv = & dtlck->lv[dtlck->index];
1875 static int dtSplitRoot(
tid_t tid,
1888 int fsi, stblsize,
n;
1891 struct pxdlist *pxdlist;
1900 sp = &JFS_IP(ip)->i_dtroot;
1909 pxd = &pxdlist->
pxd[pxdlist->
npxd];
1913 xsize = xlen << JFS_SBI(sb)->l2bsize;
1921 rc = dquot_alloc_block(ip,
lengthPXD(pxd));
1946 ASSERT(dtlck->index == 0);
1947 lv = & dtlck->lv[0];
1954 stblsize = (n + 31) >> L2DTSLOTSIZE;
1971 for (fsi++; fsi < rp->
header.maxslot; f++, fsi++)
1976 fsi = sp->
header.freelist;
1980 rp->
header.freelist = fsi;
1985 }
while (fsi != -1);
1998 struct ldtentry *ldtentry;
2001 for (n = 0; n < rp->
header.nextindex; n++) {
2002 ldtentry = (
struct ldtentry *) & rp->
slot[stbl[n]];
2004 rbn,
n, &
mp, &lblock);
2013 dtInsertEntry(rp, split->
index, split->
key, split->
data, &dtlck);
2032 ASSERT(dtlck->index == 0);
2033 lv = & dtlck->lv[0];
2053 sp->
header.nextindex = 1;
2090 struct btstack btstack;
2095 struct ldtentry *ldtentry;
2097 u32 table_index, next_index;
2106 if ((rc =
dtSearch(ip, key, ino, &btstack, flag)))
2119 ldtentry = (
struct ldtentry *) & p->
slot[stbl[index]];
2121 if (index == (p->
header.nextindex - 1)) {
2126 || (p->
header.next == 0))
2131 nmp,
PSIZE, np, rc);
2137 (
struct ldtentry *) & np->
2146 (
struct ldtentry *) & p->
slot[stbl[index + 1]];
2149 free_index(tid, ip, table_index, next_index);
2154 if (p->
header.nextindex == 1) {
2156 rc = dtDeleteUp(tid, ip, mp, p, &btstack);
2178 if (dtlck->index >= dtlck->maxcnt)
2180 lv = & dtlck->lv[dtlck->index];
2187 if (dtlck->index >= dtlck->maxcnt)
2189 lv = & dtlck->lv[dtlck->index];
2193 ((p->
header.nextindex - 1) >> L2DTSLOTSIZE) -
2199 dtDeleteEntry(p, index, &dtlck);
2209 for (i = index; i < p->
header.nextindex; i++) {
2211 (
struct ldtentry *) & p->
slot[stbl[i]];
2212 modify_index(tid, ip,
2214 bn,
i, &imp, &lblock);
2237 static int dtDeleteUp(
tid_t tid,
struct inode *ip,
2243 int index, nextindex;
2281 pxdlock->pxd = fp->
header.self;
2285 if ((rc = dtRelink(tid, ip, fp))) {
2293 dquot_free_block(ip, xlen);
2296 discard_metapage(fmp);
2315 index = parent->
index;
2320 nextindex = p->
header.nextindex;
2327 if (nextindex == 1) {
2357 pxdlock->pxd = p->
header.self;
2361 if ((rc = dtRelink(tid, ip, p))) {
2369 dquot_free_block(ip, xlen);
2372 discard_metapage(mp);
2394 if (dtlck->index >= dtlck->maxcnt)
2396 lv = & dtlck->lv[dtlck->index];
2403 if (dtlck->index < dtlck->maxcnt)
2407 lv = & dtlck->lv[0];
2412 ((p->
header.nextindex - 1) >> L2DTSLOTSIZE) -
2418 dtDeleteEntry(p, index, &dtlck);
2423 dtTruncateEntry(p, 0, &dtlck);
2445 int dtRelocate(
tid_t tid,
struct inode *ip,
s64 lmxaddr,
pxd_t * opxd,
2453 struct btstack btstack;
2455 s64 oxaddr, nextbn, prevbn;
2466 jfs_info(
"dtRelocate: lmxaddr:%Ld xaddr:%Ld:%Ld xlen:%d",
2467 (
long long)lmxaddr, (
long long)oxaddr, (
long long)nxaddr,
2474 rc = dtSearchNode(ip, lmxaddr, opxd, &btstack);
2480 jfs_info(
"dtRelocate: parent router entry validated.");
2529 ASSERT(dtlck->index == 0);
2530 lv = & dtlck->lv[0];
2543 ASSERT(dtlck->index == 0);
2544 lv = & dtlck->lv[0];
2565 ASSERT(dtlck->index == 0);
2566 lv = & dtlck->lv[0];
2580 xsize = xlen << JFS_SBI(ip->
i_sb)->l2bsize;
2584 jfs_info(
"dtRelocate: target dtpage relocated.");
2612 jfs_info(
"dtRelocate: update parent router entry.");
2615 lv = & dtlck->lv[dtlck->index];
2619 pxd = (
pxd_t *) & pp->
slot[stbl[index]];
2642 static int dtSearchNode(
struct inode *ip,
s64 lmxaddr,
pxd_t * kpxd,
2643 struct btstack * btstack)
2701 for (i = 0; i < p->
header.nextindex; i++) {
2707 btsp = btstack->
top;
2747 static int dtRelink(
tid_t tid,
struct inode *ip,
dtpage_t * p)
2772 jfs_info(
"dtRelink nextbn: tlck = 0x%p, ip = 0x%p, mp=0x%p",
2777 if (dtlck->index >= dtlck->maxcnt)
2779 lv = & dtlck->lv[dtlck->index];
2801 jfs_info(
"dtRelink prevbn: tlck = 0x%p, ip = 0x%p, mp=0x%p",
2806 if (dtlck->index >= dtlck->maxcnt)
2808 lv = & dtlck->lv[dtlck->index];
2842 if (!jfs_dirtable_inline(ip)) {
2850 xflag_save = tblk->
xflag;
2863 tblk->
xflag = xflag_save;
2881 ASSERT(dtlck->index == 0);
2882 lv = & dtlck->lv[0];
2887 p = &jfs_ip->i_dtroot;
2918 static void add_missing_indices(
struct inode *inode,
s64 bn)
2951 for (i = 0; i < p->
header.nextindex; i++) {
2952 d = (
struct ldtentry *) &p->
slot[stbl[i]];
2954 if ((index < 2) || (index >= JFS_IP(inode)->next_index)) {
2956 if (dtlck->index >= dtlck->maxcnt)
2958 lv = &dtlck->lv[dtlck->index];
2991 ~(
sizeof (loff_t) - 1)));
3007 struct inode *ip = filp->
f_path.dentry->d_inode;
3015 } *dtoffset = (
struct dtoffset *) &dtpos;
3021 struct btstack btstack;
3026 unsigned long dirent_buf;
3030 uint loop_count = 0;
3033 int overflow, fix_page, page_fixed = 0;
3034 static int unique_pos = 2;
3050 if (dir_index > 1) {
3054 (dir_index >= JFS_IP(ip)->next_index)) {
3060 rc = read_index(ip, dir_index, &dirtab_slot);
3066 if (loop_count++ > JFS_IP(ip)->next_index) {
3067 jfs_err(
"jfs_readdir detected "
3073 if (dir_index == -1) {
3080 index = dirtab_slot.
slot;
3087 jfs_err(
"jfs_readdir: bad index table");
3093 if (dir_index == 0) {
3098 if (filldir(dirent,
".", 1, 0, ip->
i_ino,
3117 if ((rc = dtReadFirst(ip, &btstack)))
3131 dtpos = filp->
f_pos;
3135 if (filldir(dirent,
".", 1, filp->
f_pos, ip->
i_ino,
3138 dtoffset->index = 1;
3139 filp->
f_pos = dtpos;
3142 if (dtoffset->pn == 0) {
3143 if (dtoffset->index == 1) {
3146 if (filldir(dirent,
"..", 2, filp->
f_pos,
3150 jfs_err(
"jfs_readdir called with "
3154 dtoffset->index = 0;
3155 filp->
f_pos = dtpos;
3163 if ((rc = dtReadNext(ip, &filp->
f_pos, &btstack))) {
3164 jfs_err(
"jfs_readdir: unexpected rc = %d "
3165 "from dtReadNext", rc);
3180 if (dirent_buf == 0) {
3182 jfs_warn(
"jfs_readdir: __get_free_page failed!");
3188 jfs_dirent = (
struct jfs_dirent *) dirent_buf;
3190 overflow = fix_page = 0;
3194 for (i = index; i < p->
header.nextindex; i++) {
3195 d = (
struct ldtentry *) & p->
slot[stbl[i]];
3197 if (((
long) jfs_dirent + d->
namlen + 1) >
3206 name_ptr = jfs_dirent->
name;
3221 JFS_IP(ip)->next_index)) {
3222 if (!page_fixed && !isReadOnly(ip)) {
3234 jfs_dirent->
position = unique_pos++;
3253 if (d_namleft == 0) {
3255 "JFS:Dtree error: ino = "
3256 "%ld, bn=%Ld, index = %d",
3271 jfs_dirent = next_jfs_dirent(jfs_dirent);
3287 dtoffset->index = 0;
3296 jfs_dirent = (
struct jfs_dirent *) dirent_buf;
3297 while (jfs_dirents--) {
3299 if (filldir(dirent, jfs_dirent->
name,
3303 jfs_dirent = next_jfs_dirent(jfs_dirent);
3307 add_missing_indices(ip, bn);
3311 if (!overflow && (bn == 0)) {
3335 static int dtReadFirst(
struct inode *ip,
struct btstack * btstack)
3363 btsp = btstack->
top;
3377 BT_STACK_DUMP(btstack);
3407 static int dtReadNext(
struct inode *ip, loff_t * offset,
3408 struct btstack * btstack)
3415 } *dtoffset = (
struct dtoffset *) offset;
3422 struct btframe *btsp, *parent;
3428 if ((rc = dtReadFirst(ip, btstack)))
3435 pn = dtoffset->pn - 1;
3436 index = dtoffset->index;
3441 if (index < p->
header.nextindex)
3451 dtoffset->index = index = 0;
3488 btsp = btstack->
top;
3496 while (pn >= p->
header.nextindex) {
3497 pn -= p->
header.nextindex;
3540 if (index >= p->
header.nextindex) {
3559 dtoffset->index = 0;
3564 btsp = btstack->
top;
3566 btsp->
index = dtoffset->index;
3589 int klen, namlen,
len,
rc;
3590 struct idtentry *ih;
3612 ih = (
struct idtentry *) & p->
slot[si];
3619 len =
min(klen, len);
3620 if ((rc = UniStrncmp_le(kname, name, len)))
3628 while (klen > 0 && namlen > 0) {
3632 len =
min(klen, len);
3634 if ((rc = UniStrncmp_le(kname, name, len)))
3643 return (klen - namlen);
3666 int klen, namlen, len,
rc;
3667 struct ldtentry *lh;
3668 struct idtentry *ih;
3695 lh = (
struct ldtentry *) & p->
slot[si];
3708 ih = (
struct idtentry *) & p->
slot[si];
3716 len =
min(klen, len);
3717 for (i = 0; i < len; i++, kname++, name++) {
3719 if ((flag &
JFS_OS2) == JFS_OS2)
3723 if ((rc = *kname - x))
3731 while (klen > 0 && namlen > 0) {
3735 len =
min(klen, len);
3737 for (i = 0; i < len; i++, kname++, name++) {
3739 if ((flag & JFS_OS2) == JFS_OS2)
3744 if ((rc = *kname - x))
3753 return (klen - namlen);
3771 wchar_t *
pl, *
pr, *kname;
3788 dtGetKey(lp, li, &
lkey, flag);
3791 if ((flag & JFS_OS2) == JFS_OS2)
3794 dtGetKey(rp, ri, &
rkey, flag);
3798 if ((flag & JFS_OS2) == JFS_OS2)
3805 for (pl =
lkey.name, pr =
rkey.name;
3806 namlen; pl++, pr++, namlen--, klen++, kname++) {
3834 static void dtGetKey(
dtpage_t * p,
int i,
3839 struct ldtentry *lh;
3840 struct idtentry *ih;
3850 lh = (
struct ldtentry *) & p->
slot[si];
3859 ih = (
struct idtentry *) & p->
slot[si];
3872 UniStrncpy_from_le(kname, name, len);
3883 UniStrncpy_from_le(kname, t->
name, len);
3902 struct ldtentry *lh =
NULL;
3903 struct idtentry *ih =
NULL;
3904 int hsi, fsi, klen, len, nextindex;
3909 struct dt_lock *dtlck = *dtlock;
3919 hsi = fsi = p->
header.freelist;
3925 if (dtlck->index >= dtlck->maxcnt)
3928 lv = & dtlck->lv[dtlck->index];
3933 lh = (
struct ldtentry *) h;
3938 if (data->
leaf.ip) {
3948 ih = (
struct idtentry *) h;
3957 UniStrncpy_to_le(name, kname, len);
3967 fsi = p->
header.freelist;
3973 if (fsi != xsi + 1) {
3979 if (dtlck->index < dtlck->maxcnt)
3983 lv = & dtlck->lv[0];
3992 UniStrncpy_to_le(t->
name, kname, len);
4018 nextindex = p->
header.nextindex;
4019 if (index < nextindex) {
4020 memmove(stbl + index + 1, stbl + index, nextindex - index);
4030 for (n = index + 1; n <= nextindex; n++) {
4031 lh = (
struct ldtentry *) & (p->
slot[stbl[n]]);
4032 modify_index(data->
leaf.tid, data->
leaf.ip,
4065 struct ldtentry *slh, *dlh =
NULL;
4066 struct idtentry *
sih, *dih =
NULL;
4068 struct dt_lock *sdtlck = *sdtlock, *ddtlck = *ddtlock;
4069 struct lv *slv, *dlv;
4076 dsi = dp->
header.freelist;
4077 sfsi = sp->
header.freelist;
4080 dlv = & ddtlck->lv[ddtlck->index];
4084 slv = & sdtlck->lv[sdtlck->index];
4092 for (di = 0; si < sp->
header.nextindex; si++, di++) {
4097 if (ssi != xssi + 1) {
4103 if (sdtlck->index < sdtlck->maxcnt)
4107 slv = & sdtlck->lv[0];
4118 h = d = &dp->
slot[dsi];
4124 slh = (
struct ldtentry *) s;
4125 dlh = (
struct ldtentry *) h;
4134 memcpy(dlh, slh, 6 + len * 2);
4142 sih = (
struct idtentry *) s;
4146 dih = (
struct idtentry *) h;
4147 memcpy(dih, sih, 10 + len * 2);
4167 while ((ssi = next) >= 0) {
4169 if (ssi != xssi + 1) {
4175 if (sdtlck->index < sdtlck->maxcnt)
4181 slv = & sdtlck->lv[0];
4195 UniStrncpy_le(d->
name, s->
name, len);
4235 sp->
header.freelist = sfsi;
4236 sp->
header.freecnt += nd;
4239 dp->
header.nextindex = di;
4241 dp->
header.freelist = dsi;
4242 dp->
header.freecnt -= nd;
4257 static void dtDeleteEntry(
dtpage_t * p,
int fi,
struct dt_lock ** dtlock)
4263 struct dt_lock *dtlck = *dtlock;
4272 if (dtlck->index >= dtlck->maxcnt)
4274 lv = & dtlck->lv[dtlck->index];
4281 si = ((
struct ldtentry *) t)->next;
4283 si = ((
struct idtentry *) t)->next;
4293 if (si != xsi + 1) {
4299 if (dtlck->index < dtlck->maxcnt)
4303 lv = & dtlck->lv[0];
4327 p->
header.freelist = fsi;
4328 p->
header.freecnt += freecnt;
4333 si = p->
header.nextindex;
4335 memmove(&stbl[fi], &stbl[fi + 1], si - fi - 1);
4352 static void dtTruncateEntry(
dtpage_t * p,
int ti,
struct dt_lock ** dtlock)
4358 struct dt_lock *dtlck = *dtlock;
4367 if (dtlck->index >= dtlck->maxcnt)
4369 lv = & dtlck->lv[dtlck->index];
4376 ((
struct idtentry *) t)->namlen = 0;
4377 si = ((
struct idtentry *) t)->next;
4378 ((
struct idtentry *) t)->next = -1;
4388 if (si != xsi + 1) {
4394 if (dtlck->index < dtlck->maxcnt)
4398 lv = & dtlck->lv[0];
4424 p->
header.freelist = fsi;
4425 p->
header.freecnt += freecnt;
4432 static void dtLinelockFreelist(
dtpage_t * p,
4439 struct dt_lock *dtlck = *dtlock;
4444 fsi = p->
header.freelist;
4447 if (dtlck->index >= dtlck->maxcnt)
4449 lv = & dtlck->lv[dtlck->index];
4460 while (si < m && si >= 0) {
4462 if (si != xsi + 1) {
4468 if (dtlck->index < dtlck->maxcnt)
4472 lv = & dtlck->lv[0];
4520 struct btstack btstack;
4526 struct ldtentry *
entry;
4533 if ((rc =
dtSearch(ip, key, orig_ino, &btstack, flag)))
4548 entry_si = stbl[
index];
4551 ASSERT(dtlck->index == 0);
4552 lv = & dtlck->lv[0];
4558 entry = (
struct ldtentry *) & p->
slot[entry_si];