mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
ksmbd: retrieve number of blocks using vfs_getattr in set_file_allocation_info
[ Upstream commit 34cd86b6632718b7df3999d96f51e63de41c5e4f ] Use vfs_getattr() to retrieve stat information, rather than make assumptions about how a filesystem fills inode structs. Cc: stable@vger.kernel.org Signed-off-by: Marios Makassikis <mmakassikis@freebox.fr> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4ee09d4099
commit
2952d0db18
@@ -5757,15 +5757,21 @@ static int set_file_allocation_info(struct ksmbd_work *work,
|
|||||||
|
|
||||||
loff_t alloc_blks;
|
loff_t alloc_blks;
|
||||||
struct inode *inode;
|
struct inode *inode;
|
||||||
|
struct kstat stat;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!(fp->daccess & FILE_WRITE_DATA_LE))
|
if (!(fp->daccess & FILE_WRITE_DATA_LE))
|
||||||
return -EACCES;
|
return -EACCES;
|
||||||
|
|
||||||
|
rc = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS,
|
||||||
|
AT_STATX_SYNC_AS_STAT);
|
||||||
|
if (rc)
|
||||||
|
return rc;
|
||||||
|
|
||||||
alloc_blks = (le64_to_cpu(file_alloc_info->AllocationSize) + 511) >> 9;
|
alloc_blks = (le64_to_cpu(file_alloc_info->AllocationSize) + 511) >> 9;
|
||||||
inode = file_inode(fp->filp);
|
inode = file_inode(fp->filp);
|
||||||
|
|
||||||
if (alloc_blks > inode->i_blocks) {
|
if (alloc_blks > stat.blocks) {
|
||||||
smb_break_all_levII_oplock(work, fp, 1);
|
smb_break_all_levII_oplock(work, fp, 1);
|
||||||
rc = vfs_fallocate(fp->filp, FALLOC_FL_KEEP_SIZE, 0,
|
rc = vfs_fallocate(fp->filp, FALLOC_FL_KEEP_SIZE, 0,
|
||||||
alloc_blks * 512);
|
alloc_blks * 512);
|
||||||
@@ -5773,7 +5779,7 @@ static int set_file_allocation_info(struct ksmbd_work *work,
|
|||||||
pr_err("vfs_fallocate is failed : %d\n", rc);
|
pr_err("vfs_fallocate is failed : %d\n", rc);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
} else if (alloc_blks < inode->i_blocks) {
|
} else if (alloc_blks < stat.blocks) {
|
||||||
loff_t size;
|
loff_t size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user