Commit db30d160cd8dfe1e53435fd76f4189778f1c728e

Authored by Anton Altaparmakov
1 parent 66129f88c4

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>

Showing 2 changed files with 7 additions and 3 deletions Side-by-side Diff

... ... @@ -31,6 +31,8 @@
31 31 out.
32 32 - Use i_size_read() in fs/ntfs/attrib.c::ntfs_attr_set().
33 33 - 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().
34 36  
35 37 2.1.22 - Many bug and race fixes and error handling improvements.
36 38  
... ... @@ -140,6 +140,7 @@
140 140 LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn;
141 141 LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size;
142 142 s64 clusters;
  143 + loff_t i_size;
143 144 struct inode *lcnbmp_vi;
144 145 runlist_element *rl = NULL;
145 146 struct address_space *mapping;
... ... @@ -249,6 +250,7 @@
249 250 clusters = count;
250 251 rlpos = rlsize = 0;
251 252 mapping = lcnbmp_vi->i_mapping;
  253 + i_size = i_size_read(lcnbmp_vi);
252 254 while (1) {
253 255 ntfs_debug("Start of outer while loop: done_zones 0x%x, "
254 256 "search_zone %i, pass %i, zone_start 0x%llx, "
... ... @@ -263,7 +265,7 @@
263 265 last_read_pos = bmp_pos >> 3;
264 266 ntfs_debug("last_read_pos 0x%llx.",
265 267 (unsigned long long)last_read_pos);
266   - if (last_read_pos > lcnbmp_vi->i_size) {
  268 + if (last_read_pos > i_size) {
267 269 ntfs_debug("End of attribute reached. "
268 270 "Skipping to zone_pass_done.");
269 271 goto zone_pass_done;
... ... @@ -287,8 +289,8 @@
287 289 buf_size = last_read_pos & ~PAGE_CACHE_MASK;
288 290 buf = page_address(page) + buf_size;
289 291 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;
292 294 buf_size <<= 3;
293 295 lcn = bmp_pos & 7;
294 296 bmp_pos &= ~7;