Re: [PATCH 03/11] ntfs: punch all-zero compressed blocks
Hyunchul Lee <[email protected]> Thu, 23 Jul 2026 11:13:22 +0900
| Newsgroups | dev.linux.lists.ntfs |
|---|---|
| Message-ID | <CANFS6bbyyxMM4H4F07PiJvW5Gc4Onw6-YaLND28KePm02umBCQ@mail.gmail.com> |
2026=EB=85=84 7=EC=9B=94 21=EC=9D=BC (=ED=99=94) =EC=98=A4=ED=9B=84 6:54, N= amjae Jeon <[email protected]>=EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > When a rewritten compression block consists entirely of zeroes, > ntfs_write_cb() returns without replacing its existing runlist mapping. > The old on-disk contents therefore remain visible after cache eviction. > > Punch the compression unit so that reads resolve it as a sparse block and > release any clusters that held the previous contents. > > Signed-off-by: Namjae Jeon <[email protected]> Looks good to me. Reviewed-by: Hyunchul Lee <[email protected]> > --- > fs/ntfs/compress.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c > index 006b8831836c..33ed0456bf7e 100644 > --- a/fs/ntfs/compress.c > +++ b/fs/ntfs/compress.c > @@ -1279,9 +1279,10 @@ static int ntfs_write_cb(struct ntfs_inode *ni, lo= ff_t pos, struct page **pages, > int i, err; > int pages_count =3D (round_up(ni->itype.compressed.block_size + 2= * > (ni->itype.compressed.block_size / NTFS_SB_SIZE) + 2, PAG= E_SIZE)) / PAGE_SIZE; > + u32 cb_clusters =3D ni->itype.compressed.block_clusters; > size_t new_rl_count; > struct bio *bio =3D NULL; > - loff_t new_length; > + loff_t cb_pos, new_length; > s64 new_vcn; > > in_mapping =3D vmap(pages, pages_per_cb, VM_MAP, PAGE_KERNEL_RO); > @@ -1351,6 +1352,9 @@ static int ntfs_write_cb(struct ntfs_inode *ni, lof= f_t pos, struct page **pages, > } > } > > + cb_pos =3D pos & ~((loff_t)ni->itype.compressed.block_size - 1); > + new_vcn =3D ntfs_bytes_to_cluster(vol, cb_pos); > + > if (!fail && !allzeroes) { > outbuf[compsz++] =3D 0; > outbuf[compsz++] =3D 0; > @@ -1359,7 +1363,7 @@ static int ntfs_write_cb(struct ntfs_inode *ni, lof= f_t pos, struct page **pages, > bio_size =3D rounded; > pages =3D pages_disk; > } else if (allzeroes) { > - err =3D 0; > + err =3D ntfs_non_resident_attr_punch_hole(ni, new_vcn, cb= _clusters); > goto out; > } else { > memcpy(outbuf, inbuf, insz); > @@ -1367,8 +1371,6 @@ static int ntfs_write_cb(struct ntfs_inode *ni, lof= f_t pos, struct page **pages, > pages =3D pages_disk; > } > > - new_vcn =3D ntfs_bytes_to_cluster(vol, > - pos & ~((loff_t)ni->itype.compressed.block_size -= 1)); > new_length =3D ntfs_bytes_to_cluster(vol, round_up(bio_size, vol-= >cluster_size)); > > err =3D ntfs_non_resident_attr_punch_hole(ni, new_vcn, ni->itype.= compressed.block_clusters); > -- > 2.34.1 > --=20 Thanks, Hyunchul