IB/srpt: Simplify srpt_shutdown_session()
authorBart Van Assche <bart.vanassche@sandisk.com>
Thu, 11 Feb 2016 19:05:58 +0000 (11:05 -0800)
committerDoug Ledford <dledford@redhat.com>
Mon, 29 Feb 2016 22:12:35 +0000 (17:12 -0500)
The target core guarantees that shutdown_session() is only invoked
once per session. This means that the ib_srpt target driver doesn't
have to track whether or not shutdown_session() has been called.
Additionally, ensure that target_sess_cmd_list_set_waiting() is
called before target_wait_for_sess_cmds() by moving it into
srpt_release_channel_work().

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagig@mellanox.com>
Cc: Alex Estrin <alex.estrin@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/ulp/srpt/ib_srpt.c
drivers/infiniband/ulp/srpt/ib_srpt.h

index 863fdd130b2b099dc729c25442d23f96ab7fcd10..bffca47ade4e8addb68ffe15cf9e5f45ce107773 100644 (file)
@@ -1892,20 +1892,7 @@ static void srpt_close_ch(struct srpt_rdma_ch *ch)
  */
 static int srpt_shutdown_session(struct se_session *se_sess)
 {
-       struct srpt_rdma_ch *ch = se_sess->fabric_sess_ptr;
-       unsigned long flags;
-
-       spin_lock_irqsave(&ch->spinlock, flags);
-       if (ch->in_shutdown) {
-               spin_unlock_irqrestore(&ch->spinlock, flags);
-               return true;
-       }
-
-       ch->in_shutdown = true;
-       target_sess_cmd_list_set_waiting(se_sess);
-       spin_unlock_irqrestore(&ch->spinlock, flags);
-
-       return true;
+       return 1;
 }
 
 /**
@@ -2008,6 +1995,7 @@ static void srpt_release_channel_work(struct work_struct *w)
        se_sess = ch->sess;
        BUG_ON(!se_sess);
 
+       target_sess_cmd_list_set_waiting(se_sess);
        target_wait_for_sess_cmds(se_sess);
 
        transport_deregister_session_configfs(se_sess);
index b0ede97b5240714bb326047ce6d2e0ce1d7a87f7..9c326c71607c05cd0e8dc331814799e44dda50d4 100644 (file)
@@ -286,7 +286,6 @@ struct srpt_rdma_ch {
        u8                      sess_name[36];
        struct work_struct      release_work;
        struct completion       *release_done;
-       bool                    in_shutdown;
 };
 
 /**