Skip to contentSkip to conversation

NFSD: Fix error return code in nfsd4_interssc_connect()

PATCH In review Wei Yongjun 3 participants 4 messages Jun 4, 2021

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

PATCH v2 1/1 NFSD: Fix error return code in nfsd4_interssc_connect()

'status' has been overwritten to 0 after nfsd4_ssc_setup_dul(), this cause 0 will be return in vfs_kern_mount() error case. Fix to return nfserr_nodev in this error.

Fixes f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")

---
v1 -> v2: change to return nfserr_nodev

---
 fs/nfsd/nfs4proc.c | 1 +
 1 file changed, 1 insertion(+)
fs/nfsd/nfs4proc.c +1 -0
index 0bd71c6da81d..b082cbde3e07 100644
@@ -1323,6 +1323,7 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
 	ss_mnt = vfs_kern_mount(type, SB_KERNMOUNT, dev_name, raw_data);
 	module_put(type->owner);
 	if (IS_ERR(ss_mnt)) {
+		status = nfserr_nodev;
 		if (work)
 			nfsd4_ssc_cancel_dul_work(nn, work);
 		goto out_free_devname;
#1 lore raw
Quoted 3 lines · Wei Yongjun

'status' has been overwritten to 0 after nfsd4_ssc_setup_dul(), this cause 0 will be return in vfs_kern_mount() error case. Fix to return nfserr_nodev in this error.

Why is that the right error? I don't see it mentioned among the errors COPY can return:

	https://datatracker.ietf.org/doc/html/rfc7862#page-50

It might be reasonable to just map the error returned by vfs_kern_mount to an nfs error, I don't know--we'd need to think about the different errors vfs_kern_mount might return.

OFFLOAD_DENIED seems safe as it should cause a fallback to a normal copy.

Same goes for the other spot here where we return nodev.

--b.

Quoted 22 lines
Fixes f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")

---
v1 -> v2: change to return nfserr_nodev

---
 fs/nfsd/nfs4proc.c | 1 +
 1 file changed, 1 insertion(+)
fs/nfsd/nfs4proc.c +1 -0
index 0bd71c6da81d..b082cbde3e07 100644
@@ -1323,6 +1323,7 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
 	ss_mnt = vfs_kern_mount(type, SB_KERNMOUNT, dev_name, raw_data);
 	module_put(type->owner);
 	if (IS_ERR(ss_mnt)) {
+		status = nfserr_nodev;
 		if (work)
 			nfsd4_ssc_cancel_dul_work(nn, work);
 		goto out_free_devname;
#2 lore raw
Quoted 5 lines · J. Bruce Fields
Quoted 3 lines · Wei Yongjun

'status' has been overwritten to 0 after nfsd4_ssc_setup_dul(), this cause 0 will be return in vfs_kern_mount() error case. Fix to return nfserr_nodev in this error.

Why is that the right error?

That was the original error before it was overwritten by nfsd4_ssc_setup_dul. However, it actually does not matter which error nfsd4_interssc_connect returns to caller since nfsd4_copy maps all errors to nfserr_offload_denied before returning it to the client.

-Dai

Quoted 37 lines

I don't see it mentioned among the errors
COPY can return:

	https://urldefense.com/v3/__https://datatracker.ietf.org/doc/html/rfc7862*page-50__;Iw!!GqivPVa7Brio!NSHjr5li4vkJl0VAWWz2mrW2wiVn9wcJfK7ZJON3bmM8REVUqI82bS4FFQdajQ$

It might be reasonable to just map the error returned by vfs_kern_mount to an nfs error, I don't know--we'd need to think about the different errors vfs_kern_mount might return.

OFFLOAD_DENIED seems safe as it should cause a fallback to a normal copy.

Same goes for the other spot here where we return nodev.

--b.

Quoted 21 lines
Fixes f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")

---
v1 -> v2: change to return nfserr_nodev

---
  fs/nfsd/nfs4proc.c | 1 +
  1 file changed, 1 insertion(+)
fs/nfsd/nfs4proc.c +1 -0
index 0bd71c6da81d..b082cbde3e07 100644
@@ -1323,6 +1323,7 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
  	ss_mnt = vfs_kern_mount(type, SB_KERNMOUNT, dev_name, raw_data);
  	module_put(type->owner);
  	if (IS_ERR(ss_mnt)) {
+		status = nfserr_nodev;
  		if (work)
  			nfsd4_ssc_cancel_dul_work(nn, work);
  		goto out_free_devname;
#3 lore raw
Quoted 6 lines · On Fri, Jun 04, 2021 at 09:36:58AM -0700, [email protected] wrote:
Quoted 4 lines · J. Bruce Fields
Quoted 3 lines · Wei Yongjun

'status' has been overwritten to 0 after nfsd4_ssc_setup_dul(), this cause 0 will be return in vfs_kern_mount() error case. Fix to return nfserr_nodev in this error.

Quoted 7 lines
Quoted 1 line

Why is that the right error?

That was the original error before it was overwritten by nfsd4_ssc_setup_dul. However, it actually does not matter which error nfsd4_interssc_connect returns to caller since nfsd4_copy maps all errors to nfserr_offload_denied before returning it to the client.

OK, I overlooked that.--b.

Quoted 40 lines

-Dai

Quoted 37 lines

I don't see it mentioned among the errors
COPY can return:

	https://urldefense.com/v3/__https://datatracker.ietf.org/doc/html/rfc7862*page-50__;Iw!!GqivPVa7Brio!NSHjr5li4vkJl0VAWWz2mrW2wiVn9wcJfK7ZJON3bmM8REVUqI82bS4FFQdajQ$

It might be reasonable to just map the error returned by vfs_kern_mount to an nfs error, I don't know--we'd need to think about the different errors vfs_kern_mount might return.

OFFLOAD_DENIED seems safe as it should cause a fallback to a normal copy.

Same goes for the other spot here where we return nodev.

--b.

Quoted 21 lines
Fixes f4e44b393389 ("NFSD: delay unmount source's export after inter-server copy completed.")

---
v1 -> v2: change to return nfserr_nodev

---
 fs/nfsd/nfs4proc.c | 1 +
 1 file changed, 1 insertion(+)
fs/nfsd/nfs4proc.c +1 -0
index 0bd71c6da81d..b082cbde3e07 100644
@@ -1323,6 +1323,7 @@ nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
 	ss_mnt = vfs_kern_mount(type, SB_KERNMOUNT, dev_name, raw_data);
 	module_put(type->owner);
 	if (IS_ERR(ss_mnt)) {
+		status = nfserr_nodev;
 		if (work)
 			nfsd4_ssc_cancel_dul_work(nn, work);
 		goto out_free_devname;