fs/ntfs3: Implement fallocate for compressed files
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
This commit is contained in:
parent
70dd48ca3a
commit
9a2d6a40b8
@ -976,15 +976,17 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
|
|||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
/* Check for compressed frame. */
|
/* Check for compressed frame. */
|
||||||
err = attr_is_frame_compressed(ni, attr, vcn >> NTFS_LZNT_CUNIT, &hint);
|
err = attr_is_frame_compressed(ni, attr_b, vcn >> NTFS_LZNT_CUNIT,
|
||||||
|
&hint);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (hint) {
|
if (hint) {
|
||||||
/* if frame is compressed - don't touch it. */
|
/* if frame is compressed - don't touch it. */
|
||||||
*lcn = COMPRESSED_LCN;
|
*lcn = COMPRESSED_LCN;
|
||||||
*len = hint;
|
/* length to the end of frame. */
|
||||||
err = -EOPNOTSUPP;
|
*len = NTFS_LZNT_CLUSTERS - (vcn & (NTFS_LZNT_CLUSTERS - 1));
|
||||||
|
err = 0;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1027,16 +1029,16 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
|
|||||||
|
|
||||||
/* Check if 'vcn' and 'vcn0' in different attribute segments. */
|
/* Check if 'vcn' and 'vcn0' in different attribute segments. */
|
||||||
if (vcn < svcn || evcn1 <= vcn) {
|
if (vcn < svcn || evcn1 <= vcn) {
|
||||||
/* Load attribute for truncated vcn. */
|
struct ATTRIB *attr2;
|
||||||
attr = ni_find_attr(ni, attr_b, &le, ATTR_DATA, NULL, 0,
|
/* Load runs for truncated vcn. */
|
||||||
&vcn, &mi);
|
attr2 = ni_find_attr(ni, attr_b, &le_b, ATTR_DATA, NULL,
|
||||||
if (!attr) {
|
0, &vcn, &mi);
|
||||||
|
if (!attr2) {
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
svcn = le64_to_cpu(attr->nres.svcn);
|
evcn1 = le64_to_cpu(attr2->nres.evcn) + 1;
|
||||||
evcn1 = le64_to_cpu(attr->nres.evcn) + 1;
|
err = attr_load_runs(attr2, ni, run, NULL);
|
||||||
err = attr_load_runs(attr, ni, run, NULL);
|
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -1517,6 +1519,9 @@ out:
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* attr_is_frame_compressed - Used to detect compressed frame.
|
* attr_is_frame_compressed - Used to detect compressed frame.
|
||||||
|
*
|
||||||
|
* attr - base (primary) attribute segment.
|
||||||
|
* Only base segments contains valid 'attr->nres.c_unit'
|
||||||
*/
|
*/
|
||||||
int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr,
|
int attr_is_frame_compressed(struct ntfs_inode *ni, struct ATTRIB *attr,
|
||||||
CLST frame, CLST *clst_data)
|
CLST frame, CLST *clst_data)
|
||||||
|
@ -609,7 +609,8 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,
|
|||||||
|
|
||||||
bytes = ((u64)len << cluster_bits) - off;
|
bytes = ((u64)len << cluster_bits) - off;
|
||||||
|
|
||||||
if (lcn == SPARSE_LCN) {
|
if (lcn >= sbi->used.bitmap.nbits) {
|
||||||
|
/* This case includes resident/compressed/sparse. */
|
||||||
if (!create) {
|
if (!create) {
|
||||||
if (bh->b_size > bytes)
|
if (bh->b_size > bytes)
|
||||||
bh->b_size = bytes;
|
bh->b_size = bytes;
|
||||||
|
Loading…
Reference in New Issue
Block a user