From 329d0265e45e0f0a0d68b0ab1f58d1ee7574f15d Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Thu, 30 May 2024 09:12:17 +0300 Subject: [PATCH] EX-9858 osd: add @read param to dt_write_prep() 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 Change-Id: I2ea9888a1dab419275dbee97e9acc661101b5262 Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/55250 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Artem Blagodarenko Reviewed-by: Andreas Dilger --- lustre/include/dt_object.h | 6 +++--- lustre/mdt/mdt_io.c | 2 +- lustre/ofd/ofd_io.c | 2 +- lustre/osd-ldiskfs/osd_io.c | 14 +++----------- lustre/osd-zfs/osd_io.c | 2 +- 5 files changed, 9 insertions(+), 17 deletions(-) diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index 8bb4bbb..f7bb382 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -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, diff --git a/lustre/mdt/mdt_io.c b/lustre/mdt/mdt_io.c index eb8677f..6c42e24 100644 --- a/lustre/mdt/mdt_io.c +++ b/lustre/mdt/mdt_io.c @@ -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); diff --git a/lustre/ofd/ofd_io.c b/lustre/ofd/ofd_io.c index e97a292..d2028e7 100644 --- a/lustre/ofd/ofd_io.c +++ b/lustre/ofd/ofd_io.c @@ -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); diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 7c1bc22..3c2b643 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -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); } } diff --git a/lustre/osd-zfs/osd_io.c b/lustre/osd-zfs/osd_io.c index 450f6c4..90085c5 100644 --- a/lustre/osd-zfs/osd_io.c +++ b/lustre/osd-zfs/osd_io.c @@ -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); -- 1.8.3.1