瀏覽代碼

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>

Anton Altaparmakov 20 年之前
父節點
當前提交
db30d160cd
共有 2 個文件被更改,包括 7 次插入3 次删除
  1. 2 0
      fs/ntfs/ChangeLog
  2. 5 3
      fs/ntfs/lcnalloc.c

+ 2 - 0
fs/ntfs/ChangeLog

@@ -31,6 +31,8 @@ ToDo/Notes:
 	  out.
 	  out.
 	- Use i_size_read() in fs/ntfs/attrib.c::ntfs_attr_set().
 	- Use i_size_read() in fs/ntfs/attrib.c::ntfs_attr_set().
 	- Use i_size_read() in fs/ntfs/logfile.c::ntfs_{check,empty}_logfile().
 	- Use i_size_read() in fs/ntfs/logfile.c::ntfs_{check,empty}_logfile().
+	- Use i_size_read() once and then use the cached value in
+	  fs/ntfs/lcnalloc.c::ntfs_cluster_alloc().
 
 
 2.1.22 - Many bug and race fixes and error handling improvements.
 2.1.22 - Many bug and race fixes and error handling improvements.
 
 

+ 5 - 3
fs/ntfs/lcnalloc.c

@@ -140,6 +140,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
 	LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn;
 	LCN zone_start, zone_end, bmp_pos, bmp_initial_pos, last_read_pos, lcn;
 	LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size;
 	LCN prev_lcn = 0, prev_run_len = 0, mft_zone_size;
 	s64 clusters;
 	s64 clusters;
+	loff_t i_size;
 	struct inode *lcnbmp_vi;
 	struct inode *lcnbmp_vi;
 	runlist_element *rl = NULL;
 	runlist_element *rl = NULL;
 	struct address_space *mapping;
 	struct address_space *mapping;
@@ -249,6 +250,7 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
 	clusters = count;
 	clusters = count;
 	rlpos = rlsize = 0;
 	rlpos = rlsize = 0;
 	mapping = lcnbmp_vi->i_mapping;
 	mapping = lcnbmp_vi->i_mapping;
+	i_size = i_size_read(lcnbmp_vi);
 	while (1) {
 	while (1) {
 		ntfs_debug("Start of outer while loop: done_zones 0x%x, "
 		ntfs_debug("Start of outer while loop: done_zones 0x%x, "
 				"search_zone %i, pass %i, zone_start 0x%llx, "
 				"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,
 		last_read_pos = bmp_pos >> 3;
 		last_read_pos = bmp_pos >> 3;
 		ntfs_debug("last_read_pos 0x%llx.",
 		ntfs_debug("last_read_pos 0x%llx.",
 				(unsigned long long)last_read_pos);
 				(unsigned long long)last_read_pos);
-		if (last_read_pos > lcnbmp_vi->i_size) {
+		if (last_read_pos > i_size) {
 			ntfs_debug("End of attribute reached.  "
 			ntfs_debug("End of attribute reached.  "
 					"Skipping to zone_pass_done.");
 					"Skipping to zone_pass_done.");
 			goto zone_pass_done;
 			goto zone_pass_done;
@@ -287,8 +289,8 @@ runlist_element *ntfs_cluster_alloc(ntfs_volume *vol, const VCN start_vcn,
 		buf_size = last_read_pos & ~PAGE_CACHE_MASK;
 		buf_size = last_read_pos & ~PAGE_CACHE_MASK;
 		buf = page_address(page) + buf_size;
 		buf = page_address(page) + buf_size;
 		buf_size = PAGE_CACHE_SIZE - buf_size;
 		buf_size = PAGE_CACHE_SIZE - buf_size;
-		if (unlikely(last_read_pos + buf_size > lcnbmp_vi->i_size))
-			buf_size = lcnbmp_vi->i_size - last_read_pos;
+		if (unlikely(last_read_pos + buf_size > i_size))
+			buf_size = i_size - last_read_pos;
 		buf_size <<= 3;
 		buf_size <<= 3;
 		lcn = bmp_pos & 7;
 		lcn = bmp_pos & 7;
 		bmp_pos &= ~7;
 		bmp_pos &= ~7;