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

Dmitry Monakhov dmonakhov at openvz.org
Wed Jun 10 08:29:28 PDT 2015


Konstantin Khorenko <khorenko at virtuozzo.com> writes:

Acked-by <dmonakhov at parallels.com>
> Dima, please review.
>
> --
> Best regards,
>
> Konstantin Khorenko,
> Virtuozzo Linux Kernel Team
>
> On 06/10/2015 11:16 AM, Vladimir Davydov wrote:
>> 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:
>> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 472 bytes
Desc: not available
URL: <http://lists.openvz.org/pipermail/devel/attachments/20150610/0bd2b8f0/attachment-0001.sig>


More information about the Devel mailing list