tree 98c9e85271354a878237d77c30a144680cbc1bb1
parent 218357ff1b1b2f1bfdce89d608dbe33dd2f9f14b
author Anton Altaparmakov <[EMAIL PROTECTED]> Fri, 19 Nov 2004 22:16:00 +0000
committer Anton Altaparmakov <[EMAIL PROTECTED]> Thu, 05 May 2005 10:37:22 +0100

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 <[EMAIL PROTECTED]>

 fs/ntfs/ChangeLog |    2 ++
 fs/ntfs/inode.c   |   25 ++++++++++++++-----------
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/fs/ntfs/ChangeLog b/fs/ntfs/ChangeLog
--- a/fs/ntfs/ChangeLog
+++ b/fs/ntfs/ChangeLog
@@ -47,6 +47,8 @@ ToDo/Notes:
          value afterwards.  Cache the initialized_size in the same way and
          protect access to the two sizes using the size_lock.
        - 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.
 
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -174,7 +174,7 @@ struct inode *ntfs_iget(struct super_blo
 
        vi = iget5_locked(sb, mft_no, (test_t)ntfs_test_inode,
                        (set_t)ntfs_init_locked_inode, &na);
-       if (!vi)
+       if (unlikely(!vi))
                return ERR_PTR(-ENOMEM);
 
        err = 0;
@@ -188,7 +188,7 @@ struct inode *ntfs_iget(struct super_blo
         * 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.
         */
-       if (err == -ENOMEM) {
+       if (unlikely(err == -ENOMEM)) {
                iput(vi);
                vi = ERR_PTR(err);
        }
@@ -235,7 +235,7 @@ struct inode *ntfs_attr_iget(struct inod
 
        vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
                        (set_t)ntfs_init_locked_inode, &na);
-       if (!vi)
+       if (unlikely(!vi))
                return ERR_PTR(-ENOMEM);
 
        err = 0;
@@ -250,7 +250,7 @@ struct inode *ntfs_attr_iget(struct inod
         * simplifies things in that we never need to check for bad attribute
         * inodes elsewhere.
         */
-       if (err) {
+       if (unlikely(err)) {
                iput(vi);
                vi = ERR_PTR(err);
        }
@@ -290,7 +290,7 @@ struct inode *ntfs_index_iget(struct ino
 
        vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
                        (set_t)ntfs_init_locked_inode, &na);
-       if (!vi)
+       if (unlikely(!vi))
                return ERR_PTR(-ENOMEM);
 
        err = 0;
@@ -305,7 +305,7 @@ struct inode *ntfs_index_iget(struct ino
         * simplifies things in that we never need to check for bad index
         * inodes elsewhere.
         */
-       if (err) {
+       if (unlikely(err)) {
                iput(vi);
                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.
         */
        if (S_ISDIR(vi->i_mode)) {
+               loff_t bvi_size;
                struct inode *bvi;
                ntfs_inode *bni;
                INDEX_ROOT *ir;
@@ -959,11 +960,12 @@ skip_attr_list_load:
                        goto unm_err_out;
                }
                /* 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)) {
                        ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) "
                                        "for index allocation (0x%llx).",
-                                       bvi->i_size << 3, vi->i_size);
+                                       bvi_size << 3, vi->i_size);
                        goto unm_err_out;
                }
 skip_large_dir_stuff:
@@ -1430,6 +1432,7 @@ err_out:
  */
 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_inode *ni, *base_ni, *bni;
        struct inode *bvi;
@@ -1633,10 +1636,10 @@ static int ntfs_read_locked_index_inode(
                goto iput_unm_err_out;
        }
        /* Consistency check bitmap size vs. index allocation size. */
-       if ((bvi->i_size << 3) < (vi->i_size >>
-                       ni->itype.index.block_size_bits)) {
+       bvi_size = i_size_read(bvi);
+       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 "
-                               "index allocation (0x%llx).", bvi->i_size << 3,
+                               "index allocation (0x%llx).", bvi_size << 3,
                                vi->i_size);
                goto iput_unm_err_out;
        }
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to