]> www.infradead.org Git - users/hch/misc.git/commitdiff
scsi: lpfc: Convert debugfs directory counts from atomic to unsigned int
authorJustin Tee <justin.tee@broadcom.com>
Mon, 15 Sep 2025 18:08:09 +0000 (11:08 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 17 Sep 2025 02:20:00 +0000 (22:20 -0400)
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>
drivers/scsi/lpfc/lpfc.h
drivers/scsi/lpfc/lpfc_debugfs.c

index f0e7f7ee4760b2b0ba96a7db51914274c48a9b69..8d9870764a8e04551500ddbbb9e9b4562edfa98b 100644 (file)
@@ -1332,7 +1332,7 @@ struct lpfc_hba {
        unsigned long last_ramp_down_time;
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
        struct dentry *hba_debugfs_root;
-       atomic_t debugfs_vport_count;
+       unsigned int debugfs_vport_count;
 
        struct lpfc_debugfs_nvmeio_trc *nvmeio_trc;
        atomic_t nvmeio_trc_cnt;
index eaedbaff5a78d2395601d4b1f96249535c24c395..92b5b2dbe8474d91e0acbf72bd122d452655d613 100644 (file)
@@ -5752,7 +5752,7 @@ static const struct file_operations lpfc_debugfs_op_slow_ring_trc = {
 };
 
 static struct dentry *lpfc_debugfs_root = NULL;
-static atomic_t lpfc_debugfs_hba_count;
+static unsigned int lpfc_debugfs_hba_count;
 
 /*
  * File operations for the iDiag debugfs
@@ -6074,7 +6074,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
        /* Setup lpfc root directory */
        if (!lpfc_debugfs_root) {
                lpfc_debugfs_root = debugfs_create_dir("lpfc", NULL);
-               atomic_set(&lpfc_debugfs_hba_count, 0);
+               lpfc_debugfs_hba_count = 0;
                if (IS_ERR(lpfc_debugfs_root)) {
                        lpfc_vlog_msg(vport, KERN_WARNING, LOG_INIT,
                                      "0527 Cannot create debugfs lpfc\n");
@@ -6090,13 +6090,13 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
                pport_setup = true;
                phba->hba_debugfs_root =
                        debugfs_create_dir(name, lpfc_debugfs_root);
-               atomic_set(&phba->debugfs_vport_count, 0);
+               phba->debugfs_vport_count = 0;
                if (IS_ERR(phba->hba_debugfs_root)) {
                        lpfc_vlog_msg(vport, KERN_WARNING, LOG_INIT,
                                      "0528 Cannot create debugfs %s\n", name);
                        return;
                }
-               atomic_inc(&lpfc_debugfs_hba_count);
+               lpfc_debugfs_hba_count++;
 
                /* Multi-XRI pools */
                debugfs_create_file("multixripools", 0644,
@@ -6268,7 +6268,7 @@ nvmeio_off:
                                      "0529 Cannot create debugfs %s\n", name);
                        return;
                }
-               atomic_inc(&phba->debugfs_vport_count);
+               phba->debugfs_vport_count++;
        }
 
        if (lpfc_debugfs_max_disc_trc) {
@@ -6402,10 +6402,10 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
        if (vport->vport_debugfs_root) {
                debugfs_remove(vport->vport_debugfs_root); /* vportX */
                vport->vport_debugfs_root = NULL;
-               atomic_dec(&phba->debugfs_vport_count);
+               phba->debugfs_vport_count--;
        }
 
-       if (atomic_read(&phba->debugfs_vport_count) == 0) {
+       if (!phba->debugfs_vport_count) {
                kfree(phba->slow_ring_trc);
                phba->slow_ring_trc = NULL;
 
@@ -6415,10 +6415,10 @@ lpfc_debugfs_terminate(struct lpfc_vport *vport)
                if (phba->hba_debugfs_root) {
                        debugfs_remove(phba->hba_debugfs_root); /* fnX */
                        phba->hba_debugfs_root = NULL;
-                       atomic_dec(&lpfc_debugfs_hba_count);
+                       lpfc_debugfs_hba_count--;
                }
 
-               if (atomic_read(&lpfc_debugfs_hba_count) == 0) {
+               if (!lpfc_debugfs_hba_count) {
                        debugfs_remove(lpfc_debugfs_root); /* lpfc */
                        lpfc_debugfs_root = NULL;
                }