[PATCH v2 4/5] PMFS: Remove unnecessary flushing from pmfs_fsync()

Vishal Verma vishal.l.verma at linux.intel.com
Thu May 2 18:31:12 EDT 2013


From: Sanjay Kumar <sanjay.k.kumar at intel.com>

Fixing a bug in pmfs_fsync() where we were clflushing the specified
range even if the file was not mmaped. Now we do clflushes only for the
files that are mmaped.  Also fixed some indentation in bbuild.c

Signed-off-by: Sanjay Kumar <sanjay.k.kumar at intel.com>
---
 fs/pmfs/bbuild.c |   37 +++++++++++++++++++++----------------
 fs/pmfs/file.c   |    6 +++++-
 2 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/fs/pmfs/bbuild.c b/fs/pmfs/bbuild.c
index e279b64..9405882 100644
--- a/fs/pmfs/bbuild.c
+++ b/fs/pmfs/bbuild.c
@@ -423,28 +423,33 @@ static int __pmfs_build_blocknode_map(struct super_block *sb,
 	unsigned long next = 1;
 	unsigned long low = 0;
 
-        while (1) {
-                next = find_next_bit(bitmap, bsize, next);
-                if (next == bsize)
-                        break;
-                low = next;
-                next = find_next_zero_bit(bitmap, bsize, next);
-                if (pmfs_alloc_insert_blocknode_map(sb, low << scale , (next << scale) - 1)) {
-                        printk("PMFS: Error could not insert 0x%lx-0x%lx\n", low << scale, ((next << scale) - 1));
-                }
-                if (next == bsize)
-                        break;
-        }
-        return 0;
+	while (1) {
+		next = find_next_bit(bitmap, bsize, next);
+		if (next == bsize)
+			break;
+		low = next;
+		next = find_next_zero_bit(bitmap, bsize, next);
+		if (pmfs_alloc_insert_blocknode_map(sb, low << scale ,
+				(next << scale) - 1)) {
+			printk("PMFS: Error could not insert 0x%lx-0x%lx\n",
+				low << scale, ((next << scale) - 1));
+		}
+		if (next == bsize)
+			break;
+	}
+	return 0;
 }
 	
 static int pmfs_build_blocknode_map(struct super_block *sb)
 {
 	struct pmfs_sb_info *sbi = PMFS_SB(sb);
 	
-	__pmfs_build_blocknode_map(sb, sbi->bitmap_4k, sbi->bitmap_4k_size * 8, PAGE_SHIFT - 12);
-	__pmfs_build_blocknode_map(sb, sbi->bitmap_2M, sbi->bitmap_2M_size * 8, PAGE_SHIFT_2M - 12);
-	__pmfs_build_blocknode_map(sb, sbi->bitmap_1G, sbi->bitmap_1G_size * 8, PAGE_SHIFT_1G - 12);
+	__pmfs_build_blocknode_map(sb, sbi->bitmap_4k, sbi->bitmap_4k_size * 8,
+		PAGE_SHIFT - 12);
+	__pmfs_build_blocknode_map(sb, sbi->bitmap_2M, sbi->bitmap_2M_size * 8,
+		PAGE_SHIFT_2M - 12);
+	__pmfs_build_blocknode_map(sb, sbi->bitmap_1G, sbi->bitmap_1G_size * 8,
+		PAGE_SHIFT_1G - 12);
 
 	return 0;
 }
diff --git a/fs/pmfs/file.c b/fs/pmfs/file.c
index e6c3812..fa49037 100644
--- a/fs/pmfs/file.c
+++ b/fs/pmfs/file.c
@@ -191,6 +191,10 @@ int pmfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 	loff_t isize;
 	int error;
 
+	/* if the file is not mmap'ed, there is no need to do clflushes */
+	if (mapping_mapped(mapping) == 0)
+		goto persist;
+
 	end += 1; /* end is inclusive. We like our indices normal please ! */
 
 	isize = i_size_read(inode);
@@ -234,7 +238,7 @@ int pmfs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 
 		start += nr_flush_bytes;
 	} while (start < end);
-
+persist:
 	PERSISTENT_MARK();
 	PERSISTENT_BARRIER();
 	return 0;
-- 
1.7.0.4




More information about the Linux-pmfs mailing list