diff mbox series

ksmbd: remove unnecessary generic_fillattr in smb2_open

Message ID 20220809224522.11725-1-hyc.lee@gmail.com (mailing list archive)
State New, archived
Headers show
Series ksmbd: remove unnecessary generic_fillattr in smb2_open | expand

Commit Message

Hyunchul Lee Aug. 9, 2022, 10:45 p.m. UTC
Move the call of ksmbd_vfs_getattr above the place
where stat is needed, and remove unnecessary
the call of generic_fillattr.

This patch fixes wrong AllocationSize of SMB2_CREATE
response because generic_fillattr does not reflect
i_blocks for delayed allocation.

Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
---
 fs/ksmbd/smb2pdu.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

Comments

Namjae Jeon Aug. 10, 2022, 12:46 a.m. UTC | #1
2022-08-10 7:45 GMT+09:00, Hyunchul Lee <hyc.lee@gmail.com>:
> Move the call of ksmbd_vfs_getattr above the place
> where stat is needed, and remove unnecessary
> the call of generic_fillattr.
>
> This patch fixes wrong AllocationSize of SMB2_CREATE
> response because generic_fillattr does not reflect
> i_blocks for delayed allocation.
Could you please elaborate more ? I didn't understand how moving a few
lines would fix this.

>
> Signed-off-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
>  fs/ksmbd/smb2pdu.c | 15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)
>
> diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
> index 9751cc92c111..d0a0256334ea 100644
> --- a/fs/ksmbd/smb2pdu.c
> +++ b/fs/ksmbd/smb2pdu.c
> @@ -3042,12 +3042,6 @@ int smb2_open(struct ksmbd_work *work)
>  	list_add(&fp->node, &fp->f_ci->m_fp_list);
>  	write_unlock(&fp->f_ci->m_lock);
>
> -	rc = ksmbd_vfs_getattr(&path, &stat);
> -	if (rc) {
> -		generic_fillattr(user_ns, d_inode(path.dentry), &stat);
> -		rc = 0;
> -	}
> -
>  	/* Check delete pending among previous fp before oplock break */
>  	if (ksmbd_inode_pending_delete(fp)) {
>  		rc = -EBUSY;
> @@ -3134,6 +3128,12 @@ int smb2_open(struct ksmbd_work *work)
>  		}
>  	}
>
> +	rc = ksmbd_vfs_getattr(&path, &stat);
> +	if (rc) {
> +		generic_fillattr(user_ns, d_inode(path.dentry), &stat);
> +		rc = 0;
> +	}
> +
>  	if (stat.result_mask & STATX_BTIME)
>  		fp->create_time = ksmbd_UnixTimeToNT(stat.btime);
>  	else
> @@ -3149,9 +3149,6 @@ int smb2_open(struct ksmbd_work *work)
>
>  	memcpy(fp->client_guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE);
>
> -	generic_fillattr(user_ns, file_inode(fp->filp),
> -			 &stat);
> -
>  	rsp->StructureSize = cpu_to_le16(89);
>  	rcu_read_lock();
>  	opinfo = rcu_dereference(fp->f_opinfo);
> --
> 2.17.1
>
>
diff mbox series

Patch

diff --git a/fs/ksmbd/smb2pdu.c b/fs/ksmbd/smb2pdu.c
index 9751cc92c111..d0a0256334ea 100644
--- a/fs/ksmbd/smb2pdu.c
+++ b/fs/ksmbd/smb2pdu.c
@@ -3042,12 +3042,6 @@  int smb2_open(struct ksmbd_work *work)
 	list_add(&fp->node, &fp->f_ci->m_fp_list);
 	write_unlock(&fp->f_ci->m_lock);
 
-	rc = ksmbd_vfs_getattr(&path, &stat);
-	if (rc) {
-		generic_fillattr(user_ns, d_inode(path.dentry), &stat);
-		rc = 0;
-	}
-
 	/* Check delete pending among previous fp before oplock break */
 	if (ksmbd_inode_pending_delete(fp)) {
 		rc = -EBUSY;
@@ -3134,6 +3128,12 @@  int smb2_open(struct ksmbd_work *work)
 		}
 	}
 
+	rc = ksmbd_vfs_getattr(&path, &stat);
+	if (rc) {
+		generic_fillattr(user_ns, d_inode(path.dentry), &stat);
+		rc = 0;
+	}
+
 	if (stat.result_mask & STATX_BTIME)
 		fp->create_time = ksmbd_UnixTimeToNT(stat.btime);
 	else
@@ -3149,9 +3149,6 @@  int smb2_open(struct ksmbd_work *work)
 
 	memcpy(fp->client_guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE);
 
-	generic_fillattr(user_ns, file_inode(fp->filp),
-			 &stat);
-
 	rsp->StructureSize = cpu_to_le16(89);
 	rcu_read_lock();
 	opinfo = rcu_dereference(fp->f_opinfo);