All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] NFSD: pass range end to vfs_fsync_range() instead of count
@ 2022-11-16 15:28 Brian Foster
  2022-11-16 15:34 ` Chuck Lever III
  0 siblings, 1 reply; 5+ messages in thread
From: Brian Foster @ 2022-11-16 15:28 UTC (permalink / raw)
  To: linux-nfs

_nfsd_copy_file_range() calls vfs_fsync_range() with an offset and
count (bytes written), but the former wants the start and end bytes
of the range to sync. Fix it up.

Fixes: eac0b17a77fb ("NFSD add vfs_fsync after async copy is done")
Signed-off-by: Brian Foster <bfoster@redhat.com>
---

Hi all,

This is just a quick drive-by patch from scanning through various flush
callers for something unrelated. It looked like this instance passes a
count instead of the end offset and it was easy enough to throw up a
patch. Compile tested only, feel free to toss it if I've just missed
something, etc. etc.

Brian

 fs/nfsd/nfs4proc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 8beb2bc4c328..3c67d4cb1eba 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1644,6 +1644,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
 	u64 src_pos = copy->cp_src_pos;
 	u64 dst_pos = copy->cp_dst_pos;
 	int status;
+	loff_t end;
 
 	/* See RFC 7862 p.67: */
 	if (bytes_total == 0)
@@ -1663,8 +1664,8 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
 	/* for a non-zero asynchronous copy do a commit of data */
 	if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) {
 		since = READ_ONCE(dst->f_wb_err);
-		status = vfs_fsync_range(dst, copy->cp_dst_pos,
-					 copy->cp_res.wr_bytes_written, 0);
+		end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1;
+		status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0);
 		if (!status)
 			status = filemap_check_wb_err(dst->f_mapping, since);
 		if (!status)
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] NFSD: pass range end to vfs_fsync_range() instead of count
  2022-11-16 15:28 [PATCH] NFSD: pass range end to vfs_fsync_range() instead of count Brian Foster
@ 2022-11-16 15:34 ` Chuck Lever III
  2022-11-16 18:50   ` dai.ngo
  0 siblings, 1 reply; 5+ messages in thread
From: Chuck Lever III @ 2022-11-16 15:34 UTC (permalink / raw)
  To: Dai Ngo, Olga Kornievskaia; +Cc: Linux NFS Mailing List, Brian Foster



> On Nov 16, 2022, at 10:28 AM, Brian Foster <bfoster@redhat.com> wrote:
> 
> _nfsd_copy_file_range() calls vfs_fsync_range() with an offset and
> count (bytes written), but the former wants the start and end bytes
> of the range to sync. Fix it up.
> 
> Fixes: eac0b17a77fb ("NFSD add vfs_fsync after async copy is done")
> Signed-off-by: Brian Foster <bfoster@redhat.com>
> ---
> 
> Hi all,
> 
> This is just a quick drive-by patch from scanning through various flush
> callers for something unrelated. It looked like this instance passes a
> count instead of the end offset and it was easy enough to throw up a
> patch. Compile tested only, feel free to toss it if I've just missed
> something, etc. etc.

Dai, Olga, can you review this, and one of you test it?


> Brian
> 
> fs/nfsd/nfs4proc.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
> index 8beb2bc4c328..3c67d4cb1eba 100644
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -1644,6 +1644,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
> 	u64 src_pos = copy->cp_src_pos;
> 	u64 dst_pos = copy->cp_dst_pos;
> 	int status;
> +	loff_t end;
> 
> 	/* See RFC 7862 p.67: */
> 	if (bytes_total == 0)
> @@ -1663,8 +1664,8 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
> 	/* for a non-zero asynchronous copy do a commit of data */
> 	if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) {
> 		since = READ_ONCE(dst->f_wb_err);
> -		status = vfs_fsync_range(dst, copy->cp_dst_pos,
> -					 copy->cp_res.wr_bytes_written, 0);
> +		end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1;
> +		status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0);
> 		if (!status)
> 			status = filemap_check_wb_err(dst->f_mapping, since);
> 		if (!status)
> -- 
> 2.37.3
> 

--
Chuck Lever




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] NFSD: pass range end to vfs_fsync_range() instead of count
  2022-11-16 15:34 ` Chuck Lever III
@ 2022-11-16 18:50   ` dai.ngo
  2022-11-16 19:01     ` Chuck Lever III
  0 siblings, 1 reply; 5+ messages in thread
