From a0ef0b8fb22c621cf5a96fcf8c7c418332032150 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Mon, 8 Jan 2007 17:56:35 +0000 Subject: [PATCH] Minor fixes and cleanups from Ming Zhang: - Fixed scst_cur_cmd_mem leak for real devices - Since scst_unregister_target_template() returnes void it should use down() instead of down_interruptible() - Cleanups git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@73 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst.c | 6 +----- scst/src/scst_lib.c | 6 ++---- scst/src/scst_priv.h | 3 +-- scst/src/scst_proc.c | 2 ++ scst/src/scst_targ.c | 2 -- 5 files changed, 6 insertions(+), 13 deletions(-) diff --git a/scst/src/scst.c b/scst/src/scst.c index 7aa3aa923..3127850c3 100644 --- a/scst/src/scst.c +++ b/scst/src/scst.c @@ -197,14 +197,11 @@ void scst_unregister_target_template(struct scst_tgt_template *vtt) TRACE_ENTRY(); - if (down_interruptible(&scst_mutex) != 0) - goto out; - restart: + down(&scst_mutex); list_for_each_entry(tgt, &vtt->tgt_list, tgt_list_entry) { up(&scst_mutex); scst_unregister(tgt); - down(&scst_mutex); goto restart; } list_del(&vtt->scst_template_list_entry); @@ -212,7 +209,6 @@ restart: scst_cleanup_proc_target_dir_entries(vtt); -out: TRACE_EXIT(); return; } diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index ec79f57d6..3e8ae0bbf 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -1363,14 +1363,12 @@ int scst_alloc_space(struct scst_cmd *cmd) if (cmd->no_sgv) { cmd->sg = scst_alloc(cmd->bufflen, gfp_mask, use_clustering, &cmd->sg_cnt); - if (cmd->sg == NULL) - goto out; } else { cmd->sg = sgv_pool_alloc(pool, cmd->bufflen, gfp_mask, &cmd->sg_cnt, &cmd->sgv); - if (cmd->sg == NULL) - goto out; } + if (cmd->sg == NULL) + goto out; if (unlikely(cmd->sg_cnt > ini_sg)) { static int ll; diff --git a/scst/src/scst_priv.h b/scst/src/scst_priv.h index 744b1406a..20844cda3 100644 --- a/scst/src/scst_priv.h +++ b/scst/src/scst_priv.h @@ -211,10 +211,9 @@ static inline int __scst_inc_expected_sn(struct scst_tgt_dev *tgt_dev) typeof(tgt_dev->expected_sn) e; - e = tgt_dev->expected_sn; tgt_dev->expected_sn++; + e = tgt_dev->expected_sn; smp_mb(); /* write must be before def_cmd_count read */ - e++; TRACE(TRACE_DEBUG/*TRACE_SCSI_SERIALIZING*/, "Next expected_sn: %d", e); return e; } diff --git a/scst/src/scst_proc.c b/scst/src/scst_proc.c index 60efbf69c..fd6a0a659 100644 --- a/scst/src/scst_proc.c +++ b/scst/src/scst_proc.c @@ -474,6 +474,7 @@ static void scst_proc_del_acg_tree(struct proc_dir_entry *acg_proc_root, return; } +/* scst_mutex supposed to be held */ static int scst_proc_group_add(const char *p) { int res = 0, len = strlen(p) + 1; @@ -514,6 +515,7 @@ out_nomem: goto out; } +/* scst_mutex supposed to be held */ static int scst_proc_del_free_acg(struct scst_acg *acg, int remove_proc) { const char *name; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 8e36d0c37..d5a22a0ce 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -1250,8 +1250,6 @@ static void scst_cmd_done(struct scsi_cmnd *scsi_cmd) req->sr_underflow = 0; req->sr_request->rq_disk = NULL; /* disown request blk */ - cmd->bufflen = req->sr_bufflen; //?? - scst_release_request(cmd); cmd->state = next_state;