[Devel] [PATCH RHEL7 COMMIT] ub/fs: resurrect sync accounting

Konstantin Khorenko khorenko at virtuozzo.com
Tue Jun 16 09:17:08 PDT 2015


The commit is pushed to "branch-rh7-3.10.0-123.1.2-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-123.1.2.vz7.5.13
------>
commit 944120565f7765cee3e69bf285320760da1e60ed
Author: Vladimir Davydov <vdavydov at parallels.com>
Date:   Tue Jun 16 20:17:08 2015 +0400

    ub/fs: resurrect sync accounting
    
    Related to https://jira.sw.ru/browse/PSBM-34007
    
    Signed-off-by: Vladimir Davydov <vdavydov at parallels.com>
    Acked-by: Dmitry Monakhov <dmonakhov at virtuozzo.com>
---
 fs/sync.c | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/fs/sync.c b/fs/sync.c
index abad041..45649b6 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:



More information about the Devel mailing list