From f8299fdf41442e007d531aee21f73146b6d1bd92 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Thu, 2 Nov 2023 17:26:58 -0400 Subject: [PATCH] EX-7601 tgt: identify writes to round If the beginning or end of a client write is unaligned, we must round the locking. This patch identifies writes where this is required, the next patch will do the locking. Signed-off-by: Patrick Farrell Change-Id: Iec140c24423a0da478f6d42ff6fc620d7ad3ba4a Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52960 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Artem Blagodarenko Reviewed-by: Andreas Dilger --- lustre/target/tgt_handler.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index fdf34e0..01787c3 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -2811,11 +2811,11 @@ int tgt_brw_write(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 cksum_types cksum_type = OBD_CKSUM_CRC32; /* '1' for consistency with code that checks !mpflag to restore */ unsigned int mpflags = 1; - struct ost_layout_compr *olc; enum ll_compr_type type; bool wait_sync = false; bool no_reply = false; @@ -2922,14 +2922,38 @@ int tgt_brw_write(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 = io_start; + chunk_end = io_end; + + chunk_round(&chunk_start, &chunk_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 write\n"); } rc = tgt_brw_lock(tsi->tsi_env, exp, &tsi->tsi_resid, remote_nb, &lockh, -- 1.8.3.1