summaryrefslogtreecommitdiffstats
path: root/fs/ntfs
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2004-11-18 15:01:06 +0000
committerAnton Altaparmakov <aia21@cantab.net>2005-05-05 10:32:43 +0100
commit206f9f35b2348b7b966ff18a5564b8a3ca325ed5 (patch)
tree2f221334cf8b1b9756a58e323b5fba2cdd4dc583 /fs/ntfs
parent367636772f094fd840d2d79e75257bcfaa28e70f (diff)
NTFS: In fs/ntfs/dir.c, use i_size_read() once and then the cached value
afterwards. Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
Diffstat (limited to 'fs/ntfs')
-rw-r--r--fs/ntfs/ChangeLog2
-rw-r--r--fs/ntfs/dir.c13
2 files changed, 9 insertions, 6 deletions
diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
index 97c4fe93204..7bbbb9152fe 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -41,6 +41,8 @@ ToDo/Notes:
- Use i_size_read() in fs/ntfs/compress.c at the start of the read and
use the cached value afterwards. Cache the initialized_size in the
same way and protect access to the two sizes using the size_lock.
+ - Use i_size_read() in fs/ntfs/dir.c once and then use the cached
+ value afterwards.
2.1.22 - Many bug and race fixes and error handling improvements.
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 93577561cdb..d261ac4596f 100644
--- a/fs/ntfs/dir.c
+++ b/fs/ntfs/dir.c
@@ -1101,7 +1101,7 @@ static inline int ntfs_filldir(ntfs_volume *vol, loff_t fpos,
static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
{
s64 ia_pos, ia_start, prev_ia_pos, bmp_pos;
- loff_t fpos;
+ loff_t fpos, i_size;
struct inode *bmp_vi, *vdir = filp->f_dentry->d_inode;
struct super_block *sb = vdir->i_sb;
ntfs_inode *ndir = NTFS_I(vdir);
@@ -1122,7 +1122,8 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
vdir->i_ino, fpos);
rc = err = 0;
/* Are we at end of dir yet? */
- if (fpos >= vdir->i_size + vol->mft_record_size)
+ i_size = i_size_read(vdir);
+ if (fpos >= i_size + vol->mft_record_size)
goto done;
/* Emulate . and .. for all directories. */
if (!fpos) {
@@ -1264,7 +1265,7 @@ skip_index_root:
bmp_mapping = bmp_vi->i_mapping;
/* Get the starting bitmap bit position and sanity check it. */
bmp_pos = ia_pos >> ndir->itype.index.block_size_bits;
- if (unlikely(bmp_pos >> 3 >= bmp_vi->i_size)) {
+ if (unlikely(bmp_pos >> 3 >= i_size_read(bmp_vi))) {
ntfs_error(sb, "Current index allocation position exceeds "
"index bitmap size.");
goto err_out;
@@ -1301,7 +1302,7 @@ find_next_index_buffer:
goto get_next_bmp_page;
}
/* If we have reached the end of the bitmap, we are done. */
- if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= vdir->i_size))
+ if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= i_size))
goto unm_EOD;
ia_pos = (bmp_pos + cur_bmp_pos) <<
ndir->itype.index.block_size_bits;
@@ -1441,7 +1442,7 @@ unm_EOD:
ntfs_unmap_page(bmp_page);
EOD:
/* We are finished, set fpos to EOD. */
- fpos = vdir->i_size + vol->mft_record_size;
+ fpos = i_size + vol->mft_record_size;
abort:
kfree(name);
done:
@@ -1495,7 +1496,7 @@ err_out:
static int ntfs_dir_open(struct inode *vi, struct file *filp)
{
if (sizeof(unsigned long) < 8) {
- if (vi->i_size > MAX_LFS_FILESIZE)
+ if (i_size_read(vi) > MAX_LFS_FILESIZE)
return -EFBIG;
}
return 0;