Whamcloud - gitweb
LU-13814 lov: add lov dio_pages_init 10/52110/32
authorPatrick Farrell <pfarrell@whamcloud.com>
Tue, 22 Apr 2025 19:13:23 +0000 (15:13 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 7 May 2025 21:10:08 +0000 (21:10 +0000)
Implement dio_pages_init for the lov layer.

Note this has a place to call to the OSC layer, but there
is no corresponding function there.  The OSC function will
be added when the corresponding functionality is needed by
the main conversion process.

This patch allows us to continue the conversion of the
io_submit path.

Signed-off-by: Patrick Farrell <pfarrell@whamcloud.com>
Change-Id: Ib8db45e89fd699febce4978f2ea95c7500b0325d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52110
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Qian Yingjin <qian@ddn.com>
Reviewed-by: Marc Vef <mvef@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/cl_object.h
lustre/lov/lov_cl_internal.h
lustre/lov/lov_io.c
lustre/lov/lov_object.c
lustre/lov/lov_page.c

index 0d1a49b..ddb8da1 100644 (file)
@@ -2557,6 +2557,7 @@ struct cl_dio_pages {
        struct cl_2queue        cdp_queue;
        /* the file offset of the first page. */
        loff_t                  cdp_file_offset;
+       unsigned int            cdp_lov_index;
        /** # of pages in the array. */
        unsigned int            cdp_page_count;
        /* the first and last page can be incomplete, this records the
index 3f75ca8..9ca55b0 100644 (file)
@@ -556,11 +556,24 @@ enum {
        CP_LOV_INDEX_EMPTY = -1U,
 };
 
+static inline bool lov_pages_is_empty(struct cl_dio_pages *cdp)
+{
+       return cdp->cdp_lov_index == CP_LOV_INDEX_EMPTY;
+}
+
 static inline bool lov_page_is_empty(const struct cl_page *cp)
 {
        return cp->cp_lov_index == CP_LOV_INDEX_EMPTY;
 }
 
+
+int lov_dio_pages_init_empty(const struct lu_env *env, struct cl_object *obj,
+                            struct cl_dio_pages *cdp, pgoff_t index);
+int lov_dio_pages_init_composite(const struct lu_env *env,
+                                struct cl_object *obj,
+                                struct cl_dio_pages *cdp, pgoff_t index);
+int lov_dio_pages_init_foreign(const struct lu_env *env, struct cl_object *obj,
+                              struct cl_dio_pages *cdp, pgoff_t index);
 int   lov_page_init_empty(const struct lu_env *env, struct cl_object *obj,
                           struct cl_page *page, pgoff_t index);
 int   lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
index bc0669a..9fdff42 100644 (file)
@@ -1348,7 +1348,7 @@ static int lov_dio_submit(const struct lu_env *env,
                struct cl_2queue  *cl2q = &lov_env_info(env)->lti_cl2q;
 
                page = cl_page_list_first(qin);
-               if (lov_page_is_empty(page)) {
+               if (lov_pages_is_empty(cdp)) {
                        cl_page_list_move(&queue->c2_qout, qin, page);
 
                        /*
index b39d0a4..f147099 100644 (file)
@@ -47,6 +47,9 @@ struct lov_layout_operations {
                          lu_printer_t p, const struct lu_object *o);
        int  (*llo_page_init)(const struct lu_env *env, struct cl_object *obj,
                              struct cl_page *page, pgoff_t index);
+       int  (*llo_dio_pages_init)(const struct lu_env *env,
+                                  struct cl_object *obj,
+                                  struct cl_dio_pages *cdp, pgoff_t index);
        int  (*llo_lock_init)(const struct lu_env *env,
                              struct cl_object *obj, struct cl_lock *lock,
                              const struct cl_io *io);
@@ -1125,6 +1128,7 @@ static const struct lov_layout_operations lov_dispatch[] = {
                .llo_fini      = lov_fini_empty,
                .llo_print     = lov_print_empty,
                .llo_page_init = lov_page_init_empty,
+               .llo_dio_pages_init = lov_dio_pages_init_empty,
                .llo_lock_init = lov_lock_init_empty,
                .llo_io_init   = lov_io_init_empty,
                .llo_getattr   = lov_attr_get_empty,
@@ -1136,6 +1140,7 @@ static const struct lov_layout_operations lov_dispatch[] = {
                .llo_fini      = lov_fini_released,
                .llo_print     = lov_print_released,
                .llo_page_init = lov_page_init_empty,
+               .llo_dio_pages_init = lov_dio_pages_init_empty,
                .llo_lock_init = lov_lock_init_empty,
                .llo_io_init   = lov_io_init_released,
                .llo_getattr   = lov_attr_get_released,
@@ -1147,6 +1152,7 @@ static const struct lov_layout_operations lov_dispatch[] = {
                .llo_fini      = lov_fini_composite,
                .llo_print     = lov_print_composite,
                .llo_page_init = lov_page_init_composite,
+               .llo_dio_pages_init = lov_dio_pages_init_composite,
                .llo_lock_init = lov_lock_init_composite,
                .llo_io_init   = lov_io_init_composite,
                .llo_getattr   = lov_attr_get_composite,
@@ -1158,6 +1164,7 @@ static const struct lov_layout_operations lov_dispatch[] = {
                .llo_fini      = lov_fini_released,
                .llo_print     = lov_print_foreign,
                .llo_page_init = lov_page_init_foreign,
+               .llo_dio_pages_init = lov_dio_pages_init_foreign,
                .llo_lock_init = lov_lock_init_empty,
                .llo_io_init   = lov_io_init_empty,
                .llo_getattr   = lov_attr_get_empty,
@@ -1566,6 +1573,13 @@ static int lov_page_init(const struct lu_env *env, struct cl_object *obj,
                                    index);
 }
 
+static int lov_dio_pages_init(const struct lu_env *env, struct cl_object *obj,
+                        struct cl_dio_pages *cdp, pgoff_t index)
+{
+       return LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_dio_pages_init, env, obj,
+                                   cdp, index);
+}
+
 /**
  * Implements cl_object_operations::clo_io_init() method for lov
  * layer. Dispatches to the appropriate layout io initialization method.
@@ -2312,6 +2326,7 @@ static int lov_object_flush(const struct lu_env *env, struct cl_object *obj,
 
 static const struct cl_object_operations lov_ops = {
        .coo_page_init    = lov_page_init,
+       .coo_dio_pages_init = lov_dio_pages_init,
        .coo_lock_init    = lov_lock_init,
        .coo_io_init      = lov_io_init,
        .coo_attr_get     = lov_attr_get,
index db0c852..234e590 100644 (file)
 /**
  * Lov page operations.
  */
+int lov_dio_pages_init_composite(const struct lu_env *env,
+                                struct cl_object *obj,
+                                struct cl_dio_pages *cdp, pgoff_t index)
+{
+       struct lov_object *loo = cl2lov(obj);
+       struct lov_io *lio = lov_env_io(env);
+       struct cl_object *subobj;
+       struct cl_object *o;
+       struct lov_io_sub *sub;
+       struct lov_layout_raid0 *r0;
+       loff_t offset;
+       loff_t suboff;
+       int entry;
+       int stripe;
+       int rc;
+
+       ENTRY;
+
+       offset = index << PAGE_SHIFT;
+
+       entry = lov_io_layout_at(lio, offset);
+       if (entry < 0)
+               RETURN(-ENODATA);
+
+       stripe = lov_stripe_number(loo->lo_lsm, entry, offset);
+       rc = lov_stripe_offset(loo->lo_lsm, entry, offset, stripe,
+                                      &suboff);
+       LASSERT(rc == 0);
+
+       if (entry < 0 || !lsm_entry_inited(loo->lo_lsm, entry)) {
+               /* non-existing layout component */
+               lov_dio_pages_init_empty(env, obj, cdp, index);
+               RETURN(0);
+       }
+
+       CDEBUG(D_PAGE, "offset %llu, entry %d, stripe %d, suboff %llu\n",
+              offset, entry, stripe, suboff);
+
+       cdp->cdp_lov_index = lov_comp_index(entry, stripe);
+       LASSERT(cdp->cdp_lov_index != CP_LOV_INDEX_EMPTY);
+
+       sub = lov_sub_get(env, lio, cdp->cdp_lov_index);
+       if (IS_ERR(sub))
+               RETURN(PTR_ERR(sub));
+
+       r0 = lov_r0(loo, entry);
+       LASSERT(stripe < r0->lo_nr);
+
+       subobj = lovsub2cl(r0->lo_sub[stripe]);
+       cl_object_for_each(o, subobj) {
+               if (o->co_ops->coo_dio_pages_init) {
+                       rc = o->co_ops->coo_dio_pages_init(sub->sub_env, o, cdp,
+                                                         suboff >> PAGE_SHIFT);
+                       if (rc != 0)
+                               break;
+               }
+       }
+
+       RETURN(rc);
+}
+
 int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
                            struct cl_page *page, pgoff_t index)
 {
@@ -139,6 +200,14 @@ int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
        RETURN(rc);
 }
 
+int lov_dio_pages_init_empty(const struct lu_env *env, struct cl_object *obj,
+                            struct cl_dio_pages *cdp, pgoff_t index)
+{
+       cdp->cdp_lov_index = CP_LOV_INDEX_EMPTY;
+
+       RETURN(0);
+}
+
 int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj,
                        struct cl_page *cl_page, pgoff_t index)
 {
@@ -155,6 +224,13 @@ int lov_page_init_empty(const struct lu_env *env, struct cl_object *obj,
        RETURN(0);
 }
 
+int lov_dio_pages_init_foreign(const struct lu_env *env, struct cl_object *obj,
+                              struct cl_dio_pages *cdp, pgoff_t index)
+{
+       CDEBUG(D_PAGE, DFID" has no data\n", PFID(lu_object_fid(&obj->co_lu)));
+       RETURN(-ENODATA);
+}
+
 int lov_page_init_foreign(const struct lu_env *env, struct cl_object *obj,
                        struct cl_page *page, pgoff_t index)
 {