[PATCH v2 2/6] smb/server: fix return value of smb2_notify()

chenxiaosong.chenxiaosong@linux.dev posted 6 patches 3 months, 3 weeks ago
[PATCH v2 2/6] smb/server: fix return value of smb2_notify()
Posted by chenxiaosong.chenxiaosong@linux.dev 3 months, 3 weeks ago
From: ChenXiaoSong <chenxiaosong@kylinos.cn>

smb2_notify() should return error code when an error occurs,
__process_request() will print the error messages.

I may implement the SMB2 CHANGE_NOTIFY response (see MS-SMB2 2.2.36)
in the future.

Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
---
 fs/smb/server/smb2pdu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index f80a3dbb2d4e..5b5f25a2eb8a 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -8787,7 +8787,7 @@ int smb2_oplock_break(struct ksmbd_work *work)
  * smb2_notify() - handler for smb2 notify request
  * @work:   smb work containing notify command buffer
  *
- * Return:      0
+ * Return:      0 on success, otherwise error
  */
 int smb2_notify(struct ksmbd_work *work)
 {
@@ -8801,12 +8801,12 @@ int smb2_notify(struct ksmbd_work *work)
 	if (work->next_smb2_rcv_hdr_off && req->hdr.NextCommand) {
 		rsp->hdr.Status = STATUS_INTERNAL_ERROR;
 		smb2_set_err_rsp(work);
-		return 0;
+		return -EIO;
 	}
 
 	smb2_set_err_rsp(work);
 	rsp->hdr.Status = STATUS_NOT_IMPLEMENTED;
-	return 0;
+	return -EOPNOTSUPP;
 }
 
 /**
-- 
2.43.0
Re: [PATCH v2 2/6] smb/server: fix return value of smb2_notify()
Posted by ChenXiaoSong 2 months, 4 weeks ago
Hi Steve and Namjae,

https://chenxiaosong.com/en/smb2-change-notify.html

The link above is my analysis of the change notify feature, and my 
progress on developing this feature will be posted at this link. This 
link will remain permanently accessible.

I will complete the implementation of this feature as soon as possible.

Thanks,
ChenXiaoSong.

On 10/17/25 6:46 PM, chenxiaosong.chenxiaosong@linux.dev wrote:
> From: ChenXiaoSong <chenxiaosong@kylinos.cn>
> 
> smb2_notify() should return error code when an error occurs,
> __process_request() will print the error messages.
> 
> I may implement the SMB2 CHANGE_NOTIFY response (see MS-SMB2 2.2.36)
> in the future.
> 
> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn>
> ---
>   fs/smb/server/smb2pdu.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index f80a3dbb2d4e..5b5f25a2eb8a 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -8787,7 +8787,7 @@ int smb2_oplock_break(struct ksmbd_work *work)
>    * smb2_notify() - handler for smb2 notify request
>    * @work:   smb work containing notify command buffer
>    *
> - * Return:      0
> + * Return:      0 on success, otherwise error
>    */
>   int smb2_notify(struct ksmbd_work *work)
>   {
> @@ -8801,12 +8801,12 @@ int smb2_notify(struct ksmbd_work *work)
>   	if (work->next_smb2_rcv_hdr_off && req->hdr.NextCommand) {
>   		rsp->hdr.Status = STATUS_INTERNAL_ERROR;
>   		smb2_set_err_rsp(work);
> -		return 0;
> +		return -EIO;
>   	}
>   
>   	smb2_set_err_rsp(work);
>   	rsp->hdr.Status = STATUS_NOT_IMPLEMENTED;
> -	return 0;
> +	return -EOPNOTSUPP;
>   }
>   
>   /**
Re: [PATCH v2 2/6] smb/server: fix return value of smb2_notify()
Posted by Markus Elfring 3 months, 3 weeks ago
> smb2_notify() should return error code when an error occurs,
> __process_request() will print the error messages.
> 
> I may implement the SMB2 CHANGE_NOTIFY response (see MS-SMB2 2.2.36)
> in the future.

Will another imperative wording approach become more helpful for an improved
change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc1#n94

Regards,
Markus