Skip to contentSkip to conversation

nfsd: use DEFINE_SPINLOCK() for spinlock

PATCH In review Qinglang Miao 2 participants 2 messages Jul 25, 2020 – Jul 31, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: use DEFINE_SPINLOCK() for spinlock

nfsd_drc_lock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

---
 fs/nfsd/nfssvc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfssvc.c +1 -2
index b603dfcdd..20f0a27fe 100644
@@ -88,7 +88,7 @@ DEFINE_MUTEX(nfsd_mutex);
  * version 4.1 DRC caches.
  * nfsd_drc_pages_used tracks the current version 4.1 DRC memory usage.
  */
-spinlock_t	nfsd_drc_lock;
+DEFINE_SPINLOCK(nfsd_drc_lock);
 unsigned long	nfsd_drc_max_mem;
 unsigned long	nfsd_drc_mem_used;
 
@@ -568,7 +568,6 @@ static void set_max_drc(void)
 	nfsd_drc_max_mem = (nr_free_buffer_pages()
 					>> NFSD_DRC_SIZE_SHIFT) * PAGE_SIZE;
 	nfsd_drc_mem_used = 0;
-	spin_lock_init(&nfsd_drc_lock);
 	dprintk("%s nfsd_drc_max_mem %lu \n", __func__, nfsd_drc_max_mem);
 }
 
Signature · 1 line
2.25.1
#1 lore raw

Hello-

Quoted 6 lines · Qinglang Miao

nfsd_drc_lock can be initialized automatically with DEFINE_SPINLOCK() rather than explicitly calling spin_lock_init().

Thanks for your patch.

I am quite honestly on the fence about this one. It doesn't seem to make a difference behaviorally or in terms of code legibility.

A broader clean-up that moves set_max_drc and those global variables into nfs4state.c might be better, but again, there isn't much to justify such a change.

Bruce, any thoughts?

Quoted 28 lines

---
fs/nfsd/nfssvc.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
fs/nfsd/nfssvc.c +1 -2
index b603dfcdd..20f0a27fe 100644
@@ -88,7 +88,7 @@ DEFINE_MUTEX(nfsd_mutex);
 * version 4.1 DRC caches.
 * nfsd_drc_pages_used tracks the current version 4.1 DRC memory usage.
 */
-spinlock_t	nfsd_drc_lock;
+DEFINE_SPINLOCK(nfsd_drc_lock);
 unsigned long	nfsd_drc_max_mem;
 unsigned long	nfsd_drc_mem_used;
 
@@ -568,7 +568,6 @@ static void set_max_drc(void)
 	nfsd_drc_max_mem = (nr_free_buffer_pages()
 					>> NFSD_DRC_SIZE_SHIFT) * PAGE_SIZE;
 	nfsd_drc_mem_used = 0;
-	spin_lock_init(&nfsd_drc_lock);
 	dprintk("%s nfsd_drc_max_mem %lu \n", __func__, nfsd_drc_max_mem);
 }
 
Signature · 1 line
2.25.1

--
Chuck Lever