From 28e9fbedf0175441ae57a2351f11bad6d33cd00f Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Fri, 27 Oct 2023 15:29:24 -0400 Subject: [PATCH] EX-7601 ofd: add chunk_size to preprw_read preprw_read needs chunk size for rounding. Add this in a separate patch to keep things trivial, it will be used in a subsequent patch. Also use this to add a check in DOM to ensure it doesn't attempt to do compression. This should already be prevented by setstripe, so this is just an extra safety check. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I9dc4d1559e5c8be315268a593466571b54c90a96 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52866 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Artem Blagodarenko Reviewed-by: Andreas Dilger --- lustre/include/obd.h | 3 ++- lustre/include/obd_class.h | 4 ++-- lustre/mdt/mdt_internal.h | 2 +- lustre/mdt/mdt_io.c | 12 +++++++++++- lustre/obdecho/echo.c | 2 +- lustre/obdecho/echo_client.c | 3 ++- lustre/ofd/ofd_internal.h | 2 +- lustre/ofd/ofd_io.c | 10 ++++++---- lustre/target/tgt_handler.c | 7 ++++--- 9 files changed, 30 insertions(+), 15 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index c16f62e..f03c2e6 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -1063,7 +1063,8 @@ struct obd_ops { int (*o_preprw)(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *remote, - int *nr_pages, struct niobuf_local *local); + int *nr_pages, struct niobuf_local *local, + int chunk_size); int (*o_commitrw)(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index db4a3cb..55a1b32 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1111,7 +1111,7 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *remote, int *pages, - struct niobuf_local *local) + struct niobuf_local *local, int chunk_size) { int rc; @@ -1128,7 +1128,7 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, } rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, - pages, local); + pages, local, chunk_size); RETURN(rc); } diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index 8f46cf2..2a3f634 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -1384,7 +1384,7 @@ static inline char *mdt_req_get_jobid(struct ptlrpc_request *req) int mdt_obd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, 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); int mdt_obd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, diff --git a/lustre/mdt/mdt_io.c b/lustre/mdt/mdt_io.c index 5fb428e..c7e044e 100644 --- a/lustre/mdt/mdt_io.c +++ b/lustre/mdt/mdt_io.c @@ -512,7 +512,7 @@ unlock: int mdt_obd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, 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 tgt_session_info *tsi = tgt_ses_info(env); struct mdt_thread_info *info = tsi2mdt_info(tsi); @@ -521,6 +521,16 @@ int mdt_obd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, struct mdt_object *mo; int rc = 0; + /* this should never be hit because setstripe does not allow DOM + + * compression, but it's here just in case + */ + if (chunk_size != 0) { + rc = -EOPNOTSUPP; + CERROR("%s: Compression is not supported on dom, rc %d\n", + exp->exp_obd->obd_name, rc); + GOTO(out, rc); + } + /* The default value PTLRPC_MAX_BRW_PAGES is set in tgt_brw_write() * but for MDT it is different, correct it here. */ if (*nr_local > MD_MAX_BRW_PAGES) diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index 812c4ac6..56d5b0c 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -309,7 +309,7 @@ static int echo_preprw(const struct lu_env *env, int cmd, struct obd_export *export, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *nb, int *pages, - struct niobuf_local *res) + struct niobuf_local *res, int chunk_size) { struct obd_device *obd; int tot_bytes = 0; diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 86beda5..40d32fc 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -2692,7 +2692,8 @@ static int echo_client_prep_commit(const struct lu_env *env, off += npages * PAGE_SIZE; lpages = npages; - ret = obd_preprw(env, rw, exp, oa, 1, &ioo, &rnb, &lpages, lnb); + ret = obd_preprw(env, rw, exp, oa, 1, &ioo, &rnb, &lpages, lnb, + 0); if (ret != 0) GOTO(out, ret); diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 1bde618..c0f2227 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -349,7 +349,7 @@ int ofd_verify_layout_version(const struct lu_env *env, int ofd_preprw(const struct lu_env *env,int cmd, struct obd_export *exp, 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); int ofd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *rnb, int npages, diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index c381c49..379ca9a 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -577,7 +577,7 @@ out_tx: * \param[in] rnb remote buffers * \param[in] nr_local number of local buffers * \param[in] lnb local buffers - * \param[in] jobid job ID name + * \param[in] chunk_size compression chunk size * * \retval 0 on successful prepare * \retval negative value on error @@ -586,7 +586,7 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp, struct ofd_device *ofd, const struct lu_fid *fid, struct lu_attr *la, struct obdo *oa, int niocount, 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, rc, tot_bytes = 0; @@ -903,6 +903,7 @@ out: * \param[in] rnb remote buffers * \param[in] nr_local number of local buffers * \param[in] lnb local buffers + * \param[in] chunk compression chunk size * * \retval 0 on successful prepare * \retval negative value on error @@ -910,7 +911,7 @@ out: int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, 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 tgt_session_info *tsi = tgt_ses_info(env); struct ofd_device *ofd = ofd_exp(exp); @@ -963,7 +964,8 @@ int ofd_preprw(const struct lu_env *env, int cmd, struct obd_export *exp, } 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, - obj->ioo_bufcnt, rnb, nr_local, lnb); + obj->ioo_bufcnt, rnb, nr_local, lnb, + chunk_size); } else { CERROR("%s: wrong cmd %d received!\n", exp->exp_obd->obd_name, cmd); diff --git a/lustre/target/tgt_handler.c b/lustre/target/tgt_handler.c index 463ddb3..ff97954 100644 --- a/lustre/target/tgt_handler.c +++ b/lustre/target/tgt_handler.c @@ -2314,6 +2314,7 @@ int tgt_brw_read(struct tgt_session_info *tsi) const char *obd_name = exp->exp_obd->obd_name; bool compr_rounded_read_lock = false; enum ll_compr_type type; + int chunk_size = 0; int no_reply = 0; int npages_read; ktime_t kstart; @@ -2392,7 +2393,6 @@ int tgt_brw_read(struct tgt_session_info *tsi) unsigned int chunk_log_bits; __u64 chunk_start; __u64 chunk_end; - int chunk_size; __u64 io_start; __u64 io_end; @@ -2460,8 +2460,9 @@ int tgt_brw_read(struct tgt_session_info *tsi) npages = PTLRPC_MAX_BRW_PAGES; kstart = ktime_get(); + rc = obd_preprw(tsi->tsi_env, OBD_BRW_READ, exp, &repbody->oa, 1, - ioo, remote_nb, &npages, local_nb); + ioo, remote_nb, &npages, local_nb, chunk_size); if (rc != 0) GOTO(out_lock, rc); @@ -2838,7 +2839,7 @@ 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); + objcount, ioo, remote_nb, &npages, local_nb, 0); if (rc < 0) GOTO(out_lock, rc); if (body->oa.o_valid & OBD_MD_FLFLAGS && -- 1.8.3.1