From: <vl...@us...> - 2007-06-08 14:08:09
|
Revision: 127 http://svn.sourceforge.net/scst/?rev=127&view=rev Author: vlnb Date: 2007-06-08 07:08:06 -0700 (Fri, 08 Jun 2007) Log Message: ----------- Minor threads related fixes Modified Paths: -------------- trunk/scst/include/scsi_tgt.h trunk/scst/src/scst.c trunk/scst/src/scst_lib.c Modified: trunk/scst/include/scsi_tgt.h =================================================================== --- trunk/scst/include/scsi_tgt.h 2007-06-08 10:54:18 UTC (rev 126) +++ trunk/scst/include/scsi_tgt.h 2007-06-08 14:08:06 UTC (rev 127) @@ -1181,7 +1181,7 @@ /* Pointer to lists of commands with the lock */ struct scst_cmd_lists *p_cmd_lists; - /* Lists of commands with the lock, if dedicated threads are used */ + /* Lists of commands with lock, if dedicated threads are used */ struct scst_cmd_lists cmd_lists; /* How many cmds alive on this dev */ @@ -1257,8 +1257,11 @@ /* List of acg_dev's, one per acg, protected by scst_mutex */ struct list_head dev_acg_dev_list; - /* List of dedicated threads. Doesn't need any protection. */ + /* List of dedicated threads, protected by scst_mutex */ struct list_head threads_list; + + /* Device number */ + int dev_num; }; /* Modified: trunk/scst/src/scst.c =================================================================== --- trunk/scst/src/scst.c 2007-06-08 10:54:18 UTC (rev 126) +++ trunk/scst/src/scst.c 2007-06-08 14:08:06 UTC (rev 127) @@ -898,17 +898,17 @@ int scst_add_dev_threads(struct scst_device *dev, int num) { int i, res = 0; - static atomic_t major = ATOMIC_INIT(0); - int N, n = 0; + int n = 0; + struct scst_cmd_thread_t *thr; char nm[12]; TRACE_ENTRY(); - N = atomic_inc_return(&major); + list_for_each_entry(thr, &dev->threads_list, thread_list_entry) { + n++; + } for (i = 0; i < num; i++) { - struct scst_cmd_thread_t *thr; - thr = kmalloc(sizeof(*thr), GFP_KERNEL); if (!thr) { res = -ENOMEM; @@ -918,7 +918,7 @@ strncpy(nm, dev->handler->name, ARRAY_SIZE(nm)-1); nm[ARRAY_SIZE(nm)-1] = '\0'; thr->cmd_thread = kthread_run(scst_cmd_thread, - &dev->cmd_lists, "%sd%d_%d", nm, N, n++); + &dev->cmd_lists, "%sd%d_%d", nm, dev->dev_num, n++); if (IS_ERR(thr->cmd_thread)) { res = PTR_ERR(thr->cmd_thread); PRINT_ERROR_PR("kthread_create() failed: %d", res); Modified: trunk/scst/src/scst_lib.c =================================================================== --- trunk/scst/src/scst_lib.c 2007-06-08 10:54:18 UTC (rev 126) +++ trunk/scst/src/scst_lib.c 2007-06-08 14:08:06 UTC (rev 127) @@ -150,6 +150,7 @@ { struct scst_device *dev; int res = 0; + static int dev_num; /* protected by scst_mutex */ TRACE_ENTRY(); @@ -172,6 +173,7 @@ init_waitqueue_head(&dev->on_dev_waitQ); dev->dev_double_ua_possible = 1; dev->dev_serialized = 1; + dev->dev_num = dev_num++; *out_dev = dev; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |