From: <vl...@us...> - 2006-12-29 11:38:58
|
Revision: 71 http://svn.sourceforge.net/scst/?rev=71&view=rev Author: vlnb Date: 2006-12-29 03:38:43 -0800 (Fri, 29 Dec 2006) Log Message: ----------- A bunch of cleanups and minor fixes by Ming: - Dead code removed from scst_prepare_space() - LUN and CDB check moved out of EXTRACHECKS section - Fixed error processing in scst_register_dev_driver(), scst_sgv_pools_init() and scst_register() - Since scst_unregister_dev_driver() returnes void it should use down() instead of down_interruptible() - Clean out scst_num_cpus - Fixed race in scst_register_target_template() Modified Paths: -------------- trunk/scst/src/scst.c trunk/scst/src/scst_mem.c trunk/scst/src/scst_priv.h trunk/scst/src/scst_targ.c Modified: trunk/scst/src/scst.c =================================================================== --- trunk/scst/src/scst.c 2006-12-28 11:10:22 UTC (rev 70) +++ trunk/scst/src/scst.c 2006-12-29 11:38:43 UTC (rev 71) @@ -42,7 +42,6 @@ */ DECLARE_MUTEX(scst_mutex); -int scst_num_cpus; DECLARE_WAIT_QUEUE_HEAD(scst_dev_cmd_waitQ); LIST_HEAD(scst_dev_wait_sess_list); @@ -116,6 +115,7 @@ { int res = 0; struct scst_tgt_template *t; + static DECLARE_MUTEX(m); TRACE_ENTRY(); @@ -149,8 +149,11 @@ } } - if (down_interruptible(&scst_mutex) != 0) + if (down_interruptible(&m) != 0) goto out; + + if (down_interruptible(&scst_mutex) != 0) + goto out_m_up; list_for_each_entry(t, &scst_template_list, scst_template_list_entry) { if (strcmp(t->name, vtt->name) == 0) { PRINT_ERROR_PR("Target driver %s already registered", @@ -159,7 +162,6 @@ goto out_cleanup; } } - /* That's OK to drop it. The race doesn't matter */ up(&scst_mutex); TRACE_DBG("%s", "Calling target driver's detect()"); @@ -177,6 +179,9 @@ res = 0; +out_m_up: + up(&m); + out: TRACE_EXIT_RES(res); return res; @@ -238,21 +243,16 @@ down(&scst_mutex); if (scst_build_proc_target_entries(tgt) < 0) { + kfree(tgt); tgt = NULL; - goto out_free; - } + } else + list_add_tail(&tgt->tgt_list_entry, &vtt->tgt_list); - list_add_tail(&tgt->tgt_list_entry, &vtt->tgt_list); - up(&scst_mutex); out: TRACE_EXIT(); return tgt; - -out_free: - kfree(tgt); - goto out; } static inline int test_sess_list(struct scst_tgt *tgt) @@ -632,16 +632,16 @@ break; } } - + + if (exist) + goto out_up; + res = scst_build_proc_dev_handler_dir_entries(dev_type); if (res < 0) { goto out_up; } list_add_tail(&dev_type->dev_type_list_entry, &scst_dev_type_list); - - if (exist) - goto out_up; __scst_suspend_activity(); list_for_each_entry(dev, &scst_dev_list, dev_list_entry) { @@ -671,8 +671,7 @@ TRACE_ENTRY(); - if (down_interruptible(&scst_mutex) != 0) - goto out; + down(&scst_mutex); __scst_suspend_activity(); list_for_each_entry(dev, &scst_dev_list, dev_list_entry) { @@ -692,7 +691,6 @@ PRINT_INFO_PR("Device handler %s for type %d unloaded", dev_type->name, dev_type->type); -out: TRACE_EXIT(); return; } @@ -1053,19 +1051,11 @@ .remove = scst_remove, }; -static inline int get_cpus_count(void) -{ -#ifdef CONFIG_SMP - return cpus_weight(cpu_online_map); -#else - return 1; -#endif -} - static int __init init_scst(void) { int res = 0, i; struct scst_cmd *cmd; + int scst_num_cpus; TRACE_ENTRY(); @@ -1083,8 +1073,8 @@ } #endif - scst_num_cpus = get_cpus_count(); - + scst_num_cpus = num_online_cpus(); + /* ToDo: register_cpu_notifier() */ if (scst_threads == 0) Modified: trunk/scst/src/scst_mem.c =================================================================== --- trunk/scst/src/scst_mem.c 2006-12-28 11:10:22 UTC (rev 70) +++ trunk/scst/src/scst_mem.c 2006-12-29 11:38:43 UTC (rev 71) @@ -514,11 +514,11 @@ res = sgv_pool_init(&pools->norm, "sgv", 0); if (res != 0) - goto out_free_clust; + goto out; res = sgv_pool_init(&pools->norm_clust, "sgv-clust", 1); if (res != 0) - goto out; + goto out_free_clust; res = sgv_pool_init(&pools->dma, "sgv-dma", 0); if (res != 0) Modified: trunk/scst/src/scst_priv.h =================================================================== --- trunk/scst/src/scst_priv.h 2006-12-28 11:10:22 UTC (rev 70) +++ trunk/scst/src/scst_priv.h 2006-12-29 11:38:43 UTC (rev 71) @@ -131,7 +131,6 @@ extern struct scst_sgv_pools scst_sgv; -extern int scst_num_cpus; extern unsigned long scst_flags; extern struct semaphore scst_mutex; extern atomic_t scst_cmd_count; Modified: trunk/scst/src/scst_targ.c =================================================================== --- trunk/scst/src/scst_targ.c 2006-12-28 11:10:22 UTC (rev 70) +++ trunk/scst/src/scst_targ.c 2006-12-29 11:38:43 UTC (rev 71) @@ -188,7 +188,6 @@ } } -#ifdef EXTRACHECKS if (unlikely(cmd->lun == (lun_t)-1)) { PRINT_ERROR_PR("Wrong LUN %d, finishing cmd", -1); scst_set_cmd_error(cmd, @@ -204,7 +203,6 @@ scst_setup_to_active(cmd); goto active; } -#endif TRACE_DBG("Adding cmd %p to init cmd list", cmd); list_add_tail(&cmd->cmd_list_entry, &scst_init_cmd_list); @@ -608,8 +606,7 @@ r = scst_alloc_space(cmd); else if (r == 0) { cmd->data_buf_alloced = 1; - if (cmd->data_buf_alloced && - unlikely(orig_bufflen < cmd->bufflen)) { + if (unlikely(orig_bufflen < cmd->bufflen)) { PRINT_ERROR_PR("Target driver allocated data " "buffer (size %d), is less, than " "required (size %d)", orig_bufflen, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |