mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 18:41:58 +09:00
fs/ntfs3: Fix transform resident to nonresident for compressed files
[ Upstream commit 25610ff98d4a34e6a85cbe4fd8671be6b0829f8f ]
Сorrected calculation of required space len (in clusters)
for attribute data storage in case of compression.
Fixes: be71b5cba2 ("fs/ntfs3: Add attrib operations")
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
59ae9e524c
commit
2b0633368a
@@ -242,7 +242,7 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|||||||
struct ntfs_sb_info *sbi;
|
struct ntfs_sb_info *sbi;
|
||||||
struct ATTRIB *attr_s;
|
struct ATTRIB *attr_s;
|
||||||
struct MFT_REC *rec;
|
struct MFT_REC *rec;
|
||||||
u32 used, asize, rsize, aoff, align;
|
u32 used, asize, rsize, aoff;
|
||||||
bool is_data;
|
bool is_data;
|
||||||
CLST len, alen;
|
CLST len, alen;
|
||||||
char *next;
|
char *next;
|
||||||
@@ -263,10 +263,13 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
|
|||||||
rsize = le32_to_cpu(attr->res.data_size);
|
rsize = le32_to_cpu(attr->res.data_size);
|
||||||
is_data = attr->type == ATTR_DATA && !attr->name_len;
|
is_data = attr->type == ATTR_DATA && !attr->name_len;
|
||||||
|
|
||||||
align = sbi->cluster_size;
|
/* len - how many clusters required to store 'rsize' bytes */
|
||||||
if (is_attr_compressed(attr))
|
if (is_attr_compressed(attr)) {
|
||||||
align <<= NTFS_LZNT_CUNIT;
|
u8 shift = sbi->cluster_bits + NTFS_LZNT_CUNIT;
|
||||||
len = (rsize + align - 1) >> sbi->cluster_bits;
|
len = ((rsize + (1u << shift) - 1) >> shift) << NTFS_LZNT_CUNIT;
|
||||||
|
} else {
|
||||||
|
len = bytes_to_cluster(sbi, rsize);
|
||||||
|
}
|
||||||
|
|
||||||
run_init(run);
|
run_init(run);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user