Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Justin Tee and committed by
Martin K. Petersen
a045ae21 8221b345

+10 -10
+1 -1
drivers/scsi/lpfc/lpfc.h
··· 1332 1332 unsigned long last_ramp_down_time; 1333 1333 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS 1334 1334 struct dentry *hba_debugfs_root; 1335 - atomic_t debugfs_vport_count; 1335 + unsigned int debugfs_vport_count; 1336 1336 1337 1337 struct lpfc_debugfs_nvmeio_trc *nvmeio_trc; 1338 1338 atomic_t nvmeio_trc_cnt;
+9 -9
drivers/scsi/lpfc/lpfc_debugfs.c
··· 5752 5752 }; 5753 5753 5754 5754 static struct dentry *lpfc_debugfs_root = NULL; 5755 - static atomic_t lpfc_debugfs_hba_count; 5755 + static unsigned int lpfc_debugfs_hba_count; 5756 5756 5757 5757 /* 5758 5758 * File operations for the iDiag debugfs ··· 6074 6074 /* Setup lpfc root directory */ 6075 6075 if (!lpfc_debugfs_root) { 6076 6076 lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL); 6077 - atomic_set(&lpfc_debugfs_hba_count, 0); 6077 + lpfc_debugfs_hba_count = 0; 6078 6078 if (IS_ERR(lpfc_debugfs_root)) { 6079 6079 lpfc_vlog_msg(vport, KERN_WARNING, LOG_INIT, 6080 6080 "0527 Cannot create debugfs lpfc\n"); ··· 6090 6090 pport_setup = true; 6091 6091 phba->hba_debugfs_root = 6092 6092 debugfs_create_dir(name, lpfc_debugfs_root); 6093 - atomic_set(&phba->debugfs_vport_count, 0); 6093 + phba->debugfs_vport_count = 0; 6094 6094 if (IS_ERR(phba->hba_debugfs_root)) { 6095 6095 lpfc_vlog_msg(vport, KERN_WARNING, LOG_INIT, 6096 6096 "0528 Cannot create debugfs %s\n", name); 6097 6097 return; 6098 6098 } 6099 - atomic_inc(&lpfc_debugfs_hba_count); 6099 + lpfc_debugfs_hba_count++; 6100 6100 6101 6101 /* Multi-XRI pools */ 6102 6102 debugfs_create_file("multixripools", 0644, ··· 6268 6268 "0529 Cannot create debugfs %s\n", name); 6269 6269 return; 6270 6270 } 6271 - atomic_inc(&phba->debugfs_vport_count); 6271 + phba->debugfs_vport_count++; 6272 6272 } 6273 6273 6274 6274 if (lpfc_debugfs_max_disc_trc) { ··· 6402 6402 if (vport->vport_debugfs_root) { 6403 6403 debugfs_remove(vport->vport_debugfs_root); /* vportX */ 6404 6404 vport->vport_debugfs_root = NULL; 6405 - atomic_dec(&phba->debugfs_vport_count); 6405 + phba->debugfs_vport_count--; 6406 6406 } 6407 6407 6408 - if (atomic_read(&phba->debugfs_vport_count) == 0) { 6408 + if (!phba->debugfs_vport_count) { 6409 6409 kfree(phba->slow_ring_trc); 6410 6410 phba->slow_ring_trc = NULL; 6411 6411 ··· 6415 6415 if (phba->hba_debugfs_root) { 6416 6416 debugfs_remove(phba->hba_debugfs_root); /* fnX */ 6417 6417 phba->hba_debugfs_root = NULL; 6418 - atomic_dec(&lpfc_debugfs_hba_count); 6418 + lpfc_debugfs_hba_count--; 6419 6419 } 6420 6420 6421 - if (atomic_read(&lpfc_debugfs_hba_count) == 0) { 6421 + if (!lpfc_debugfs_hba_count) { 6422 6422 debugfs_remove(lpfc_debugfs_root); /* lpfc */ 6423 6423 lpfc_debugfs_root = NULL; 6424 6424 }