diff options
author | Mark Fasheh <mark.fasheh@oracle.com> | 2007-03-22 19:53:23 -0400 |
---|---|---|
committer | Mark Fasheh <mark.fasheh@oracle.com> | 2007-04-26 18:07:40 -0400 |
commit | 8110b073a9135acf0a71bccfc20c0d1023f179c6 (patch) | |
tree | b668738e25648f3fcfd7b1063ab8d4948cebc668 /fs/ocfs2/dir.c | |
parent | 4f902c37727bbedbc0508a1477874c58ddcc9af8 (diff) |
ocfs2: Fix up i_blocks calculation to know about holes
Older file systems which didn't support holes did a dumb calculation of
i_blocks based on i_size. This is no longer accurate, so fix things up to
take actual allocation into account.
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
Diffstat (limited to 'fs/ocfs2/dir.c')
-rw-r--r-- | fs/ocfs2/dir.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 8d22e1e4a88d..67e6866a2a4f 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -358,7 +358,7 @@ int ocfs2_do_extend_dir(struct super_block *sb, | |||
358 | { | 358 | { |
359 | int status; | 359 | int status; |
360 | int extend; | 360 | int extend; |
361 | u64 p_blkno; | 361 | u64 p_blkno, v_blkno; |
362 | 362 | ||
363 | spin_lock(&OCFS2_I(dir)->ip_lock); | 363 | spin_lock(&OCFS2_I(dir)->ip_lock); |
364 | extend = (i_size_read(dir) == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)); | 364 | extend = (i_size_read(dir) == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)); |
@@ -377,9 +377,8 @@ int ocfs2_do_extend_dir(struct super_block *sb, | |||
377 | } | 377 | } |
378 | } | 378 | } |
379 | 379 | ||
380 | status = ocfs2_extent_map_get_blocks(dir, (dir->i_blocks >> | 380 | v_blkno = ocfs2_blocks_for_bytes(sb, i_size_read(dir)); |
381 | (sb->s_blocksize_bits - 9)), | 381 | status = ocfs2_extent_map_get_blocks(dir, v_blkno, &p_blkno, NULL, NULL); |
382 | &p_blkno, NULL, NULL); | ||
383 | if (status < 0) { | 382 | if (status < 0) { |
384 | mlog_errno(status); | 383 | mlog_errno(status); |
385 | goto bail; | 384 | goto bail; |
@@ -488,7 +487,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
488 | 487 | ||
489 | dir_i_size += dir->i_sb->s_blocksize; | 488 | dir_i_size += dir->i_sb->s_blocksize; |
490 | i_size_write(dir, dir_i_size); | 489 | i_size_write(dir, dir_i_size); |
491 | dir->i_blocks = ocfs2_align_bytes_to_sectors(dir_i_size); | 490 | dir->i_blocks = ocfs2_inode_sector_count(dir); |
492 | status = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh); | 491 | status = ocfs2_mark_inode_dirty(handle, dir, parent_fe_bh); |
493 | if (status < 0) { | 492 | if (status < 0) { |
494 | mlog_errno(status); | 493 | mlog_errno(status); |