diff options
Diffstat (limited to 'fs/jfs')
-rw-r--r-- | fs/jfs/jfs_dmap.c | 298 | ||||
-rw-r--r-- | fs/jfs/jfs_dtree.c | 199 | ||||
-rw-r--r-- | fs/jfs/jfs_dtree.h | 7 | ||||
-rw-r--r-- | fs/jfs/jfs_imap.c | 105 | ||||
-rw-r--r-- | fs/jfs/jfs_xtree.c | 340 | ||||
-rw-r--r-- | fs/jfs/jfs_xtree.h | 6 |
6 files changed, 8 insertions, 947 deletions
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index cced2fed9d0f..0732f206ca60 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c | |||
@@ -26,36 +26,6 @@ | |||
26 | #include "jfs_debug.h" | 26 | #include "jfs_debug.h" |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * Debug code for double-checking block map | ||
30 | */ | ||
31 | /* #define _JFS_DEBUG_DMAP 1 */ | ||
32 | |||
33 | #ifdef _JFS_DEBUG_DMAP | ||
34 | #define DBINITMAP(size,ipbmap,results) \ | ||
35 | DBinitmap(size,ipbmap,results) | ||
36 | #define DBALLOC(dbmap,mapsize,blkno,nblocks) \ | ||
37 | DBAlloc(dbmap,mapsize,blkno,nblocks) | ||
38 | #define DBFREE(dbmap,mapsize,blkno,nblocks) \ | ||
39 | DBFree(dbmap,mapsize,blkno,nblocks) | ||
40 | #define DBALLOCCK(dbmap,mapsize,blkno,nblocks) \ | ||
41 | DBAllocCK(dbmap,mapsize,blkno,nblocks) | ||
42 | #define DBFREECK(dbmap,mapsize,blkno,nblocks) \ | ||
43 | DBFreeCK(dbmap,mapsize,blkno,nblocks) | ||
44 | |||
45 | static void DBinitmap(s64, struct inode *, u32 **); | ||
46 | static void DBAlloc(uint *, s64, s64, s64); | ||
47 | static void DBFree(uint *, s64, s64, s64); | ||
48 | static void DBAllocCK(uint *, s64, s64, s64); | ||
49 | static void DBFreeCK(uint *, s64, s64, s64); | ||
50 | #else | ||
51 | #define DBINITMAP(size,ipbmap,results) | ||
52 | #define DBALLOC(dbmap, mapsize, blkno, nblocks) | ||
53 | #define DBFREE(dbmap, mapsize, blkno, nblocks) | ||
54 | #define DBALLOCCK(dbmap, mapsize, blkno, nblocks) | ||
55 | #define DBFREECK(dbmap, mapsize, blkno, nblocks) | ||
56 | #endif /* _JFS_DEBUG_DMAP */ | ||
57 | |||
58 | /* | ||
59 | * SERIALIZATION of the Block Allocation Map. | 29 | * SERIALIZATION of the Block Allocation Map. |
60 | * | 30 | * |
61 | * the working state of the block allocation map is accessed in | 31 | * the working state of the block allocation map is accessed in |
@@ -242,7 +212,6 @@ int dbMount(struct inode *ipbmap) | |||
242 | JFS_SBI(ipbmap->i_sb)->bmap = bmp; | 212 | JFS_SBI(ipbmap->i_sb)->bmap = bmp; |
243 | 213 | ||
244 | memset(bmp->db_active, 0, sizeof(bmp->db_active)); | 214 | memset(bmp->db_active, 0, sizeof(bmp->db_active)); |
245 | DBINITMAP(bmp->db_mapsize, ipbmap, &bmp->db_DBmap); | ||
246 | 215 | ||
247 | /* | 216 | /* |
248 | * allocate/initialize the bmap lock | 217 | * allocate/initialize the bmap lock |
@@ -407,16 +376,12 @@ int dbFree(struct inode *ip, s64 blkno, s64 nblocks) | |||
407 | */ | 376 | */ |
408 | nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1))); | 377 | nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1))); |
409 | 378 | ||
410 | DBALLOCCK(bmp->db_DBmap, bmp->db_mapsize, blkno, nb); | ||
411 | |||
412 | /* free the blocks. */ | 379 | /* free the blocks. */ |
413 | if ((rc = dbFreeDmap(bmp, dp, blkno, nb))) { | 380 | if ((rc = dbFreeDmap(bmp, dp, blkno, nb))) { |
414 | release_metapage(mp); | 381 | release_metapage(mp); |
415 | IREAD_UNLOCK(ipbmap); | 382 | IREAD_UNLOCK(ipbmap); |
416 | return (rc); | 383 | return (rc); |
417 | } | 384 | } |
418 | |||
419 | DBFREE(bmp->db_DBmap, bmp->db_mapsize, blkno, nb); | ||
420 | } | 385 | } |
421 | 386 | ||
422 | /* write the last buffer. */ | 387 | /* write the last buffer. */ |
@@ -775,10 +740,6 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) | |||
775 | IWRITE_LOCK(ipbmap); | 740 | IWRITE_LOCK(ipbmap); |
776 | 741 | ||
777 | rc = dbAllocAny(bmp, nblocks, l2nb, results); | 742 | rc = dbAllocAny(bmp, nblocks, l2nb, results); |
778 | if (rc == 0) { | ||
779 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results, | ||
780 | nblocks); | ||
781 | } | ||
782 | 743 | ||
783 | goto write_unlock; | 744 | goto write_unlock; |
784 | } | 745 | } |
@@ -836,8 +797,6 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) | |||
836 | != -ENOSPC) { | 797 | != -ENOSPC) { |
837 | if (rc == 0) { | 798 | if (rc == 0) { |
838 | *results = blkno; | 799 | *results = blkno; |
839 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, | ||
840 | *results, nblocks); | ||
841 | mark_metapage_dirty(mp); | 800 | mark_metapage_dirty(mp); |
842 | } | 801 | } |
843 | 802 | ||
@@ -863,11 +822,8 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) | |||
863 | if ((rc = | 822 | if ((rc = |
864 | dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results)) | 823 | dbAllocNear(bmp, dp, blkno, (int) nblocks, l2nb, results)) |
865 | != -ENOSPC) { | 824 | != -ENOSPC) { |
866 | if (rc == 0) { | 825 | if (rc == 0) |
867 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, | ||
868 | *results, nblocks); | ||
869 | mark_metapage_dirty(mp); | 826 | mark_metapage_dirty(mp); |
870 | } | ||
871 | 827 | ||
872 | release_metapage(mp); | 828 | release_metapage(mp); |
873 | goto read_unlock; | 829 | goto read_unlock; |
@@ -878,11 +834,8 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) | |||
878 | */ | 834 | */ |
879 | if ((rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results)) | 835 | if ((rc = dbAllocDmapLev(bmp, dp, (int) nblocks, l2nb, results)) |
880 | != -ENOSPC) { | 836 | != -ENOSPC) { |
881 | if (rc == 0) { | 837 | if (rc == 0) |
882 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, | ||
883 | *results, nblocks); | ||
884 | mark_metapage_dirty(mp); | 838 | mark_metapage_dirty(mp); |
885 | } | ||
886 | 839 | ||
887 | release_metapage(mp); | 840 | release_metapage(mp); |
888 | goto read_unlock; | 841 | goto read_unlock; |
@@ -896,13 +849,9 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) | |||
896 | * the same allocation group as the hint. | 849 | * the same allocation group as the hint. |
897 | */ | 850 | */ |
898 | IWRITE_LOCK(ipbmap); | 851 | IWRITE_LOCK(ipbmap); |
899 | if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) | 852 | if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) != -ENOSPC) |
900 | != -ENOSPC) { | ||
901 | if (rc == 0) | ||
902 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, | ||
903 | *results, nblocks); | ||
904 | goto write_unlock; | 853 | goto write_unlock; |
905 | } | 854 | |
906 | IWRITE_UNLOCK(ipbmap); | 855 | IWRITE_UNLOCK(ipbmap); |
907 | 856 | ||
908 | 857 | ||
@@ -918,9 +867,6 @@ int dbAlloc(struct inode *ip, s64 hint, s64 nblocks, s64 * results) | |||
918 | */ | 867 | */ |
919 | if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) == -ENOSPC) | 868 | if ((rc = dbAllocAG(bmp, agno, nblocks, l2nb, results)) == -ENOSPC) |
920 | rc = dbAllocAny(bmp, nblocks, l2nb, results); | 869 | rc = dbAllocAny(bmp, nblocks, l2nb, results); |
921 | if (rc == 0) { | ||
922 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, *results, nblocks); | ||
923 | } | ||
924 | 870 | ||
925 | write_unlock: | 871 | write_unlock: |
926 | IWRITE_UNLOCK(ipbmap); | 872 | IWRITE_UNLOCK(ipbmap); |
@@ -992,10 +938,9 @@ int dbAllocExact(struct inode *ip, s64 blkno, int nblocks) | |||
992 | 938 | ||
993 | IREAD_UNLOCK(ipbmap); | 939 | IREAD_UNLOCK(ipbmap); |
994 | 940 | ||
995 | if (rc == 0) { | 941 | if (rc == 0) |
996 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, blkno, nblocks); | ||
997 | mark_metapage_dirty(mp); | 942 | mark_metapage_dirty(mp); |
998 | } | 943 | |
999 | release_metapage(mp); | 944 | release_metapage(mp); |
1000 | 945 | ||
1001 | return (rc); | 946 | return (rc); |
@@ -1144,7 +1089,6 @@ static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks) | |||
1144 | return -EIO; | 1089 | return -EIO; |
1145 | } | 1090 | } |
1146 | 1091 | ||
1147 | DBALLOCCK(bmp->db_DBmap, bmp->db_mapsize, blkno, nblocks); | ||
1148 | dp = (struct dmap *) mp->data; | 1092 | dp = (struct dmap *) mp->data; |
1149 | 1093 | ||
1150 | /* try to allocate the blocks immediately following the | 1094 | /* try to allocate the blocks immediately following the |
@@ -1155,11 +1099,9 @@ static int dbExtend(struct inode *ip, s64 blkno, s64 nblocks, s64 addnblocks) | |||
1155 | IREAD_UNLOCK(ipbmap); | 1099 | IREAD_UNLOCK(ipbmap); |
1156 | 1100 | ||
1157 | /* were we successful ? */ | 1101 | /* were we successful ? */ |
1158 | if (rc == 0) { | 1102 | if (rc == 0) |
1159 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, extblkno, | ||
1160 | addnblocks); | ||
1161 | write_metapage(mp); | 1103 | write_metapage(mp); |
1162 | } else | 1104 | else |
1163 | /* we were not successful */ | 1105 | /* we were not successful */ |
1164 | release_metapage(mp); | 1106 | release_metapage(mp); |
1165 | 1107 | ||
@@ -3185,16 +3127,12 @@ int dbAllocBottomUp(struct inode *ip, s64 blkno, s64 nblocks) | |||
3185 | */ | 3127 | */ |
3186 | nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1))); | 3128 | nb = min(rem, BPERDMAP - (blkno & (BPERDMAP - 1))); |
3187 | 3129 | ||
3188 | DBFREECK(bmp->db_DBmap, bmp->db_mapsize, blkno, nb); | ||
3189 | |||
3190 | /* allocate the blocks. */ | 3130 | /* allocate the blocks. */ |
3191 | if ((rc = dbAllocDmapBU(bmp, dp, blkno, nb))) { | 3131 | if ((rc = dbAllocDmapBU(bmp, dp, blkno, nb))) { |
3192 | release_metapage(mp); | 3132 | release_metapage(mp); |
3193 | IREAD_UNLOCK(ipbmap); | 3133 | IREAD_UNLOCK(ipbmap); |
3194 | return (rc); | 3134 | return (rc); |
3195 | } | 3135 | } |
3196 | |||
3197 | DBALLOC(bmp->db_DBmap, bmp->db_mapsize, blkno, nb); | ||
3198 | } | 3136 | } |
3199 | 3137 | ||
3200 | /* write the last buffer. */ | 3138 | /* write the last buffer. */ |
@@ -4041,223 +3979,3 @@ s64 dbMapFileSizeToMapSize(struct inode * ipbmap) | |||
4041 | 3979 | ||
4042 | return (nblocks); | 3980 | return (nblocks); |
4043 | } | 3981 | } |
4044 | |||
4045 | |||
4046 | #ifdef _JFS_DEBUG_DMAP | ||
4047 | /* | ||
4048 | * DBinitmap() | ||
4049 | */ | ||
4050 | static void DBinitmap(s64 size, struct inode *ipbmap, u32 ** results) | ||
4051 | { | ||
4052 | int npages; | ||
4053 | u32 *dbmap, *d; | ||
4054 | int n; | ||
4055 | s64 lblkno, cur_block; | ||
4056 | struct dmap *dp; | ||
4057 | struct metapage *mp; | ||
4058 | |||
4059 | npages = size / 32768; | ||
4060 | npages += (size % 32768) ? 1 : 0; | ||
4061 | |||
4062 | dbmap = (u32 *) xmalloc(npages * 4096, L2PSIZE, kernel_heap); | ||
4063 | if (dbmap == NULL) | ||
4064 | BUG(); /* Not robust since this is only unused debug code */ | ||
4065 | |||
4066 | for (n = 0, d = dbmap; n < npages; n++, d += 1024) | ||
4067 | bzero(d, 4096); | ||
4068 | |||
4069 | /* Need to initialize from disk map pages | ||
4070 | */ | ||
4071 | for (d = dbmap, cur_block = 0; cur_block < size; | ||
4072 | cur_block += BPERDMAP, d += LPERDMAP) { | ||
4073 | lblkno = BLKTODMAP(cur_block, | ||
4074 | JFS_SBI(ipbmap->i_sb)->bmap-> | ||
4075 | db_l2nbperpage); | ||
4076 | mp = read_metapage(ipbmap, lblkno, PSIZE, 0); | ||
4077 | if (mp == NULL) { | ||
4078 | jfs_error(ipbmap->i_sb, | ||
4079 | "DBinitmap: could not read disk map page"); | ||
4080 | continue; | ||
4081 | } | ||
4082 | dp = (struct dmap *) mp->data; | ||
4083 | |||
4084 | for (n = 0; n < LPERDMAP; n++) | ||
4085 | d[n] = le32_to_cpu(dp->wmap[n]); | ||
4086 | |||
4087 | release_metapage(mp); | ||
4088 | } | ||
4089 | |||
4090 | *results = dbmap; | ||
4091 | } | ||
4092 | |||
4093 | |||
4094 | /* | ||
4095 | * DBAlloc() | ||
4096 | */ | ||
4097 | void DBAlloc(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks) | ||
4098 | { | ||
4099 | int word, nb, bitno; | ||
4100 | u32 mask; | ||
4101 | |||
4102 | assert(blkno > 0 && blkno < mapsize); | ||
4103 | assert(nblocks > 0 && nblocks <= mapsize); | ||
4104 | |||
4105 | assert(blkno + nblocks <= mapsize); | ||
4106 | |||
4107 | dbmap += (blkno / 32); | ||
4108 | while (nblocks > 0) { | ||
4109 | bitno = blkno & (32 - 1); | ||
4110 | nb = min(nblocks, 32 - bitno); | ||
4111 | |||
4112 | mask = (0xffffffff << (32 - nb) >> bitno); | ||
4113 | assert((mask & *dbmap) == 0); | ||
4114 | *dbmap |= mask; | ||
4115 | |||
4116 | dbmap++; | ||
4117 | blkno += nb; | ||
4118 | nblocks -= nb; | ||
4119 | } | ||
4120 | } | ||
4121 | |||
4122 | |||
4123 | /* | ||
4124 | * DBFree() | ||
4125 | */ | ||
4126 | static void DBFree(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks) | ||
4127 | { | ||
4128 | int word, nb, bitno; | ||
4129 | u32 mask; | ||
4130 | |||
4131 | assert(blkno > 0 && blkno < mapsize); | ||
4132 | assert(nblocks > 0 && nblocks <= mapsize); | ||
4133 | |||
4134 | assert(blkno + nblocks <= mapsize); | ||
4135 | |||
4136 | dbmap += (blkno / 32); | ||
4137 | while (nblocks > 0) { | ||
4138 | bitno = blkno & (32 - 1); | ||
4139 | nb = min(nblocks, 32 - bitno); | ||
4140 | |||
4141 | mask = (0xffffffff << (32 - nb) >> bitno); | ||
4142 | assert((mask & *dbmap) == mask); | ||
4143 | *dbmap &= ~mask; | ||
4144 | |||
4145 | dbmap++; | ||
4146 | blkno += nb; | ||
4147 | nblocks -= nb; | ||
4148 | } | ||
4149 | } | ||
4150 | |||
4151 | |||
4152 | /* | ||
4153 | * DBAllocCK() | ||
4154 | */ | ||
4155 | static void DBAllocCK(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks) | ||
4156 | { | ||
4157 | int word, nb, bitno; | ||
4158 | u32 mask; | ||
4159 | |||
4160 | assert(blkno > 0 && blkno < mapsize); | ||
4161 | assert(nblocks > 0 && nblocks <= mapsize); | ||
4162 | |||
4163 | assert(blkno + nblocks <= mapsize); | ||
4164 | |||
4165 | dbmap += (blkno / 32); | ||
4166 | while (nblocks > 0) { | ||
4167 | bitno = blkno & (32 - 1); | ||
4168 | nb = min(nblocks, 32 - bitno); | ||
4169 | |||
4170 | mask = (0xffffffff << (32 - nb) >> bitno); | ||
4171 | assert((mask & *dbmap) == mask); | ||
4172 | |||
4173 | dbmap++; | ||
4174 | blkno += nb; | ||
4175 | nblocks -= nb; | ||
4176 | } | ||
4177 | } | ||
4178 | |||
4179 | |||
4180 | /* | ||
4181 | * DBFreeCK() | ||
4182 | */ | ||
4183 | static void DBFreeCK(uint * dbmap, s64 mapsize, s64 blkno, s64 nblocks) | ||
4184 | { | ||
4185 | int word, nb, bitno; | ||
4186 | u32 mask; | ||
4187 | |||
4188 | assert(blkno > 0 && blkno < mapsize); | ||
4189 | assert(nblocks > 0 && nblocks <= mapsize); | ||
4190 | |||
4191 | assert(blkno + nblocks <= mapsize); | ||
4192 | |||
4193 | dbmap += (blkno / 32); | ||
4194 | while (nblocks > 0) { | ||
4195 | bitno = blkno & (32 - 1); | ||
4196 | nb = min(nblocks, 32 - bitno); | ||
4197 | |||
4198 | mask = (0xffffffff << (32 - nb) >> bitno); | ||
4199 | assert((mask & *dbmap) == 0); | ||
4200 | |||
4201 | dbmap++; | ||
4202 | blkno += nb; | ||
4203 | nblocks -= nb; | ||
4204 | } | ||
4205 | } | ||
4206 | |||
4207 | |||
4208 | /* | ||
4209 | * dbPrtMap() | ||
4210 | */ | ||
4211 | static void dbPrtMap(struct bmap * bmp) | ||
4212 | { | ||
4213 | printk(" mapsize: %d%d\n", bmp->db_mapsize); | ||
4214 | printk(" nfree: %d%d\n", bmp->db_nfree); | ||
4215 | printk(" numag: %d\n", bmp->db_numag); | ||
4216 | printk(" agsize: %d%d\n", bmp->db_agsize); | ||
4217 | printk(" agl2size: %d\n", bmp->db_agl2size); | ||
4218 | printk(" agwidth: %d\n", bmp->db_agwidth); | ||
4219 | printk(" agstart: %d\n", bmp->db_agstart); | ||
4220 | printk(" agheigth: %d\n", bmp->db_agheigth); | ||
4221 | printk(" aglevel: %d\n", bmp->db_aglevel); | ||
4222 | printk(" maxlevel: %d\n", bmp->db_maxlevel); | ||
4223 | printk(" maxag: %d\n", bmp->db_maxag); | ||
4224 | printk(" agpref: %d\n", bmp->db_agpref); | ||
4225 | printk(" l2nbppg: %d\n", bmp->db_l2nbperpage); | ||
4226 | } | ||
4227 | |||
4228 | |||
4229 | /* | ||
4230 | * dbPrtCtl() | ||
4231 | */ | ||
4232 | static void dbPrtCtl(struct dmapctl * dcp) | ||
4233 | { | ||
4234 | int i, j, n; | ||
4235 | |||
4236 | printk(" height: %08x\n", le32_to_cpu(dcp->height)); | ||
4237 | printk(" leafidx: %08x\n", le32_to_cpu(dcp->leafidx)); | ||
4238 | printk(" budmin: %08x\n", dcp->budmin); | ||
4239 | printk(" nleafs: %08x\n", le32_to_cpu(dcp->nleafs)); | ||
4240 | printk(" l2nleafs: %08x\n", le32_to_cpu(dcp->l2nleafs)); | ||
4241 | |||
4242 | printk("\n Tree:\n"); | ||
4243 | for (i = 0; i < CTLLEAFIND; i += 8) { | ||
4244 | n = min(8, CTLLEAFIND - i); | ||
4245 | |||
4246 | for (j = 0; j < n; j++) | ||
4247 | printf(" [%03x]: %02x", i + j, | ||
4248 | (char) dcp->stree[i + j]); | ||
4249 | printf("\n"); | ||
4250 | } | ||
4251 | |||
4252 | printk("\n Tree Leaves:\n"); | ||
4253 | for (i = 0; i < LPERCTL; i += 8) { | ||
4254 | n = min(8, LPERCTL - i); | ||
4255 | |||
4256 | for (j = 0; j < n; j++) | ||
4257 | printf(" [%03x]: %02x", | ||
4258 | i + j, | ||
4259 | (char) dcp->stree[i + j + CTLLEAFIND]); | ||
4260 | printf("\n"); | ||
4261 | } | ||
4262 | } | ||
4263 | #endif /* _JFS_DEBUG_DMAP */ | ||
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c index 8676aee3ae48..73b5fc7eda80 100644 --- a/fs/jfs/jfs_dtree.c +++ b/fs/jfs/jfs_dtree.c | |||
@@ -4554,202 +4554,3 @@ int dtModify(tid_t tid, struct inode *ip, | |||
4554 | 4554 | ||
4555 | return 0; | 4555 | return 0; |
4556 | } | 4556 | } |
4557 | |||
4558 | #ifdef _JFS_DEBUG_DTREE | ||
4559 | /* | ||
4560 | * dtDisplayTree() | ||
4561 | * | ||
4562 | * function: traverse forward | ||
4563 | */ | ||
4564 | int dtDisplayTree(struct inode *ip) | ||
4565 | { | ||
4566 | int rc; | ||
4567 | struct metapage *mp; | ||
4568 | dtpage_t *p; | ||
4569 | s64 bn, pbn; | ||
4570 | int index, lastindex, v, h; | ||
4571 | pxd_t *xd; | ||
4572 | struct btstack btstack; | ||
4573 | struct btframe *btsp; | ||
4574 | struct btframe *parent; | ||
4575 | u8 *stbl; | ||
4576 | int psize = 256; | ||
4577 | |||
4578 | printk("display B+-tree.\n"); | ||
4579 | |||
4580 | /* clear stack */ | ||
4581 | btsp = btstack.stack; | ||
4582 | |||
4583 | /* | ||
4584 | * start with root | ||
4585 | * | ||
4586 | * root resides in the inode | ||
4587 | */ | ||
4588 | bn = 0; | ||
4589 | v = h = 0; | ||
4590 | |||
4591 | /* | ||
4592 | * first access of each page: | ||
4593 | */ | ||
4594 | newPage: | ||
4595 | DT_GETPAGE(ip, bn, mp, psize, p, rc); | ||
4596 | if (rc) | ||
4597 | return rc; | ||
4598 | |||
4599 | /* process entries forward from first index */ | ||
4600 | index = 0; | ||
4601 | lastindex = p->header.nextindex - 1; | ||
4602 | |||
4603 | if (p->header.flag & BT_INTERNAL) { | ||
4604 | /* | ||
4605 | * first access of each internal page | ||
4606 | */ | ||
4607 | printf("internal page "); | ||
4608 | dtDisplayPage(ip, bn, p); | ||
4609 | |||
4610 | goto getChild; | ||
4611 | } else { /* (p->header.flag & BT_LEAF) */ | ||
4612 | |||
4613 | /* | ||
4614 | * first access of each leaf page | ||
4615 | */ | ||
4616 | printf("leaf page "); | ||
4617 | dtDisplayPage(ip, bn, p); | ||
4618 | |||
4619 | /* | ||
4620 | * process leaf page entries | ||
4621 | * | ||
4622 | for ( ; index <= lastindex; index++) | ||
4623 | { | ||
4624 | } | ||
4625 | */ | ||
4626 | |||
4627 | /* unpin the leaf page */ | ||
4628 | DT_PUTPAGE(mp); | ||
4629 | } | ||
4630 | |||
4631 | /* | ||
4632 | * go back up to the parent page | ||
4633 | */ | ||
4634 | getParent: | ||
4635 | /* pop/restore parent entry for the current child page */ | ||
4636 | if ((parent = (btsp == btstack.stack ? NULL : --btsp)) == NULL) | ||
4637 | /* current page must have been root */ | ||
4638 | return; | ||
4639 | |||
4640 | /* | ||
4641 | * parent page scan completed | ||
4642 | */ | ||
4643 | if ((index = parent->index) == (lastindex = parent->lastindex)) { | ||
4644 | /* go back up to the parent page */ | ||
4645 | goto getParent; | ||
4646 | } | ||
4647 | |||
4648 | /* | ||
4649 | * parent page has entries remaining | ||
4650 | */ | ||
4651 | /* get back the parent page */ | ||
4652 | bn = parent->bn; | ||
4653 | /* v = parent->level; */ | ||
4654 | DT_GETPAGE(ip, bn, mp, PSIZE, p, rc); | ||
4655 | if (rc) | ||
4656 | return rc; | ||
4657 | |||
4658 | /* get next parent entry */ | ||
4659 | index++; | ||
4660 | |||
4661 | /* | ||
4662 | * internal page: go down to child page of current entry | ||
4663 | */ | ||
4664 | getChild: | ||
4665 | /* push/save current parent entry for the child page */ | ||
4666 | btsp->bn = pbn = bn; | ||
4667 | btsp->index = index; | ||
4668 | btsp->lastindex = lastindex; | ||
4669 | /* btsp->level = v; */ | ||
4670 | /* btsp->node = h; */ | ||
4671 | ++btsp; | ||
4672 | |||
4673 | /* get current entry for the child page */ | ||
4674 | stbl = DT_GETSTBL(p); | ||
4675 | xd = (pxd_t *) & p->slot[stbl[index]]; | ||
4676 | |||
4677 | /* | ||
4678 | * first access of each internal entry: | ||
4679 | */ | ||
4680 | |||
4681 | /* get child page */ | ||
4682 | bn = addressPXD(xd); | ||
4683 | psize = lengthPXD(xd) << ip->i_ipmnt->i_l2bsize; | ||
4684 | |||
4685 | printk("traverse down 0x%Lx[%d]->0x%Lx\n", pbn, index, bn); | ||
4686 | v++; | ||
4687 | h = index; | ||
4688 | |||
4689 | /* release parent page */ | ||
4690 | DT_PUTPAGE(mp); | ||
4691 | |||
4692 | /* process the child page */ | ||
4693 | goto newPage; | ||
4694 | } | ||
4695 | |||
4696 | |||
4697 | /* | ||
4698 | * dtDisplayPage() | ||
4699 | * | ||
4700 | * function: display page | ||
4701 | */ | ||
4702 | int dtDisplayPage(struct inode *ip, s64 bn, dtpage_t * p) | ||
4703 | { | ||
4704 | int rc; | ||
4705 | struct metapage *mp; | ||
4706 | struct ldtentry *lh; | ||
4707 | struct idtentry *ih; | ||
4708 | pxd_t *xd; | ||
4709 | int i, j; | ||
4710 | u8 *stbl; | ||
4711 | wchar_t name[JFS_NAME_MAX + 1]; | ||
4712 | struct component_name key = { 0, name }; | ||
4713 | int freepage = 0; | ||
4714 | |||
4715 | if (p == NULL) { | ||
4716 | freepage = 1; | ||
4717 | DT_GETPAGE(ip, bn, mp, PSIZE, p, rc); | ||
4718 | if (rc) | ||
4719 | return rc; | ||
4720 | } | ||
4721 | |||
4722 | /* display page control */ | ||
4723 | printk("bn:0x%Lx flag:0x%08x nextindex:%d\n", | ||
4724 | bn, p->header.flag, p->header.nextindex); | ||
4725 | |||
4726 | /* display entries */ | ||
4727 | stbl = DT_GETSTBL(p); | ||
4728 | for (i = 0, j = 1; i < p->header.nextindex; i++, j++) { | ||
4729 | dtGetKey(p, i, &key, JFS_SBI(ip->i_sb)->mntflag); | ||
4730 | key.name[key.namlen] = '\0'; | ||
4731 | if (p->header.flag & BT_LEAF) { | ||
4732 | lh = (struct ldtentry *) & p->slot[stbl[i]]; | ||
4733 | printf("\t[%d] %s:%d", i, key.name, | ||
4734 | le32_to_cpu(lh->inumber)); | ||
4735 | } else { | ||
4736 | ih = (struct idtentry *) & p->slot[stbl[i]]; | ||
4737 | xd = (pxd_t *) ih; | ||
4738 | bn = addressPXD(xd); | ||
4739 | printf("\t[%d] %s:0x%Lx", i, key.name, bn); | ||
4740 | } | ||
4741 | |||
4742 | if (j == 4) { | ||
4743 | printf("\n"); | ||
4744 | j = 0; | ||
4745 | } | ||
4746 | } | ||
4747 | |||
4748 | printf("\n"); | ||
4749 | |||
4750 | if (freepage) | ||
4751 | DT_PUTPAGE(mp); | ||
4752 | |||
4753 | return 0; | ||
4754 | } | ||
4755 | #endif /* _JFS_DEBUG_DTREE */ | ||
diff --git a/fs/jfs/jfs_dtree.h b/fs/jfs/jfs_dtree.h index 273a80130c9d..13e4fdf07724 100644 --- a/fs/jfs/jfs_dtree.h +++ b/fs/jfs/jfs_dtree.h | |||
@@ -269,11 +269,4 @@ extern int dtModify(tid_t tid, struct inode *ip, struct component_name * key, | |||
269 | ino_t * orig_ino, ino_t new_ino, int flag); | 269 | ino_t * orig_ino, ino_t new_ino, int flag); |
270 | 270 | ||
271 | extern int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir); | 271 | extern int jfs_readdir(struct file *filp, void *dirent, filldir_t filldir); |
272 | |||
273 | #ifdef _JFS_DEBUG_DTREE | ||
274 | extern int dtDisplayTree(struct inode *ip); | ||
275 | |||
276 | extern int dtDisplayPage(struct inode *ip, s64 bn, dtpage_t * p); | ||
277 | #endif /* _JFS_DEBUG_DTREE */ | ||
278 | |||
279 | #endif /* !_H_JFS_DTREE */ | 272 | #endif /* !_H_JFS_DTREE */ |
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c index 971af2977eff..4021d46da7e3 100644 --- a/fs/jfs/jfs_imap.c +++ b/fs/jfs/jfs_imap.c | |||
@@ -87,25 +87,6 @@ static int copy_from_dinode(struct dinode *, struct inode *); | |||
87 | static void copy_to_dinode(struct dinode *, struct inode *); | 87 | static void copy_to_dinode(struct dinode *, struct inode *); |
88 | 88 | ||
89 | /* | 89 | /* |
90 | * debug code for double-checking inode map | ||
91 | */ | ||
92 | /* #define _JFS_DEBUG_IMAP 1 */ | ||
93 | |||
94 | #ifdef _JFS_DEBUG_IMAP | ||
95 | #define DBG_DIINIT(imap) DBGdiInit(imap) | ||
96 | #define DBG_DIALLOC(imap, ino) DBGdiAlloc(imap, ino) | ||
97 | #define DBG_DIFREE(imap, ino) DBGdiFree(imap, ino) | ||
98 | |||
99 | static void *DBGdiInit(struct inomap * imap); | ||
100 | static void DBGdiAlloc(struct inomap * imap, ino_t ino); | ||
101 | static void DBGdiFree(struct inomap * imap, ino_t ino); | ||
102 | #else | ||
103 | #define DBG_DIINIT(imap) | ||
104 | #define DBG_DIALLOC(imap, ino) | ||
105 | #define DBG_DIFREE(imap, ino) | ||
106 | #endif /* _JFS_DEBUG_IMAP */ | ||
107 | |||
108 | /* | ||
109 | * NAME: diMount() | 90 | * NAME: diMount() |
110 | * | 91 | * |
111 | * FUNCTION: initialize the incore inode map control structures for | 92 | * FUNCTION: initialize the incore inode map control structures for |
@@ -188,8 +169,6 @@ int diMount(struct inode *ipimap) | |||
188 | imap->im_ipimap = ipimap; | 169 | imap->im_ipimap = ipimap; |
189 | JFS_IP(ipimap)->i_imap = imap; | 170 | JFS_IP(ipimap)->i_imap = imap; |
190 | 171 | ||
191 | // DBG_DIINIT(imap); | ||
192 | |||
193 | return (0); | 172 | return (0); |
194 | } | 173 | } |
195 | 174 | ||
@@ -1043,7 +1022,6 @@ int diFree(struct inode *ip) | |||
1043 | /* update the bitmap. | 1022 | /* update the bitmap. |
1044 | */ | 1023 | */ |
1045 | iagp->wmap[extno] = cpu_to_le32(bitmap); | 1024 | iagp->wmap[extno] = cpu_to_le32(bitmap); |
1046 | DBG_DIFREE(imap, inum); | ||
1047 | 1025 | ||
1048 | /* update the free inode counts at the iag, ag and | 1026 | /* update the free inode counts at the iag, ag and |
1049 | * map level. | 1027 | * map level. |
@@ -1231,7 +1209,6 @@ int diFree(struct inode *ip) | |||
1231 | jfs_error(ip->i_sb, "diFree: the pmap does not show inode free"); | 1209 | jfs_error(ip->i_sb, "diFree: the pmap does not show inode free"); |
1232 | } | 1210 | } |
1233 | iagp->wmap[extno] = 0; | 1211 | iagp->wmap[extno] = 0; |
1234 | DBG_DIFREE(imap, inum); | ||
1235 | PXDlength(&iagp->inoext[extno], 0); | 1212 | PXDlength(&iagp->inoext[extno], 0); |
1236 | PXDaddress(&iagp->inoext[extno], 0); | 1213 | PXDaddress(&iagp->inoext[extno], 0); |
1237 | 1214 | ||
@@ -1350,7 +1327,6 @@ diInitInode(struct inode *ip, int iagno, int ino, int extno, struct iag * iagp) | |||
1350 | struct jfs_inode_info *jfs_ip = JFS_IP(ip); | 1327 | struct jfs_inode_info *jfs_ip = JFS_IP(ip); |
1351 | 1328 | ||
1352 | ip->i_ino = (iagno << L2INOSPERIAG) + ino; | 1329 | ip->i_ino = (iagno << L2INOSPERIAG) + ino; |
1353 | DBG_DIALLOC(JFS_IP(ipimap)->i_imap, ip->i_ino); | ||
1354 | jfs_ip->ixpxd = iagp->inoext[extno]; | 1330 | jfs_ip->ixpxd = iagp->inoext[extno]; |
1355 | jfs_ip->agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi); | 1331 | jfs_ip->agno = BLKTOAG(le64_to_cpu(iagp->agstart), sbi); |
1356 | jfs_ip->active_ag = -1; | 1332 | jfs_ip->active_ag = -1; |
@@ -3185,84 +3161,3 @@ static void copy_to_dinode(struct dinode * dip, struct inode *ip) | |||
3185 | if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) | 3161 | if (S_ISCHR(ip->i_mode) || S_ISBLK(ip->i_mode)) |
3186 | dip->di_rdev = cpu_to_le32(jfs_ip->dev); | 3162 | dip->di_rdev = cpu_to_le32(jfs_ip->dev); |
3187 | } | 3163 | } |
3188 | |||
3189 | #ifdef _JFS_DEBUG_IMAP | ||
3190 | /* | ||
3191 | * DBGdiInit() | ||
3192 | */ | ||
3193 | static void *DBGdiInit(struct inomap * imap) | ||
3194 | { | ||
3195 | u32 *dimap; | ||
3196 | int size; | ||
3197 | size = 64 * 1024; | ||
3198 | if ((dimap = (u32 *) xmalloc(size, L2PSIZE, kernel_heap)) == NULL) | ||
3199 | assert(0); | ||
3200 | bzero((void *) dimap, size); | ||
3201 | imap->im_DBGdimap = dimap; | ||
3202 | } | ||
3203 | |||
3204 | /* | ||
3205 | * DBGdiAlloc() | ||
3206 | */ | ||
3207 | static void DBGdiAlloc(struct inomap * imap, ino_t ino) | ||
3208 | { | ||
3209 | u32 *dimap = imap->im_DBGdimap; | ||
3210 | int w, b; | ||
3211 | u32 m; | ||
3212 | w = ino >> 5; | ||
3213 | b = ino & 31; | ||
3214 | m = 0x80000000 >> b; | ||
3215 | assert(w < 64 * 256); | ||
3216 | if (dimap[w] & m) { | ||
3217 | printk("DEBUG diAlloc: duplicate alloc ino:0x%x\n", ino); | ||
3218 | } | ||
3219 | dimap[w] |= m; | ||
3220 | } | ||
3221 | |||
3222 | /* | ||
3223 | * DBGdiFree() | ||
3224 | */ | ||
3225 | static void DBGdiFree(struct inomap * imap, ino_t ino) | ||
3226 | { | ||
3227 | u32 *dimap = imap->im_DBGdimap; | ||
3228 | int w, b; | ||
3229 | u32 m; | ||
3230 | w = ino >> 5; | ||
3231 | b = ino & 31; | ||
3232 | m = 0x80000000 >> b; | ||
3233 | assert(w < 64 * 256); | ||
3234 | if ((dimap[w] & m) == 0) { | ||
3235 | printk("DEBUG diFree: duplicate free ino:0x%x\n", ino); | ||
3236 | } | ||
3237 | dimap[w] &= ~m; | ||
3238 | } | ||
3239 | |||
3240 | static void dump_cp(struct inomap * ipimap, char *function, int line) | ||
3241 | { | ||
3242 | printk("\n* ********* *\nControl Page %s %d\n", function, line); | ||
3243 | printk("FreeIAG %d\tNextIAG %d\n", ipimap->im_freeiag, | ||
3244 | ipimap->im_nextiag); | ||
3245 | printk("NumInos %d\tNumFree %d\n", | ||
3246 | atomic_read(&ipimap->im_numinos), | ||
3247 | atomic_read(&ipimap->im_numfree)); | ||
3248 | printk("AG InoFree %d\tAG ExtFree %d\n", | ||
3249 | ipimap->im_agctl[0].inofree, ipimap->im_agctl[0].extfree); | ||
3250 | printk("AG NumInos %d\tAG NumFree %d\n", | ||
3251 | ipimap->im_agctl[0].numinos, ipimap->im_agctl[0].numfree); | ||
3252 | } | ||
3253 | |||
3254 | static void dump_iag(struct iag * iag, char *function, int line) | ||
3255 | { | ||
3256 | printk("\n* ********* *\nIAG %s %d\n", function, line); | ||
3257 | printk("IagNum %d\tIAG Free %d\n", le32_to_cpu(iag->iagnum), | ||
3258 | le32_to_cpu(iag->iagfree)); | ||
3259 | printk("InoFreeFwd %d\tInoFreeBack %d\n", | ||
3260 | le32_to_cpu(iag->inofreefwd), | ||
3261 | le32_to_cpu(iag->inofreeback)); | ||
3262 | printk("ExtFreeFwd %d\tExtFreeBack %d\n", | ||
3263 | le32_to_cpu(iag->extfreefwd), | ||
3264 | le32_to_cpu(iag->extfreeback)); | ||
3265 | printk("NFreeInos %d\tNFreeExts %d\n", le32_to_cpu(iag->nfreeinos), | ||
3266 | le32_to_cpu(iag->nfreeexts)); | ||
3267 | } | ||
3268 | #endif /* _JFS_DEBUG_IMAP */ | ||
diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c index 31b34db4519e..a7fe2f2b969f 100644 --- a/fs/jfs/jfs_xtree.c +++ b/fs/jfs/jfs_xtree.c | |||
@@ -135,14 +135,6 @@ static int xtSearchNode(struct inode *ip, | |||
135 | static int xtRelink(tid_t tid, struct inode *ip, xtpage_t * fp); | 135 | 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 | /* External references */ | ||
139 | |||
140 | /* | ||
141 | * debug control | ||
142 | */ | ||
143 | /* #define _JFS_DEBUG_XTREE 1 */ | ||
144 | |||
145 | |||
146 | /* | 138 | /* |
147 | * xtLookup() | 139 | * xtLookup() |
148 | * | 140 | * |
@@ -4140,338 +4132,6 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) | |||
4140 | return 0; | 4132 | return 0; |
4141 | } | 4133 | } |
4142 | 4134 | ||
4143 | |||
4144 | #ifdef _JFS_DEBUG_XTREE | ||
4145 | /* | ||
4146 | * xtDisplayTree() | ||
4147 | * | ||
4148 | * function: traverse forward | ||
4149 | */ | ||
4150 | int xtDisplayTree(struct inode *ip) | ||
4151 | { | ||
4152 | int rc = 0; | ||
4153 | struct metapage *mp; | ||
4154 | xtpage_t *p; | ||
4155 | s64 bn, pbn; | ||
4156 | int index, lastindex, v, h; | ||
4157 | xad_t *xad; | ||
4158 | struct btstack btstack; | ||
4159 | struct btframe *btsp; | ||
4160 | struct btframe *parent; | ||
4161 | |||
4162 | printk("display B+-tree.\n"); | ||
4163 | |||
4164 | /* clear stack */ | ||
4165 | btsp = btstack.stack; | ||
4166 | |||
4167 | /* | ||
4168 | * start with root | ||
4169 | * | ||
4170 | * root resides in the inode | ||
4171 | */ | ||
4172 | bn = 0; | ||
4173 | v = h = 0; | ||
4174 | |||
4175 | /* | ||
4176 | * first access of each page: | ||
4177 | */ | ||
4178 | getPage: | ||
4179 | XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); | ||
4180 | if (rc) | ||
4181 | return rc; | ||
4182 | |||
4183 | /* process entries forward from first index */ | ||
4184 | index = XTENTRYSTART; | ||
4185 | lastindex = le16_to_cpu(p->header.nextindex) - 1; | ||
4186 | |||
4187 | if (p->header.flag & BT_INTERNAL) { | ||
4188 | /* | ||
4189 | * first access of each internal page | ||
4190 | */ | ||
4191 | goto getChild; | ||
4192 | } else { /* (p->header.flag & BT_LEAF) */ | ||
4193 | |||
4194 | /* | ||
4195 | * first access of each leaf page | ||
4196 | */ | ||
4197 | printf("leaf page "); | ||
4198 | xtDisplayPage(ip, bn, p); | ||
4199 | |||
4200 | /* unpin the leaf page */ | ||
4201 | XT_PUTPAGE(mp); | ||
4202 | } | ||
4203 | |||
4204 | /* | ||
4205 | * go back up to the parent page | ||
4206 | */ | ||
4207 | getParent: | ||
4208 | /* pop/restore parent entry for the current child page */ | ||
4209 | if ((parent = (btsp == btstack.stack ? NULL : --btsp)) == NULL) | ||
4210 | /* current page must have been root */ | ||
4211 | return; | ||
4212 | |||
4213 | /* | ||
4214 | * parent page scan completed | ||
4215 | */ | ||
4216 | if ((index = parent->index) == (lastindex = parent->lastindex)) { | ||
4217 | /* go back up to the parent page */ | ||
4218 | goto getParent; | ||
4219 | } | ||
4220 | |||
4221 | /* | ||
4222 | * parent page has entries remaining | ||
4223 | */ | ||
4224 | /* get back the parent page */ | ||
4225 | bn = parent->bn; | ||
4226 | /* v = parent->level; */ | ||
4227 | XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); | ||
4228 | if (rc) | ||
4229 | return rc; | ||
4230 | |||
4231 | /* get next parent entry */ | ||
4232 | index++; | ||
4233 | |||
4234 | /* | ||
4235 | * internal page: go down to child page of current entry | ||
4236 | */ | ||
4237 | getChild: | ||
4238 | /* push/save current parent entry for the child page */ | ||
4239 | btsp->bn = pbn = bn; | ||
4240 | btsp->index = index; | ||
4241 | btsp->lastindex = lastindex; | ||
4242 | /* btsp->level = v; */ | ||
4243 | /* btsp->node = h; */ | ||
4244 | ++btsp; | ||
4245 | |||
4246 | /* get child page */ | ||
4247 | xad = &p->xad[index]; | ||
4248 | bn = addressXAD(xad); | ||
4249 | |||
4250 | /* | ||
4251 | * first access of each internal entry: | ||
4252 | */ | ||
4253 | /* release parent page */ | ||
4254 | XT_PUTPAGE(mp); | ||
4255 | |||
4256 | printk("traverse down 0x%lx[%d]->0x%lx\n", (ulong) pbn, index, | ||
4257 | (ulong) bn); | ||
4258 | v++; | ||
4259 | h = index; | ||
4260 | |||
4261 | /* process the child page */ | ||
4262 | goto getPage; | ||
4263 | } | ||
4264 | |||
4265 | |||
4266 | /* | ||
4267 | * xtDisplayPage() | ||
4268 | * | ||
4269 | * function: display page | ||
4270 | */ | ||
4271 | int xtDisplayPage(struct inode *ip, s64 bn, xtpage_t * p) | ||
4272 | { | ||
4273 | int rc = 0; | ||
4274 | xad_t *xad; | ||
4275 | s64 xaddr, xoff; | ||
4276 | int xlen, i, j; | ||
4277 | |||
4278 | /* display page control */ | ||
4279 | printf("bn:0x%lx flag:0x%x nextindex:%d\n", | ||
4280 | (ulong) bn, p->header.flag, | ||
4281 | le16_to_cpu(p->header.nextindex)); | ||
4282 | |||
4283 | /* display entries */ | ||
4284 | xad = &p->xad[XTENTRYSTART]; | ||
4285 | for (i = XTENTRYSTART, j = 1; i < le16_to_cpu(p->header.nextindex); | ||
4286 | i++, xad++, j++) { | ||
4287 | xoff = offsetXAD(xad); | ||
4288 | xaddr = addressXAD(xad); | ||
4289 | xlen = lengthXAD(xad); | ||
4290 | printf("\t[%d] 0x%lx:0x%lx(0x%x)", i, (ulong) xoff, | ||
4291 | (ulong) xaddr, xlen); | ||
4292 | |||
4293 | if (j == 4) { | ||
4294 | printf("\n"); | ||
4295 | j = 0; | ||
4296 | } | ||
4297 | } | ||
4298 | |||
4299 | printf("\n"); | ||
4300 | } | ||
4301 | #endif /* _JFS_DEBUG_XTREE */ | ||
4302 | |||
4303 | |||
4304 | #ifdef _JFS_WIP | ||
4305 | /* | ||
4306 | * xtGather() | ||
4307 | * | ||
4308 | * function: | ||
4309 | * traverse for allocation acquiring tlock at commit time | ||
4310 | * (vs at the time of update) logging backward top down | ||
4311 | * | ||
4312 | * note: | ||
4313 | * problem - establishing that all new allocation have been | ||
4314 | * processed both for append and random write in sparse file | ||
4315 | * at the current entry at the current subtree root page | ||
4316 | * | ||
4317 | */ | ||
4318 | int xtGather(btree_t *t) | ||
4319 | { | ||
4320 | int rc = 0; | ||
4321 | xtpage_t *p; | ||
4322 | u64 bn; | ||
4323 | int index; | ||
4324 | btentry_t *e; | ||
4325 | struct btstack btstack; | ||
4326 | struct btsf *parent; | ||
4327 | |||
4328 | /* clear stack */ | ||
4329 | BT_CLR(&btstack); | ||
4330 | |||
4331 | /* | ||
4332 | * start with root | ||
4333 | * | ||
4334 | * root resides in the inode | ||
4335 | */ | ||
4336 | bn = 0; | ||
4337 | XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); | ||
4338 | if (rc) | ||
4339 | return rc; | ||
4340 | |||
4341 | /* new root is NOT pointed by a new entry | ||
4342 | if (p->header.flag & NEW) | ||
4343 | allocate new page lock; | ||
4344 | write a NEWPAGE log; | ||
4345 | */ | ||
4346 | |||
4347 | dopage: | ||
4348 | /* | ||
4349 | * first access of each page: | ||
4350 | */ | ||
4351 | /* process entries backward from last index */ | ||
4352 | index = le16_to_cpu(p->header.nextindex) - 1; | ||
4353 | |||
4354 | if (p->header.flag & BT_LEAF) { | ||
4355 | /* | ||
4356 | * first access of each leaf page | ||
4357 | */ | ||
4358 | /* process leaf page entries backward */ | ||
4359 | for (; index >= XTENTRYSTART; index--) { | ||
4360 | e = &p->xad[index]; | ||
4361 | /* | ||
4362 | * if newpage, log NEWPAGE. | ||
4363 | * | ||
4364 | if (e->flag & XAD_NEW) { | ||
4365 | nfound =+ entry->length; | ||
4366 | update current page lock for the entry; | ||
4367 | newpage(entry); | ||
4368 | * | ||
4369 | * if moved, log move. | ||
4370 | * | ||
4371 | } else if (e->flag & XAD_MOVED) { | ||
4372 | reset flag; | ||
4373 | update current page lock for the entry; | ||
4374 | } | ||
4375 | */ | ||
4376 | } | ||
4377 | |||
4378 | /* unpin the leaf page */ | ||
4379 | XT_PUTPAGE(mp); | ||
4380 | |||
4381 | /* | ||
4382 | * go back up to the parent page | ||
4383 | */ | ||
4384 | getParent: | ||
4385 | /* restore parent entry for the current child page */ | ||
4386 | if ((parent = BT_POP(&btstack)) == NULL) | ||
4387 | /* current page must have been root */ | ||
4388 | return 0; | ||
4389 | |||
4390 | if ((index = parent->index) == XTENTRYSTART) { | ||
4391 | /* | ||
4392 | * parent page scan completed | ||
4393 | */ | ||
4394 | /* go back up to the parent page */ | ||
4395 | goto getParent; | ||
4396 | } else { | ||
4397 | /* | ||
4398 | * parent page has entries remaining | ||
4399 | */ | ||
4400 | /* get back the parent page */ | ||
4401 | bn = parent->bn; | ||
4402 | XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); | ||
4403 | if (rc) | ||
4404 | return -EIO; | ||
4405 | |||
4406 | /* first subroot page which | ||
4407 | * covers all new allocated blocks | ||
4408 | * itself not new/modified. | ||
4409 | * (if modified from split of descendent, | ||
4410 | * go down path of split page) | ||
4411 | |||
4412 | if (nfound == nnew && | ||
4413 | !(p->header.flag & (NEW | MOD))) | ||
4414 | exit scan; | ||
4415 | */ | ||
4416 | |||
4417 | /* process parent page entries backward */ | ||
4418 | index--; | ||
4419 | } | ||
4420 | } else { | ||
4421 | /* | ||
4422 | * first access of each internal page | ||
4423 | */ | ||
4424 | } | ||
4425 | |||
4426 | /* | ||
4427 | * internal page: go down to child page of current entry | ||
4428 | */ | ||
4429 | |||
4430 | /* save current parent entry for the child page */ | ||
4431 | BT_PUSH(&btstack, bn, index); | ||
4432 | |||
4433 | /* get current entry for the child page */ | ||
4434 | e = &p->xad[index]; | ||
4435 | |||
4436 | /* | ||
4437 | * first access of each internal entry: | ||
4438 | */ | ||
4439 | /* | ||
4440 | * if new entry, log btree_tnewentry. | ||
4441 | * | ||
4442 | if (e->flag & XAD_NEW) | ||
4443 | update parent page lock for the entry; | ||
4444 | */ | ||
4445 | |||
4446 | /* release parent page */ | ||
4447 | XT_PUTPAGE(mp); | ||
4448 | |||
4449 | /* get child page */ | ||
4450 | bn = e->bn; | ||
4451 | XT_GETPAGE(ip, bn, mp, PSIZE, p, rc); | ||
4452 | if (rc) | ||
4453 | return rc; | ||
4454 | |||
4455 | /* | ||
4456 | * first access of each non-root page: | ||
4457 | */ | ||
4458 | /* | ||
4459 | * if new, log btree_newpage. | ||
4460 | * | ||
4461 | if (p->header.flag & NEW) | ||
4462 | allocate new page lock; | ||
4463 | write a NEWPAGE log (next, prev); | ||
4464 | */ | ||
4465 | |||
4466 | /* process the child page */ | ||
4467 | goto dopage; | ||
4468 | |||
4469 | out: | ||
4470 | return 0; | ||
4471 | } | ||
4472 | #endif /* _JFS_WIP */ | ||
4473 | |||
4474 | |||
4475 | #ifdef CONFIG_JFS_STATISTICS | 4135 | #ifdef CONFIG_JFS_STATISTICS |
4476 | int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length, | 4136 | int jfs_xtstat_read(char *buffer, char **start, off_t offset, int length, |
4477 | int *eof, void *data) | 4137 | int *eof, void *data) |
diff --git a/fs/jfs/jfs_xtree.h b/fs/jfs/jfs_xtree.h index a69784254fe7..af668a80b40f 100644 --- a/fs/jfs/jfs_xtree.h +++ b/fs/jfs/jfs_xtree.h | |||
@@ -131,10 +131,4 @@ extern int xtRelocate(tid_t tid, struct inode *ip, | |||
131 | extern int xtAppend(tid_t tid, | 131 | extern int xtAppend(tid_t tid, |
132 | struct inode *ip, int xflag, s64 xoff, int maxblocks, | 132 | struct inode *ip, int xflag, s64 xoff, int maxblocks, |
133 | int *xlenp, s64 * xaddrp, int flag); | 133 | int *xlenp, s64 * xaddrp, int flag); |
134 | |||
135 | #ifdef _JFS_DEBUG_XTREE | ||
136 | extern int xtDisplayTree(struct inode *ip); | ||
137 | extern int xtDisplayPage(struct inode *ip, s64 bn, xtpage_t * p); | ||
138 | #endif /* _JFS_DEBUG_XTREE */ | ||
139 | |||
140 | #endif /* !_H_JFS_XTREE */ | 134 | #endif /* !_H_JFS_XTREE */ |