diff options
Diffstat (limited to 'fs/minix/itree_common.c')
-rw-r--r-- | fs/minix/itree_common.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/minix/itree_common.c b/fs/minix/itree_common.c index 429baf8de105..a731cabf1540 100644 --- a/fs/minix/itree_common.c +++ b/fs/minix/itree_common.c | |||
@@ -23,7 +23,7 @@ static inline int verify_chain(Indirect *from, Indirect *to) | |||
23 | 23 | ||
24 | static inline block_t *block_end(struct buffer_head *bh) | 24 | static inline block_t *block_end(struct buffer_head *bh) |
25 | { | 25 | { |
26 | return (block_t *)((char*)bh->b_data + BLOCK_SIZE); | 26 | return (block_t *)((char*)bh->b_data + bh->b_size); |
27 | } | 27 | } |
28 | 28 | ||
29 | static inline Indirect *get_branch(struct inode *inode, | 29 | static inline Indirect *get_branch(struct inode *inode, |
@@ -85,7 +85,7 @@ static int alloc_branch(struct inode *inode, | |||
85 | branch[n].key = cpu_to_block(nr); | 85 | branch[n].key = cpu_to_block(nr); |
86 | bh = sb_getblk(inode->i_sb, parent); | 86 | bh = sb_getblk(inode->i_sb, parent); |
87 | lock_buffer(bh); | 87 | lock_buffer(bh); |
88 | memset(bh->b_data, 0, BLOCK_SIZE); | 88 | memset(bh->b_data, 0, bh->b_size); |
89 | branch[n].bh = bh; | 89 | branch[n].bh = bh; |
90 | branch[n].p = (block_t*) bh->b_data + offsets[n]; | 90 | branch[n].p = (block_t*) bh->b_data + offsets[n]; |
91 | *branch[n].p = branch[n].key; | 91 | *branch[n].p = branch[n].key; |
@@ -292,6 +292,7 @@ static void free_branches(struct inode *inode, block_t *p, block_t *q, int depth | |||
292 | 292 | ||
293 | static inline void truncate (struct inode * inode) | 293 | static inline void truncate (struct inode * inode) |
294 | { | 294 | { |
295 | struct super_block *sb = inode->i_sb; | ||
295 | block_t *idata = i_data(inode); | 296 | block_t *idata = i_data(inode); |
296 | int offsets[DEPTH]; | 297 | int offsets[DEPTH]; |
297 | Indirect chain[DEPTH]; | 298 | Indirect chain[DEPTH]; |
@@ -301,7 +302,7 @@ static inline void truncate (struct inode * inode) | |||
301 | int first_whole; | 302 | int first_whole; |
302 | long iblock; | 303 | long iblock; |
303 | 304 | ||
304 | iblock = (inode->i_size + BLOCK_SIZE-1) >> 10; | 305 | iblock = (inode->i_size + sb->s_blocksize -1) >> sb->s_blocksize_bits; |
305 | block_truncate_page(inode->i_mapping, inode->i_size, get_block); | 306 | block_truncate_page(inode->i_mapping, inode->i_size, get_block); |
306 | 307 | ||
307 | n = block_to_path(inode, iblock, offsets); | 308 | n = block_to_path(inode, iblock, offsets); |
@@ -346,15 +347,16 @@ do_indirects: | |||
346 | mark_inode_dirty(inode); | 347 | mark_inode_dirty(inode); |
347 | } | 348 | } |
348 | 349 | ||
349 | static inline unsigned nblocks(loff_t size) | 350 | static inline unsigned nblocks(loff_t size, struct super_block *sb) |
350 | { | 351 | { |
352 | int k = sb->s_blocksize_bits - 10; | ||
351 | unsigned blocks, res, direct = DIRECT, i = DEPTH; | 353 | unsigned blocks, res, direct = DIRECT, i = DEPTH; |
352 | blocks = (size + BLOCK_SIZE - 1) >> BLOCK_SIZE_BITS; | 354 | blocks = (size + sb->s_blocksize - 1) >> (BLOCK_SIZE_BITS + k); |
353 | res = blocks; | 355 | res = blocks; |
354 | while (--i && blocks > direct) { | 356 | while (--i && blocks > direct) { |
355 | blocks -= direct; | 357 | blocks -= direct; |
356 | blocks += BLOCK_SIZE/sizeof(block_t) - 1; | 358 | blocks += sb->s_blocksize/sizeof(block_t) - 1; |
357 | blocks /= BLOCK_SIZE/sizeof(block_t); | 359 | blocks /= sb->s_blocksize/sizeof(block_t); |
358 | res += blocks; | 360 | res += blocks; |
359 | direct = 1; | 361 | direct = 1; |
360 | } | 362 | } |