Skip to content

Commit a045ae2

Browse files
Justin Teemartinkpetersen
authored andcommitted
scsi: lpfc: Convert debugfs directory counts from atomic to unsigned int
Atomicity is not necessary for debugfs directory accounting because vport deletion and creation is already serialized. Creation has always been serialized through sysfs. Deletion is serialized via walking the lpfc_create_vport_work_array and calling fc_vport_terminate one-by-one for each NPIV port. Reported-by: Al Viro <viro@zeniv.linux.org.uk> Closes: https://lore.kernel.org/linux-fsdevel/20250702212917.GK3406663@ZenIV/ Signed-off-by: Justin Tee <justin.tee@broadcom.com> Message-ID: <20250915180811.137530-13-justintee8345@gmail.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 8221b34 commit a045ae2

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

drivers/scsi/lpfc/lpfc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ struct lpfc_hba {
13321332
unsigned long last_ramp_down_time;
13331333
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
13341334
struct dentry *hba_debugfs_root;
1335-
atomic_t debugfs_vport_count;
1335+
unsigned int debugfs_vport_count;
13361336

13371337
struct lpfc_debugfs_nvmeio_trc *nvmeio_trc;
13381338
atomic_t nvmeio_trc_cnt;

drivers/scsi/lpfc/lpfc_debugfs.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5752,7 +5752,7 @@ static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
57525752
};
57535753

57545754
static struct dentry *lpfc_debugfs_root = NULL;
5755-
static atomic_t lpfc_debugfs_hba_count;
5755+
static unsigned int lpfc_debugfs_hba_count;
57565756

57575757
/*
57585758
* File operations for the iDiag debugfs
@@ -6074,7 +6074,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
60746074
/* Setup lpfc root directory */
60756075
if (!lpfc_debugfs_root) {
60766076
lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL);
6077-
atomic_set(&lpfc_debugfs_hba_count, 0);
6077+
lpfc_debugfs_hba_count = 0;
60786078
if (IS_ERR(lpfc_debugfs_root)) {
60796079
lpfc_vlog_msg(vport, KERN_WARNING, LOG_INIT,
60806080
"0527 Cannot create debugfs lpfc\n");
@@ -6090,13 +6090,13 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
60906090
pport_setup = true;
60916091
phba->hba_debugfs_root =
60926092
debugfs_create_dir(name, lpfc_debugfs_root);
6093-
atomic_set(&phba->debugfs_vport_count, 0);
6093+
phba->debugfs_vport_count = 0;
60946094
if (IS_ERR(phba->hba_debugfs_root)) {
60956095
lpfc_vlog_msg(vport, KERN_WARNING, LOG_INIT,
60966096
"0528 Cannot create debugfs %s\n", name);
60976097
return;
60986098
}
6099-
atomic_inc(&lpfc_debugfs_hba_count);
6099+
lpfc_debugfs_hba_count++;
61006100

61016101
/* Multi-XRI pools */
61026102
debugfs_create_file("multixripools", 0644,
@@ -6268,7 +6268,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
62686268
"0529 Cannot create debugfs %s\n", name);
62696269
return;
62706270
}
6271-
atomic_inc(&phba->debugfs_vport_count);
6271+
phba->debugfs_vport_count++;
62726272
}
62736273

62746274
if (lpfc_debugfs_max_disc_trc) {
@@ -6402,10 +6402,10 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
64026402
if (vport->vport_debugfs_root) {
64036403
debugfs_remove(vport->vport_debugfs_root); /* vportX */
64046404
vport->vport_debugfs_root = NULL;
6405-
atomic_dec(&phba->debugfs_vport_count);
6405+
phba->debugfs_vport_count--;
64066406
}
64076407

6408-
if (atomic_read(&phba->debugfs_vport_count) == 0) {
6408+
if (!phba->debugfs_vport_count) {
64096409
kfree(phba->slow_ring_trc);
64106410
phba->slow_ring_trc = NULL;
64116411

@@ -6415,10 +6415,10 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
64156415
if (phba->hba_debugfs_root) {
64166416
debugfs_remove(phba->hba_debugfs_root); /* fnX */
64176417
phba->hba_debugfs_root = NULL;
6418-
atomic_dec(&lpfc_debugfs_hba_count);
6418+
lpfc_debugfs_hba_count--;
64196419
}
64206420

6421-
if (atomic_read(&lpfc_debugfs_hba_count) == 0) {
6421+
if (!lpfc_debugfs_hba_count) {
64226422
debugfs_remove(lpfc_debugfs_root); /* lpfc */
64236423
lpfc_debugfs_root = NULL;
64246424
}

0 commit comments

Comments
 (0)