scst_copy_mgr: Convert comments about locking into runtime checks

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7095 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2017-02-24 02:07:29 +00:00
parent 2a074789ac
commit 585c5d2fe0

View File

@@ -2498,7 +2498,6 @@ out_free:
goto out;
}
/* scst_mutex supposed to be held and activities suspended */
static bool scst_cm_is_lun_free(unsigned int lun)
{
bool res = true;
@@ -2507,6 +2506,9 @@ static bool scst_cm_is_lun_free(unsigned int lun)
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) {
if (tgt_dev->lun == lun) {
res = false;
@@ -2518,7 +2520,6 @@ static bool scst_cm_is_lun_free(unsigned int lun)
return res;
}
/* scst_mutex supposed to be held and activities suspended */
static unsigned int scst_cm_get_lun(const struct scst_device *dev)
{
unsigned int res = -1;
@@ -2527,6 +2528,9 @@ static unsigned int scst_cm_get_lun(const struct scst_device *dev)
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) {
struct list_head *head = &scst_cm_sess->sess_tgt_dev_list[i];
struct scst_tgt_dev *tgt_dev;
@@ -2549,7 +2553,6 @@ out:
return res;
}
/* scst_mutex supposed to be held and activities suspended */
static int scst_cm_dev_register(struct scst_device *dev, uint64_t lun)
{
int res, i;
@@ -2558,6 +2561,9 @@ static int scst_cm_dev_register(struct scst_device *dev, uint64_t lun)
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
TRACE_DBG("dev %s, LUN %ld", dev->virt_name, (unsigned long)lun);
for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) {
@@ -2622,7 +2628,6 @@ out_err:
goto out;
}
/* scst_mutex supposed to be held and activities suspended */
static void scst_cm_dev_unregister(struct scst_device *dev, bool del_lun)
{
int i;
@@ -2630,6 +2635,9 @@ static void scst_cm_dev_unregister(struct scst_device *dev, bool del_lun)
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
TRACE_DBG("dev %s, del_lun %d", dev->virt_name, del_lun);
list_for_each_entry_safe(des, t, &scst_cm_desig_list, cm_desig_list_entry) {
@@ -2696,13 +2704,15 @@ out_unblock:
goto out_resume;
}
/* scst_mutex supposed to be held and activities suspended */
int scst_cm_on_dev_register(struct scst_device *dev)
{
int res = 0;
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
if (!dev->handler->auto_cm_assignment_possible)
goto out;
@@ -2713,24 +2723,28 @@ out:
return res;
}
/* scst_mutex supposed to be held and activities suspended */
void scst_cm_on_dev_unregister(struct scst_device *dev)
{
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
scst_cm_dev_unregister(dev, true);
TRACE_EXIT();
return;
}
/* scst_mutex supposed to be held and activities suspended */
int scst_cm_on_add_acg(struct scst_acg *acg)
{
int res = 0;
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
if (scst_cm_tgt == NULL)
goto out;
@@ -2748,13 +2762,13 @@ out:
return res;
}
/* scst_mutex supposed to be held and activities suspended */
void scst_cm_on_del_acg(struct scst_acg *acg)
{
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
/* Nothing to do */
}
/* scst_mutex supposed to be held and activities suspended */
int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun,
unsigned int *flags)
{
@@ -2762,6 +2776,9 @@ int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun,
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
if (acg_dev->acg != scst_cm_tgt->default_acg)
goto out;
@@ -2780,13 +2797,15 @@ out:
return res;
}
/* scst_mutex supposed to be held and activities suspended */
bool scst_cm_on_del_lun(struct scst_acg_dev *acg_dev, bool gen_report_luns_changed)
{
bool res = gen_report_luns_changed;
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
if (acg_dev->acg != scst_cm_tgt->default_acg)
goto out;
@@ -2799,7 +2818,6 @@ out:
return res;
}
/* scst_mutex supposed to be locked */
static bool scst_cm_check_access_acg(const char *initiator_name,
const struct scst_device *dev, const struct scst_acg *acg,
bool default_acg)
@@ -2809,6 +2827,9 @@ static bool scst_cm_check_access_acg(const char *initiator_name,
TRACE_ENTRY();
scst_assert_activity_suspended();
lockdep_assert_held(&scst_mutex);
list_for_each_entry(acg_dev, &acg->acg_dev_list, acg_dev_list_entry) {
if (acg_dev->dev == dev) {
struct scst_acn *acn;