Skip to content

Commit db30d16

Browse files
NTFS: Use i_size_read() once and then use the cached value in
fs/ntfs/lcnalloc.c::ntfs_cluster_alloc(). Signed-off-by: Anton Altaparmakov <aia21@cantab.net>
1 parent 66129f8 commit db30d16

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎fs/ntfs/ChangeLog‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ ToDo/Notes:
3131
out.
3232
- Use i_size_read() in fs/ntfs/attrib.c::ntfs_attr_set().
3333
- Use i_size_read() in fs/ntfs/logfile.c::ntfs_{check,empty}_logfile().
34+
- Use i_size_read() once and then use the cached value in
35+
fs/ntfs/lcnalloc.c::ntfs_cluster_alloc().
3436

3537
2.1.22 - Many bug and race fixes and error handling improvements.
3638

‎fs/ntfs/lcnalloc.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
140140
LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn;
141141
LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size;
142142
s64 clusters;
143+
loff_t i_size;
143144
struct inode *lcnbmp_vi;
144145
runlist_element *rl = NULL;
145146
struct address_space *mapping;
@@ -249,6 +250,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
249250
clusters = count;
250251
rlpos = rlsize = 0;
251252
mapping = lcnbmp_vi->i_mapping;
253+
i_size = i_size_read(lcnbmp_vi);
252254
while (1) {
253255
ntfs_debug("Start of outer while loop: done_zones 0x%x, "
254256
"search_zone %i, pass %i, zone_start 0x%llx, "
@@ -263,7 +265,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
263265
last_read_pos = bmp_pos >> 3;
264266
ntfs_debug("last_read_pos 0x%llx.",
265267
(unsigned long long)last_read_pos);
266-
if (last_read_pos > lcnbmp_vi->i_size) {
268+
if (last_read_pos > i_size) {
267269
ntfs_debug("End of attribute reached. "
268270
"Skipping to zone_pass_done.");
269271
goto zone_pass_done;
@@ -287,8 +289,8 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
287289
buf_size = last_read_pos & ~PAGE_CACHE_MASK;
288290
buf = page_address(page) + buf_size;
289291
buf_size = PAGE_CACHE_SIZE - buf_size;
290-
if (unlikely(last_read_pos + buf_size > lcnbmp_vi->i_size))
291-
buf_size = lcnbmp_vi->i_size - last_read_pos;
292+
if (unlikely(last_read_pos + buf_size > i_size))
293+
buf_size = i_size - last_read_pos;
292294
buf_size <<= 3;
293295
lcn = bmp_pos & 7;
294296
bmp_pos &= ~7;

0 commit comments

Comments
 (0)