diff mbox series

[2/2] ksmbd: remove generic_fillattr use in smb2_open()

Message ID 20220830141732.9982-2-linkinjeon@kernel.org
State New
Headers show
Series [1/2] ksmbd: update documentation | expand

Commit Message

Namjae Jeon Aug. 30, 2022, 2:17 p.m. UTC
Removed the use of unneeded generic_fillattr() in smb2_open().

Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
 fs/ksmbd/smb2pdu.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Hyunchul Lee Sept. 1, 2022, 6:08 a.m. UTC | #1
2022년 8월 30일 (화) 오후 11:17, Namjae Jeon <linkinjeon@kernel.org>님이 작성:
>
> Removed the use of unneeded generic_fillattr() in smb2_open().
>
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>

> ---
>  fs/ksmbd/smb2pdu.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index c49f65146ab3..ad6410874b95 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -2761,7 +2761,6 @@ int smb2_open(struct ksmbd_work *work)
>         } else {
>                 file_present = true;
>                 user_ns = mnt_user_ns(path.mnt);
> -               generic_fillattr(user_ns, d_inode(path.dentry), &stat);
>         }
>         if (stream_name) {
>                 if (req->CreateOptions & FILE_DIRECTORY_FILE_LE) {
> @@ -2770,7 +2769,8 @@ int smb2_open(struct ksmbd_work *work)
>                                 rsp->hdr.Status = STATUS_NOT_A_DIRECTORY;
>                         }
>                 } else {
> -                       if (S_ISDIR(stat.mode) && s_type == DATA_STREAM) {
> +                       if (file_present && S_ISDIR(d_inode(path.dentry)->i_mode) &&
> +                           s_type == DATA_STREAM) {
>                                 rc = -EIO;
>                                 rsp->hdr.Status = STATUS_FILE_IS_A_DIRECTORY;
>                         }
> @@ -2787,7 +2787,8 @@ int smb2_open(struct ksmbd_work *work)
>         }
>
>         if (file_present && req->CreateOptions & FILE_NON_DIRECTORY_FILE_LE &&
> -           S_ISDIR(stat.mode) && !(req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)) {
> +           S_ISDIR(d_inode(path.dentry)->i_mode) &&
> +           !(req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)) {
>                 ksmbd_debug(SMB, "open() argument is a directory: %s, %x\n",
>                             name, req->CreateOptions);
>                 rsp->hdr.Status = STATUS_FILE_IS_A_DIRECTORY;
> @@ -2797,7 +2798,7 @@ int smb2_open(struct ksmbd_work *work)
>
>         if (file_present && (req->CreateOptions & FILE_DIRECTORY_FILE_LE) &&
>             !(req->CreateDisposition == FILE_CREATE_LE) &&
> -           !S_ISDIR(stat.mode)) {
> +           !S_ISDIR(d_inode(path.dentry)->i_mode)) {
>                 rsp->hdr.Status = STATUS_NOT_A_DIRECTORY;
>                 rc = -EIO;
>                 goto err_out;
> --
> 2.25.1
>
diff mbox series

Patch

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index c49f65146ab3..ad6410874b95 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -2761,7 +2761,6 @@  int smb2_open(struct ksmbd_work *work)
 	} else {
 		file_present = true;
 		user_ns = mnt_user_ns(path.mnt);
-		generic_fillattr(user_ns, d_inode(path.dentry), &stat);
 	}
 	if (stream_name) {
 		if (req->CreateOptions & FILE_DIRECTORY_FILE_LE) {
@@ -2770,7 +2769,8 @@  int smb2_open(struct ksmbd_work *work)
 				rsp->hdr.Status = STATUS_NOT_A_DIRECTORY;
 			}
 		} else {
-			if (S_ISDIR(stat.mode) && s_type == DATA_STREAM) {
+			if (file_present && S_ISDIR(d_inode(path.dentry)->i_mode) &&
+			    s_type == DATA_STREAM) {
 				rc = -EIO;
 				rsp->hdr.Status = STATUS_FILE_IS_A_DIRECTORY;
 			}
@@ -2787,7 +2787,8 @@  int smb2_open(struct ksmbd_work *work)
 	}
 
 	if (file_present && req->CreateOptions & FILE_NON_DIRECTORY_FILE_LE &&
-	    S_ISDIR(stat.mode) && !(req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)) {
+	    S_ISDIR(d_inode(path.dentry)->i_mode) &&
+	    !(req->CreateOptions & FILE_DELETE_ON_CLOSE_LE)) {
 		ksmbd_debug(SMB, "open() argument is a directory: %s, %x\n",
 			    name, req->CreateOptions);
 		rsp->hdr.Status = STATUS_FILE_IS_A_DIRECTORY;
@@ -2797,7 +2798,7 @@  int smb2_open(struct ksmbd_work *work)
 
 	if (file_present && (req->CreateOptions & FILE_DIRECTORY_FILE_LE) &&
 	    !(req->CreateDisposition == FILE_CREATE_LE) &&
-	    !S_ISDIR(stat.mode)) {
+	    !S_ISDIR(d_inode(path.dentry)->i_mode)) {
 		rsp->hdr.Status = STATUS_NOT_A_DIRECTORY;
 		rc = -EIO;
 		goto err_out;