From: Ronnie Sahlberg Date: Thu, 19 Sep 2024 02:48:46 +0000 (-0400) Subject: LU-18231 obd: change obd_set_up into OBDF_SET_UP X-Git-Tag: 2.16.51~104 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F56414%2F5;p=fs%2Flustre-release.git LU-18231 obd: change obd_set_up into OBDF_SET_UP Change the use of the odb_set_up bitfield into a bit in the ofd_flags bitmap and use atomic bit set/clear/test operations on it. No logical changes to the code and no changes to locking. Test-Parameters: trivial Signed-off-by: Ronnie Sahlberg Change-Id: I6b2b691e7cac733788fe239f9fc8ca5f8e749891 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56414 Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Reviewed-by: Timothy Day Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 63500c0..d82d3d1 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -596,6 +596,7 @@ struct obd_llog_group { /* Obd flag bits */ enum { OBDF_ATTACHED, /* finished attach */ + OBDF_SET_UP, /* finished setup */ OBDF_NUM_FLAGS, }; @@ -615,7 +616,6 @@ struct obd_device { /* bitfield modification is protected by obd_dev_lock */ DECLARE_BITMAP(obd_flags, OBDF_NUM_FLAGS); unsigned long - obd_set_up:1, /* finished setup */ obd_recovering:1, /* there are recoverable clients */ obd_abort_recovery:1, /* abort client and MDT recovery */ obd_abort_mdt_recovery:1, /* abort recovery between MDTs */ diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index c92b930..06a4e6d 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -471,7 +471,8 @@ do { \ if (rc) \ return rc; \ \ - if (!(obd)->obd_set_up || (obd)->obd_stopping) { \ + if (!test_bit(OBDF_SET_UP, (obd)->obd_flags) || \ + (obd)->obd_stopping) { \ CERROR("Device %d not setup\n", \ (obd)->obd_minor); \ RETURN(-ENODEV); \ @@ -1243,7 +1244,8 @@ static inline void obd_import_event(struct obd_device *obd, return; } - if (obd->obd_set_up && obd->obd_type->typ_dt_ops->o_import_event) + if (test_bit(OBDF_SET_UP, obd->obd_flags) && + obd->obd_type->typ_dt_ops->o_import_event) obd->obd_type->typ_dt_ops->o_import_event(obd, imp, event); EXIT; @@ -1261,7 +1263,7 @@ static inline int obd_notify(struct obd_device *obd, if (rc) return rc; - if (!obd->obd_set_up) { + if (!test_bit(OBDF_SET_UP, obd->obd_flags)) { CDEBUG(D_HA, "obd %s not set up\n", obd->obd_name); RETURN(-EINVAL); } @@ -1358,7 +1360,7 @@ static inline int obd_health_check(const struct lu_env *env, CERROR("cleaned up obd\n"); RETURN(-EOPNOTSUPP); } - if (!obd->obd_set_up || obd->obd_stopping) + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) RETURN(0); if (!obd->obd_type->typ_dt_ops->o_health_check) RETURN(0); diff --git a/lustre/kunit/llog_test.c b/lustre/kunit/llog_test.c index 8d143df..a21567b 100644 --- a/lustre/kunit/llog_test.c +++ b/lustre/kunit/llog_test.c @@ -2280,7 +2280,8 @@ static int llog_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) /* disk obd */ tgt = class_name2obd(lustre_cfg_string(lcfg, 1)); - if (!tgt || !test_bit(OBDF_ATTACHED, tgt->obd_flags) || !tgt->obd_set_up) { + if (!tgt || !test_bit(OBDF_ATTACHED, tgt->obd_flags) || + !test_bit(OBDF_SET_UP, tgt->obd_flags)) { CERROR("target device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); RETURN(-EINVAL); diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 692b412..d2f67c0 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -1096,7 +1096,7 @@ int target_handle_connect(struct ptlrpc_request *req) atomic_inc(&target->obd_conn_inprogress); - if (target->obd_stopping || !target->obd_set_up) { + if (target->obd_stopping || !test_bit(OBDF_SET_UP, target->obd_flags)) { deuuidify(str, NULL, &target_start, &target_len); LCONSOLE_INFO("%.*s: Not available for connect from %s (%s)\n", target_len, target_start, diff --git a/lustre/llite/lcommon_misc.c b/lustre/llite/lcommon_misc.c index d0bfd86..c46e33a 100644 --- a/lustre/llite/lcommon_misc.c +++ b/lustre/llite/lcommon_misc.c @@ -93,7 +93,8 @@ int cl_ocd_update(struct obd_device *host, struct obd_device *watched, ENTRY; if (!strcmp(watched->obd_type->typ_name, LUSTRE_OSC_NAME) && - watched->obd_set_up && !watched->obd_stopping) { + test_bit(OBDF_SET_UP, watched->obd_flags) && + !watched->obd_stopping) { cli = &watched->u.cli; lco = owner; flags = cli->cl_import->imp_connect_data.ocd_connect_flags; @@ -111,7 +112,8 @@ int cl_ocd_update(struct obd_device *host, struct obd_device *watched, CERROR("unexpected notification from %s %s" "(setup:%d,stopping:%d)!\n", watched->obd_type->typ_name, - watched->obd_name, watched->obd_set_up, + watched->obd_name, + test_bit(OBDF_SET_UP, watched->obd_flags), watched->obd_stopping); result = -EINVAL; } diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index c5623e7..c5581aa 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -326,7 +326,7 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) mdc_obd->obd_name, mdc_obd->obd_uuid.uuid, tgt->ltd_uuid.uuid, obd->obd_uuid.uuid); - if (!mdc_obd->obd_set_up) { + if (!test_bit(OBDF_SET_UP, mdc_obd->obd_flags)) { CERROR("target %s is not set up\n", tgt->ltd_uuid.uuid); RETURN(-EINVAL); } diff --git a/lustre/lod/lod_dev.c b/lustre/lod/lod_dev.c index 7930aae..4e7daf2 100644 --- a/lustre/lod/lod_dev.c +++ b/lustre/lod/lod_dev.c @@ -2402,7 +2402,7 @@ static int lod_obd_get_info(const struct lu_env *env, struct obd_export *exp, struct lod_tgt_desc *tgt; int rc = 1; - if (!obd->obd_set_up || obd->obd_stopping) + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) RETURN(-EAGAIN); d = lu2lod_dev(obd->obd_lu_dev); diff --git a/lustre/lov/lov_dev.c b/lustre/lov/lov_dev.c index 0e87d36..d24c156 100644 --- a/lustre/lov/lov_dev.c +++ b/lustre/lov/lov_dev.c @@ -406,7 +406,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, LASSERT(tgt != NULL); LASSERT(tgt->ltd_obd != NULL); - if (!tgt->ltd_obd->obd_set_up) { + if (!test_bit(OBDF_SET_UP, tgt->ltd_obd->obd_flags)) { CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); RETURN(-EINVAL); } diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 95f284a..5842c49 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -107,7 +107,7 @@ static int lov_connect_osc(struct obd_device *obd, u32 index, int activate, tgt_uuid = &lov->lov_tgts[index]->ltd_uuid; tgt_obd = lov->lov_tgts[index]->ltd_obd; - if (!tgt_obd->obd_set_up) { + if (!test_bit(OBDF_SET_UP, tgt_obd->obd_flags)) { rc = -EINVAL; CERROR("%s: target not set up: rc = %d\n", obd_uuid2str(tgt_uuid), rc); diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index db88e5b..1498371 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -1605,7 +1605,7 @@ static int mdd_obd_get_info(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct mdd_device *mdd; - if (!obd->obd_set_up || obd->obd_stopping) + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) RETURN(-EAGAIN); mdd = lu2mdd_dev(obd->obd_lu_dev); @@ -1628,7 +1628,7 @@ static int mdd_obd_set_info_async(const struct lu_env *env, struct mdd_device *mdd; int rc; - if (!obd->obd_set_up || obd->obd_stopping) + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) RETURN(-EAGAIN); mdd = lu2mdd_dev(obd->obd_lu_dev); diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 19ed996..5e11c8d 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -461,7 +461,7 @@ int class_handle_ioctl(unsigned int cmd, void __user *uarg) status = "ST"; else if (obd->obd_inactive) status = "IN"; - else if (obd->obd_set_up) + else if (test_bit(OBDF_SET_UP, obd->obd_flags)) status = "UP"; else if (test_bit(OBDF_ATTACHED, obd->obd_flags)) status = "AT"; @@ -498,7 +498,7 @@ int class_handle_ioctl(unsigned int cmd, void __user *uarg) } LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); - if (!obd->obd_set_up || obd->obd_stopping) { + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) { rc = -EINVAL; CERROR("obdclass: device %d not set up: rc = %d\n", data->ioc_dev, rc); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 94ff971..702e258 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -758,7 +758,7 @@ int class_notify_sptlrpc_conf(const char *fsname, int namelen) obd_device_lock(); obd_device_for_each(dev_no, obd) { - if (obd->obd_set_up == 0 || obd->obd_stopping) + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) continue; /* only notify mdc, osc, osp, lwp, mdt, ost diff --git a/lustre/obdclass/kernelcomm.c b/lustre/obdclass/kernelcomm.c index dfd1332..47c45eb 100644 --- a/lustre/obdclass/kernelcomm.c +++ b/lustre/obdclass/kernelcomm.c @@ -229,7 +229,7 @@ static int lustre_device_list_dump(struct sk_buff *msg, status = "ST"; else if (obd->obd_inactive) status = "IN"; - else if (obd->obd_set_up) + else if (test_bit(OBDF_SET_UP, obd->obd_flags)) status = "UP"; else if (test_bit(OBDF_ATTACHED, obd->obd_flags)) status = "AT"; diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index 94d889c..1dd83e3 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -88,9 +88,10 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) * in error case while obd is starting up. */ LASSERTF(obd->obd_starting == 1 || - obd->obd_stopping == 1 || obd->obd_set_up == 0, + obd->obd_stopping == 1 || + !test_bit(OBDF_SET_UP, obd->obd_flags), "wrong obd state: %d/%d/%d\n", !!obd->obd_starting, - !!obd->obd_stopping, !!obd->obd_set_up); + !!obd->obd_stopping, test_bit(OBDF_SET_UP, obd->obd_flags)); /* cleanup the llog ctxt here */ if (ctxt->loc_logops->lop_cleanup) diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index f22b353..6657fce 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -698,7 +698,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(-ENODEV); } - if (obd->obd_set_up) { + if (test_bit(OBDF_SET_UP, obd->obd_flags)) { CERROR("Device %d already setup (type %s)\n", obd->obd_minor, obd->obd_type->typ_name); RETURN(-EEXIST); @@ -713,7 +713,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) RETURN(-EEXIST); } /* - * just leave this on forever. I can't use obd_set_up here because + * just leave this on forever. I can't use OBDF_SET_UP here because * other fns check that status, and we're not actually set up yet. */ obd->obd_starting = 1; @@ -764,7 +764,7 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg) GOTO(err_uuid_hash, err); #endif /* ! HAVE_SERVER_SUPPORT */ - obd->obd_set_up = 1; + set_bit(OBDF_SET_UP, obd->obd_flags); spin_lock(&obd->obd_dev_lock); /* cleanup drops this */ @@ -807,7 +807,7 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) { ENTRY; - if (obd->obd_set_up) { + if (test_bit(OBDF_SET_UP, obd->obd_flags)) { CERROR("OBD device %d still set up\n", obd->obd_minor); RETURN(-EBUSY); } @@ -846,7 +846,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) CFS_RACE(OBD_FAIL_LDLM_RECOV_CLIENTS); - if (!obd->obd_set_up) { + if (!test_bit(OBDF_SET_UP, obd->obd_flags)) { CERROR("Device %d not setup\n", obd->obd_minor); RETURN(-ENODEV); } @@ -927,7 +927,7 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg) } #endif /* HAVE_SERVER_SUPPORT */ class_decref(obd, "setup", obd); - obd->obd_set_up = 0; + clear_bit(OBDF_SET_UP, obd->obd_flags); RETURN(0); } diff --git a/lustre/obdclass/obd_sysfs.c b/lustre/obdclass/obd_sysfs.c index 1ae1bf7a..3875647 100644 --- a/lustre/obdclass/obd_sysfs.c +++ b/lustre/obdclass/obd_sysfs.c @@ -249,7 +249,7 @@ health_check_show(struct kobject *kobj, struct attribute *attr, char *buf) obd_device_lock(); obd_device_for_each_cond(dev_no, obd, test_bit(OBDF_ATTACHED, obd->obd_flags) && - obd->obd_set_up && !obd->obd_stopping && + test_bit(OBDF_SET_UP, obd->obd_flags) && !obd->obd_stopping && !obd->obd_read_only) { LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); @@ -586,7 +586,7 @@ static int obd_device_list_seq_show(struct seq_file *p, void *v) status = "ST"; else if (obd->obd_inactive) status = "IN"; - else if (obd->obd_set_up) + else if (test_bit(OBDF_SET_UP, obd->obd_flags)) status = "UP"; else if (test_bit(OBDF_ATTACHED, obd->obd_flags)) status = "AT"; @@ -694,7 +694,7 @@ health_check_seq_show(struct seq_file *m, void *unused) obd_device_lock(); obd_device_for_each_cond(dev_no, obd, test_bit(OBDF_ATTACHED, obd->obd_flags) && - obd->obd_set_up && !obd->obd_stopping) { + test_bit(OBDF_SET_UP, obd->obd_flags) && !obd->obd_stopping) { LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC); class_incref(obd, __func__, current); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index e6080df..bf7b3f1 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -2446,7 +2446,8 @@ static int echo_client_setup(const struct lu_env *env, } tgt = class_name2obd(lustre_cfg_string(lcfg, 1)); - if (!tgt || !test_bit(OBDF_ATTACHED, tgt->obd_flags) || !tgt->obd_set_up) { + if (!tgt || !test_bit(OBDF_ATTACHED, tgt->obd_flags) || + !test_bit(OBDF_SET_UP, tgt->obd_flags)) { CERROR("device not attached or not set up (%s)\n", lustre_cfg_string(lcfg, 1)); RETURN(-EINVAL); diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 760f506..5681338 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -1740,7 +1740,7 @@ static int osp_obd_get_info(const struct lu_env *env, struct obd_export *exp, struct obd_device *obd = exp->exp_obd; struct osp_device *osp; - if (!obd->obd_set_up || obd->obd_stopping) + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) RETURN(-EAGAIN); osp = lu2osp_dev(obd->obd_lu_dev); @@ -1775,7 +1775,7 @@ static int osp_obd_set_info_async(const struct lu_env *env, } LASSERT(set != NULL); - if (!obd->obd_set_up || obd->obd_stopping) + if (!test_bit(OBDF_SET_UP, obd->obd_flags) || obd->obd_stopping) RETURN(-EAGAIN); osp = lu2osp_dev(obd->obd_lu_dev); diff --git a/lustre/ptlrpc/gss/gss_cli_upcall.c b/lustre/ptlrpc/gss/gss_cli_upcall.c index 62a6527..f4f5ce0 100644 --- a/lustre/ptlrpc/gss/gss_cli_upcall.c +++ b/lustre/ptlrpc/gss/gss_cli_upcall.c @@ -258,7 +258,7 @@ int gss_do_ctx_init_rpc(char __user *buffer, unsigned long count) RETURN(rc); } - if (unlikely(!obd->obd_set_up)) { + if (unlikely(!test_bit(OBDF_SET_UP, obd->obd_flags))) { rc = -EINVAL; CERROR("%s: obd not setup: rc = %d\n", obdname, rc); RETURN(rc); diff --git a/lustre/ptlrpc/gss/sec_gss.c b/lustre/ptlrpc/gss/sec_gss.c index 00276cc..9a9045d 100644 --- a/lustre/ptlrpc/gss/sec_gss.c +++ b/lustre/ptlrpc/gss/sec_gss.c @@ -2011,7 +2011,8 @@ int gss_svc_handle_init(struct ptlrpc_request *req, struct gss_wire_ctx *gw) uuid = (struct obd_uuid *) uuid_obj.data; target = class_uuid2obd(uuid); - if (!target || target->obd_stopping || !target->obd_set_up) { + if (!target || target->obd_stopping || + !test_bit(OBDF_SET_UP, target->obd_flags)) { char *target_start; int target_len; diff --git a/lustre/target/tgt_mount.c b/lustre/target/tgt_mount.c index 99484f6..8cd9553 100644 --- a/lustre/target/tgt_mount.c +++ b/lustre/target/tgt_mount.c @@ -395,7 +395,7 @@ int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp, RETURN(-ENOMEM); lwp = class_name2obd(lwpname); - if (lwp && lwp->obd_set_up == 1) { + if (lwp && test_bit(OBDF_SET_UP, lwp->obd_flags)) { struct obd_uuid *uuid; OBD_ALLOC_PTR(uuid);