Skip to content

Commit c90b31e

Browse files
hcleesmfrench
authored andcommitted
ksmbd: remove unnecessary generic_fillattr in smb2_open
Remove unnecessary generic_fillattr to fix wrong AllocationSize of SMB2_CREATE response, And Move the call of ksmbd_vfs_getattr above the place where stat is needed because of truncate. This patch fixes wrong AllocationSize of SMB2_CREATE response. Because ext4 updates inode->i_blocks only when disk space is allocated, generic_fillattr does not set stat.blocks properly for delayed allocation. But ext4 returns the blocks that include the delayed allocation blocks when getattr is called. The issue can be reproduced with commands below: touch ${FILENAME} xfs_io -c "pwrite -S 0xAB 0 40k" ${FILENAME} xfs_io -c "stat" ${FILENAME} 40KB are written, but the count of blocks is 8. Signed-off-by: Hyunchul Lee <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 4963d74 commit c90b31e

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

fs/ksmbd/smb2pdu.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3044,12 +3044,6 @@ int smb2_open(struct ksmbd_work *work)
30443044
list_add(&fp->node, &fp->f_ci->m_fp_list);
30453045
write_unlock(&fp->f_ci->m_lock);
30463046

3047-
rc = ksmbd_vfs_getattr(&path, &stat);
3048-
if (rc) {
3049-
generic_fillattr(user_ns, d_inode(path.dentry), &stat);
3050-
rc = 0;
3051-
}
3052-
30533047
/* Check delete pending among previous fp before oplock break */
30543048
if (ksmbd_inode_pending_delete(fp)) {
30553049
rc = -EBUSY;
@@ -3136,6 +3130,10 @@ int smb2_open(struct ksmbd_work *work)
31363130
}
31373131
}
31383132

3133+
rc = ksmbd_vfs_getattr(&path, &stat);
3134+
if (rc)
3135+
goto err_out;
3136+
31393137
if (stat.result_mask & STATX_BTIME)
31403138
fp->create_time = ksmbd_UnixTimeToNT(stat.btime);
31413139
else
@@ -3151,9 +3149,6 @@ int smb2_open(struct ksmbd_work *work)
31513149

31523150
memcpy(fp->client_guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE);
31533151

3154-
generic_fillattr(user_ns, file_inode(fp->filp),
3155-
&stat);
3156-
31573152
rsp->StructureSize = cpu_to_le16(89);
31583153
rcu_read_lock();
31593154
opinfo = rcu_dereference(fp->f_opinfo);

0 commit comments

Comments
 (0)