[Devel] [PATCH rh7] ub: resurrect sync accounting

Vladimir Davydov vdavydov at parallels.com
Wed Jun 10 01:16:31 PDT 2015


Related to https://jira.sw.ru/browse/PSBM-34007

Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
---
 fs/sync.c | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/fs/sync.c b/fs/sync.c
index abad041f52a4..45649b617bae 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -229,9 +229,13 @@ int ve_fsync_behavior(void)
 SYSCALL_DEFINE0(sync)
 {
 	struct ve_struct *ve = get_exec_env();
+	struct user_beancounter *ub;
 	int nowait = 0, wait = 1;
 	unsigned long start = jiffies;
 
+	ub = get_exec_ub();
+	ub_percpu_inc(ub, sync);
+
 	if (!ve_is_super(ve)) {
 		int fsb;
 		/*
@@ -258,6 +262,7 @@ SYSCALL_DEFINE0(sync)
 	if (unlikely(laptop_mode))
 		laptop_sync_completion();
 skip:
+	ub_percpu_inc(ub, sync_done);
 	return 0;
 }
 
@@ -358,9 +363,26 @@ skip:
  */
 int vfs_fsync_range(struct file *file, loff_t start, loff_t end, int datasync)
 {
+	struct user_beancounter *ub;
+	int ret;
+
 	if (!file->f_op || !file->f_op->fsync)
 		return -EINVAL;
-	return file->f_op->fsync(file, start, end, datasync);
+
+	ub = get_exec_ub();
+	if (datasync)
+		ub_percpu_inc(ub, fdsync);
+	else
+		ub_percpu_inc(ub, fsync);
+
+	ret = file->f_op->fsync(file, start, end, datasync);
+
+	if (datasync)
+		ub_percpu_inc(ub, fdsync_done);
+	else
+		ub_percpu_inc(ub, fsync_done);
+
+	return ret;
 }
 EXPORT_SYMBOL(vfs_fsync_range);
 
@@ -473,6 +495,7 @@ EXPORT_SYMBOL(generic_write_sync);
 SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes,
 				unsigned int, flags)
 {
+	struct user_beancounter *ub;
 	int ret;
 	struct fd f;
 	struct address_space *mapping;
@@ -534,22 +557,27 @@ SYSCALL_DEFINE4(sync_file_range, int, fd, loff_t, offset, loff_t, nbytes,
 		goto out_put;
 	}
 
+	ub = get_exec_ub();
+	ub_percpu_inc(ub, frsync);
+
 	ret = 0;
 	if (flags & SYNC_FILE_RANGE_WAIT_BEFORE) {
 		ret = filemap_fdatawait_range(mapping, offset, endbyte);
 		if (ret < 0)
-			goto out_put;
+			goto out_acct;
 	}
 
 	if (flags & SYNC_FILE_RANGE_WRITE) {
 		ret = filemap_fdatawrite_range(mapping, offset, endbyte);
 		if (ret < 0)
-			goto out_put;
+			goto out_acct;
 	}
 
 	if (flags & SYNC_FILE_RANGE_WAIT_AFTER)
 		ret = filemap_fdatawait_range(mapping, offset, endbyte);
 
+out_acct:
+	ub_percpu_inc(ub, frsync_done);
 out_put:
 	fdput(f);
 out:
-- 
2.1.4




More information about the Devel mailing list