Re: [PATCH 08/11] ntfs: submit one bio per compressed write unit
Hyunchul Lee <[email protected]> Thu, 23 Jul 2026 11:16:11 +0900
| Newsgroups | dev.linux.lists.ntfs |
|---|---|
| Message-ID | <CANFS6ba7DAGHvH0uanfq1+X-qZNCSQOry+5kRm_nRdFjjAbq=Q@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:55, N= amjae Jeon <[email protected]>=EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > ntfs_write_cb() allocates a single-vector bio and synchronously submits i= t > whenever another output page cannot be added. A 64 KiB uncompressed unit > therefore requires up to sixteen separate bio submissions. > > Allocate enough vectors for the complete unit, add all output pages, and > perform one synchronous submission. > > Signed-off-by: Namjae Jeon <[email protected]> Looks good to me. Reviewed-by: Hyunchul Lee <[email protected]> > --- > fs/ntfs/compress.c | 43 +++++++++++-------------------------------- > 1 file changed, 11 insertions(+), 32 deletions(-) > > diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c > index f3c14518f78e..a3af669b1008 100644 > --- a/fs/ntfs/compress.c > +++ b/fs/ntfs/compress.c > @@ -1327,7 +1327,7 @@ static int ntfs_write_cb(struct ntfs_inode *ni, lof= f_t pos, struct page **pages, > static char twozeroes[] =3D {0x02, 0xb0, 0x00, 0x00, 0x00}; > /* more compressed zeroes, to be followed by some count */ > static char morezeroes[] =3D {0x03, 0xb0, 0x02, 0x00}; > - s64 bio_lcn; > + s64 bio_lcn, bio_pos; > struct runlist_element *rlc, *rl; > int i, err; > u32 cb_clusters =3D ni->itype.compressed.block_clusters; > @@ -1410,41 +1410,20 @@ static int ntfs_write_cb(struct ntfs_inode *ni, l= off_t pos, struct page **pages, > } > > bio_lcn =3D rlc->lcn; > - i =3D 0; > - while (bio_size > 0) { > - int page_size; > - > - if (bio_size >=3D PAGE_SIZE) { > - page_size =3D PAGE_SIZE; > - bio_size -=3D PAGE_SIZE; > - } else { > - page_size =3D bio_size; > - bio_size =3D 0; > - } > + bio_pos =3D ntfs_cluster_to_bytes(vol, bio_lcn); > + bio =3D bio_alloc(vol->sb->s_bdev, DIV_ROUND_UP(bio_size, PAGE_SI= ZE), > + REQ_OP_WRITE, GFP_NOIO); > + bio->bi_iter.bi_sector =3D ntfs_bytes_to_sector(vol, bio_pos); > > -setup_bio: > - if (!bio) { > - bio =3D bio_alloc(vol->sb->s_bdev, 1, REQ_OP_WRIT= E, > - GFP_NOIO); > - if (!bio) { > - err =3D -ENOMEM; > - goto free_rlc; > - } > - bio->bi_iter.bi_sector =3D > - ntfs_bytes_to_sector(vol, > - ntfs_cluster_to_bytes(vol= , bio_lcn) + > - ((s64)i << PAGE_SHIFT)); > - } > + for (i =3D 0; bio_size; i++) { > + unsigned int len =3D min_t(unsigned int, bio_size, PAGE_S= IZE); > > - if (!bio_add_page(bio, ws->pages[i], page_size, 0)) { > - err =3D submit_bio_wait(bio); > + if (bio_add_page(bio, ws->pages[i], len, 0) !=3D len) { > + err =3D -EIO; > bio_put(bio); > - if (err) > - goto free_rlc; > - bio =3D NULL; > - goto setup_bio; > + goto free_rlc; > } > - i++; > + bio_size -=3D len; > } > > err =3D submit_bio_wait(bio); > -- > 2.34.1 > --=20 Thanks, Hyunchul