From: Timothy Day Date: Thu, 4 Jul 2024 18:32:06 +0000 (+0000) Subject: LU-17848 dt: allow dio_lookup/insert/delete to be optional X-Git-Tag: 2.15.65~88 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=7b02081da056695e6cccb9eac6d5b03f87686ee2;p=fs%2Flustre-release.git LU-17848 dt: allow dio_lookup/insert/delete to be optional 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 Change-Id: I2df23b87cfca5844f8c5ca843251c463909fcd47 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55633 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index 1e49979..6201f66 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -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; diff --git a/lustre/lfsck/lfsck_layout.c b/lustre/lfsck/lfsck_layout.c index 7bc6282..6a2efcf 100644 --- a/lustre/lfsck/lfsck_layout.c +++ b/lustre/lfsck/lfsck_layout.c @@ -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, diff --git a/lustre/osp/osp_object.c b/lustre/osp/osp_object.c index 716dfb0..bd05639 100644 --- a/lustre/osp/osp_object.c +++ b/lustre/osp/osp_object.c @@ -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,