From 6691b60c3983179194cabcd2539f7277e5dd417d Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 19 Aug 2021 04:12:36 +0000 Subject: [PATCH] scst: Fix copy manager LUN assignment for auto_cm_assignment=0 The INQUIRY command sent by the copy manager can only succeed if the LUN it is submitted to exists before the INQUIRY command is sent. Hence this patch that swaps the order of the scst_cm_on_add_lun() and scst_alloc_add_tgt_dev() calls in scst_acg_add_lun(). This patch prevents that the INQUIRY commands submitted by the copy manager fail as follows: Not supported dev type 7f, ignoring Reported-by: Eitan Cohen git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@9491 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 9010e1c78..3020bd570 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4541,12 +4541,6 @@ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, list_add_tail(&acg_dev->acg_dev_list_entry, &acg->acg_dev_list); list_add_tail(&acg_dev->dev_acg_dev_list_entry, &dev->dev_acg_dev_list); - if (!(flags & SCST_ADD_LUN_CM)) { - res = scst_cm_on_add_lun(acg_dev, lun, &flags); - if (res != 0) - goto out_free; - } - list_for_each_entry(sess, &acg->acg_sess_list, acg_sess_list_entry) { res = scst_alloc_add_tgt_dev(sess, acg_dev, &tgt_dev); if (res == -EPERM) @@ -4558,6 +4552,12 @@ int scst_acg_add_lun(struct scst_acg *acg, struct kobject *parent, &tmp_tgt_dev_list); } + if (!(flags & SCST_ADD_LUN_CM)) { + res = scst_cm_on_add_lun(acg_dev, lun, &flags); + if (res != 0) + goto out_free; + } + res = scst_acg_dev_sysfs_create(acg_dev, parent); if (res != 0) goto out_on_del;