From 8064fdcf348c4378b0ff4fc9a826f58032c41f37 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 24 Jul 2019 01:13:41 +0000 Subject: [PATCH] scst: Move the code that decrements dev->not_pr_supporting_tgt_devs_num A later patch will introduce a delay between deleting and freeing a tgt_dev. Move the code that decrements dev->not_pr_supporting_tgt_devs_num from the function that frees a tgt_dev into the function that deletes a tgt_dev such that the decrement code does not get delayed. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8476 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 2dff03838..542cc3640 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5539,6 +5539,7 @@ void scst_nexus_loss(struct scst_tgt_dev *tgt_dev, bool queue_UA) static void scst_del_tgt_dev(struct scst_tgt_dev *tgt_dev) { + struct scst_tgt_template *tgtt = tgt_dev->sess->tgt->tgtt; struct scst_device *dev = tgt_dev->dev; lockdep_assert_held(&scst_mutex); @@ -5555,6 +5556,9 @@ static void scst_del_tgt_dev(struct scst_tgt_dev *tgt_dev) scst_tgt_dev_sysfs_del(tgt_dev); + if (tgtt->get_initiator_port_transport_id == NULL) + dev->not_pr_supporting_tgt_devs_num--; + atomic_dec(&tgt_dev->tgt_dev_cmd_count); } @@ -5566,7 +5570,6 @@ static void scst_del_tgt_dev(struct scst_tgt_dev *tgt_dev) */ static void scst_free_tgt_dev(struct scst_tgt_dev *tgt_dev) { - struct scst_tgt_template *tgtt = tgt_dev->tgtt; struct scst_device *dev = tgt_dev->dev; TRACE_ENTRY(); @@ -5576,9 +5579,6 @@ static void scst_free_tgt_dev(struct scst_tgt_dev *tgt_dev) #endif WARN_ON_ONCE(atomic_read(&tgt_dev->tgt_dev_cmd_count) != 0); - if (tgtt->get_initiator_port_transport_id == NULL) - dev->not_pr_supporting_tgt_devs_num--; - scst_clear_reservation(tgt_dev); scst_pr_clear_tgt_dev(tgt_dev); scst_free_all_UA(tgt_dev);