NTFS: Use i_size_read() in fs/ntfs/inode.c once and then use the cached value

afterwards when reading the size of the bitmap inode.

Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
This commit is contained in:
Anton Altaparmakov 2004-11-19 22:16:00 +00:00
parent 218357ff1b
commit f50f3ac519
2 changed files with 16 additions and 11 deletions

View File

@ -47,6 +47,8 @@ ToDo/Notes:
value afterwards. Cache the initialized_size in the same way and value afterwards. Cache the initialized_size in the same way and
protect access to the two sizes using the size_lock. protect access to the two sizes using the size_lock.
- Minor optimization to fs/ntfs/super.c::ntfs_statfs() and its helpers. - Minor optimization to fs/ntfs/super.c::ntfs_statfs() and its helpers.
- Use i_size_read() in fs/ntfs/inode.c once and then use the cached
value afterwards when reading the size of the bitmap inode.
2.1.22 - Many bug and race fixes and error handling improvements. 2.1.22 - Many bug and race fixes and error handling improvements.

View File

@ -174,7 +174,7 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
vi = iget5_locked(sb, mft_no, (test_t)ntfs_test_inode, vi = iget5_locked(sb, mft_no, (test_t)ntfs_test_inode,
(set_t)ntfs_init_locked_inode, &na); (set_t)ntfs_init_locked_inode, &na);
if (!vi) if (unlikely(!vi))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = 0; err = 0;
@ -188,7 +188,7 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
* There is no point in keeping bad inodes around if the failure was * There is no point in keeping bad inodes around if the failure was
* due to ENOMEM. We want to be able to retry again later. * due to ENOMEM. We want to be able to retry again later.
*/ */
if (err == -ENOMEM) { if (unlikely(err == -ENOMEM)) {
iput(vi); iput(vi);
vi = ERR_PTR(err); vi = ERR_PTR(err);
} }
@ -235,7 +235,7 @@ struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode, vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
(set_t)ntfs_init_locked_inode, &na); (set_t)ntfs_init_locked_inode, &na);
if (!vi) if (unlikely(!vi))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = 0; err = 0;
@ -250,7 +250,7 @@ struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
* simplifies things in that we never need to check for bad attribute * simplifies things in that we never need to check for bad attribute
* inodes elsewhere. * inodes elsewhere.
*/ */
if (err) { if (unlikely(err)) {
iput(vi); iput(vi);
vi = ERR_PTR(err); vi = ERR_PTR(err);
} }
@ -290,7 +290,7 @@ struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode, vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
(set_t)ntfs_init_locked_inode, &na); (set_t)ntfs_init_locked_inode, &na);
if (!vi) if (unlikely(!vi))
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
err = 0; err = 0;
@ -305,7 +305,7 @@ struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
* simplifies things in that we never need to check for bad index * simplifies things in that we never need to check for bad index
* inodes elsewhere. * inodes elsewhere.
*/ */
if (err) { if (unlikely(err)) {
iput(vi); iput(vi);
vi = ERR_PTR(err); vi = ERR_PTR(err);
} }
@ -742,6 +742,7 @@ skip_attr_list_load:
* in ntfs_ino->attr_list and it is ntfs_ino->attr_list_size bytes. * in ntfs_ino->attr_list and it is ntfs_ino->attr_list_size bytes.
*/ */
if (S_ISDIR(vi->i_mode)) { if (S_ISDIR(vi->i_mode)) {
loff_t bvi_size;
struct inode *bvi; struct inode *bvi;
ntfs_inode *bni; ntfs_inode *bni;
INDEX_ROOT *ir; INDEX_ROOT *ir;
@ -959,11 +960,12 @@ skip_attr_list_load:
goto unm_err_out; goto unm_err_out;
} }
/* Consistency check bitmap size vs. index allocation size. */ /* Consistency check bitmap size vs. index allocation size. */
if ((bvi->i_size << 3) < (vi->i_size >> bvi_size = i_size_read(bvi);
if ((bvi_size << 3) < (vi->i_size >>
ni->itype.index.block_size_bits)) { ni->itype.index.block_size_bits)) {
ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) " ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) "
"for index allocation (0x%llx).", "for index allocation (0x%llx).",
bvi->i_size << 3, vi->i_size); bvi_size << 3, vi->i_size);
goto unm_err_out; goto unm_err_out;
} }
skip_large_dir_stuff: skip_large_dir_stuff:
@ -1430,6 +1432,7 @@ err_out:
*/ */
static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
{ {
loff_t bvi_size;
ntfs_volume *vol = NTFS_SB(vi->i_sb); ntfs_volume *vol = NTFS_SB(vi->i_sb);
ntfs_inode *ni, *base_ni, *bni; ntfs_inode *ni, *base_ni, *bni;
struct inode *bvi; struct inode *bvi;
@ -1633,10 +1636,10 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
goto iput_unm_err_out; goto iput_unm_err_out;
} }
/* Consistency check bitmap size vs. index allocation size. */ /* Consistency check bitmap size vs. index allocation size. */
if ((bvi->i_size << 3) < (vi->i_size >> bvi_size = i_size_read(bvi);
ni->itype.index.block_size_bits)) { if ((bvi_size << 3) < (vi->i_size >> ni->itype.index.block_size_bits)) {
ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) for " ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) for "
"index allocation (0x%llx).", bvi->i_size << 3, "index allocation (0x%llx).", bvi_size << 3,
vi->i_size); vi->i_size);
goto iput_unm_err_out; goto iput_unm_err_out;
} }