diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2008-01-28 23:58:27 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-01-28 23:58:27 -0500 |
commit | 725d26d3f09ccb5bac4b4293096b985a312a0d67 (patch) | |
tree | 1c49a07da252832fc6842c88a2359e8cd43af636 /fs/ext4/namei.c | |
parent | a72d7f834e1afa08421938d7eb06bd8e56b0e58c (diff) |
ext4: Introduce ext4_lblk_t
This patch adds a new data type ext4_lblk_t to represent
the logical file blocks.
This is the preparatory patch to support large files in ext4
The follow up patch with convert the ext4_inode i_blocks to
represent the number of blocks in file system block size. This
changes makes it possible to have a block number 2**32 -1 which
will result in overflow if the block number is represented by
signed long. This patch convert all the block number to type
ext4_lblk_t which is typedef to __u32
Also remove dead code ext4_ext_walk_space
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r-- | fs/ext4/namei.c | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index d9a3a2fc5b0d..fb673b14ccd5 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -51,7 +51,7 @@ | |||
51 | 51 | ||
52 | static struct buffer_head *ext4_append(handle_t *handle, | 52 | static struct buffer_head *ext4_append(handle_t *handle, |
53 | struct inode *inode, | 53 | struct inode *inode, |
54 | u32 *block, int *err) | 54 | ext4_lblk_t *block, int *err) |
55 | { | 55 | { |
56 | struct buffer_head *bh; | 56 | struct buffer_head *bh; |
57 | 57 | ||
@@ -144,8 +144,8 @@ struct dx_map_entry | |||
144 | u16 size; | 144 | u16 size; |
145 | }; | 145 | }; |
146 | 146 | ||
147 | static inline unsigned dx_get_block (struct dx_entry *entry); | 147 | static inline ext4_lblk_t dx_get_block(struct dx_entry *entry); |
148 | static void dx_set_block (struct dx_entry *entry, unsigned value); | 148 | static void dx_set_block(struct dx_entry *entry, ext4_lblk_t value); |
149 | static inline unsigned dx_get_hash (struct dx_entry *entry); | 149 | static inline unsigned dx_get_hash (struct dx_entry *entry); |
150 | static void dx_set_hash (struct dx_entry *entry, unsigned value); | 150 | static void dx_set_hash (struct dx_entry *entry, unsigned value); |
151 | static unsigned dx_get_count (struct dx_entry *entries); | 151 | static unsigned dx_get_count (struct dx_entry *entries); |
@@ -166,7 +166,8 @@ static void dx_sort_map(struct dx_map_entry *map, unsigned count); | |||
166 | static struct ext4_dir_entry_2 *dx_move_dirents (char *from, char *to, | 166 | static struct ext4_dir_entry_2 *dx_move_dirents (char *from, char *to, |
167 | struct dx_map_entry *offsets, int count); | 167 | struct dx_map_entry *offsets, int count); |
168 | static struct ext4_dir_entry_2* dx_pack_dirents (char *base, int size); | 168 | static struct ext4_dir_entry_2* dx_pack_dirents (char *base, int size); |
169 | static void dx_insert_block (struct dx_frame *frame, u32 hash, u32 block); | 169 | static void dx_insert_block(struct dx_frame *frame, |
170 | u32 hash, ext4_lblk_t block); | ||
170 | static int ext4_htree_next_block(struct inode *dir, __u32 hash, | 171 | static int ext4_htree_next_block(struct inode *dir, __u32 hash, |
171 | struct dx_frame *frame, | 172 | struct dx_frame *frame, |
172 | struct dx_frame *frames, | 173 | struct dx_frame *frames, |
@@ -181,12 +182,12 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | |||
181 | * Mask them off for now. | 182 | * Mask them off for now. |
182 | */ | 183 | */ |
183 | 184 | ||
184 | static inline unsigned dx_get_block (struct dx_entry *entry) | 185 | static inline ext4_lblk_t dx_get_block(struct dx_entry *entry) |
185 | { | 186 | { |
186 | return le32_to_cpu(entry->block) & 0x00ffffff; | 187 | return le32_to_cpu(entry->block) & 0x00ffffff; |
187 | } | 188 | } |
188 | 189 | ||
189 | static inline void dx_set_block (struct dx_entry *entry, unsigned value) | 190 | static inline void dx_set_block(struct dx_entry *entry, ext4_lblk_t value) |
190 | { | 191 | { |
191 | entry->block = cpu_to_le32(value); | 192 | entry->block = cpu_to_le32(value); |
192 | } | 193 | } |
@@ -243,8 +244,8 @@ static void dx_show_index (char * label, struct dx_entry *entries) | |||
243 | int i, n = dx_get_count (entries); | 244 | int i, n = dx_get_count (entries); |
244 | printk("%s index ", label); | 245 | printk("%s index ", label); |
245 | for (i = 0; i < n; i++) { | 246 | for (i = 0; i < n; i++) { |
246 | printk("%x->%u ", i? dx_get_hash(entries + i) : | 247 | printk("%x->%lu ", i? dx_get_hash(entries + i) : |
247 | 0, dx_get_block(entries + i)); | 248 | 0, (unsigned long)dx_get_block(entries + i)); |
248 | } | 249 | } |
249 | printk("\n"); | 250 | printk("\n"); |
250 | } | 251 | } |
@@ -297,7 +298,8 @@ struct stats dx_show_entries(struct dx_hash_info *hinfo, struct inode *dir, | |||
297 | printk("%i indexed blocks...\n", count); | 298 | printk("%i indexed blocks...\n", count); |
298 | for (i = 0; i < count; i++, entries++) | 299 | for (i = 0; i < count; i++, entries++) |
299 | { | 300 | { |
300 | u32 block = dx_get_block(entries), hash = i? dx_get_hash(entries): 0; | 301 | ext4_lblk_t block = dx_get_block(entries); |
302 | ext4_lblk_t hash = i ? dx_get_hash(entries): 0; | ||
301 | u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash; | 303 | u32 range = i < count - 1? (dx_get_hash(entries + 1) - hash): ~hash; |
302 | struct stats stats; | 304 | struct stats stats; |
303 | printk("%s%3u:%03u hash %8x/%8x ",levels?"":" ", i, block, hash, range); | 305 | printk("%s%3u:%03u hash %8x/%8x ",levels?"":" ", i, block, hash, range); |
@@ -561,7 +563,7 @@ static inline struct ext4_dir_entry_2 *ext4_next_entry(struct ext4_dir_entry_2 * | |||
561 | * into the tree. If there is an error it is returned in err. | 563 | * into the tree. If there is an error it is returned in err. |
562 | */ | 564 | */ |
563 | static int htree_dirblock_to_tree(struct file *dir_file, | 565 | static int htree_dirblock_to_tree(struct file *dir_file, |
564 | struct inode *dir, int block, | 566 | struct inode *dir, ext4_lblk_t block, |
565 | struct dx_hash_info *hinfo, | 567 | struct dx_hash_info *hinfo, |
566 | __u32 start_hash, __u32 start_minor_hash) | 568 | __u32 start_hash, __u32 start_minor_hash) |
567 | { | 569 | { |
@@ -569,7 +571,8 @@ static int htree_dirblock_to_tree(struct file *dir_file, | |||
569 | struct ext4_dir_entry_2 *de, *top; | 571 | struct ext4_dir_entry_2 *de, *top; |
570 | int err, count = 0; | 572 | int err, count = 0; |
571 | 573 | ||
572 | dxtrace(printk("In htree dirblock_to_tree: block %d\n", block)); | 574 | dxtrace(printk(KERN_INFO "In htree dirblock_to_tree: block %lu\n", |
575 | (unsigned long)block)); | ||
573 | if (!(bh = ext4_bread (NULL, dir, block, 0, &err))) | 576 | if (!(bh = ext4_bread (NULL, dir, block, 0, &err))) |
574 | return err; | 577 | return err; |
575 | 578 | ||
@@ -621,9 +624,9 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash, | |||
621 | struct ext4_dir_entry_2 *de; | 624 | struct ext4_dir_entry_2 *de; |
622 | struct dx_frame frames[2], *frame; | 625 | struct dx_frame frames[2], *frame; |
623 | struct inode *dir; | 626 | struct inode *dir; |
624 | int block, err; | 627 | ext4_lblk_t block; |
625 | int count = 0; | 628 | int count = 0; |
626 | int ret; | 629 | int ret, err; |
627 | __u32 hashval; | 630 | __u32 hashval; |
628 | 631 | ||
629 | dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash, | 632 | dxtrace(printk("In htree_fill_tree, start hash: %x:%x\n", start_hash, |
@@ -753,7 +756,7 @@ static void dx_sort_map (struct dx_map_entry *map, unsigned count) | |||
753 | } while(more); | 756 | } while(more); |
754 | } | 757 | } |
755 | 758 | ||
756 | static void dx_insert_block(struct dx_frame *frame, u32 hash, u32 block) | 759 | static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block) |
757 | { | 760 | { |
758 | struct dx_entry *entries = frame->entries; | 761 | struct dx_entry *entries = frame->entries; |
759 | struct dx_entry *old = frame->at, *new = old + 1; | 762 | struct dx_entry *old = frame->at, *new = old + 1; |
@@ -848,13 +851,14 @@ static struct buffer_head * ext4_find_entry (struct dentry *dentry, | |||
848 | struct super_block * sb; | 851 | struct super_block * sb; |
849 | struct buffer_head * bh_use[NAMEI_RA_SIZE]; | 852 | struct buffer_head * bh_use[NAMEI_RA_SIZE]; |
850 | struct buffer_head * bh, *ret = NULL; | 853 | struct buffer_head * bh, *ret = NULL; |
851 | unsigned long start, block, b; | 854 | ext4_lblk_t start, block, b; |
852 | int ra_max = 0; /* Number of bh's in the readahead | 855 | int ra_max = 0; /* Number of bh's in the readahead |
853 | buffer, bh_use[] */ | 856 | buffer, bh_use[] */ |
854 | int ra_ptr = 0; /* Current index into readahead | 857 | int ra_ptr = 0; /* Current index into readahead |
855 | buffer */ | 858 | buffer */ |
856 | int num = 0; | 859 | int num = 0; |
857 | int nblocks, i, err; | 860 | ext4_lblk_t nblocks; |
861 | int i, err; | ||
858 | struct inode *dir = dentry->d_parent->d_inode; | 862 | struct inode *dir = dentry->d_parent->d_inode; |
859 | int namelen; | 863 | int namelen; |
860 | const u8 *name; | 864 | const u8 *name; |
@@ -915,7 +919,8 @@ restart: | |||
915 | if (!buffer_uptodate(bh)) { | 919 | if (!buffer_uptodate(bh)) { |
916 | /* read error, skip block & hope for the best */ | 920 | /* read error, skip block & hope for the best */ |
917 | ext4_error(sb, __FUNCTION__, "reading directory #%lu " | 921 | ext4_error(sb, __FUNCTION__, "reading directory #%lu " |
918 | "offset %lu", dir->i_ino, block); | 922 | "offset %lu", dir->i_ino, |
923 | (unsigned long)block); | ||
919 | brelse(bh); | 924 | brelse(bh); |
920 | goto next; | 925 | goto next; |
921 | } | 926 | } |
@@ -962,7 +967,7 @@ static struct buffer_head * ext4_dx_find_entry(struct dentry *dentry, | |||
962 | struct dx_frame frames[2], *frame; | 967 | struct dx_frame frames[2], *frame; |
963 | struct ext4_dir_entry_2 *de, *top; | 968 | struct ext4_dir_entry_2 *de, *top; |
964 | struct buffer_head *bh; | 969 | struct buffer_head *bh; |
965 | unsigned long block; | 970 | ext4_lblk_t block; |
966 | int retval; | 971 | int retval; |
967 | int namelen = dentry->d_name.len; | 972 | int namelen = dentry->d_name.len; |
968 | const u8 *name = dentry->d_name.name; | 973 | const u8 *name = dentry->d_name.name; |
@@ -1174,7 +1179,7 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, | |||
1174 | unsigned blocksize = dir->i_sb->s_blocksize; | 1179 | unsigned blocksize = dir->i_sb->s_blocksize; |
1175 | unsigned count, continued; | 1180 | unsigned count, continued; |
1176 | struct buffer_head *bh2; | 1181 | struct buffer_head *bh2; |
1177 | u32 newblock; | 1182 | ext4_lblk_t newblock; |
1178 | u32 hash2; | 1183 | u32 hash2; |
1179 | struct dx_map_entry *map; | 1184 | struct dx_map_entry *map; |
1180 | char *data1 = (*bh)->b_data, *data2; | 1185 | char *data1 = (*bh)->b_data, *data2; |
@@ -1221,8 +1226,9 @@ static struct ext4_dir_entry_2 *do_split(handle_t *handle, struct inode *dir, | |||
1221 | split = count - move; | 1226 | split = count - move; |
1222 | hash2 = map[split].hash; | 1227 | hash2 = map[split].hash; |
1223 | continued = hash2 == map[split - 1].hash; | 1228 | continued = hash2 == map[split - 1].hash; |
1224 | dxtrace(printk("Split block %i at %x, %i/%i\n", | 1229 | dxtrace(printk(KERN_INFO "Split block %lu at %x, %i/%i\n", |
1225 | dx_get_block(frame->at), hash2, split, count-split)); | 1230 | (unsigned long)dx_get_block(frame->at), |
1231 | hash2, split, count-split)); | ||
1226 | 1232 | ||
1227 | /* Fancy dance to stay within two buffers */ | 1233 | /* Fancy dance to stay within two buffers */ |
1228 | de2 = dx_move_dirents(data1, data2, map + split, count - split); | 1234 | de2 = dx_move_dirents(data1, data2, map + split, count - split); |
@@ -1374,7 +1380,7 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, | |||
1374 | int retval; | 1380 | int retval; |
1375 | unsigned blocksize; | 1381 | unsigned blocksize; |
1376 | struct dx_hash_info hinfo; | 1382 | struct dx_hash_info hinfo; |
1377 | u32 block; | 1383 | ext4_lblk_t block; |
1378 | struct fake_dirent *fde; | 1384 | struct fake_dirent *fde; |
1379 | 1385 | ||
1380 | blocksize = dir->i_sb->s_blocksize; | 1386 | blocksize = dir->i_sb->s_blocksize; |
@@ -1455,7 +1461,7 @@ static int ext4_add_entry (handle_t *handle, struct dentry *dentry, | |||
1455 | int retval; | 1461 | int retval; |
1456 | int dx_fallback=0; | 1462 | int dx_fallback=0; |
1457 | unsigned blocksize; | 1463 | unsigned blocksize; |
1458 | u32 block, blocks; | 1464 | ext4_lblk_t block, blocks; |
1459 | 1465 | ||
1460 | sb = dir->i_sb; | 1466 | sb = dir->i_sb; |
1461 | blocksize = sb->s_blocksize; | 1467 | blocksize = sb->s_blocksize; |
@@ -1532,7 +1538,7 @@ static int ext4_dx_add_entry(handle_t *handle, struct dentry *dentry, | |||
1532 | dx_get_count(entries), dx_get_limit(entries))); | 1538 | dx_get_count(entries), dx_get_limit(entries))); |
1533 | /* Need to split index? */ | 1539 | /* Need to split index? */ |
1534 | if (dx_get_count(entries) == dx_get_limit(entries)) { | 1540 | if (dx_get_count(entries) == dx_get_limit(entries)) { |
1535 | u32 newblock; | 1541 | ext4_lblk_t newblock; |
1536 | unsigned icount = dx_get_count(entries); | 1542 | unsigned icount = dx_get_count(entries); |
1537 | int levels = frame - frames; | 1543 | int levels = frame - frames; |
1538 | struct dx_entry *entries2; | 1544 | struct dx_entry *entries2; |