diff options
Diffstat (limited to 'fs/jfs/jfs_xtree.c')
-rw-r--r-- | fs/jfs/jfs_xtree.c | 428 |
1 files changed, 212 insertions, 216 deletions
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c index acc97c46d8a4..1543906a2e0d 100644 --- a/fs/jfs/jfs_xtree.c +++ b/fs/jfs/jfs_xtree.c | |||
@@ -16,7 +16,7 @@ | |||
16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 | */ | 17 | */ |
18 | /* | 18 | /* |
19 | * jfs_xtree.c: extent allocation descriptor B+-tree manager | 19 | * jfs_xtree.c: extent allocation descriptor B+-tree manager |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/fs.h> | 22 | #include <linux/fs.h> |
@@ -32,30 +32,30 @@ | |||
32 | /* | 32 | /* |
33 | * xtree local flag | 33 | * xtree local flag |
34 | */ | 34 | */ |
35 | #define XT_INSERT 0x00000001 | 35 | #define XT_INSERT 0x00000001 |
36 | 36 | ||
37 | /* | 37 | /* |
38 | * xtree key/entry comparison: extent offset | 38 | * xtree key/entry comparison: extent offset |
39 | * | 39 | * |
40 | * return: | 40 | * return: |
41 | * -1: k < start of extent | 41 | * -1: k < start of extent |
42 | * 0: start_of_extent <= k <= end_of_extent | 42 | * 0: start_of_extent <= k <= end_of_extent |
43 | * 1: k > end_of_extent | 43 | * 1: k > end_of_extent |
44 | */ | 44 | */ |
45 | #define XT_CMP(CMP, K, X, OFFSET64)\ | 45 | #define XT_CMP(CMP, K, X, OFFSET64)\ |
46 | {\ | 46 | {\ |
47 | OFFSET64 = offsetXAD(X);\ | 47 | OFFSET64 = offsetXAD(X);\ |
48 | (CMP) = ((K) >= OFFSET64 + lengthXAD(X)) ? 1 :\ | 48 | (CMP) = ((K) >= OFFSET64 + lengthXAD(X)) ? 1 :\ |
49 | ((K) < OFFSET64) ? -1 : 0;\ | 49 | ((K) < OFFSET64) ? -1 : 0;\ |
50 | } | 50 | } |
51 | 51 | ||
52 | /* write a xad entry */ | 52 | /* write a xad entry */ |
53 | #define XT_PUTENTRY(XAD, FLAG, OFF, LEN, ADDR)\ | 53 | #define XT_PUTENTRY(XAD, FLAG, OFF, LEN, ADDR)\ |
54 | {\ | 54 | {\ |
55 | (XAD)->flag = (FLAG);\ | 55 | (XAD)->flag = (FLAG);\ |
56 | XADoffset((XAD), (OFF));\ | 56 | XADoffset((XAD), (OFF));\ |
57 | XADlength((XAD), (LEN));\ | 57 | XADlength((XAD), (LEN));\ |
58 | XADaddress((XAD), (ADDR));\ | 58 | XADaddress((XAD), (ADDR));\ |
59 | } | 59 | } |
60 | 60 | ||
61 | #define XT_PAGE(IP, MP) BT_PAGE(IP, MP, xtpage_t, i_xtroot) | 61 | #define XT_PAGE(IP, MP) BT_PAGE(IP, MP, xtpage_t, i_xtroot) |
@@ -76,13 +76,13 @@ | |||
76 | MP = NULL;\ | 76 | MP = NULL;\ |
77 | RC = -EIO;\ | 77 | RC = -EIO;\ |
78 | }\ | 78 | }\ |
79 | }\ | 79 | }\ |
80 | } | 80 | } |
81 | 81 | ||
82 | /* for consistency */ | 82 | /* for consistency */ |
83 | #define XT_PUTPAGE(MP) BT_PUTPAGE(MP) | 83 | #define XT_PUTPAGE(MP) BT_PUTPAGE(MP) |
84 | 84 | ||
85 | #define XT_GETSEARCH(IP, LEAF, BN, MP, P, INDEX) \ | 85 | #define XT_GETSEARCH(IP, LEAF, BN, MP, P, INDEX) \ |
86 | BT_GETSEARCH(IP, LEAF, BN, MP, xtpage_t, P, INDEX, i_xtroot) | 86 | BT_GETSEARCH(IP, LEAF, BN, MP, xtpage_t, P, INDEX, i_xtroot) |
87 | /* xtree entry parameter descriptor */ | 87 | /* xtree entry parameter descriptor */ |
88 | struct xtsplit { | 88 | struct xtsplit { |
@@ -97,7 +97,7 @@ struct xtsplit { | |||
97 | 97 | ||
98 | 98 | ||
99 | /* | 99 | /* |
100 | * statistics | 100 | * statistics |
101 | */ | 101 | */ |
102 | #ifdef CONFIG_JFS_STATISTICS | 102 | #ifdef CONFIG_JFS_STATISTICS |
103 | static struct { | 103 | static struct { |
@@ -136,7 +136,7 @@ static int xtRelink(tid_t tid, struct inode *ip, xtpage_t * fp); | |||
136 | #endif /* _STILL_TO_PORT */ | 136 | #endif /* _STILL_TO_PORT */ |
137 | 137 | ||
138 | /* | 138 | /* |
139 | * xtLookup() | 139 | * xtLookup() |
140 | * | 140 | * |
141 | * function: map a single page into a physical extent; | 141 | * function: map a single page into a physical extent; |
142 | */ | 142 | */ |
@@ -179,7 +179,7 @@ int xtLookup(struct inode *ip, s64 lstart, | |||
179 | } | 179 | } |
180 | 180 | ||
181 | /* | 181 | /* |
182 | * compute the physical extent covering logical extent | 182 | * compute the physical extent covering logical extent |
183 | * | 183 | * |
184 | * N.B. search may have failed (e.g., hole in sparse file), | 184 | * N.B. search may have failed (e.g., hole in sparse file), |
185 | * and returned the index of the next entry. | 185 | * and returned the index of the next entry. |
@@ -220,27 +220,27 @@ int xtLookup(struct inode *ip, s64 lstart, | |||
220 | 220 | ||
221 | 221 | ||
222 | /* | 222 | /* |
223 | * xtLookupList() | 223 | * xtLookupList() |
224 | * | 224 | * |
225 | * function: map a single logical extent into a list of physical extent; | 225 | * function: map a single logical extent into a list of physical extent; |
226 | * | 226 | * |
227 | * parameter: | 227 | * parameter: |
228 | * struct inode *ip, | 228 | * struct inode *ip, |
229 | * struct lxdlist *lxdlist, lxd list (in) | 229 | * struct lxdlist *lxdlist, lxd list (in) |
230 | * struct xadlist *xadlist, xad list (in/out) | 230 | * struct xadlist *xadlist, xad list (in/out) |
231 | * int flag) | 231 | * int flag) |
232 | * | 232 | * |
233 | * coverage of lxd by xad under assumption of | 233 | * coverage of lxd by xad under assumption of |
234 | * . lxd's are ordered and disjoint. | 234 | * . lxd's are ordered and disjoint. |
235 | * . xad's are ordered and disjoint. | 235 | * . xad's are ordered and disjoint. |
236 | * | 236 | * |
237 | * return: | 237 | * return: |
238 | * 0: success | 238 | * 0: success |
239 | * | 239 | * |
240 | * note: a page being written (even a single byte) is backed fully, | 240 | * note: a page being written (even a single byte) is backed fully, |
241 | * except the last page which is only backed with blocks | 241 | * except the last page which is only backed with blocks |
242 | * required to cover the last byte; | 242 | * required to cover the last byte; |
243 | * the extent backing a page is fully contained within an xad; | 243 | * the extent backing a page is fully contained within an xad; |
244 | */ | 244 | */ |
245 | int xtLookupList(struct inode *ip, struct lxdlist * lxdlist, | 245 | int xtLookupList(struct inode *ip, struct lxdlist * lxdlist, |
246 | struct xadlist * xadlist, int flag) | 246 | struct xadlist * xadlist, int flag) |
@@ -284,7 +284,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist, | |||
284 | return rc; | 284 | return rc; |
285 | 285 | ||
286 | /* | 286 | /* |
287 | * compute the physical extent covering logical extent | 287 | * compute the physical extent covering logical extent |
288 | * | 288 | * |
289 | * N.B. search may have failed (e.g., hole in sparse file), | 289 | * N.B. search may have failed (e.g., hole in sparse file), |
290 | * and returned the index of the next entry. | 290 | * and returned the index of the next entry. |
@@ -343,7 +343,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist, | |||
343 | if (lstart >= size) | 343 | if (lstart >= size) |
344 | goto mapend; | 344 | goto mapend; |
345 | 345 | ||
346 | /* compare with the current xad */ | 346 | /* compare with the current xad */ |
347 | goto compare1; | 347 | goto compare1; |
348 | } | 348 | } |
349 | /* lxd is covered by xad */ | 349 | /* lxd is covered by xad */ |
@@ -430,7 +430,7 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist, | |||
430 | /* | 430 | /* |
431 | * lxd is partially covered by xad | 431 | * lxd is partially covered by xad |
432 | */ | 432 | */ |
433 | else { /* (xend < lend) */ | 433 | else { /* (xend < lend) */ |
434 | 434 | ||
435 | /* | 435 | /* |
436 | * get next xad | 436 | * get next xad |
@@ -477,22 +477,22 @@ int xtLookupList(struct inode *ip, struct lxdlist * lxdlist, | |||
477 | 477 | ||
478 | 478 | ||
479 | /* | 479 | /* |
480 | * xtSearch() | 480 | * xtSearch() |
481 | * | 481 | * |
482 | * function: search for the xad entry covering specified offset. | 482 | * function: search for the xad entry covering specified offset. |
483 | * | 483 | * |
484 | * parameters: | 484 | * parameters: |
485 | * ip - file object; | 485 | * ip - file object; |
486 | * xoff - extent offset; | 486 | * xoff - extent offset; |
487 | * nextp - address of next extent (if any) for search miss | 487 | * nextp - address of next extent (if any) for search miss |
488 | * cmpp - comparison result: | 488 | * cmpp - comparison result: |
489 | * btstack - traverse stack; | 489 | * btstack - traverse stack; |
490 | * flag - search process flag (XT_INSERT); | 490 | * flag - search process flag (XT_INSERT); |
491 | * | 491 | * |
492 | * returns: | 492 | * returns: |
493 | * btstack contains (bn, index) of search path traversed to the entry. | 493 | * btstack contains (bn, index) of search path traversed to the entry. |
494 | * *cmpp is set to result of comparison with the entry returned. | 494 | * *cmpp is set to result of comparison with the entry returned. |
495 | * the page containing the entry is pinned at exit. | 495 | * the page containing the entry is pinned at exit. |
496 | */ | 496 | */ |
497 | static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp, | 497 | static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp, |
498 | int *cmpp, struct btstack * btstack, int flag) | 498 | int *cmpp, struct btstack * btstack, int flag) |
@@ -517,7 +517,7 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp, | |||
517 | btstack->nsplit = 0; | 517 | btstack->nsplit = 0; |
518 | 518 | ||
519 | /* | 519 | /* |
520 | * search down tree from root: | 520 | * search down tree from root: |
521 | * | 521 | * |
522 | * between two consecutive entries of <Ki, Pi> and <Kj, Pj> of | 522 | * between two consecutive entries of <Ki, Pi> and <Kj, Pj> of |
523 | * internal page, child page Pi contains entry with k, Ki <= K < Kj. | 523 | * internal page, child page Pi contains entry with k, Ki <= K < Kj. |
@@ -642,7 +642,7 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp, | |||
642 | XT_CMP(cmp, xoff, &p->xad[index], t64); | 642 | XT_CMP(cmp, xoff, &p->xad[index], t64); |
643 | if (cmp == 0) { | 643 | if (cmp == 0) { |
644 | /* | 644 | /* |
645 | * search hit | 645 | * search hit |
646 | */ | 646 | */ |
647 | /* search hit - leaf page: | 647 | /* search hit - leaf page: |
648 | * return the entry found | 648 | * return the entry found |
@@ -692,7 +692,7 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp, | |||
692 | } | 692 | } |
693 | 693 | ||
694 | /* | 694 | /* |
695 | * search miss | 695 | * search miss |
696 | * | 696 | * |
697 | * base is the smallest index with key (Kj) greater than | 697 | * base is the smallest index with key (Kj) greater than |
698 | * search key (K) and may be zero or maxentry index. | 698 | * search key (K) and may be zero or maxentry index. |
@@ -773,22 +773,22 @@ static int xtSearch(struct inode *ip, s64 xoff, s64 *nextp, | |||
773 | } | 773 | } |
774 | 774 | ||
775 | /* | 775 | /* |
776 | * xtInsert() | 776 | * xtInsert() |
777 | * | 777 | * |
778 | * function: | 778 | * function: |
779 | * | 779 | * |
780 | * parameter: | 780 | * parameter: |
781 | * tid - transaction id; | 781 | * tid - transaction id; |
782 | * ip - file object; | 782 | * ip - file object; |
783 | * xflag - extent flag (XAD_NOTRECORDED): | 783 | * xflag - extent flag (XAD_NOTRECORDED): |
784 | * xoff - extent offset; | 784 | * xoff - extent offset; |
785 | * xlen - extent length; | 785 | * xlen - extent length; |
786 | * xaddrp - extent address pointer (in/out): | 786 | * xaddrp - extent address pointer (in/out): |
787 | * if (*xaddrp) | 787 | * if (*xaddrp) |
788 | * caller allocated data extent at *xaddrp; | 788 | * caller allocated data extent at *xaddrp; |
789 | * else | 789 | * else |
790 | * allocate data extent and return its xaddr; | 790 | * allocate data extent and return its xaddr; |
791 | * flag - | 791 | * flag - |
792 | * | 792 | * |
793 | * return: | 793 | * return: |
794 | */ | 794 | */ |
@@ -813,7 +813,7 @@ int xtInsert(tid_t tid, /* transaction id */ | |||
813 | jfs_info("xtInsert: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen); | 813 | jfs_info("xtInsert: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen); |
814 | 814 | ||
815 | /* | 815 | /* |
816 | * search for the entry location at which to insert: | 816 | * search for the entry location at which to insert: |
817 | * | 817 | * |
818 | * xtFastSearch() and xtSearch() both returns (leaf page | 818 | * xtFastSearch() and xtSearch() both returns (leaf page |
819 | * pinned, index at which to insert). | 819 | * pinned, index at which to insert). |
@@ -853,13 +853,13 @@ int xtInsert(tid_t tid, /* transaction id */ | |||
853 | } | 853 | } |
854 | 854 | ||
855 | /* | 855 | /* |
856 | * insert entry for new extent | 856 | * insert entry for new extent |
857 | */ | 857 | */ |
858 | xflag |= XAD_NEW; | 858 | xflag |= XAD_NEW; |
859 | 859 | ||
860 | /* | 860 | /* |
861 | * if the leaf page is full, split the page and | 861 | * if the leaf page is full, split the page and |
862 | * propagate up the router entry for the new page from split | 862 | * propagate up the router entry for the new page from split |
863 | * | 863 | * |
864 | * The xtSplitUp() will insert the entry and unpin the leaf page. | 864 | * The xtSplitUp() will insert the entry and unpin the leaf page. |
865 | */ | 865 | */ |
@@ -886,7 +886,7 @@ int xtInsert(tid_t tid, /* transaction id */ | |||
886 | } | 886 | } |
887 | 887 | ||
888 | /* | 888 | /* |
889 | * insert the new entry into the leaf page | 889 | * insert the new entry into the leaf page |
890 | */ | 890 | */ |
891 | /* | 891 | /* |
892 | * acquire a transaction lock on the leaf page; | 892 | * acquire a transaction lock on the leaf page; |
@@ -930,16 +930,16 @@ int xtInsert(tid_t tid, /* transaction id */ | |||
930 | 930 | ||
931 | 931 | ||
932 | /* | 932 | /* |
933 | * xtSplitUp() | 933 | * xtSplitUp() |
934 | * | 934 | * |
935 | * function: | 935 | * function: |
936 | * split full pages as propagating insertion up the tree | 936 | * split full pages as propagating insertion up the tree |
937 | * | 937 | * |
938 | * parameter: | 938 | * parameter: |
939 | * tid - transaction id; | 939 | * tid - transaction id; |
940 | * ip - file object; | 940 | * ip - file object; |
941 | * split - entry parameter descriptor; | 941 | * split - entry parameter descriptor; |
942 | * btstack - traverse stack from xtSearch() | 942 | * btstack - traverse stack from xtSearch() |
943 | * | 943 | * |
944 | * return: | 944 | * return: |
945 | */ | 945 | */ |
@@ -1199,22 +1199,22 @@ xtSplitUp(tid_t tid, | |||
1199 | 1199 | ||
1200 | 1200 | ||
1201 | /* | 1201 | /* |
1202 | * xtSplitPage() | 1202 | * xtSplitPage() |
1203 | * | 1203 | * |
1204 | * function: | 1204 | * function: |
1205 | * split a full non-root page into | 1205 | * split a full non-root page into |
1206 | * original/split/left page and new right page | 1206 | * original/split/left page and new right page |
1207 | * i.e., the original/split page remains as left page. | 1207 | * i.e., the original/split page remains as left page. |
1208 | * | 1208 | * |
1209 | * parameter: | 1209 | * parameter: |
1210 | * int tid, | 1210 | * int tid, |
1211 | * struct inode *ip, | 1211 | * struct inode *ip, |
1212 | * struct xtsplit *split, | 1212 | * struct xtsplit *split, |
1213 | * struct metapage **rmpp, | 1213 | * struct metapage **rmpp, |
1214 | * u64 *rbnp, | 1214 | * u64 *rbnp, |
1215 | * | 1215 | * |
1216 | * return: | 1216 | * return: |
1217 | * Pointer to page in which to insert or NULL on error. | 1217 | * Pointer to page in which to insert or NULL on error. |
1218 | */ | 1218 | */ |
1219 | static int | 1219 | static int |
1220 | xtSplitPage(tid_t tid, struct inode *ip, | 1220 | xtSplitPage(tid_t tid, struct inode *ip, |
@@ -1248,9 +1248,9 @@ xtSplitPage(tid_t tid, struct inode *ip, | |||
1248 | rbn = addressPXD(pxd); | 1248 | rbn = addressPXD(pxd); |
1249 | 1249 | ||
1250 | /* Allocate blocks to quota. */ | 1250 | /* Allocate blocks to quota. */ |
1251 | if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) { | 1251 | if (DQUOT_ALLOC_BLOCK(ip, lengthPXD(pxd))) { |
1252 | rc = -EDQUOT; | 1252 | rc = -EDQUOT; |
1253 | goto clean_up; | 1253 | goto clean_up; |
1254 | } | 1254 | } |
1255 | 1255 | ||
1256 | quota_allocation += lengthPXD(pxd); | 1256 | quota_allocation += lengthPXD(pxd); |
@@ -1304,7 +1304,7 @@ xtSplitPage(tid_t tid, struct inode *ip, | |||
1304 | skip = split->index; | 1304 | skip = split->index; |
1305 | 1305 | ||
1306 | /* | 1306 | /* |
1307 | * sequential append at tail (after last entry of last page) | 1307 | * sequential append at tail (after last entry of last page) |
1308 | * | 1308 | * |
1309 | * if splitting the last page on a level because of appending | 1309 | * if splitting the last page on a level because of appending |
1310 | * a entry to it (skip is maxentry), it's likely that the access is | 1310 | * a entry to it (skip is maxentry), it's likely that the access is |
@@ -1342,7 +1342,7 @@ xtSplitPage(tid_t tid, struct inode *ip, | |||
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | /* | 1344 | /* |
1345 | * non-sequential insert (at possibly middle page) | 1345 | * non-sequential insert (at possibly middle page) |
1346 | */ | 1346 | */ |
1347 | 1347 | ||
1348 | /* | 1348 | /* |
@@ -1465,25 +1465,24 @@ xtSplitPage(tid_t tid, struct inode *ip, | |||
1465 | 1465 | ||
1466 | 1466 | ||
1467 | /* | 1467 | /* |
1468 | * xtSplitRoot() | 1468 | * xtSplitRoot() |
1469 | * | 1469 | * |
1470 | * function: | 1470 | * function: |
1471 | * split the full root page into | 1471 | * split the full root page into original/root/split page and new |
1472 | * original/root/split page and new right page | 1472 | * right page |
1473 | * i.e., root remains fixed in tree anchor (inode) and | 1473 | * i.e., root remains fixed in tree anchor (inode) and the root is |
1474 | * the root is copied to a single new right child page | 1474 | * copied to a single new right child page since root page << |
1475 | * since root page << non-root page, and | 1475 | * non-root page, and the split root page contains a single entry |
1476 | * the split root page contains a single entry for the | 1476 | * for the new right child page. |
1477 | * new right child page. | ||
1478 | * | 1477 | * |
1479 | * parameter: | 1478 | * parameter: |
1480 | * int tid, | 1479 | * int tid, |
1481 | * struct inode *ip, | 1480 | * struct inode *ip, |
1482 | * struct xtsplit *split, | 1481 | * struct xtsplit *split, |
1483 | * struct metapage **rmpp) | 1482 | * struct metapage **rmpp) |
1484 | * | 1483 | * |
1485 | * return: | 1484 | * return: |
1486 | * Pointer to page in which to insert or NULL on error. | 1485 | * Pointer to page in which to insert or NULL on error. |
1487 | */ | 1486 | */ |
1488 | static int | 1487 | static int |
1489 | xtSplitRoot(tid_t tid, | 1488 | xtSplitRoot(tid_t tid, |
@@ -1505,7 +1504,7 @@ xtSplitRoot(tid_t tid, | |||
1505 | INCREMENT(xtStat.split); | 1504 | INCREMENT(xtStat.split); |
1506 | 1505 | ||
1507 | /* | 1506 | /* |
1508 | * allocate a single (right) child page | 1507 | * allocate a single (right) child page |
1509 | */ | 1508 | */ |
1510 | pxdlist = split->pxdlist; | 1509 | pxdlist = split->pxdlist; |
1511 | pxd = &pxdlist->pxd[pxdlist->npxd]; | 1510 | pxd = &pxdlist->pxd[pxdlist->npxd]; |
@@ -1573,7 +1572,7 @@ xtSplitRoot(tid_t tid, | |||
1573 | } | 1572 | } |
1574 | 1573 | ||
1575 | /* | 1574 | /* |
1576 | * reset the root | 1575 | * reset the root |
1577 | * | 1576 | * |
1578 | * init root with the single entry for the new right page | 1577 | * init root with the single entry for the new right page |
1579 | * set the 1st entry offset to 0, which force the left-most key | 1578 | * set the 1st entry offset to 0, which force the left-most key |
@@ -1610,7 +1609,7 @@ xtSplitRoot(tid_t tid, | |||
1610 | 1609 | ||
1611 | 1610 | ||
1612 | /* | 1611 | /* |
1613 | * xtExtend() | 1612 | * xtExtend() |
1614 | * | 1613 | * |
1615 | * function: extend in-place; | 1614 | * function: extend in-place; |
1616 | * | 1615 | * |
@@ -1677,7 +1676,7 @@ int xtExtend(tid_t tid, /* transaction id */ | |||
1677 | goto extendOld; | 1676 | goto extendOld; |
1678 | 1677 | ||
1679 | /* | 1678 | /* |
1680 | * extent overflow: insert entry for new extent | 1679 | * extent overflow: insert entry for new extent |
1681 | */ | 1680 | */ |
1682 | //insertNew: | 1681 | //insertNew: |
1683 | xoff = offsetXAD(xad) + MAXXLEN; | 1682 | xoff = offsetXAD(xad) + MAXXLEN; |
@@ -1685,8 +1684,8 @@ int xtExtend(tid_t tid, /* transaction id */ | |||
1685 | nextindex = le16_to_cpu(p->header.nextindex); | 1684 | nextindex = le16_to_cpu(p->header.nextindex); |
1686 | 1685 | ||
1687 | /* | 1686 | /* |
1688 | * if the leaf page is full, insert the new entry and | 1687 | * if the leaf page is full, insert the new entry and |
1689 | * propagate up the router entry for the new page from split | 1688 | * propagate up the router entry for the new page from split |
1690 | * | 1689 | * |
1691 | * The xtSplitUp() will insert the entry and unpin the leaf page. | 1690 | * The xtSplitUp() will insert the entry and unpin the leaf page. |
1692 | */ | 1691 | */ |
@@ -1731,7 +1730,7 @@ int xtExtend(tid_t tid, /* transaction id */ | |||
1731 | } | 1730 | } |
1732 | } | 1731 | } |
1733 | /* | 1732 | /* |
1734 | * insert the new entry into the leaf page | 1733 | * insert the new entry into the leaf page |
1735 | */ | 1734 | */ |
1736 | else { | 1735 | else { |
1737 | /* insert the new entry: mark the entry NEW */ | 1736 | /* insert the new entry: mark the entry NEW */ |
@@ -1771,11 +1770,11 @@ int xtExtend(tid_t tid, /* transaction id */ | |||
1771 | 1770 | ||
1772 | #ifdef _NOTYET | 1771 | #ifdef _NOTYET |
1773 | /* | 1772 | /* |
1774 | * xtTailgate() | 1773 | * xtTailgate() |
1775 | * | 1774 | * |
1776 | * function: split existing 'tail' extent | 1775 | * function: split existing 'tail' extent |
1777 | * (split offset >= start offset of tail extent), and | 1776 | * (split offset >= start offset of tail extent), and |
1778 | * relocate and extend the split tail half; | 1777 | * relocate and extend the split tail half; |
1779 | * | 1778 | * |
1780 | * note: existing extent may or may not have been committed. | 1779 | * note: existing extent may or may not have been committed. |
1781 | * caller is responsible for pager buffer cache update, and | 1780 | * caller is responsible for pager buffer cache update, and |
@@ -1804,7 +1803,7 @@ int xtTailgate(tid_t tid, /* transaction id */ | |||
1804 | 1803 | ||
1805 | /* | 1804 | /* |
1806 | printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n", | 1805 | printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n", |
1807 | (ulong)xoff, xlen, (ulong)xaddr); | 1806 | (ulong)xoff, xlen, (ulong)xaddr); |
1808 | */ | 1807 | */ |
1809 | 1808 | ||
1810 | /* there must exist extent to be tailgated */ | 1809 | /* there must exist extent to be tailgated */ |
@@ -1842,18 +1841,18 @@ printf("xtTailgate: nxoff:0x%lx nxlen:0x%x nxaddr:0x%lx\n", | |||
1842 | xad = &p->xad[index]; | 1841 | xad = &p->xad[index]; |
1843 | /* | 1842 | /* |
1844 | printf("xtTailgate: xoff:0x%lx xlen:0x%x xaddr:0x%lx\n", | 1843 | printf("xtTailgate: xoff:0x%lx xlen:0x%x xaddr:0x%lx\n", |
1845 | (ulong)offsetXAD(xad), lengthXAD(xad), (ulong)addressXAD(xad)); | 1844 | (ulong)offsetXAD(xad), lengthXAD(xad), (ulong)addressXAD(xad)); |
1846 | */ | 1845 | */ |
1847 | if ((llen = xoff - offsetXAD(xad)) == 0) | 1846 | if ((llen = xoff - offsetXAD(xad)) == 0) |
1848 | goto updateOld; | 1847 | goto updateOld; |
1849 | 1848 | ||
1850 | /* | 1849 | /* |
1851 | * partially replace extent: insert entry for new extent | 1850 | * partially replace extent: insert entry for new extent |
1852 | */ | 1851 | */ |
1853 | //insertNew: | 1852 | //insertNew: |
1854 | /* | 1853 | /* |
1855 | * if the leaf page is full, insert the new entry and | 1854 | * if the leaf page is full, insert the new entry and |
1856 | * propagate up the router entry for the new page from split | 1855 | * propagate up the router entry for the new page from split |
1857 | * | 1856 | * |
1858 | * The xtSplitUp() will insert the entry and unpin the leaf page. | 1857 | * The xtSplitUp() will insert the entry and unpin the leaf page. |
1859 | */ | 1858 | */ |
@@ -1898,7 +1897,7 @@ printf("xtTailgate: xoff:0x%lx xlen:0x%x xaddr:0x%lx\n", | |||
1898 | } | 1897 | } |
1899 | } | 1898 | } |
1900 | /* | 1899 | /* |
1901 | * insert the new entry into the leaf page | 1900 | * insert the new entry into the leaf page |
1902 | */ | 1901 | */ |
1903 | else { | 1902 | else { |
1904 | /* insert the new entry: mark the entry NEW */ | 1903 | /* insert the new entry: mark the entry NEW */ |
@@ -1955,17 +1954,17 @@ printf("xtTailgate: xoff:0x%lx xlen:0x%x xaddr:0x%lx\n", | |||
1955 | #endif /* _NOTYET */ | 1954 | #endif /* _NOTYET */ |
1956 | 1955 | ||
1957 | /* | 1956 | /* |
1958 | * xtUpdate() | 1957 | * xtUpdate() |
1959 | * | 1958 | * |
1960 | * function: update XAD; | 1959 | * function: update XAD; |
1961 | * | 1960 | * |
1962 | * update extent for allocated_but_not_recorded or | 1961 | * update extent for allocated_but_not_recorded or |
1963 | * compressed extent; | 1962 | * compressed extent; |
1964 | * | 1963 | * |
1965 | * parameter: | 1964 | * parameter: |
1966 | * nxad - new XAD; | 1965 | * nxad - new XAD; |
1967 | * logical extent of the specified XAD must be completely | 1966 | * logical extent of the specified XAD must be completely |
1968 | * contained by an existing XAD; | 1967 | * contained by an existing XAD; |
1969 | */ | 1968 | */ |
1970 | int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad) | 1969 | int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad) |
1971 | { /* new XAD */ | 1970 | { /* new XAD */ |
@@ -2416,19 +2415,19 @@ printf("xtUpdate.updateLeft.split p:0x%p\n", p); | |||
2416 | 2415 | ||
2417 | 2416 | ||
2418 | /* | 2417 | /* |
2419 | * xtAppend() | 2418 | * xtAppend() |
2420 | * | 2419 | * |
2421 | * function: grow in append mode from contiguous region specified ; | 2420 | * function: grow in append mode from contiguous region specified ; |
2422 | * | 2421 | * |
2423 | * parameter: | 2422 | * parameter: |
2424 | * tid - transaction id; | 2423 | * tid - transaction id; |
2425 | * ip - file object; | 2424 | * ip - file object; |
2426 | * xflag - extent flag: | 2425 | * xflag - extent flag: |
2427 | * xoff - extent offset; | 2426 | * xoff - extent offset; |
2428 | * maxblocks - max extent length; | 2427 | * maxblocks - max extent length; |
2429 | * xlen - extent length (in/out); | 2428 | * xlen - extent length (in/out); |
2430 | * xaddrp - extent address pointer (in/out): | 2429 | * xaddrp - extent address pointer (in/out): |
2431 | * flag - | 2430 | * flag - |
2432 | * | 2431 | * |
2433 | * return: | 2432 | * return: |
2434 | */ | 2433 | */ |
@@ -2460,7 +2459,7 @@ int xtAppend(tid_t tid, /* transaction id */ | |||
2460 | (ulong) xoff, maxblocks, xlen, (ulong) xaddr); | 2459 | (ulong) xoff, maxblocks, xlen, (ulong) xaddr); |
2461 | 2460 | ||
2462 | /* | 2461 | /* |
2463 | * search for the entry location at which to insert: | 2462 | * search for the entry location at which to insert: |
2464 | * | 2463 | * |
2465 | * xtFastSearch() and xtSearch() both returns (leaf page | 2464 | * xtFastSearch() and xtSearch() both returns (leaf page |
2466 | * pinned, index at which to insert). | 2465 | * pinned, index at which to insert). |
@@ -2482,13 +2481,13 @@ int xtAppend(tid_t tid, /* transaction id */ | |||
2482 | xlen = min(xlen, (int)(next - xoff)); | 2481 | xlen = min(xlen, (int)(next - xoff)); |
2483 | //insert: | 2482 | //insert: |
2484 | /* | 2483 | /* |
2485 | * insert entry for new extent | 2484 | * insert entry for new extent |
2486 | */ | 2485 | */ |
2487 | xflag |= XAD_NEW; | 2486 | xflag |= XAD_NEW; |
2488 | 2487 | ||
2489 | /* | 2488 | /* |
2490 | * if the leaf page is full, split the page and | 2489 | * if the leaf page is full, split the page and |
2491 | * propagate up the router entry for the new page from split | 2490 | * propagate up the router entry for the new page from split |
2492 | * | 2491 | * |
2493 | * The xtSplitUp() will insert the entry and unpin the leaf page. | 2492 | * The xtSplitUp() will insert the entry and unpin the leaf page. |
2494 | */ | 2493 | */ |
@@ -2545,7 +2544,7 @@ int xtAppend(tid_t tid, /* transaction id */ | |||
2545 | return 0; | 2544 | return 0; |
2546 | 2545 | ||
2547 | /* | 2546 | /* |
2548 | * insert the new entry into the leaf page | 2547 | * insert the new entry into the leaf page |
2549 | */ | 2548 | */ |
2550 | insertLeaf: | 2549 | insertLeaf: |
2551 | /* | 2550 | /* |
@@ -2589,17 +2588,17 @@ int xtAppend(tid_t tid, /* transaction id */ | |||
2589 | 2588 | ||
2590 | /* - TBD for defragmentaion/reorganization - | 2589 | /* - TBD for defragmentaion/reorganization - |
2591 | * | 2590 | * |
2592 | * xtDelete() | 2591 | * xtDelete() |
2593 | * | 2592 | * |
2594 | * function: | 2593 | * function: |
2595 | * delete the entry with the specified key. | 2594 | * delete the entry with the specified key. |
2596 | * | 2595 | * |
2597 | * N.B.: whole extent of the entry is assumed to be deleted. | 2596 | * N.B.: whole extent of the entry is assumed to be deleted. |
2598 | * | 2597 | * |
2599 | * parameter: | 2598 | * parameter: |
2600 | * | 2599 | * |
2601 | * return: | 2600 | * return: |
2602 | * ENOENT: if the entry is not found. | 2601 | * ENOENT: if the entry is not found. |
2603 | * | 2602 | * |
2604 | * exception: | 2603 | * exception: |
2605 | */ | 2604 | */ |
@@ -2665,10 +2664,10 @@ int xtDelete(tid_t tid, struct inode *ip, s64 xoff, s32 xlen, int flag) | |||
2665 | 2664 | ||
2666 | /* - TBD for defragmentaion/reorganization - | 2665 | /* - TBD for defragmentaion/reorganization - |
2667 | * | 2666 | * |
2668 | * xtDeleteUp() | 2667 | * xtDeleteUp() |
2669 | * | 2668 | * |
2670 | * function: | 2669 | * function: |
2671 | * free empty pages as propagating deletion up the tree | 2670 | * free empty pages as propagating deletion up the tree |
2672 | * | 2671 | * |
2673 | * parameter: | 2672 | * parameter: |
2674 | * | 2673 | * |
@@ -2815,15 +2814,15 @@ xtDeleteUp(tid_t tid, struct inode *ip, | |||
2815 | 2814 | ||
2816 | 2815 | ||
2817 | /* | 2816 | /* |
2818 | * NAME: xtRelocate() | 2817 | * NAME: xtRelocate() |
2819 | * | 2818 | * |
2820 | * FUNCTION: relocate xtpage or data extent of regular file; | 2819 | * FUNCTION: relocate xtpage or data extent of regular file; |
2821 | * This function is mainly used by defragfs utility. | 2820 | * This function is mainly used by defragfs utility. |
2822 | * | 2821 | * |
2823 | * NOTE: This routine does not have the logic to handle | 2822 | * NOTE: This routine does not have the logic to handle |
2824 | * uncommitted allocated extent. The caller should call | 2823 | * uncommitted allocated extent. The caller should call |
2825 | * txCommit() to commit all the allocation before call | 2824 | * txCommit() to commit all the allocation before call |
2826 | * this routine. | 2825 | * this routine. |
2827 | */ | 2826 | */ |
2828 | int | 2827 | int |
2829 | xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | 2828 | xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ |
@@ -2865,8 +2864,8 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
2865 | xtype, (ulong) xoff, xlen, (ulong) oxaddr, (ulong) nxaddr); | 2864 | xtype, (ulong) xoff, xlen, (ulong) oxaddr, (ulong) nxaddr); |
2866 | 2865 | ||
2867 | /* | 2866 | /* |
2868 | * 1. get and validate the parent xtpage/xad entry | 2867 | * 1. get and validate the parent xtpage/xad entry |
2869 | * covering the source extent to be relocated; | 2868 | * covering the source extent to be relocated; |
2870 | */ | 2869 | */ |
2871 | if (xtype == DATAEXT) { | 2870 | if (xtype == DATAEXT) { |
2872 | /* search in leaf entry */ | 2871 | /* search in leaf entry */ |
@@ -2910,7 +2909,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
2910 | jfs_info("xtRelocate: parent xad entry validated."); | 2909 | jfs_info("xtRelocate: parent xad entry validated."); |
2911 | 2910 | ||
2912 | /* | 2911 | /* |
2913 | * 2. relocate the extent | 2912 | * 2. relocate the extent |
2914 | */ | 2913 | */ |
2915 | if (xtype == DATAEXT) { | 2914 | if (xtype == DATAEXT) { |
2916 | /* if the extent is allocated-but-not-recorded | 2915 | /* if the extent is allocated-but-not-recorded |
@@ -2923,7 +2922,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
2923 | XT_PUTPAGE(pmp); | 2922 | XT_PUTPAGE(pmp); |
2924 | 2923 | ||
2925 | /* | 2924 | /* |
2926 | * cmRelocate() | 2925 | * cmRelocate() |
2927 | * | 2926 | * |
2928 | * copy target data pages to be relocated; | 2927 | * copy target data pages to be relocated; |
2929 | * | 2928 | * |
@@ -2945,8 +2944,8 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
2945 | pno = offset >> CM_L2BSIZE; | 2944 | pno = offset >> CM_L2BSIZE; |
2946 | npages = (nbytes + (CM_BSIZE - 1)) >> CM_L2BSIZE; | 2945 | npages = (nbytes + (CM_BSIZE - 1)) >> CM_L2BSIZE; |
2947 | /* | 2946 | /* |
2948 | npages = ((offset + nbytes - 1) >> CM_L2BSIZE) - | 2947 | npages = ((offset + nbytes - 1) >> CM_L2BSIZE) - |
2949 | (offset >> CM_L2BSIZE) + 1; | 2948 | (offset >> CM_L2BSIZE) + 1; |
2950 | */ | 2949 | */ |
2951 | sxaddr = oxaddr; | 2950 | sxaddr = oxaddr; |
2952 | dxaddr = nxaddr; | 2951 | dxaddr = nxaddr; |
@@ -2981,7 +2980,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
2981 | 2980 | ||
2982 | XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index); | 2981 | XT_GETSEARCH(ip, btstack.top, bn, pmp, pp, index); |
2983 | jfs_info("xtRelocate: target data extent relocated."); | 2982 | jfs_info("xtRelocate: target data extent relocated."); |
2984 | } else { /* (xtype == XTPAGE) */ | 2983 | } else { /* (xtype == XTPAGE) */ |
2985 | 2984 | ||
2986 | /* | 2985 | /* |
2987 | * read in the target xtpage from the source extent; | 2986 | * read in the target xtpage from the source extent; |
@@ -3026,16 +3025,14 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
3026 | */ | 3025 | */ |
3027 | if (lmp) { | 3026 | if (lmp) { |
3028 | BT_MARK_DIRTY(lmp, ip); | 3027 | BT_MARK_DIRTY(lmp, ip); |
3029 | tlck = | 3028 | tlck = txLock(tid, ip, lmp, tlckXTREE | tlckRELINK); |
3030 | txLock(tid, ip, lmp, tlckXTREE | tlckRELINK); | ||
3031 | lp->header.next = cpu_to_le64(nxaddr); | 3029 | lp->header.next = cpu_to_le64(nxaddr); |
3032 | XT_PUTPAGE(lmp); | 3030 | XT_PUTPAGE(lmp); |
3033 | } | 3031 | } |
3034 | 3032 | ||
3035 | if (rmp) { | 3033 | if (rmp) { |
3036 | BT_MARK_DIRTY(rmp, ip); | 3034 | BT_MARK_DIRTY(rmp, ip); |
3037 | tlck = | 3035 | tlck = txLock(tid, ip, rmp, tlckXTREE | tlckRELINK); |
3038 | txLock(tid, ip, rmp, tlckXTREE | tlckRELINK); | ||
3039 | rp->header.prev = cpu_to_le64(nxaddr); | 3036 | rp->header.prev = cpu_to_le64(nxaddr); |
3040 | XT_PUTPAGE(rmp); | 3037 | XT_PUTPAGE(rmp); |
3041 | } | 3038 | } |
@@ -3062,7 +3059,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
3062 | * scan may be skipped by commit() and logredo(); | 3059 | * scan may be skipped by commit() and logredo(); |
3063 | */ | 3060 | */ |
3064 | BT_MARK_DIRTY(mp, ip); | 3061 | BT_MARK_DIRTY(mp, ip); |
3065 | /* tlckNEW init xtlck->lwm.offset = XTENTRYSTART; */ | 3062 | /* tlckNEW init xtlck->lwm.offset = XTENTRYSTART; */ |
3066 | tlck = txLock(tid, ip, mp, tlckXTREE | tlckNEW); | 3063 | tlck = txLock(tid, ip, mp, tlckXTREE | tlckNEW); |
3067 | xtlck = (struct xtlock *) & tlck->lock; | 3064 | xtlck = (struct xtlock *) & tlck->lock; |
3068 | 3065 | ||
@@ -3084,7 +3081,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
3084 | } | 3081 | } |
3085 | 3082 | ||
3086 | /* | 3083 | /* |
3087 | * 3. acquire maplock for the source extent to be freed; | 3084 | * 3. acquire maplock for the source extent to be freed; |
3088 | * | 3085 | * |
3089 | * acquire a maplock saving the src relocated extent address; | 3086 | * acquire a maplock saving the src relocated extent address; |
3090 | * to free of the extent at commit time; | 3087 | * to free of the extent at commit time; |
@@ -3105,7 +3102,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
3105 | * is no buffer associated with this lock since the buffer | 3102 | * is no buffer associated with this lock since the buffer |
3106 | * has been redirected to the target location. | 3103 | * has been redirected to the target location. |
3107 | */ | 3104 | */ |
3108 | else /* (xtype == XTPAGE) */ | 3105 | else /* (xtype == XTPAGE) */ |
3109 | tlck = txMaplock(tid, ip, tlckMAP | tlckRELOCATE); | 3106 | tlck = txMaplock(tid, ip, tlckMAP | tlckRELOCATE); |
3110 | 3107 | ||
3111 | pxdlock = (struct pxd_lock *) & tlck->lock; | 3108 | pxdlock = (struct pxd_lock *) & tlck->lock; |
@@ -3115,7 +3112,7 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
3115 | pxdlock->index = 1; | 3112 | pxdlock->index = 1; |
3116 | 3113 | ||
3117 | /* | 3114 | /* |
3118 | * 4. update the parent xad entry for relocation; | 3115 | * 4. update the parent xad entry for relocation; |
3119 | * | 3116 | * |
3120 | * acquire tlck for the parent entry with XAD_NEW as entry | 3117 | * acquire tlck for the parent entry with XAD_NEW as entry |
3121 | * update which will write LOG_REDOPAGE and update bmap for | 3118 | * update which will write LOG_REDOPAGE and update bmap for |
@@ -3143,22 +3140,22 @@ xtRelocate(tid_t tid, struct inode * ip, xad_t * oxad, /* old XAD */ | |||
3143 | 3140 | ||
3144 | 3141 | ||
3145 | /* | 3142 | /* |
3146 | * xtSearchNode() | 3143 | * xtSearchNode() |
3147 | * | 3144 | * |
3148 | * function: search for the internal xad entry covering specified extent. | 3145 | * function: search for the internal xad entry covering specified extent. |
3149 | * This function is mainly used by defragfs utility. | 3146 | * This function is mainly used by defragfs utility. |
3150 | * | 3147 | * |
3151 | * parameters: | 3148 | * parameters: |
3152 | * ip - file object; | 3149 | * ip - file object; |
3153 | * xad - extent to find; | 3150 | * xad - extent to find; |
3154 | * cmpp - comparison result: | 3151 | * cmpp - comparison result: |
3155 | * btstack - traverse stack; | 3152 | * btstack - traverse stack; |
3156 | * flag - search process flag; | 3153 | * flag - search process flag; |
3157 | * | 3154 | * |
3158 | * returns: | 3155 | * returns: |
3159 | * btstack contains (bn, index) of search path traversed to the entry. | 3156 | * btstack contains (bn, index) of search path traversed to the entry. |
3160 | * *cmpp is set to result of comparison with the entry returned. | 3157 | * *cmpp is set to result of comparison with the entry returned. |
3161 | * the page containing the entry is pinned at exit. | 3158 | * the page containing the entry is pinned at exit. |
3162 | */ | 3159 | */ |
3163 | static int xtSearchNode(struct inode *ip, xad_t * xad, /* required XAD entry */ | 3160 | static int xtSearchNode(struct inode *ip, xad_t * xad, /* required XAD entry */ |
3164 | int *cmpp, struct btstack * btstack, int flag) | 3161 | int *cmpp, struct btstack * btstack, int flag) |
@@ -3181,7 +3178,7 @@ static int xtSearchNode(struct inode *ip, xad_t * xad, /* required XAD entry */ | |||
3181 | xaddr = addressXAD(xad); | 3178 | xaddr = addressXAD(xad); |
3182 | 3179 | ||
3183 | /* | 3180 | /* |
3184 | * search down tree from root: | 3181 | * search down tree from root: |
3185 | * | 3182 | * |
3186 | * between two consecutive entries of <Ki, Pi> and <Kj, Pj> of | 3183 | * between two consecutive entries of <Ki, Pi> and <Kj, Pj> of |
3187 | * internal page, child page Pi contains entry with k, Ki <= K < Kj. | 3184 | * internal page, child page Pi contains entry with k, Ki <= K < Kj. |
@@ -3217,7 +3214,7 @@ static int xtSearchNode(struct inode *ip, xad_t * xad, /* required XAD entry */ | |||
3217 | XT_CMP(cmp, xoff, &p->xad[index], t64); | 3214 | XT_CMP(cmp, xoff, &p->xad[index], t64); |
3218 | if (cmp == 0) { | 3215 | if (cmp == 0) { |
3219 | /* | 3216 | /* |
3220 | * search hit | 3217 | * search hit |
3221 | * | 3218 | * |
3222 | * verify for exact match; | 3219 | * verify for exact match; |
3223 | */ | 3220 | */ |
@@ -3245,7 +3242,7 @@ static int xtSearchNode(struct inode *ip, xad_t * xad, /* required XAD entry */ | |||
3245 | } | 3242 | } |
3246 | 3243 | ||
3247 | /* | 3244 | /* |
3248 | * search miss - non-leaf page: | 3245 | * search miss - non-leaf page: |
3249 | * | 3246 | * |
3250 | * base is the smallest index with key (Kj) greater than | 3247 | * base is the smallest index with key (Kj) greater than |
3251 | * search key (K) and may be zero or maxentry index. | 3248 | * search key (K) and may be zero or maxentry index. |
@@ -3268,15 +3265,15 @@ static int xtSearchNode(struct inode *ip, xad_t * xad, /* required XAD entry */ | |||
3268 | 3265 | ||
3269 | 3266 | ||
3270 | /* | 3267 | /* |
3271 | * xtRelink() | 3268 | * xtRelink() |
3272 | * | 3269 | * |
3273 | * function: | 3270 | * function: |
3274 | * link around a freed page. | 3271 | * link around a freed page. |
3275 | * | 3272 | * |
3276 | * Parameter: | 3273 | * Parameter: |
3277 | * int tid, | 3274 | * int tid, |
3278 | * struct inode *ip, | 3275 | * struct inode *ip, |
3279 | * xtpage_t *p) | 3276 | * xtpage_t *p) |
3280 | * | 3277 | * |
3281 | * returns: | 3278 | * returns: |
3282 | */ | 3279 | */ |
@@ -3338,7 +3335,7 @@ static int xtRelink(tid_t tid, struct inode *ip, xtpage_t * p) | |||
3338 | 3335 | ||
3339 | 3336 | ||
3340 | /* | 3337 | /* |
3341 | * xtInitRoot() | 3338 | * xtInitRoot() |
3342 | * | 3339 | * |
3343 | * initialize file root (inline in inode) | 3340 | * initialize file root (inline in inode) |
3344 | */ | 3341 | */ |
@@ -3385,42 +3382,42 @@ void xtInitRoot(tid_t tid, struct inode *ip) | |||
3385 | #define MAX_TRUNCATE_LEAVES 50 | 3382 | #define MAX_TRUNCATE_LEAVES 50 |
3386 | 3383 | ||
3387 | /* | 3384 | /* |
3388 | * xtTruncate() | 3385 | * xtTruncate() |
3389 | * | 3386 | * |
3390 | * function: | 3387 | * function: |
3391 | * traverse for truncation logging backward bottom up; | 3388 | * traverse for truncation logging backward bottom up; |
3392 | * terminate at the last extent entry at the current subtree | 3389 | * terminate at the last extent entry at the current subtree |
3393 | * root page covering new down size. | 3390 | * root page covering new down size. |
3394 | * truncation may occur within the last extent entry. | 3391 | * truncation may occur within the last extent entry. |
3395 | * | 3392 | * |
3396 | * parameter: | 3393 | * parameter: |
3397 | * int tid, | 3394 | * int tid, |
3398 | * struct inode *ip, | 3395 | * struct inode *ip, |
3399 | * s64 newsize, | 3396 | * s64 newsize, |
3400 | * int type) {PWMAP, PMAP, WMAP; DELETE, TRUNCATE} | 3397 | * int type) {PWMAP, PMAP, WMAP; DELETE, TRUNCATE} |
3401 | * | 3398 | * |
3402 | * return: | 3399 | * return: |
3403 | * | 3400 | * |
3404 | * note: | 3401 | * note: |
3405 | * PWMAP: | 3402 | * PWMAP: |
3406 | * 1. truncate (non-COMMIT_NOLINK file) | 3403 | * 1. truncate (non-COMMIT_NOLINK file) |
3407 | * by jfs_truncate() or jfs_open(O_TRUNC): | 3404 | * by jfs_truncate() or jfs_open(O_TRUNC): |
3408 | * xtree is updated; | 3405 | * xtree is updated; |
3409 | * 2. truncate index table of directory when last entry removed | 3406 | * 2. truncate index table of directory when last entry removed |
3410 | * map update via tlock at commit time; | 3407 | * map update via tlock at commit time; |
3411 | * PMAP: | 3408 | * PMAP: |
3412 | * Call xtTruncate_pmap instead | 3409 | * Call xtTruncate_pmap instead |
3413 | * WMAP: | 3410 | * WMAP: |
3414 | * 1. remove (free zero link count) on last reference release | 3411 | * 1. remove (free zero link count) on last reference release |
3415 | * (pmap has been freed at commit zero link count); | 3412 | * (pmap has been freed at commit zero link count); |
3416 | * 2. truncate (COMMIT_NOLINK file, i.e., tmp file): | 3413 | * 2. truncate (COMMIT_NOLINK file, i.e., tmp file): |
3417 | * xtree is updated; | 3414 | * xtree is updated; |
3418 | * map update directly at truncation time; | 3415 | * map update directly at truncation time; |
3419 | * | 3416 | * |
3420 | * if (DELETE) | 3417 | * if (DELETE) |
3421 | * no LOG_NOREDOPAGE is required (NOREDOFILE is sufficient); | 3418 | * no LOG_NOREDOPAGE is required (NOREDOFILE is sufficient); |
3422 | * else if (TRUNCATE) | 3419 | * else if (TRUNCATE) |
3423 | * must write LOG_NOREDOPAGE for deleted index page; | 3420 | * must write LOG_NOREDOPAGE for deleted index page; |
3424 | * | 3421 | * |
3425 | * pages may already have been tlocked by anonymous transactions | 3422 | * pages may already have been tlocked by anonymous transactions |
3426 | * during file growth (i.e., write) before truncation; | 3423 | * during file growth (i.e., write) before truncation; |
@@ -3493,7 +3490,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) | |||
3493 | * retained in the new sized file. | 3490 | * retained in the new sized file. |
3494 | * if type is PMAP, the data and index pages are NOT | 3491 | * if type is PMAP, the data and index pages are NOT |
3495 | * freed, and the data and index blocks are NOT freed | 3492 | * freed, and the data and index blocks are NOT freed |
3496 | * from working map. | 3493 | * from working map. |
3497 | * (this will allow continued access of data/index of | 3494 | * (this will allow continued access of data/index of |
3498 | * temporary file (zerolink count file truncated to zero-length)). | 3495 | * temporary file (zerolink count file truncated to zero-length)). |
3499 | */ | 3496 | */ |
@@ -3542,7 +3539,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) | |||
3542 | goto getChild; | 3539 | goto getChild; |
3543 | 3540 | ||
3544 | /* | 3541 | /* |
3545 | * leaf page | 3542 | * leaf page |
3546 | */ | 3543 | */ |
3547 | freed = 0; | 3544 | freed = 0; |
3548 | 3545 | ||
@@ -3916,7 +3913,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) | |||
3916 | } | 3913 | } |
3917 | 3914 | ||
3918 | /* | 3915 | /* |
3919 | * internal page: go down to child page of current entry | 3916 | * internal page: go down to child page of current entry |
3920 | */ | 3917 | */ |
3921 | getChild: | 3918 | getChild: |
3922 | /* save current parent entry for the child page */ | 3919 | /* save current parent entry for the child page */ |
@@ -3965,7 +3962,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) | |||
3965 | 3962 | ||
3966 | 3963 | ||
3967 | /* | 3964 | /* |
3968 | * xtTruncate_pmap() | 3965 | * xtTruncate_pmap() |
3969 | * | 3966 | * |
3970 | * function: | 3967 | * function: |
3971 | * Perform truncate to zero lenghth for deleted file, leaving the | 3968 | * Perform truncate to zero lenghth for deleted file, leaving the |
@@ -3974,9 +3971,9 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) | |||
3974 | * is committed to disk. | 3971 | * is committed to disk. |
3975 | * | 3972 | * |
3976 | * parameter: | 3973 | * parameter: |
3977 | * tid_t tid, | 3974 | * tid_t tid, |
3978 | * struct inode *ip, | 3975 | * struct inode *ip, |
3979 | * s64 committed_size) | 3976 | * s64 committed_size) |
3980 | * | 3977 | * |
3981 | * return: new committed size | 3978 | * return: new committed size |
3982 | * | 3979 | * |
@@ -4050,7 +4047,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) | |||
4050 | } | 4047 | } |
4051 | 4048 | ||
4052 | /* | 4049 | /* |
4053 | * leaf page | 4050 | * leaf page |
4054 | */ | 4051 | */ |
4055 | 4052 | ||
4056 | if (++locked_leaves > MAX_TRUNCATE_LEAVES) { | 4053 | if (++locked_leaves > MAX_TRUNCATE_LEAVES) { |
@@ -4062,7 +4059,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) | |||
4062 | xoff = offsetXAD(xad); | 4059 | xoff = offsetXAD(xad); |
4063 | xlen = lengthXAD(xad); | 4060 | xlen = lengthXAD(xad); |
4064 | XT_PUTPAGE(mp); | 4061 | XT_PUTPAGE(mp); |
4065 | return (xoff + xlen) << JFS_SBI(ip->i_sb)->l2bsize; | 4062 | return (xoff + xlen) << JFS_SBI(ip->i_sb)->l2bsize; |
4066 | } | 4063 | } |
4067 | tlck = txLock(tid, ip, mp, tlckXTREE); | 4064 | tlck = txLock(tid, ip, mp, tlckXTREE); |
4068 | tlck->type = tlckXTREE | tlckFREE; | 4065 | tlck->type = tlckXTREE | tlckFREE; |
@@ -4099,8 +4096,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) | |||
4099 | */ | 4096 | */ |
4100 | tlck = txLock(tid, ip, mp, tlckXTREE); | 4097 | tlck = txLock(tid, ip, mp, tlckXTREE); |
4101 | xtlck = (struct xtlock *) & tlck->lock; | 4098 | xtlck = (struct xtlock *) & tlck->lock; |
4102 | xtlck->hwm.offset = | 4099 | xtlck->hwm.offset = le16_to_cpu(p->header.nextindex) - 1; |
4103 | le16_to_cpu(p->header.nextindex) - 1; | ||
4104 | tlck->type = tlckXTREE | tlckFREE; | 4100 | tlck->type = tlckXTREE | tlckFREE; |
4105 | 4101 | ||
4106 | XT_PUTPAGE(mp); | 4102 | XT_PUTPAGE(mp); |
@@ -4118,7 +4114,7 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) | |||
4118 | else | 4114 | else |
4119 | index--; | 4115 | index--; |
4120 | /* | 4116 | /* |
4121 | * internal page: go down to child page of current entry | 4117 | * internal page: go down to child page of current entry |
4122 | */ | 4118 | */ |
4123 | getChild: | 4119 | getChild: |
4124 | /* save current parent entry for the child page */ | 4120 | /* save current parent entry for the child page */ |