From 4c2b6e8fe17eca2db9f43e152b43dbbeb586ad77 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 12 Sep 2013 10:09:58 +0000 Subject: [PATCH] scst, implicit ALUA: Document locking strategy git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4999 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 15 +++++++++++++ scst/src/scst_tg.c | 52 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/scst/include/scst.h b/scst/include/scst.h index 4e4420fdd..bddc7c749 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -2732,6 +2732,13 @@ struct scst_acn { /** * struct scst_dev_group - A group of SCST devices (struct scst_device). + * @name: Name of this device group. + * @entry: Entry in scst_dev_group_list. + * @dev_list: List of scst_dg_dev structures; protected by scst_mutex. + * @tg_list: List of scst_target_group structures; protected by scst_mutex. + * @kobj: For making this object visible in sysfs. + * @dev_kobj: Sysfs devices directory. + * @tg_kobj: Sysfs target groups directory. * * Each device is member of zero or one device groups. With each device group * there are zero or more target groups associated. @@ -2756,6 +2763,14 @@ struct scst_dg_dev { /** * struct scst_target_group - A group of SCSI targets (struct scst_tgt). + * @dg: Pointer to the device group that contains this target group. + * @name: Name of this target group. + * @group_id: SPC-4 target port group ID. + * @state: SPC-4 target port group ALUA state. + * @preferred: Value of the SPC-4 target port group PREF attribute. + * @entry: Entry in scst_dev_group.tg_list. + * @tgt_list: list of scst_tg_tgt elements; protected by scst_mutex. + * @kobj: For making this object visible in sysfs. * * Such a group is either a primary target port group or a secondary * port group. See also SPC-4 for more information. diff --git a/scst/src/scst_tg.c b/scst/src/scst_tg.c index 188a95edc..6fc7a8f7d 100644 --- a/scst/src/scst_tg.c +++ b/scst/src/scst_tg.c @@ -77,6 +77,10 @@ static struct scst_device *__lookup_dev(const char *name) { struct scst_device *dev; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(dev, &scst_dev_list, dev_list_entry) if (strcmp(dev->virt_name, name) == 0) return dev; @@ -90,6 +94,10 @@ static struct scst_tgt *__lookup_tgt(const char *name) struct scst_tgt_template *t; struct scst_tgt *tgt; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(t, &scst_template_list, scst_template_list_entry) list_for_each_entry(tgt, &t->tgt_list, tgt_list_entry) if (strcmp(tgt->tgt_name, name) == 0) @@ -105,6 +113,10 @@ static struct scst_tg_tgt *__lookup_dg_tgt(struct scst_dev_group *dg, struct scst_target_group *tg; struct scst_tg_tgt *tg_tgt; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + BUG_ON(!dg); BUG_ON(!tgt_name); list_for_each_entry(tg, &dg->tg_list, entry) @@ -121,6 +133,10 @@ __lookup_tg_by_name(struct scst_dev_group *dg, const char *name) { struct scst_target_group *tg; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(tg, &dg->tg_list, entry) if (strcmp(tg->name, name) == 0) return tg; @@ -135,6 +151,10 @@ __lookup_tg_by_tgt(struct scst_dev_group *dg, const struct scst_tgt *tgt) struct scst_target_group *tg; struct scst_tg_tgt *tg_tgt; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(tg, &dg->tg_list, entry) list_for_each_entry(tg_tgt, &tg->tgt_list, entry) if (tg_tgt->tgt == tgt) @@ -149,6 +169,10 @@ static struct scst_dg_dev *__lookup_dg_dev_by_dev(struct scst_dev_group *dg, { struct scst_dg_dev *dgd; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(dgd, &dg->dev_list, entry) if (dgd->dev == dev) return dgd; @@ -162,6 +186,10 @@ static struct scst_dg_dev *__lookup_dg_dev_by_name(struct scst_dev_group *dg, { struct scst_dg_dev *dgd; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(dgd, &dg->dev_list, entry) if (strcmp(dgd->dev->virt_name, name) == 0) return dgd; @@ -175,6 +203,10 @@ static struct scst_dg_dev *__global_lookup_dg_dev_by_name(const char *name) struct scst_dev_group *dg; struct scst_dg_dev *dgd; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(dg, &scst_dev_group_list, entry) { dgd = __lookup_dg_dev_by_name(dg, name); if (dgd) @@ -188,6 +220,10 @@ static struct scst_dev_group *__lookup_dg_by_name(const char *name) { struct scst_dev_group *dg; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(dg, &scst_dev_group_list, entry) if (strcmp(dg->name, name) == 0) return dg; @@ -200,6 +236,10 @@ static struct scst_dev_group *__lookup_dg_by_dev(struct scst_device *dev) { struct scst_dev_group *dg; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(dg, &scst_dev_group_list, entry) if (__lookup_dg_dev_by_dev(dg, dev)) return dg; @@ -541,6 +581,10 @@ void scst_tg_tgt_remove_by_tgt(struct scst_tgt *tgt) struct scst_target_group *tg; struct scst_tg_tgt *t, *t2; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + BUG_ON(!tgt); list_for_each_entry(dg, &scst_dev_group_list, entry) list_for_each_entry(tg, &dg->tg_list, entry) @@ -742,6 +786,10 @@ static void __scst_gen_alua_state_changed_ua(struct scst_target_group *tg) struct scst_tg_tgt *tg_tgt; struct scst_tgt *tgt; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_for_each_entry(dg_dev, &tg->dg->dev_list, entry) { dev = dg_dev->dev; list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list, @@ -1012,6 +1060,10 @@ static void __scst_dg_remove(struct scst_dev_group *dg) struct scst_dg_dev *dgdev; struct scst_target_group *tg; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) + lockdep_assert_held(&scst_mutex); +#endif + list_del(&dg->entry); scst_dg_sysfs_del(dg); list_for_each_entry(tg, &dg->tg_list, entry)