Whamcloud - gitweb
EX-7601 ofd: identify reads to round
authorPatrick Farrell <pfarrell@whamcloud.com>
Fri, 27 Oct 2023 18:37:11 +0000 (14:37 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 30 Nov 2023 17:15:23 +0000 (17:15 +0000)
If the beginning or end of a client read is unaligned, we
must round the locking.  This patch identifies reads where
this is required, the next patch will do the locking.

Print a debug message when such an IO is found, but don't
do anything different - yet.

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ibdab35b733225b4b1349ef457f66ca37dcb2d9bf
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52863
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/target/tgt_handler.c

index 13dafe0..68c555d 100644 (file)
@@ -2308,7 +2308,9 @@ int tgt_brw_read(struct tgt_session_info *tsi)
        struct ost_body         *repbody;
        struct ost_body         *body;
        struct obd_ioobj        *ioo;
+       struct ost_layout_compr *olc;
        const char *obd_name = exp->exp_obd->obd_name;
+       enum ll_compr_type type;
        int no_reply = 0;
        int npages_read;
        ktime_t kstart;
@@ -2380,6 +2382,39 @@ int tgt_brw_read(struct tgt_session_info *tsi)
 
        local_nb = tbc->tbc_lnb;
 
+       olc = &body->oa.o_layout_compr;
+       type = olc->ol_compr_type;
+       if (type != LL_COMPR_TYPE_NONE) {
+               int nrbufs = ioo->ioo_bufcnt;
+               unsigned int chunk_log_bits;
+               __u64 chunk_start;
+               __u64 chunk_end;
+               int chunk_size;
+               __u64 io_start;
+               __u64 io_end;
+
+               chunk_log_bits = olc->ol_compr_chunk_log_bits;
+               chunk_size = COMPR_GET_CHUNK_SIZE(chunk_log_bits);
+
+               /* rnbs are in offset order, so we get the start of IO from the
+                * first and end of IO from the last
+                */
+               io_start = remote_nb[0].rnb_offset;
+               io_end = remote_nb[nrbufs - 1].rnb_offset +
+                        remote_nb[nrbufs - 1].rnb_len;
+
+               chunk_start = round_down(io_start, chunk_size);
+               chunk_end = round_up(io_end, chunk_size);
+
+               CDEBUG(D_SEC,
+                      "io_start: %llu io_end: %llu, chunk_start %llu, chunk_end %llu\n",
+                      io_start, io_end, chunk_start, chunk_end);
+
+               /* the start or end of this IO is unaligned */
+               if (io_start != chunk_start || io_end != chunk_end)
+                       CDEBUG(D_SEC, "unaligned IO\n");
+       }
+
        rc = tgt_brw_lock(tsi->tsi_env, exp, &tsi->tsi_resid, ioo, remote_nb,
                          &lockh, LCK_PR);
        if (rc != 0)