Whamcloud - gitweb
EX-7601 osd: add assert for prepare partial page
authorPatrick Farrell <pfarrell@whamcloud.com>
Mon, 20 Nov 2023 00:40:27 +0000 (19:40 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Tue, 2 Jan 2024 08:22:23 +0000 (08:22 +0000)
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 <pfarrell@whamcloud.com>
Change-Id: I1366b1f5b191a4d581448d692933d562198c3a1f
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53179
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
lustre/osd-ldiskfs/osd_io.c

index bc55cbe..4e1fa32 100644 (file)
@@ -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);
                }
        }