From 6c852d0e8334b7a1085c37e731ec73e01d2d6d22 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Thu, 2 Nov 2023 17:37:43 -0400 Subject: [PATCH] EX-7601 ofd: add chunk_size to preprw_write preprw_write needs chunk size for rounding. Add this in a separate patch to keep things trivial, it will be used in a subsequent patch. This patch is really trivial on the write side, since the read side already did most of this. But it's being kept separate for symmetry. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: Id25957dbc185b6e61b7f208cee8cf5f897f03944 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52962 Reviewed-by: Artem Blagodarenko Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/ofd/ofd_io.c | 5 +++-- lustre/target/tgt_handler.c | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index a11ba66..1ef0723 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -740,7 +740,7 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp, struct lu_attr *la, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *rnb, int *nr_local, - struct niobuf_local *lnb) + struct niobuf_local *lnb, int chunk_size) { struct ofd_object *fo; int i, j, k, rc = 0, tot_bytes = 0; @@ -1002,7 +1002,8 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, if (cmd == OBD_BRW_WRITE) { la_from_obdo(&info->fti_attr, oa, OBD_MD_FLGETATTR); rc = ofd_preprw_write(env, exp, ofd, fid, &info->fti_attr, oa, - objcount, obj, rnb, nr_local, lnb); + objcount, obj, rnb, nr_local, lnb, + chunk_size); } else if (cmd == OBD_BRW_READ) { tgt_grant_prepare_read(env, exp, oa); rc = ofd_preprw_read(env, exp, ofd, fid, &info->fti_attr, oa, diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 35bf91e..8d84fde 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -2810,6 +2810,9 @@ int tgt_brw_write(struct tgt_session_info *tsi) const char *obd_name = exp->exp_obd->obd_name; /* '1' for consistency with code that checks !mpflag to restore */ unsigned int mpflags = 1; + struct ost_layout_compr *olc; + enum ll_compr_type type; + int chunk_size = 0; ktime_t kstart; int nob = 0; @@ -2904,6 +2907,16 @@ 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) { + unsigned int chunk_log_bits; + + chunk_log_bits = olc->ol_compr_chunk_log_bits; + chunk_size = COMPR_GET_CHUNK_SIZE(chunk_log_bits); + } + rc = tgt_brw_lock(tsi->tsi_env, exp, &tsi->tsi_resid, remote_nb, &lockh, LCK_PW, niocount); if (rc != 0) @@ -2940,7 +2953,8 @@ int tgt_brw_write(struct tgt_session_info *tsi) npages = PTLRPC_MAX_BRW_PAGES; kstart = ktime_get(); rc = obd_preprw(tsi->tsi_env, OBD_BRW_WRITE, exp, &repbody->oa, - objcount, ioo, remote_nb, &npages, local_nb, 0); + objcount, ioo, remote_nb, &npages, local_nb, + chunk_size); if (rc < 0) GOTO(out_lock, rc); if (body->oa.o_valid & OBD_MD_FLFLAGS && -- 1.8.3.1