Commit f50f3ac51983025405a71b70b033cc6bcb0d1fc1

Authored by Anton Altaparmakov
1 parent 218357ff1b

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>

Showing 2 changed files with 16 additions and 11 deletions Side-by-side Diff

... ... @@ -47,6 +47,8 @@
47 47 value afterwards. Cache the initialized_size in the same way and
48 48 protect access to the two sizes using the size_lock.
49 49 - Minor optimization to fs/ntfs/super.c::ntfs_statfs() and its helpers.
  50 + - Use i_size_read() in fs/ntfs/inode.c once and then use the cached
  51 + value afterwards when reading the size of the bitmap inode.
50 52  
51 53 2.1.22 - Many bug and race fixes and error handling improvements.
52 54  
... ... @@ -174,7 +174,7 @@
174 174  
175 175 vi = iget5_locked(sb, mft_no, (test_t)ntfs_test_inode,
176 176 (set_t)ntfs_init_locked_inode, &na);
177   - if (!vi)
  177 + if (unlikely(!vi))
178 178 return ERR_PTR(-ENOMEM);
179 179  
180 180 err = 0;
... ... @@ -188,7 +188,7 @@
188 188 * There is no point in keeping bad inodes around if the failure was
189 189 * due to ENOMEM. We want to be able to retry again later.
190 190 */
191   - if (err == -ENOMEM) {
  191 + if (unlikely(err == -ENOMEM)) {
192 192 iput(vi);
193 193 vi = ERR_PTR(err);
194 194 }
... ... @@ -235,7 +235,7 @@
235 235  
236 236 vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
237 237 (set_t)ntfs_init_locked_inode, &na);
238   - if (!vi)
  238 + if (unlikely(!vi))
239 239 return ERR_PTR(-ENOMEM);
240 240  
241 241 err = 0;
... ... @@ -250,7 +250,7 @@
250 250 * simplifies things in that we never need to check for bad attribute
251 251 * inodes elsewhere.
252 252 */
253   - if (err) {
  253 + if (unlikely(err)) {
254 254 iput(vi);
255 255 vi = ERR_PTR(err);
256 256 }
... ... @@ -290,7 +290,7 @@
290 290  
291 291 vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
292 292 (set_t)ntfs_init_locked_inode, &na);
293   - if (!vi)
  293 + if (unlikely(!vi))
294 294 return ERR_PTR(-ENOMEM);
295 295  
296 296 err = 0;
... ... @@ -305,7 +305,7 @@
305 305 * simplifies things in that we never need to check for bad index
306 306 * inodes elsewhere.
307 307 */
308   - if (err) {
  308 + if (unlikely(err)) {
309 309 iput(vi);
310 310 vi = ERR_PTR(err);
311 311 }
... ... @@ -742,6 +742,7 @@
742 742 * in ntfs_ino->attr_list and it is ntfs_ino->attr_list_size bytes.
743 743 */
744 744 if (S_ISDIR(vi->i_mode)) {
  745 + loff_t bvi_size;
745 746 struct inode *bvi;
746 747 ntfs_inode *bni;
747 748 INDEX_ROOT *ir;
748 749  
... ... @@ -959,11 +960,12 @@
959 960 goto unm_err_out;
960 961 }
961 962 /* Consistency check bitmap size vs. index allocation size. */
962   - if ((bvi->i_size << 3) < (vi->i_size >>
  963 + bvi_size = i_size_read(bvi);
  964 + if ((bvi_size << 3) < (vi->i_size >>
963 965 ni->itype.index.block_size_bits)) {
964 966 ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) "
965 967 "for index allocation (0x%llx).",
966   - bvi->i_size << 3, vi->i_size);
  968 + bvi_size << 3, vi->i_size);
967 969 goto unm_err_out;
968 970 }
969 971 skip_large_dir_stuff:
... ... @@ -1430,6 +1432,7 @@
1430 1432 */
1431 1433 static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1432 1434 {
  1435 + loff_t bvi_size;
1433 1436 ntfs_volume *vol = NTFS_SB(vi->i_sb);
1434 1437 ntfs_inode *ni, *base_ni, *bni;
1435 1438 struct inode *bvi;
1436 1439  
... ... @@ -1633,10 +1636,10 @@
1633 1636 goto iput_unm_err_out;
1634 1637 }
1635 1638 /* Consistency check bitmap size vs. index allocation size. */
1636   - if ((bvi->i_size << 3) < (vi->i_size >>
1637   - ni->itype.index.block_size_bits)) {
  1639 + bvi_size = i_size_read(bvi);
  1640 + if ((bvi_size << 3) < (vi->i_size >> ni->itype.index.block_size_bits)) {
1638 1641 ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) for "
1639   - "index allocation (0x%llx).", bvi->i_size << 3,
  1642 + "index allocation (0x%llx).", bvi_size << 3,
1640 1643 vi->i_size);
1641 1644 goto iput_unm_err_out;
1642 1645 }