- Fixes wrong IRQ-safe/IRQ-unsafe locking dependancy spotted by lockdep: scst_check_...
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 25 Sep 2007 09:36:27 +0000 (09:36 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 25 Sep 2007 09:36:27 +0000 (09:36 +0000)
 - Cosmetics

git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@196 d57e44dd-8a1f-0410-8b47-8ef2f437770f

scst/src/dev_handlers/scst_user.c
scst/src/scst_mem.c
scst/src/scst_targ.c

index e8283af..bac1509 100644 (file)
@@ -1446,6 +1446,7 @@ static int dev_user_process_scst_commands(struct scst_user_dev *dev)
        return res;
 }
 
+/* Called under cmd_lists.cmd_list_lock and IRQ off */
 struct dev_user_cmd *__dev_user_get_next_cmd(struct list_head *cmd_list)
 {
        struct dev_user_cmd *u;
@@ -1459,11 +1460,11 @@ again:
                EXTRACHECKS_BUG_ON(u->state & UCMD_STATE_JAMMED_MASK);
                if (u->cmd != NULL) {
                        if (u->state == UCMD_STATE_EXECING) {
-                               int rc = scst_check_local_events(u->cmd);
+                               struct scst_user_dev *dev = u->dev;
+                               int rc;
+                               spin_unlock_irq(&dev->cmd_lists.cmd_list_lock);
+                               rc = scst_check_local_events(u->cmd);
                                if (unlikely(rc != 0)) {
-                                       struct scst_user_dev *dev = u->dev;
-                                       spin_unlock_irq(
-                                               &dev->cmd_lists.cmd_list_lock);
                                        u->cmd->scst_cmd_done(u->cmd,
                                                SCST_CMD_STATE_DEFAULT);
                                        /* 
@@ -1474,6 +1475,11 @@ again:
                                                &dev->cmd_lists.cmd_list_lock);
                                        goto again;
                                }
+                               /*
+                                * There is no real need to lock again here, but
+                                * let's do it for simplicity.
+                                */
+                               spin_lock_irq(&dev->cmd_lists.cmd_list_lock);
                        } else if (unlikely(test_bit(SCST_CMD_ABORTED,
                                        &u->cmd->cmd_flags))) {
                                switch(u->state) {
index f5df889..3c1afac 100644 (file)
@@ -471,19 +471,14 @@ static int sgv_pool_hiwmk_check(int pages_to_alloc, int no_fail)
 
                pages = sgv_pool_oom_free_objs(pages);
                if (pages > 0) {
-                       static int q;
-                       if (q < 100) {
-                               q++;
-                               TRACE(TRACE_OUT_OF_MEM, "Requested amount of "
-                                       "memory for being executed commands "
-                                       "exceeds allowed maximum %dMB, "
-                                       "should you increase scst_max_cmd_mem "
-                                       "(requested %d pages)? (This warning "
-                                       "will be shown only %d more times)",
-                                       sgv_pools_mgr.mgr.thr.hi_wmk >>
-                                           (20-PAGE_SHIFT), pages_to_alloc,
-                                       100-q);
-                       }
+                       TRACE(TRACE_OUT_OF_MEM, "Requested amount of "
+                           "memory (%d pages) for being executed "
+                           "commands together with the already "
+                           "allocated memory exceeds the allowed "
+                           "maximum %dMB. Should you increase "
+                           "scst_max_cmd_mem?", pages_to_alloc,
+                          sgv_pools_mgr.mgr.thr.hi_wmk >>
+                               (20-PAGE_SHIFT));
                        sgv_pools_mgr.mgr.thr.releases_failed++;
                        res = -ENOMEM;
                        goto out_unlock;
index 0413adc..a6e3381 100644 (file)
@@ -1449,6 +1449,7 @@ out_done:
        goto out;
 }
 
+/* No locks, no IRQ or IRQ-safe context allowed */
 int scst_check_local_events(struct scst_cmd *cmd)
 {
        int res, rc;