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/inode.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/inode.c')
-rw-r--r-- | fs/ext4/inode.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 5489703d9573..488f829a8879 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -105,7 +105,7 @@ int ext4_forget(handle_t *handle, int is_metadata, struct inode *inode, | |||
105 | */ | 105 | */ |
106 | static unsigned long blocks_for_truncate(struct inode *inode) | 106 | static unsigned long blocks_for_truncate(struct inode *inode) |
107 | { | 107 | { |
108 | unsigned long needed; | 108 | ext4_lblk_t needed; |
109 | 109 | ||
110 | needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9); | 110 | needed = inode->i_blocks >> (inode->i_sb->s_blocksize_bits - 9); |
111 | 111 | ||
@@ -282,7 +282,8 @@ static int verify_chain(Indirect *from, Indirect *to) | |||
282 | */ | 282 | */ |
283 | 283 | ||
284 | static int ext4_block_to_path(struct inode *inode, | 284 | static int ext4_block_to_path(struct inode *inode, |
285 | long i_block, int offsets[4], int *boundary) | 285 | ext4_lblk_t i_block, |
286 | ext4_lblk_t offsets[4], int *boundary) | ||
286 | { | 287 | { |
287 | int ptrs = EXT4_ADDR_PER_BLOCK(inode->i_sb); | 288 | int ptrs = EXT4_ADDR_PER_BLOCK(inode->i_sb); |
288 | int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb); | 289 | int ptrs_bits = EXT4_ADDR_PER_BLOCK_BITS(inode->i_sb); |
@@ -349,7 +350,8 @@ static int ext4_block_to_path(struct inode *inode, | |||
349 | * or when it reads all @depth-1 indirect blocks successfully and finds | 350 | * or when it reads all @depth-1 indirect blocks successfully and finds |
350 | * the whole chain, all way to the data (returns %NULL, *err == 0). | 351 | * the whole chain, all way to the data (returns %NULL, *err == 0). |
351 | */ | 352 | */ |
352 | static Indirect *ext4_get_branch(struct inode *inode, int depth, int *offsets, | 353 | static Indirect *ext4_get_branch(struct inode *inode, int depth, |
354 | ext4_lblk_t *offsets, | ||
353 | Indirect chain[4], int *err) | 355 | Indirect chain[4], int *err) |
354 | { | 356 | { |
355 | struct super_block *sb = inode->i_sb; | 357 | struct super_block *sb = inode->i_sb; |
@@ -445,7 +447,7 @@ static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind) | |||
445 | * stores it in *@goal and returns zero. | 447 | * stores it in *@goal and returns zero. |
446 | */ | 448 | */ |
447 | 449 | ||
448 | static ext4_fsblk_t ext4_find_goal(struct inode *inode, long block, | 450 | static ext4_fsblk_t ext4_find_goal(struct inode *inode, ext4_lblk_t block, |
449 | Indirect chain[4], Indirect *partial) | 451 | Indirect chain[4], Indirect *partial) |
450 | { | 452 | { |
451 | struct ext4_block_alloc_info *block_i; | 453 | struct ext4_block_alloc_info *block_i; |
@@ -590,7 +592,7 @@ failed_out: | |||
590 | */ | 592 | */ |
591 | static int ext4_alloc_branch(handle_t *handle, struct inode *inode, | 593 | static int ext4_alloc_branch(handle_t *handle, struct inode *inode, |
592 | int indirect_blks, int *blks, ext4_fsblk_t goal, | 594 | int indirect_blks, int *blks, ext4_fsblk_t goal, |
593 | int *offsets, Indirect *branch) | 595 | ext4_lblk_t *offsets, Indirect *branch) |
594 | { | 596 | { |
595 | int blocksize = inode->i_sb->s_blocksize; | 597 | int blocksize = inode->i_sb->s_blocksize; |
596 | int i, n = 0; | 598 | int i, n = 0; |
@@ -680,7 +682,7 @@ failed: | |||
680 | * chain to new block and return 0. | 682 | * chain to new block and return 0. |
681 | */ | 683 | */ |
682 | static int ext4_splice_branch(handle_t *handle, struct inode *inode, | 684 | static int ext4_splice_branch(handle_t *handle, struct inode *inode, |
683 | long block, Indirect *where, int num, int blks) | 685 | ext4_lblk_t block, Indirect *where, int num, int blks) |
684 | { | 686 | { |
685 | int i; | 687 | int i; |
686 | int err = 0; | 688 | int err = 0; |
@@ -784,12 +786,12 @@ err_out: | |||
784 | * return < 0, error case. | 786 | * return < 0, error case. |
785 | */ | 787 | */ |
786 | int ext4_get_blocks_handle(handle_t *handle, struct inode *inode, | 788 | int ext4_get_blocks_handle(handle_t *handle, struct inode *inode, |
787 | sector_t iblock, unsigned long maxblocks, | 789 | ext4_lblk_t iblock, unsigned long maxblocks, |
788 | struct buffer_head *bh_result, | 790 | struct buffer_head *bh_result, |
789 | int create, int extend_disksize) | 791 | int create, int extend_disksize) |
790 | { | 792 | { |
791 | int err = -EIO; | 793 | int err = -EIO; |
792 | int offsets[4]; | 794 | ext4_lblk_t offsets[4]; |
793 | Indirect chain[4]; | 795 | Indirect chain[4]; |
794 | Indirect *partial; | 796 | Indirect *partial; |
795 | ext4_fsblk_t goal; | 797 | ext4_fsblk_t goal; |
@@ -803,7 +805,8 @@ int ext4_get_blocks_handle(handle_t *handle, struct inode *inode, | |||
803 | 805 | ||
804 | J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)); | 806 | J_ASSERT(!(EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL)); |
805 | J_ASSERT(handle != NULL || create == 0); | 807 | J_ASSERT(handle != NULL || create == 0); |
806 | depth = ext4_block_to_path(inode,iblock,offsets,&blocks_to_boundary); | 808 | depth = ext4_block_to_path(inode, iblock, offsets, |
809 | &blocks_to_boundary); | ||
807 | 810 | ||
808 | if (depth == 0) | 811 | if (depth == 0) |
809 | goto out; | 812 | goto out; |
@@ -996,7 +999,7 @@ get_block: | |||
996 | * `handle' can be NULL if create is zero | 999 | * `handle' can be NULL if create is zero |
997 | */ | 1000 | */ |
998 | struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode, | 1001 | struct buffer_head *ext4_getblk(handle_t *handle, struct inode *inode, |
999 | long block, int create, int *errp) | 1002 | ext4_lblk_t block, int create, int *errp) |
1000 | { | 1003 | { |
1001 | struct buffer_head dummy; | 1004 | struct buffer_head dummy; |
1002 | int fatal = 0, err; | 1005 | int fatal = 0, err; |
@@ -1063,7 +1066,7 @@ err: | |||
1063 | } | 1066 | } |
1064 | 1067 | ||
1065 | struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode, | 1068 | struct buffer_head *ext4_bread(handle_t *handle, struct inode *inode, |
1066 | int block, int create, int *err) | 1069 | ext4_lblk_t block, int create, int *err) |
1067 | { | 1070 | { |
1068 | struct buffer_head * bh; | 1071 | struct buffer_head * bh; |
1069 | 1072 | ||
@@ -1828,7 +1831,8 @@ int ext4_block_truncate_page(handle_t *handle, struct page *page, | |||
1828 | { | 1831 | { |
1829 | ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT; | 1832 | ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT; |
1830 | unsigned offset = from & (PAGE_CACHE_SIZE-1); | 1833 | unsigned offset = from & (PAGE_CACHE_SIZE-1); |
1831 | unsigned blocksize, iblock, length, pos; | 1834 | unsigned blocksize, length, pos; |
1835 | ext4_lblk_t iblock; | ||
1832 | struct inode *inode = mapping->host; | 1836 | struct inode *inode = mapping->host; |
1833 | struct buffer_head *bh; | 1837 | struct buffer_head *bh; |
1834 | int err = 0; | 1838 | int err = 0; |
@@ -1964,7 +1968,7 @@ static inline int all_zeroes(__le32 *p, __le32 *q) | |||
1964 | * (no partially truncated stuff there). */ | 1968 | * (no partially truncated stuff there). */ |
1965 | 1969 | ||
1966 | static Indirect *ext4_find_shared(struct inode *inode, int depth, | 1970 | static Indirect *ext4_find_shared(struct inode *inode, int depth, |
1967 | int offsets[4], Indirect chain[4], __le32 *top) | 1971 | ext4_lblk_t offsets[4], Indirect chain[4], __le32 *top) |
1968 | { | 1972 | { |
1969 | Indirect *partial, *p; | 1973 | Indirect *partial, *p; |
1970 | int k, err; | 1974 | int k, err; |
@@ -2289,12 +2293,12 @@ void ext4_truncate(struct inode *inode) | |||
2289 | __le32 *i_data = ei->i_data; | 2293 | __le32 *i_data = ei->i_data; |
2290 | int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb); | 2294 | int addr_per_block = EXT4_ADDR_PER_BLOCK(inode->i_sb); |
2291 | struct address_space *mapping = inode->i_mapping; | 2295 | struct address_space *mapping = inode->i_mapping; |
2292 | int offsets[4]; | 2296 | ext4_lblk_t offsets[4]; |
2293 | Indirect chain[4]; | 2297 | Indirect chain[4]; |
2294 | Indirect *partial; | 2298 | Indirect *partial; |
2295 | __le32 nr = 0; | 2299 | __le32 nr = 0; |
2296 | int n; | 2300 | int n; |
2297 | long last_block; | 2301 | ext4_lblk_t last_block; |
2298 | unsigned blocksize = inode->i_sb->s_blocksize; | 2302 | unsigned blocksize = inode->i_sb->s_blocksize; |
2299 | struct page *page; | 2303 | struct page *page; |
2300 | 2304 | ||