scst: Make lockdep_assert_held() easier to use (merge r5573 from trunk)

git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.0.x@5693 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2014-07-20 06:46:28 +00:00
parent 3b9682ce04
commit cb4fa8ed0d
12 changed files with 4 additions and 112 deletions

View File

@@ -407,9 +407,7 @@ static int add_session(void __user *ptr)
TRACE_ENTRY();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (info == NULL) {

View File

@@ -91,9 +91,7 @@ void conn_info_show(struct seq_file *seq, struct iscsi_session *session)
struct sock *sk;
char buf[64];
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&session->target->target_mutex);
#endif
list_for_each_entry(conn, &session->conn_list, conn_list_entry) {
sk = conn->sock->sk;
@@ -281,9 +279,7 @@ static int conn_sysfs_add(struct iscsi_conn *conn)
TRACE_ENTRY();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&conn->target->target_mutex);
#endif
iscsi_get_initiator_ip(conn, addr, sizeof(addr));
@@ -353,9 +349,7 @@ struct iscsi_conn *conn_lookup(struct iscsi_session *session, u16 cid)
{
struct iscsi_conn *conn;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&session->target->target_mutex);
#endif
/*
* We need to find the latest conn to correctly handle
@@ -832,9 +826,7 @@ int conn_free(struct iscsi_conn *conn)
TRACE_MGMT_DBG("Freeing conn %p (sess=%p, %#Lx %u)", conn,
session, (long long unsigned int)session->sid, conn->cid);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&conn->target->target_mutex);
#endif
del_timer_sync(&conn->rsp_timer);
@@ -887,9 +879,7 @@ static int iscsi_conn_alloc(struct iscsi_session *session,
struct iscsi_conn *conn;
int res = 0;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&session->target->target_mutex);
#endif
conn = kmem_cache_zalloc(iscsi_conn_cache, GFP_KERNEL);
if (!conn) {
@@ -995,9 +985,7 @@ int __add_conn(struct iscsi_session *session, struct iscsi_kern_conn_info *info)
int err;
bool reinstatement = false;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&session->target->target_mutex);
#endif
conn = conn_lookup(session, info->cid);
if ((conn != NULL) &&

View File

@@ -241,9 +241,7 @@ static int iscsi_tgt_params_set(struct iscsi_session *session,
struct iscsi_tgt_params *params = &session->tgt_params;
int32_t *iparams = info->target_params;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&session->target->target_mutex);
#endif
if (set) {
struct iscsi_conn *conn;
@@ -311,9 +309,7 @@ int iscsi_params_set(struct iscsi_target *target,
int err;
struct iscsi_session *session;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target->target_mutex);
#endif
if (info->sid == 0) {
PRINT_ERROR("sid must not be %d", 0);

View File

@@ -25,9 +25,7 @@ struct iscsi_session *session_lookup(struct iscsi_target *target, u64 sid)
{
struct iscsi_session *session;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target->target_mutex);
#endif
list_for_each_entry(session, &target->session_list,
session_list_entry) {
@@ -46,9 +44,7 @@ static int iscsi_session_alloc(struct iscsi_target *target,
struct iscsi_session *session;
char *name = NULL;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
session = kmem_cache_zalloc(iscsi_sess_cache, GFP_KERNEL);
if (!session)
@@ -138,9 +134,7 @@ void sess_reinst_finished(struct iscsi_session *sess)
TRACE_MGMT_DBG("Enabling reinstate successor sess %p", sess);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&sess->target->target_mutex);
#endif
sBUG_ON(!sess->sess_reinstating);
@@ -165,9 +159,7 @@ int __add_session(struct iscsi_target *target,
TRACE_MGMT_DBG("Adding session SID %llx", info->sid);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
err = iscsi_session_alloc(target, info, &new_sess);
if (err != 0)
@@ -318,9 +310,7 @@ int session_free(struct iscsi_session *session, bool del)
TRACE_MGMT_DBG("Freeing session %p (SID %llx)",
session, session->sid);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&session->target->target_mutex);
#endif
sBUG_ON(!list_empty(&session->conn_list));
if (unlikely(atomic_read(&session->active_cmds) != 0)) {
@@ -376,9 +366,7 @@ int __del_session(struct iscsi_target *target, u64 sid)
{
struct iscsi_session *session;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target->target_mutex);
#endif
session = session_lookup(target, sid);
if (!session)
@@ -400,9 +388,7 @@ void iscsi_sess_force_close(struct iscsi_session *sess)
TRACE_ENTRY();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&sess->target->target_mutex);
#endif
PRINT_INFO("Deleting session %llx with initiator %s (%p)",
(long long unsigned int)sess->sid, sess->initiator_name, sess);
@@ -424,9 +410,7 @@ static void iscsi_session_info_show(struct seq_file *seq,
{
struct iscsi_session *session;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target->target_mutex);
#endif
list_for_each_entry(session, &target->session_list,
session_list_entry) {

View File

@@ -34,9 +34,7 @@ struct iscsi_target *target_lookup_by_id(u32 id)
{
struct iscsi_target *target;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
list_for_each_entry(target, &target_list, target_list_entry) {
if (target->tid == id)
@@ -50,9 +48,7 @@ static struct iscsi_target *target_lookup_by_name(const char *name)
{
struct iscsi_target *target;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
list_for_each_entry(target, &target_list, target_list_entry) {
if (!strcmp(target->name, name))
@@ -71,9 +67,7 @@ static int iscsi_target_create(struct iscsi_kern_target_info *info, u32 tid,
TRACE_MGMT_DBG("Creating target tid %u, name %s", tid, name);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
len = strlen(name);
if (!len) {
@@ -144,9 +138,7 @@ int __add_target(struct iscsi_kern_target_info *info)
struct iscsi_kern_attr __user *attrs_ptr;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
if (nr_targets > MAX_NR_TARGETS) {
err = -EBUSY;
@@ -262,9 +254,7 @@ int __del_target(u32 id)
struct iscsi_target *target;
int err;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target_mgmt_mutex);
#endif
target = target_lookup_by_id(id);
if (!target) {
@@ -302,9 +292,7 @@ void target_del_session(struct iscsi_target *target,
TRACE_MGMT_DBG("Deleting session %p", session);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target->target_mutex);
#endif
if (!list_empty(&session->conn_list)) {
struct iscsi_conn *conn, *tc;
@@ -330,9 +318,7 @@ void target_del_all_sess(struct iscsi_target *target, int flags)
TRACE_ENTRY();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&target->target_mutex);
#endif
if (!list_empty(&target->session_list)) {
TRACE_MGMT_DBG("Deleting all sessions from target %p", target);

View File

@@ -79,6 +79,10 @@ typedef _Bool bool;
#define __aligned __attribute__((aligned))
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
#define lockdep_assert_held(l) do { (void)(l); } while (0)
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap);
#endif

View File

@@ -1347,9 +1347,7 @@ static void vdisk_detach(struct scst_device *dev)
TRACE_ENTRY();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
TRACE_DBG("virt_id %d", dev->virt_id);
@@ -1367,9 +1365,7 @@ static int vdisk_open_fd(struct scst_vdisk_dev *virt_dev, bool read_only)
{
int res;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
sBUG_ON(!virt_dev->filename);
virt_dev->fd = vdev_open_fd(virt_dev, read_only);
@@ -1390,9 +1386,7 @@ out:
static void vdisk_close_fd(struct scst_vdisk_dev *virt_dev)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
if (virt_dev->fd) {
filp_close(virt_dev->fd, NULL);
@@ -1409,9 +1403,7 @@ static int vdisk_attach_tgt(struct scst_tgt_dev *tgt_dev)
TRACE_ENTRY();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
if (virt_dev->tgt_dev_cnt++ > 0)
goto out;
@@ -1437,9 +1429,7 @@ static void vdisk_detach_tgt(struct scst_tgt_dev *tgt_dev)
TRACE_ENTRY();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
if (--virt_dev->tgt_dev_cnt == 0)
vdisk_close_fd(virt_dev);

View File

@@ -3782,9 +3782,7 @@ void scst_free_device(struct scst_device *dev)
bool scst_device_is_exported(struct scst_device *dev)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
WARN_ON_ONCE(!dev->dev_tgt_dev_list.next);

View File

@@ -1226,9 +1226,7 @@ static struct scst_device *__scst_lookup_device(struct scsi_device *scsidp)
{
struct scst_device *d;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
list_for_each_entry(d, &scst_dev_list, dev_list_entry)
if (d->scsi_dev == scsidp)

View File

@@ -628,9 +628,7 @@ static inline void scst_reserve_dev(struct scst_device *dev,
static inline void scst_clear_dev_reservation(struct scst_device *dev)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&dev->dev_lock);
#endif
dev->reserved_by = NULL;
}

View File

@@ -6991,9 +6991,7 @@ static char *scst_get_unique_sess_name(struct list_head *sysfs_sess_list,
int len = 0, n = 1;
BUG_ON(!initiator_name);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
restart:
list_for_each_entry(s, sysfs_sess_list, sysfs_sess_list_entry) {

View File

@@ -77,9 +77,7 @@ 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)
@@ -94,9 +92,7 @@ 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)
@@ -113,9 +109,7 @@ 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);
@@ -133,9 +127,7 @@ __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)
@@ -151,9 +143,7 @@ __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)
@@ -169,9 +159,7 @@ 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)
@@ -186,9 +174,7 @@ 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)
@@ -203,9 +189,7 @@ 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);
@@ -220,9 +204,7 @@ 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)
@@ -236,9 +218,7 @@ 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))
@@ -355,9 +335,7 @@ static void scst_check_alua_invariant(void)
struct scst_target_group *tg;
enum scst_tg_state expected_state;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
if (!alua_invariant_check)
return;
@@ -392,9 +370,7 @@ static void scst_check_alua_invariant(void)
static void scst_update_tgt_dev_alua_filter(struct scst_tgt_dev *tgt_dev,
enum scst_tg_state state)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
tgt_dev->alua_filter = scst_alua_filter[state];
}
@@ -404,9 +380,7 @@ static void scst_tg_change_tgt_dev_state(struct scst_tgt_dev *tgt_dev,
enum scst_tg_state state,
bool gen_ua)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
TRACE_MGMT_DBG("ALUA state of tgt_dev %p has changed", tgt_dev);
scst_update_tgt_dev_alua_filter(tgt_dev, state);
@@ -421,9 +395,7 @@ void scst_tg_init_tgt_dev(struct scst_tgt_dev *tgt_dev)
struct scst_dev_group *dg;
struct scst_target_group *tg;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
dg = __lookup_dg_by_dev(tgt_dev->dev);
if (dg) {
@@ -445,9 +417,7 @@ static void scst_update_tgt_alua_filter(struct scst_target_group *tg,
struct scst_dg_dev *dgd;
struct scst_tgt_dev *tgt_dev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
list_for_each_entry(dgd, &tg->dg->dev_list, entry) {
list_for_each_entry(tgt_dev, &dgd->dev->dev_tgt_dev_list,
@@ -471,9 +441,7 @@ static void scst_reset_tgt_alua_filter(struct scst_target_group *tg,
struct scst_dg_dev *dgd;
struct scst_tgt_dev *tgt_dev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
list_for_each_entry(dgd, &tg->dg->dev_list, entry) {
list_for_each_entry(tgt_dev, &dgd->dev->dev_tgt_dev_list,
@@ -584,9 +552,7 @@ 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)
@@ -723,9 +689,7 @@ static void __scst_tg_set_state(struct scst_target_group *tg,
struct scst_tgt *tgt;
sBUG_ON(state >= ARRAY_SIZE(scst_alua_filter));
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
if (tg->state == state)
return;
@@ -789,9 +753,7 @@ 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;
@@ -814,9 +776,7 @@ static void __scst_tg_set_preferred(struct scst_target_group *tg,
{
bool prev_preferred;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
if (tg->preferred == preferred)
return;
@@ -859,9 +819,7 @@ static void scst_update_dev_alua_filter(struct scst_dev_group *dg,
struct scst_tgt_dev *tgt_dev;
struct scst_target_group *tg;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list,
dev_tgt_dev_list_entry) {
@@ -881,9 +839,7 @@ static void scst_reset_dev_alua_filter(struct scst_device *dev)
{
struct scst_tgt_dev *tgt_dev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
lockdep_assert_held(&scst_mutex);
#endif
list_for_each_entry(tgt_dev, &dev->dev_tgt_dev_list,
dev_tgt_dev_list_entry)
@@ -1063,9 +1019,7 @@ 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);