Skip to content

Commit b402a0d

Browse files
Ming Leimartinkpetersen
authored andcommitted
scsi: scsi_debug: Fix create target debugfs failure
Target debugfs entry is removed via async_schedule() which isn't drained when adding same name target, so failure of "Directory 'target11:0:0' with parent 'scsi_debug' already present!" can be triggered easily. Fix it by switching to domain async schedule, and draining it before adding new target debugfs entry. Cc: Wenchao Hao <[email protected]> Fixes: f084fe5 ("scsi: scsi_debug: Add debugfs interface to fail target reset") Signed-off-by: Ming Lei <[email protected]> Acked-by: Wenchao Hao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 57619f3 commit b402a0d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

drivers/scsi/scsi_debug.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,7 @@ static const int device_qfull_result =
926926
static const int condition_met_result = SAM_STAT_CONDITION_MET;
927927

928928
static struct dentry *sdebug_debugfs_root;
929+
static ASYNC_DOMAIN_EXCLUSIVE(sdebug_async_domain);
929930

930931
static void sdebug_err_free(struct rcu_head *head)
931932
{
@@ -1148,6 +1149,8 @@ static int sdebug_target_alloc(struct scsi_target *starget)
11481149
if (!targetip)
11491150
return -ENOMEM;
11501151

1152+
async_synchronize_full_domain(&sdebug_async_domain);
1153+
11511154
targetip->debugfs_entry = debugfs_create_dir(dev_name(&starget->dev),
11521155
sdebug_debugfs_root);
11531156

@@ -1174,7 +1177,8 @@ static void sdebug_target_destroy(struct scsi_target *starget)
11741177
targetip = (struct sdebug_target_info *)starget->hostdata;
11751178
if (targetip) {
11761179
starget->hostdata = NULL;
1177-
async_schedule(sdebug_tartget_cleanup_async, targetip);
1180+
async_schedule_domain(sdebug_tartget_cleanup_async, targetip,
1181+
&sdebug_async_domain);
11781182
}
11791183
}
11801184

0 commit comments

Comments
 (0)