Whamcloud - gitweb
LU-17848 dt: allow dio_lookup/insert/delete to be optional 33/55633/2
authorTimothy Day <timday@amazon.com>
Thu, 4 Jul 2024 18:32:06 +0000 (18:32 +0000)
committerOleg Drokin <green@whamcloud.com>
Sat, 13 Jul 2024 20:56:32 +0000 (20:56 +0000)
Not every user of the dio API require these operations. Return
EOPNOTSUPP rather than LASSERT() if they are not implemented.

Clean up some stub functions in osp and lfsck.

Test-Parameters: trivial
Test-Parameters: trivial fstype=zfs
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I2df23b87cfca5844f8c5ca843251c463909fcd47
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55633
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/dt_object.h
lustre/lfsck/lfsck_layout.c
lustre/osp/osp_object.c

index 1e49979..6201f66 100644 (file)
@@ -2765,11 +2765,13 @@ static inline int dt_insert(const struct lu_env *env,
 {
        LASSERT(dt);
        LASSERT(dt->do_index_ops);
-       LASSERT(dt->do_index_ops->dio_insert);
 
        if (CFS_FAULT_CHECK(OBD_FAIL_DT_INSERT))
                return cfs_fail_err;
 
+       if (!dt->do_index_ops->dio_insert)
+               return -EOPNOTSUPP;
+
        return dt->do_index_ops->dio_insert(env, dt, rec, key, th);
 }
 
@@ -2913,11 +2915,13 @@ static inline int dt_delete(const struct lu_env *env,
 {
        LASSERT(dt);
        LASSERT(dt->do_index_ops);
-       LASSERT(dt->do_index_ops->dio_delete);
 
        if (CFS_FAULT_CHECK(OBD_FAIL_DT_DELETE))
                return cfs_fail_err;
 
+       if (!dt->do_index_ops->dio_delete)
+               return -EOPNOTSUPP;
+
        return dt->do_index_ops->dio_delete(env, dt, key, th);
 }
 
@@ -2949,11 +2953,13 @@ static inline int dt_lookup(const struct lu_env *env,
 
        LASSERT(dt);
        LASSERT(dt->do_index_ops);
-       LASSERT(dt->do_index_ops->dio_lookup);
 
        if (CFS_FAULT_CHECK(OBD_FAIL_DT_LOOKUP))
                return cfs_fail_err;
 
+       if (!dt->do_index_ops->dio_lookup)
+               return -EOPNOTSUPP;
+
        ret = dt->do_index_ops->dio_lookup(env, dt, rec, key);
        if (ret > 0)
                ret = 0;
index 7bc6282..6a2efcf 100644 (file)
@@ -7292,31 +7292,6 @@ log:
        RETURN_EXIT;
 }
 
-static int lfsck_orphan_index_lookup(const struct lu_env *env,
-                                    struct dt_object *dt,
-                                    struct dt_rec *rec,
-                                    const struct dt_key *key)
-{
-       return -EOPNOTSUPP;
-}
-
-static int lfsck_orphan_index_insert(const struct lu_env *env,
-                                    struct dt_object *dt,
-                                    const struct dt_rec *rec,
-                                    const struct dt_key *key,
-                                    struct thandle *handle)
-{
-       return -EOPNOTSUPP;
-}
-
-static int lfsck_orphan_index_delete(const struct lu_env *env,
-                                    struct dt_object *dt,
-                                    const struct dt_key *key,
-                                    struct thandle *handle)
-{
-       return -EOPNOTSUPP;
-}
-
 static struct dt_it *lfsck_orphan_it_init(const struct lu_env *env,
                                          struct dt_object *dt,
                                          __u32 attr)
@@ -7754,9 +7729,6 @@ static int lfsck_orphan_it_load(const struct lu_env *env,
 }
 
 static const struct dt_index_operations lfsck_orphan_index_ops = {
-       .dio_lookup             = lfsck_orphan_index_lookup,
-       .dio_insert             = lfsck_orphan_index_insert,
-       .dio_delete             = lfsck_orphan_index_delete,
        .dio_it = {
                .init           = lfsck_orphan_it_init,
                .fini           = lfsck_orphan_it_fini,
index 716dfb0..bd05639 100644 (file)
@@ -1735,31 +1735,6 @@ static int osp_destroy(const struct lu_env *env, struct dt_object *dt,
        RETURN(rc);
 }
 
-static int osp_orphan_index_lookup(const struct lu_env *env,
-                                  struct dt_object *dt,
-                                  struct dt_rec *rec,
-                                  const struct dt_key *key)
-{
-       return -EOPNOTSUPP;
-}
-
-static int osp_orphan_index_insert(const struct lu_env *env,
-                                  struct dt_object *dt,
-                                  const struct dt_rec *rec,
-                                  const struct dt_key *key,
-                                  struct thandle *handle)
-{
-       return -EOPNOTSUPP;
-}
-
-static int osp_orphan_index_delete(const struct lu_env *env,
-                                  struct dt_object *dt,
-                                  const struct dt_key *key,
-                                  struct thandle *handle)
-{
-       return -EOPNOTSUPP;
-}
-
 /**
  * Initialize the OSP layer index iteration.
  *
@@ -2197,9 +2172,6 @@ static int osp_orphan_it_load(const struct lu_env *env, const struct dt_it *di,
 }
 
 static const struct dt_index_operations osp_orphan_index_ops = {
-       .dio_lookup             = osp_orphan_index_lookup,
-       .dio_insert             = osp_orphan_index_insert,
-       .dio_delete             = osp_orphan_index_delete,
        .dio_it = {
                .init           = osp_it_init,
                .fini           = osp_it_fini,