Whamcloud - gitweb
EX-7601 ofd: add read to write process
authorPatrick Farrell <pfarrell@whamcloud.com>
Thu, 2 Nov 2023 22:03:15 +0000 (18:03 -0400)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 29 Dec 2023 11:08:11 +0000 (11:08 +0000)
This adds a very simple read to the write process, which
just reads up the entire chunk-rounded write range.

This is a first step - the read will eventually be modified
to only read the unaligned portions which must be
decompressed for read-modify-write.  We will create a
special lnb mapping which contains only the pages which must
be read for decompression (similar to the tx lnb mapping).

For now, this read allows us to test decompression without
handling the mapping.

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: I169ddc2e161094aebdad1a60ec62e9c1d75cd6d8
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52966
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/ofd/ofd_io.c

index 7dc9baf..42d5d28 100644 (file)
@@ -754,8 +754,9 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
        struct range_lock *range = &ofd_info(env)->fti_write_range;
        struct dt_object *dt_obj = NULL;
        struct ofd_object *fo;
-       enum dt_bufs_type dbt = DT_BUFS_TYPE_WRITE;
        int chunk_size = chunk_bits ? 1 << chunk_bits : 0;
+       enum dt_bufs_type dbt = DT_BUFS_TYPE_WRITE;
+       bool compr_unaligned_write = false;
        int maxlnb = *nr_local;
        __u64 prev_buf_end = 0;
        int tot_bytes = 0;
@@ -903,6 +904,7 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
                                        continue;
                        }
 
+                       /* this write is unaligned */
                        if (buf_start != orig_start || buf_end != orig_end) {
                                /* get attr only once for each IO */
                                if (!dt_obj) {
@@ -918,6 +920,8 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
                                if (buf_start >= la->la_size) {
                                        buf_start = orig_start;
                                        buf_end = orig_end;
+                               } else {
+                                       compr_unaligned_write = true;
                                }
                        }
                        prev_buf_end = buf_end;
@@ -968,6 +972,24 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
                        GOTO(err, rc);
        }
 
+       if (compr_unaligned_write) {
+               /* for now, read will not hold pages locked, since it's not
+                * doing decompression.  this will be changed shortly.
+                */
+               rc = dt_read_prep(env, ofd_object_child(fo), lnb, *nr_local,
+                                 false);
+               if (unlikely(rc != 0))
+                       GOTO(err, rc);
+               /* read_prep sets rc if it read data, or on error, but the write
+                * code expects rc to be zero, so we clear rc here except on
+                * error
+                */
+               for (i = 0; i < *nr_local; i++) {
+                       if (lnb[i].lnb_rc > 0)
+                               lnb[i].lnb_rc = 0;
+               }
+       }
+
        rc = dt_write_prep(env, ofd_object_child(fo), lnb, *nr_local);
        if (unlikely(rc != 0))
                GOTO(err, rc);