Skip to contentSkip to conversation

NFSD: pass range end to vfs_fsync_range() instead of count

PATCH In review Brian Foster 3 participants 5 messages Nov 16, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFSD: pass range end to vfs_fsync_range() instead of count

_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")

---

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(-)
fs/nfsd/nfs4proc.c +3 -2
index 8beb2bc4c328..3c67d4cb1eba 100644
@@ -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)
Signature · 1 line
2.37.3
#1 lore raw
Quoted 12 lines · Brian Foster

_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")

---

Quoted 7 lines

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?

Quoted 31 lines

Brian

fs/nfsd/nfs4proc.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -2
index 8beb2bc4c328..3c67d4cb1eba 100644
@@ -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)
Signature · 1 line
2.37.3

--
Chuck Lever

#2 lore raw
Quoted 11 lines · Chuck Lever III
Quoted 11 lines · Brian Foster

_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")

---

Quoted 8 lines
Quoted 7 lines

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

Quoted 38 lines
Quoted 33 lines

Brian

fs/nfsd/nfs4proc.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -2
index 8beb2bc4c328..3c67d4cb1eba 100644
@@ -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)
Signature · 1 line
2.37.3

--
Chuck Lever

#3 lore raw
Quoted 19 lines · Dai Ngo
Quoted 13 lines · Chuck Lever III
Quoted 13 lines · Brian Foster

_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")

---

Hi all,

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines

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 <[email protected]> ?

Quoted 37 lines

-Dai

Quoted 35 lines
Quoted 33 lines

Brian

fs/nfsd/nfs4proc.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -2
index 8beb2bc4c328..3c67d4cb1eba 100644
@@ -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)
Signature · 1 line
2.37.3

--
Chuck Lever

--
Chuck Lever

#4 lore raw
Quoted 17 lines · Chuck Lever III
Quoted 17 lines · Dai Ngo
Quoted 12 lines · Chuck Lever III
Quoted 12 lines · Brian Foster

_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")

---

Hi all,

Quoted 8 lines
Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

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 <[email protected]> ?

Yes,

Thanks,
-Dai

Quoted 43 lines
Quoted 38 lines

-Dai

Quoted 34 lines
Quoted 32 lines

Brian

fs/nfsd/nfs4proc.c | 5 +++--

1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfsd/nfs4proc.c +3 -2
index 8beb2bc4c328..3c67d4cb1eba 100644
@@ -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)
Signature · 1 line
2.37.3

--
Chuck Lever

--
Chuck Lever