aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Altaparmakov <aia21@cantab.net>2004-11-18 10:01:06 -0500
committerAnton Altaparmakov <aia21@cantab.net>2005-05-05 05:32:43 -0400
commit206f9f35b2348b7b966ff18a5564b8a3ca325ed5 (patch)
tree2f221334cf8b1b9756a58e323b5fba2cdd4dc583
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>
-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 97c4fe932046..7bbbb9152fee 100644
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -41,6 +41,8 @@ ToDo/Notes:
41 - Use i_size_read() in fs/ntfs/compress.c at the start of the read and 41 - Use i_size_read() in fs/ntfs/compress.c at the start of the read and
42 use the cached value afterwards. Cache the initialized_size in the 42 use the cached value afterwards. Cache the initialized_size in the
43 same way and protect access to the two sizes using the size_lock. 43 same way and protect access to the two sizes using the size_lock.
44 - Use i_size_read() in fs/ntfs/dir.c once and then use the cached
45 value afterwards.
44 46
452.1.22 - Many bug and race fixes and error handling improvements. 472.1.22 - Many bug and race fixes and error handling improvements.
46 48
diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
index 93577561cdbe..d261ac4596f5 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,
1101static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir) 1101static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
1102{ 1102{
1103 s64 ia_pos, ia_start, prev_ia_pos, bmp_pos; 1103 s64 ia_pos, ia_start, prev_ia_pos, bmp_pos;
1104 loff_t fpos; 1104 loff_t fpos, i_size;
1105 struct inode *bmp_vi, *vdir = filp->f_dentry->d_inode; 1105 struct inode *bmp_vi, *vdir = filp->f_dentry->d_inode;
1106 struct super_block *sb = vdir->i_sb; 1106 struct super_block *sb = vdir->i_sb;
1107 ntfs_inode *ndir = NTFS_I(vdir); 1107 ntfs_inode *ndir = NTFS_I(vdir);
@@ -1122,7 +1122,8 @@ static int ntfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
1122 vdir->i_ino, fpos); 1122 vdir->i_ino, fpos);
1123 rc = err = 0; 1123 rc = err = 0;
1124 /* Are we at end of dir yet? */ 1124 /* Are we at end of dir yet? */
1125 if (fpos >= vdir->i_size + vol->mft_record_size) 1125 i_size = i_size_read(vdir);
1126 if (fpos >= i_size + vol->mft_record_size)
1126 goto done; 1127 goto done;
1127 /* Emulate . and .. for all directories. */ 1128 /* Emulate . and .. for all directories. */
1128 if (!fpos) { 1129 if (!fpos) {
@@ -1264,7 +1265,7 @@ skip_index_root:
1264 bmp_mapping = bmp_vi->i_mapping; 1265 bmp_mapping = bmp_vi->i_mapping;
1265 /* Get the starting bitmap bit position and sanity check it. */ 1266 /* Get the starting bitmap bit position and sanity check it. */
1266 bmp_pos = ia_pos >> ndir->itype.index.block_size_bits; 1267 bmp_pos = ia_pos >> ndir->itype.index.block_size_bits;
1267 if (unlikely(bmp_pos >> 3 >= bmp_vi->i_size)) { 1268 if (unlikely(bmp_pos >> 3 >= i_size_read(bmp_vi))) {
1268 ntfs_error(sb, "Current index allocation position exceeds " 1269 ntfs_error(sb, "Current index allocation position exceeds "
1269 "index bitmap size."); 1270 "index bitmap size.");
1270 goto err_out; 1271 goto err_out;
@@ -1301,7 +1302,7 @@ find_next_index_buffer:
1301 goto get_next_bmp_page; 1302 goto get_next_bmp_page;
1302 } 1303 }
1303 /* If we have reached the end of the bitmap, we are done. */ 1304 /* If we have reached the end of the bitmap, we are done. */
1304 if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= vdir->i_size)) 1305 if (unlikely(((bmp_pos + cur_bmp_pos) >> 3) >= i_size))
1305 goto unm_EOD; 1306 goto unm_EOD;
1306 ia_pos = (bmp_pos + cur_bmp_pos) << 1307 ia_pos = (bmp_pos + cur_bmp_pos) <<
1307 ndir->itype.index.block_size_bits; 1308 ndir->itype.index.block_size_bits;
@@ -1441,7 +1442,7 @@ unm_EOD:
1441 ntfs_unmap_page(bmp_page); 1442 ntfs_unmap_page(bmp_page);
1442EOD: 1443EOD:
1443 /* We are finished, set fpos to EOD. */ 1444 /* We are finished, set fpos to EOD. */
1444 fpos = vdir->i_size + vol->mft_record_size; 1445 fpos = i_size + vol->mft_record_size;
1445abort: 1446abort:
1446 kfree(name); 1447 kfree(name);
1447done: 1448done:
@@ -1495,7 +1496,7 @@ err_out:
1495static int ntfs_dir_open(struct inode *vi, struct file *filp) 1496static int ntfs_dir_open(struct inode *vi, struct file *filp)
1496{ 1497{
1497 if (sizeof(unsigned long) < 8) { 1498 if (sizeof(unsigned long) < 8) {
1498 if (vi->i_size > MAX_LFS_FILESIZE) 1499 if (i_size_read(vi) > MAX_LFS_FILESIZE)
1499 return -EFBIG; 1500 return -EFBIG;
1500 } 1501 }
1501 return 0; 1502 return 0;