From: dai.ngo @ 2022-11-16 18:50 UTC (permalink / raw)
  To: Chuck Lever III, Olga Kornievskaia; +Cc: Linux NFS Mailing List, Brian Foster


On 11/16/22 7:34 AM, Chuck Lever III wrote:
>
>> On Nov 16, 2022, at 10:28 AM, Brian Foster <bfoster@redhat.com> wrote:
>>
>> _nfsd_copy_file_range() calls vfs_fsync_range() with an offset and
>> count (bytes written), but the former wants the start and end bytes
>> of the range to sync. Fix it up.
>>
>> Fixes: eac0b17a77fb ("NFSD add vfs_fsync after async copy is done")
>> Signed-off-by: Brian Foster <bfoster@redhat.com>
>> ---
>>
>> Hi all,
>>
>> This is just a quick drive-by patch from scanning through various flush
>> callers for something unrelated. It looked like this instance passes a
>> count instead of the end offset and it was easy enough to throw up a
>> patch. Compile tested only, feel free to toss it if I've just missed
>> something, etc. etc.
> Dai, Olga, can you review this, and one of you test it?

LGTM, tested ok.

-Dai

>
>
>> Brian
>>
>> fs/nfsd/nfs4proc.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
>> index 8beb2bc4c328..3c67d4cb1eba 100644
>> --- a/fs/nfsd/nfs4proc.c
>> +++ b/fs/nfsd/nfs4proc.c
>> @@ -1644,6 +1644,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
>> 	u64 src_pos = copy->cp_src_pos;
>> 	u64 dst_pos = copy->cp_dst_pos;
>> 	int status;
>> +	loff_t end;
>>
>> 	/* See RFC 7862 p.67: */
>> 	if (bytes_total == 0)
>> @@ -1663,8 +1664,8 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
>> 	/* for a non-zero asynchronous copy do a commit of data */
>> 	if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) {
>> 		since = READ_ONCE(dst->f_wb_err);
>> -		status = vfs_fsync_range(dst, copy->cp_dst_pos,
>> -					 copy->cp_res.wr_bytes_written, 0);
>> +		end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1;
>> +		status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0);
>> 		if (!status)
>> 			status = filemap_check_wb_err(dst->f_mapping, since);
>> 		if (!status)
>> -- 
>> 2.37.3
>>
> --
> Chuck Lever
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] NFSD: pass range end to vfs_fsync_range() instead of count
  2022-11-16 18:50   ` dai.ngo
@ 2022-11-16 19:01     ` Chuck Lever III
  2022-11-16 19:08       ` dai.ngo
  0 siblings, 1 reply; 5+ messages in thread
From: Chuck Lever III @ 2022-11-16 19:01 UTC (permalink / raw)
  To: Dai Ngo; +Cc: Olga Kornievskaia, Linux NFS Mailing List, Brian Foster



> On Nov 16, 2022, at 1:50 PM, Dai Ngo <dai.ngo@oracle.com> wrote:
> 
> 
> On 11/16/22 7:34 AM, Chuck Lever III wrote:
>> 
>>> On Nov 16, 2022, at 10:28 AM, Brian Foster <bfoster@redhat.com> wrote:
>>> 
>>> _nfsd_copy_file_range() calls vfs_fsync_range() with an offset and
>>> count (bytes written), but the former wants the start and end bytes
>>> of the range to sync. Fix it up.
>>> 
>>> Fixes: eac0b17a77fb ("NFSD add vfs_fsync after async copy is done")
>>> Signed-off-by: Brian Foster <bfoster@redhat.com>
>>> ---
>>> 
>>> Hi all,
>>> 
>>> This is just a quick drive-by patch from scanning through various flush
>>> callers for something unrelated. It looked like this instance passes a
>>> count instead of the end offset and it was easy enough to throw up a
>>> patch. Compile tested only, feel free to toss it if I've just missed
>>> something, etc. etc.
>> Dai, Olga, can you review this, and one of you test it?
> 
> LGTM, tested ok.

May I add Tested-by: Dai Ngo <dai.ngo@oracle.com> ?


> -Dai
> 
>> 
>> 
>>> Brian
>>> 
>>> fs/nfsd/nfs4proc.c | 5 +++--
>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>> 
>>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
>>> index 8beb2bc4c328..3c67d4cb1eba 100644
>>> --- a/fs/nfsd/nfs4proc.c
>>> +++ b/fs/nfsd/nfs4proc.c
>>> @@ -1644,6 +1644,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
>>> 	u64 src_pos = copy->cp_src_pos;
>>> 	u64 dst_pos = copy->cp_dst_pos;
>>> 	int status;
>>> +	loff_t end;
>>> 
>>> 	/* See RFC 7862 p.67: */
>>> 	if (bytes_total == 0)
>>> @@ -1663,8 +1664,8 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
>>> 	/* for a non-zero asynchronous copy do a commit of data */
>>> 	if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) {
>>> 		since = READ_ONCE(dst->f_wb_err);
>>> -		status = vfs_fsync_range(dst, copy->cp_dst_pos,
>>> -					 copy->cp_res.wr_bytes_written, 0);
>>> +		end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1;
>>> +		status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0);
>>> 		if (!status)
>>> 			status = filemap_check_wb_err(dst->f_mapping, since);
>>> 		if (!status)
>>> -- 
>>> 2.37.3
>>> 
>> --
>> Chuck Lever

--
Chuck Lever




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] NFSD: pass range end to vfs_fsync_range() instead of count
  2022-11-16 19:01     ` Chuck Lever III
