Whamcloud - gitweb
EX-9858 osd: add @read param to dt_write_prep()
authorAlex Zhuravlev <bzzz@whamcloud.com>
Thu, 30 May 2024 06:12:17 +0000 (09:12 +0300)
committerAndreas Dilger <adilger@whamcloud.com>
Wed, 19 Jun 2024 05:39:15 +0000 (05:39 +0000)
the purpose is to skip full page reading when OSD is aked for
pages to be written later. in CSDC we need all data as the
pages can be compressed and we may need to decompress them
first.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: I2ea9888a1dab419275dbee97e9acc661101b5262
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55250
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/dt_object.h
lustre/mdt/mdt_io.c
lustre/ofd/ofd_io.c
lustre/osd-ldiskfs/osd_io.c
lustre/osd-zfs/osd_io.c

index 8bb4bbb..f7bb382 100644 (file)
@@ -1336,7 +1336,7 @@ struct dt_body_operations {
        int (*dbo_write_prep)(const struct lu_env *env,
                              struct dt_object *dt,
                              struct niobuf_local *lb,
-                             int nr);
+                             int nr, bool read);
 
        /**
         * Declare intention to write data stored in the buffers.
@@ -2588,12 +2588,12 @@ static inline int dt_bufs_put(const struct lu_env *env, struct dt_object *d,
 }
 
 static inline int dt_write_prep(const struct lu_env *env, struct dt_object *d,
-                                struct niobuf_local *lnb, int n)
+                                struct niobuf_local *lnb, int n, bool read)
 {
         LASSERT(d);
         LASSERT(d->do_body_ops);
         LASSERT(d->do_body_ops->dbo_write_prep);
-        return d->do_body_ops->dbo_write_prep(env, d, lnb, n);
+        return d->do_body_ops->dbo_write_prep(env, d, lnb, n, read);
 }
 
 static inline int dt_declare_write_commit(const struct lu_env *env,
index eb8677f..6c42e24 100644 (file)
@@ -491,7 +491,7 @@ static int mdt_preprw_write(const struct lu_env *env, struct obd_export *exp,
                tot_bytes += rnb[i].rnb_len;
        }
 
-       rc = dt_write_prep(env, dob, lnb, *nr_local);
+       rc = dt_write_prep(env, dob, lnb, *nr_local, false);
        if (likely(rc))
                GOTO(err, rc);
 
index e97a292..d2028e7 100644 (file)
@@ -1164,7 +1164,7 @@ static int ofd_preprw_write(const struct lu_env *env, struct obd_export *exp,
                }
        }
 
-       rc = dt_write_prep(env, ofd_object_child(fo), write_lnb, *nr_write);
+       rc = dt_write_prep(env, ofd_object_child(fo), write_lnb, *nr_write, false);
        if (unlikely(rc != 0))
                GOTO(err, rc);
 
index 7c1bc22..3c2b643 100644 (file)
@@ -1310,7 +1310,7 @@ cleanup:
 }
 
 static int osd_write_prep(const struct lu_env *env, struct dt_object *dt,
-                         struct niobuf_local *lnb, int npages)
+                         struct niobuf_local *lnb, int npages, bool read)
 {
        struct osd_thread_info *oti   = osd_oti_get(env);
        struct osd_iobuf       *iobuf = &oti->oti_iobuf;
@@ -1342,7 +1342,7 @@ static int osd_write_prep(const struct lu_env *env, struct dt_object *dt,
                 */
                ClearPageUptodate(lnb[i].lnb_page);
 
-               if (lnb[i].lnb_len == PAGE_SIZE)
+               if (lnb[i].lnb_len == PAGE_SIZE && read == false)
                        continue;
                /* for compressed components, any partial pages have already
                 * been read up, so we should never add one here for the
@@ -1368,16 +1368,8 @@ static int osd_write_prep(const struct lu_env *env, struct dt_object *dt,
                if (maxidx >= lnb[i].lnb_page->index) {
                        osd_iobuf_add_page(iobuf, &lnb[i]);
                } else {
-                       long off;
                        char *p = kmap(lnb[i].lnb_page);
-
-                       off = lnb[i].lnb_page_offset;
-                       if (off)
-                               memset(p, 0, off);
-                       off = (lnb[i].lnb_page_offset + lnb[i].lnb_len) &
-                             ~PAGE_MASK;
-                       if (off)
-                               memset(p + off, 0, PAGE_SIZE - off);
+                       memset(p, 0, PAGE_SIZE);
                        kunmap(lnb[i].lnb_page);
                }
        }
index 450f6c4..90085c5 100644 (file)
@@ -597,7 +597,7 @@ out:
 }
 
 static int osd_write_prep(const struct lu_env *env, struct dt_object *dt,
-                       struct niobuf_local *lnb, int npages)
+                       struct niobuf_local *lnb, int npages, bool read)
 {
        struct osd_object *obj = osd_dt_obj(dt);