Whamcloud - gitweb
EX-7601 ofd: put decompress_read in read prep
authorPatrick Farrell <pfarrell@whamcloud.com>
Tue, 12 Dec 2023 17:29:22 +0000 (12:29 -0500)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 6 Jan 2024 08:18:56 +0000 (08:18 +0000)
ofd_decompress_read is called from ofd_write_prep for
writes, but from tgt_brw_read for reads.  This makes the
code a little harder to follow and makes it difficult to
check read side decompression against EOF.

Instead, we move the decompression call to ofd_preprw_read.
This makes no change to the real operations here, but makes
for better code (and more similar code between read and
write).

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ibefd0a48ad08e83725f2df64618db60ba61c5ce0
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/53427
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/obd.h
lustre/include/obd_class.h
lustre/ofd/ofd_io.c
lustre/ofd/ofd_obd.c
lustre/target/tgt_handler.c

index 52443ba..2dbcb3f 100644 (file)
@@ -1072,13 +1072,6 @@ struct obd_ops {
                         struct obdo *oa);
        int (*o_getattr)(const struct lu_env *env, struct obd_export *exp,
                         struct obdo *oa);
-       int (*o_decompress_read)(const struct lu_env *env,
-                                struct obd_export *exp, struct obdo *oa,
-                                struct niobuf_remote *rnb,
-                                struct niobuf_local *lnb,
-                                struct obd_ioobj *obj, int npages,
-                                int eof_rnb, enum ll_compr_type type, int lvl,
-                                int chunk_bits, bool write);
        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,
index 81e4c96..b2f3279 100644 (file)
@@ -1107,35 +1107,6 @@ cached:
        RETURN(rc);
 }
 
-static inline int obd_decompress_read(const struct lu_env *env,
-                                     struct obd_export *exp, struct obdo *oa,
-                                     struct niobuf_remote *rnb,
-                                     struct niobuf_local *lnb,
-                                     struct obd_ioobj *obj, int npages,
-                                     enum ll_compr_type type, int lvl,
-                                     int chunk_bits)
-{
-       int rc;
-
-       ENTRY;
-
-       rc = exp_check_ops(exp);
-       if (rc)
-               RETURN(rc);
-
-       if (!exp->exp_obd->obd_type->typ_dt_ops->o_decompress_read) {
-               CERROR("%s: no %s operation\n",
-                      (exp)->exp_obd->obd_name, __func__);
-               RETURN(-EOPNOTSUPP);
-       }
-
-       rc = OBP(exp->exp_obd, decompress_read)(env, exp, oa, rnb, lnb, obj,
-                                               npages, -1, type, lvl,
-                                               chunk_bits, false);
-
-       RETURN(rc);
-}
-
 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,
index 3dd4912..b0479f0 100644 (file)
@@ -584,13 +584,16 @@ out_tx:
  */
 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, int chunk_size)
+                          struct lu_attr *la, struct obdo *oa,
+                          struct obd_ioobj *obj, struct niobuf_remote *rnb,
+                          int *nr_local, struct niobuf_local *lnb,
+                          enum ll_compr_type type, int lvl, int chunk_bits)
 {
        struct ofd_object *fo;
+       int chunk_size = chunk_bits ? 1 << chunk_bits : 0;
        enum dt_bufs_type dbt = DT_BUFS_TYPE_READ;
        bool compr_unaligned_read = false;
+       int niocount = obj->ioo_bufcnt;
        int maxlnb = *nr_local;
        __u64 prev_buf_end = 0;
        int tot_bytes = 0;
@@ -709,6 +712,15 @@ static int ofd_preprw_read(const struct lu_env *env, struct obd_export *exp,
                          compr_unaligned_read);
        if (unlikely(rc))
                GOTO(buf_put, rc);
+
+       if (compr_unaligned_read) {
+               rc = ofd_decompress_read(env, exp, oa, rnb, lnb, obj,
+                                        *nr_local, INT_MAX, type, lvl,
+                                        chunk_bits, false);
+               if (unlikely(rc))
+                       GOTO(buf_put, rc);
+       }
+
        ofd_read_unlock(env, fo);
 
        ofd_access(env, ofd,
@@ -1390,8 +1402,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,
-                                    chunk_bits ? 1 << chunk_bits : 0);
+                                    obj, rnb, nr_local, lnb, type, lvl,
+                                    chunk_bits);
        } else {
                CERROR("%s: wrong cmd %d received!\n",
                       exp->exp_obd->obd_name, cmd);
index b072f9e..16acfa7 100644 (file)
@@ -1407,7 +1407,6 @@ const struct obd_ops ofd_obd_ops = {
        .o_create               = ofd_echo_create,
        .o_statfs               = ofd_statfs,
        .o_setattr              = ofd_echo_setattr,
-       .o_decompress_read      = ofd_decompress_read,
        .o_preprw               = ofd_preprw,
        .o_commitrw             = ofd_commitrw,
        .o_destroy              = ofd_echo_destroy,
index 2559fad..fcd7174 100644 (file)
@@ -2546,20 +2546,11 @@ int tgt_brw_read(struct tgt_session_info *tsi)
        if (rc != 0)
                GOTO(out_lock, rc);
 
-       /* the server is responsible for decompressing partial chunk reads */
-       if (npages_local != npages_remote) {
-               rc = obd_decompress_read(tsi->tsi_env, exp, &repbody->oa,
-                                        remote_nb, local_io_nb, ioo,
-                                        npages_local, compr_type, compr_lvl,
-                                        chunk_bits);
-               if (rc != 0)
-                       GOTO(out_commitrw, rc);
-       } else {
-               /* if there's no compression, the local page count should be
-                * identical to that requested by the client
-                */
-               LASSERT(npages_local == npages_remote);
-       }
+       /* if there's no compression, the local page count should be identical
+        * to that requested by the client
+        */
+       LASSERT(ergo(compr_type == LL_COMPR_TYPE_NONE,
+                    npages_local == npages_remote));
 
        if (body->oa.o_valid & OBD_MD_FLFLAGS &&
            body->oa.o_flags & OBD_FL_SHORT_IO) {