@ 2022-11-16 19:08       ` dai.ngo
  0 siblings, 0 replies; 5+ messages in thread
From: dai.ngo @ 2022-11-16 19:08 UTC (permalink / raw)
  To: Chuck Lever III; +Cc: Olga Kornievskaia, Linux NFS Mailing List, Brian Foster


On 11/16/22 11:01 AM, Chuck Lever III wrote:
>
>> On Nov 16, 2022, at 1:50 PM, Dai Ngo <dai.ngo@oracle.com> wrote:
>>
>>
>> On 11/16/22 7:34 AM, Chuck Lever III wrote:
>>>> On Nov 16, 2022, at 10:28 AM, Brian Foster <bfoster@redhat.com> wrote:
>>>>
>>>> _nfsd_copy_file_range() calls vfs_fsync_range() with an offset and
>>>> count (bytes written), but the former wants the start and end bytes
>>>> of the range to sync. Fix it up.
>>>>
>>>> Fixes: eac0b17a77fb ("NFSD add vfs_fsync after async copy is done")
>>>> Signed-off-by: Brian Foster <bfoster@redhat.com>
>>>> ---
>>>>
>>>> Hi all,
>>>>
>>>> This is just a quick drive-by patch from scanning through various flush
>>>> callers for something unrelated. It looked like this instance passes a
>>>> count instead of the end offset and it was easy enough to throw up a
>>>> patch. Compile tested only, feel free to toss it if I've just missed
>>>> something, etc. etc.
>>> Dai, Olga, can you review this, and one of you test it?
>> LGTM, tested ok.
> May I add Tested-by: Dai Ngo <dai.ngo@oracle.com> ?

Yes,

Thanks,
-Dai

>
>
>> -Dai
>>
>>>
>>>> Brian
>>>>
>>>> fs/nfsd/nfs4proc.c | 5 +++--
>>>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
>>>> index 8beb2bc4c328..3c67d4cb1eba 100644
>>>> --- a/fs/nfsd/nfs4proc.c
>>>> +++ b/fs/nfsd/nfs4proc.c
>>>> @@ -1644,6 +1644,7 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
>>>> 	u64 src_pos = copy->cp_src_pos;
>>>> 	u64 dst_pos = copy->cp_dst_pos;
>>>> 	int status;
>>>> +	loff_t end;
>>>>
>>>> 	/* See RFC 7862 p.67: */
>>>> 	if (bytes_total == 0)
>>>> @@ -1663,8 +1664,8 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
>>>> 	/* for a non-zero asynchronous copy do a commit of data */
>>>> 	if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) {
>>>> 		since = READ_ONCE(dst->f_wb_err);
>>>> -		status = vfs_fsync_range(dst, copy->cp_dst_pos,
>>>> -					 copy->cp_res.wr_bytes_written, 0);
>>>> +		end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1;
>>>> +		status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0);
>>>> 		if (!status)
>>>> 			status = filemap_check_wb_err(dst->f_mapping, since);
>>>> 		if (!status)
>>>> -- 
>>>> 2.37.3
>>>>
>>> --
>>> Chuck Lever
> --
> Chuck Lever
>
>
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-16 19:08 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-16 15:28 [PATCH] NFSD: pass range end to vfs_fsync_range() instead of count Brian Foster
2022-11-16 15:34 ` Chuck Lever III
2022-11-16 18:50   ` dai.ngo
2022-11-16 19:01     ` Chuck Lever III
2022-11-16 19:08       ` dai.ngo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.