From: Patrick Farrell Date: Mon, 20 Nov 2023 00:40:27 +0000 (-0500) Subject: EX-7601 osd: add assert for prepare partial page X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=07f106bb6486c89ff503300035da09b7f9008733;p=fs%2Flustre-release.git EX-7601 osd: add assert for prepare partial page In the write prep code, we read up any partial pages (pages which are not completely overwritten by the write) to prepare them for write. But for compressed files, we will have already done this to prepare for decompression. Add an assert to make sure we catch if this is ever wrong. Signed-off-by: Patrick Farrell Change-Id: I1366b1f5b191a4d581448d692933d562198c3a1f Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53179 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Artem Blagodarenko --- diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index bc55cbe..4e1fa32 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -1328,6 +1328,7 @@ static int osd_write_prep(const struct lu_env *env, struct dt_object *dt, maxidx = ((isize + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1; start = ktime_get(); + /* add partial pages for read to prepare them for write */ for (i = 0; i < npages; i++) { /* @@ -1339,6 +1340,11 @@ static int osd_write_prep(const struct lu_env *env, struct dt_object *dt, if (lnb[i].lnb_len == PAGE_SIZE) continue; + /* for compressed components, any partial pages have already + * been read up, so we should never add one here for the + * partial page reads + */ + LASSERT(!(lnb[i].lnb_flags & OBD_BRW_COMPRESSED)); if (maxidx >= lnb[i].lnb_page->index) { osd_iobuf_add_page(iobuf, &lnb[i]); @@ -1360,12 +1366,12 @@ static int osd_write_prep(const struct lu_env *env, struct dt_object *dt, timediff = ktime_us_delta(end, start); lprocfs_counter_add(osd->od_stats, LPROC_OSD_GET_PAGE, timediff); + /* do read to prepare partial pages for write */ if (iobuf->dr_npages) { rc = osd_ldiskfs_map_inode_pages(inode, iobuf, osd, 0, 0, 0, NULL); if (likely(rc == 0)) { rc = osd_do_bio(osd, inode, iobuf, 0, 0); - /* do IO stats for preparation reads */ osd_fini_iobuf(osd, iobuf); } }