aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ntfs/inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ntfs/inode.c')
-rw-r--r--fs/ntfs/inode.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index a02d8d9f0439..6c631dbe0f4c 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -174,7 +174,7 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
174 174
175 vi = iget5_locked(sb, mft_no, (test_t)ntfs_test_inode, 175 vi = iget5_locked(sb, mft_no, (test_t)ntfs_test_inode,
176 (set_t)ntfs_init_locked_inode, &na); 176 (set_t)ntfs_init_locked_inode, &na);
177 if (!vi) 177 if (unlikely(!vi))
178 return ERR_PTR(-ENOMEM); 178 return ERR_PTR(-ENOMEM);
179 179
180 err = 0; 180 err = 0;
@@ -188,7 +188,7 @@ struct inode *ntfs_iget(struct super_block *sb, unsigned long mft_no)
188 * There is no point in keeping bad inodes around if the failure was 188 * There is no point in keeping bad inodes around if the failure was
189 * due to ENOMEM. We want to be able to retry again later. 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 iput(vi); 192 iput(vi);
193 vi = ERR_PTR(err); 193 vi = ERR_PTR(err);
194 } 194 }
@@ -235,7 +235,7 @@ struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
235 235
236 vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode, 236 vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
237 (set_t)ntfs_init_locked_inode, &na); 237 (set_t)ntfs_init_locked_inode, &na);
238 if (!vi) 238 if (unlikely(!vi))
239 return ERR_PTR(-ENOMEM); 239 return ERR_PTR(-ENOMEM);
240 240
241 err = 0; 241 err = 0;
@@ -250,7 +250,7 @@ struct inode *ntfs_attr_iget(struct inode *base_vi, ATTR_TYPE type,
250 * simplifies things in that we never need to check for bad attribute 250 * simplifies things in that we never need to check for bad attribute
251 * inodes elsewhere. 251 * inodes elsewhere.
252 */ 252 */
253 if (err) { 253 if (unlikely(err)) {
254 iput(vi); 254 iput(vi);
255 vi = ERR_PTR(err); 255 vi = ERR_PTR(err);
256 } 256 }
@@ -290,7 +290,7 @@ struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
290 290
291 vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode, 291 vi = iget5_locked(base_vi->i_sb, na.mft_no, (test_t)ntfs_test_inode,
292 (set_t)ntfs_init_locked_inode, &na); 292 (set_t)ntfs_init_locked_inode, &na);
293 if (!vi) 293 if (unlikely(!vi))
294 return ERR_PTR(-ENOMEM); 294 return ERR_PTR(-ENOMEM);
295 295
296 err = 0; 296 err = 0;
@@ -305,7 +305,7 @@ struct inode *ntfs_index_iget(struct inode *base_vi, ntfschar *name,
305 * simplifies things in that we never need to check for bad index 305 * simplifies things in that we never need to check for bad index
306 * inodes elsewhere. 306 * inodes elsewhere.
307 */ 307 */
308 if (err) { 308 if (unlikely(err)) {
309 iput(vi); 309 iput(vi);
310 vi = ERR_PTR(err); 310 vi = ERR_PTR(err);
311 } 311 }
@@ -742,6 +742,7 @@ skip_attr_list_load:
742 * in ntfs_ino->attr_list and it is ntfs_ino->attr_list_size bytes. 742 * in ntfs_ino->attr_list and it is ntfs_ino->attr_list_size bytes.
743 */ 743 */
744 if (S_ISDIR(vi->i_mode)) { 744 if (S_ISDIR(vi->i_mode)) {
745 loff_t bvi_size;
745 struct inode *bvi; 746 struct inode *bvi;
746 ntfs_inode *bni; 747 ntfs_inode *bni;
747 INDEX_ROOT *ir; 748 INDEX_ROOT *ir;
@@ -959,11 +960,12 @@ skip_attr_list_load:
959 goto unm_err_out; 960 goto unm_err_out;
960 } 961 }
961 /* Consistency check bitmap size vs. index allocation size. */ 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 ni->itype.index.block_size_bits)) { 965 ni->itype.index.block_size_bits)) {
964 ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) " 966 ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) "
965 "for index allocation (0x%llx).", 967 "for index allocation (0x%llx).",
966 bvi->i_size << 3, vi->i_size); 968 bvi_size << 3, vi->i_size);
967 goto unm_err_out; 969 goto unm_err_out;
968 } 970 }
969skip_large_dir_stuff: 971skip_large_dir_stuff:
@@ -1430,6 +1432,7 @@ err_out:
1430 */ 1432 */
1431static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi) 1433static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1432{ 1434{
1435 loff_t bvi_size;
1433 ntfs_volume *vol = NTFS_SB(vi->i_sb); 1436 ntfs_volume *vol = NTFS_SB(vi->i_sb);
1434 ntfs_inode *ni, *base_ni, *bni; 1437 ntfs_inode *ni, *base_ni, *bni;
1435 struct inode *bvi; 1438 struct inode *bvi;
@@ -1633,10 +1636,10 @@ static int ntfs_read_locked_index_inode(struct inode *base_vi, struct inode *vi)
1633 goto iput_unm_err_out; 1636 goto iput_unm_err_out;
1634 } 1637 }
1635 /* Consistency check bitmap size vs. index allocation size. */ 1638 /* Consistency check bitmap size vs. index allocation size. */
1636 if ((bvi->i_size << 3) < (vi->i_size >> 1639 bvi_size = i_size_read(bvi);
1637 ni->itype.index.block_size_bits)) { 1640 if ((bvi_size << 3) < (vi->i_size >> ni->itype.index.block_size_bits)) {
1638 ntfs_error(vi->i_sb, "Index bitmap too small (0x%llx) for " 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 vi->i_size); 1643 vi->i_size);
1641 goto iput_unm_err_out; 1644 goto iput_unm_err_out;
1642 } 1645 }