Skip to content

Commit 6cc2268

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: fix incorrect AllocationSize set in smb2_get_info
If filesystem support sparse file, ksmbd should return allocated size using ->i_blocks instead of stat->size. This fix generic/694 xfstests. Cc: stable@vger.kernel.org Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 3632252 commit 6cc2268

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

fs/smb/server/smb2pdu.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4369,21 +4369,6 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,
43694369
return 0;
43704370
}
43714371

4372-
static unsigned long long get_allocation_size(struct inode *inode,
4373-
struct kstat *stat)
4374-
{
4375-
unsigned long long alloc_size = 0;
4376-
4377-
if (!S_ISDIR(stat->mode)) {
4378-
if ((inode->i_blocks << 9) <= stat->size)
4379-
alloc_size = stat->size;
4380-
else
4381-
alloc_size = inode->i_blocks << 9;
4382-
}
4383-
4384-
return alloc_size;
4385-
}
4386-
43874372
static void get_file_standard_info(struct smb2_query_info_rsp *rsp,
43884373
struct ksmbd_file *fp, void *rsp_org)
43894374
{
@@ -4398,7 +4383,7 @@ static void get_file_standard_info(struct smb2_query_info_rsp *rsp,
43984383
sinfo = (struct smb2_file_standard_info *)rsp->Buffer;
43994384
delete_pending = ksmbd_inode_pending_delete(fp);
44004385

4401-
sinfo->AllocationSize = cpu_to_le64(get_allocation_size(inode, &stat));
4386+
sinfo->AllocationSize = cpu_to_le64(inode->i_blocks << 9);
44024387
sinfo->EndOfFile = S_ISDIR(stat.mode) ? 0 : cpu_to_le64(stat.size);
44034388
sinfo->NumberOfLinks = cpu_to_le32(get_nlink(&stat) - delete_pending);
44044389
sinfo->DeletePending = delete_pending;
@@ -4463,7 +4448,7 @@ static int get_file_all_info(struct ksmbd_work *work,
44634448
file_info->Attributes = fp->f_ci->m_fattr;
44644449
file_info->Pad1 = 0;
44654450
file_info->AllocationSize =
4466-
cpu_to_le64(get_allocation_size(inode, &stat));
4451+
cpu_to_le64(inode->i_blocks << 9);
44674452
file_info->EndOfFile = S_ISDIR(stat.mode) ? 0 : cpu_to_le64(stat.size);
44684453
file_info->NumberOfLinks =
44694454
cpu_to_le32(get_nlink(&stat) - delete_pending);
@@ -4652,7 +4637,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
46524637
file_info->ChangeTime = cpu_to_le64(time);
46534638
file_info->Attributes = fp->f_ci->m_fattr;
46544639
file_info->AllocationSize =
4655-
cpu_to_le64(get_allocation_size(inode, &stat));
4640+
cpu_to_le64(inode->i_blocks << 9);
46564641
file_info->EndOfFile = S_ISDIR(stat.mode) ? 0 : cpu_to_le64(stat.size);
46574642
file_info->Reserved = cpu_to_le32(0);
46584643
rsp->OutputBufferLength =

0 commit comments

Comments
 (0)