Skip to content

Commit 5fade64

Browse files
committed
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. Signed-off-by: Namjae Jeon <[email protected]>
1 parent 1004a10 commit 5fade64

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

smb2pdu.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4624,21 +4624,6 @@ static int get_file_basic_info(struct smb2_query_info_rsp *rsp,
46244624
return 0;
46254625
}
46264626

4627-
static unsigned long long get_allocation_size(struct inode *inode,
4628-
struct kstat *stat)
4629-
{
4630-
unsigned long long alloc_size = 0;
4631-
4632-
if (!S_ISDIR(stat->mode)) {
4633-
if ((inode->i_blocks << 9) <= stat->size)
4634-
alloc_size = stat->size;
4635-
else
4636-
alloc_size = inode->i_blocks << 9;
4637-
}
4638-
4639-
return alloc_size;
4640-
}
4641-
46424627
static void get_file_standard_info(struct smb2_query_info_rsp *rsp,
46434628
struct ksmbd_file *fp, void *rsp_org)
46444629
{
@@ -4661,7 +4646,7 @@ static void get_file_standard_info(struct smb2_query_info_rsp *rsp,
46614646
sinfo = (struct smb2_file_standard_info *)rsp->Buffer;
46624647
delete_pending = ksmbd_inode_pending_delete(fp);
46634648

4664-
sinfo->AllocationSize = cpu_to_le64(get_allocation_size(inode, &stat));
4649+
sinfo->AllocationSize = cpu_to_le64(inode->i_blocks << 9);
46654650
sinfo->EndOfFile = S_ISDIR(stat.mode) ? 0 : cpu_to_le64(stat.size);
46664651
sinfo->NumberOfLinks = cpu_to_le32(get_nlink(&stat) - delete_pending);
46674652
sinfo->DeletePending = delete_pending;
@@ -4734,7 +4719,7 @@ static int get_file_all_info(struct ksmbd_work *work,
47344719
file_info->Attributes = fp->f_ci->m_fattr;
47354720
file_info->Pad1 = 0;
47364721
file_info->AllocationSize =
4737-
cpu_to_le64(get_allocation_size(inode, &stat));
4722+
cpu_to_le64(inode->i_blocks << 9);
47384723
file_info->EndOfFile = S_ISDIR(stat.mode) ? 0 : cpu_to_le64(stat.size);
47394724
file_info->NumberOfLinks =
47404725
cpu_to_le32(get_nlink(&stat) - delete_pending);
@@ -4949,7 +4934,7 @@ static int get_file_network_open_info(struct smb2_query_info_rsp *rsp,
49494934
file_info->ChangeTime = cpu_to_le64(time);
49504935
file_info->Attributes = fp->f_ci->m_fattr;
49514936
file_info->AllocationSize =
4952-
cpu_to_le64(get_allocation_size(inode, &stat));
4937+
cpu_to_le64(inode->i_blocks << 9);
49534938
file_info->EndOfFile = S_ISDIR(stat.mode) ? 0 : cpu_to_le64(stat.size);
49544939
file_info->Reserved = cpu_to_le32(0);
49554940
rsp->OutputBufferLength =

0 commit comments

Comments
 (0)