Skip to contentSkip to conversation

nfsd: don't destroy global nfs4_file table in per-net shutdown

PATCH In review Jeff Layton 2 participants 3 messages Feb 11, 2023

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

PATCH 1/1 nfsd: don't destroy global nfs4_file table in per-net shutdown

The nfs4_file table is global, so shutting it down when a containerized nfsd is shut down is wrong and can lead to double-frees. Tear down the nfs4_file_rhltable in nfs4_state_shutdown instead of nfs4_state_shutdown_net.

Fixes d47b295e8d76 (NFSD: Use rhashtable for managing nfs4_file objects)
---
 fs/nfsd/nfs4state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
index af22dfdc6fcc..a202be19f26f 100644
@@ -8218,7 +8218,6 @@ nfs4_state_shutdown_net(struct net *net)
 
 	nfsd4_client_tracking_exit(net);
 	nfs4_state_destroy_net(net);
-	rhltable_destroy(&nfs4_file_rhltable);
 #ifdef CONFIG_NFSD_V4_2_INTER_SSC
 	nfsd4_ssc_shutdown_umount(nn);
 #endif
@@ -8228,6 +8227,7 @@ void
 nfs4_state_shutdown(void)
 {
 	nfsd4_destroy_callback_queue();
+	rhltable_destroy(&nfs4_file_rhltable);
 }
 
 static void
Signature · 1 line
2.39.1
#1 lore raw
Quoted 8 lines · Jeff Layton

The nfs4_file table is global, so shutting it down when a containerized nfsd is shut down is wrong and can lead to double-frees. Tear down the nfs4_file_rhltable in nfs4_state_shutdown instead of nfs4_state_shutdown_net.

D'oh!

Quoted 4 lines
Fixes d47b295e8d76 (NFSD: Use rhashtable for managing nfs4_file objects)

Thanks to you and JianHong. Applied to nfsd-fixes.

Quoted 23 lines

---
fs/nfsd/nfs4state.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
index af22dfdc6fcc..a202be19f26f 100644
@@ -8218,7 +8218,6 @@ nfs4_state_shutdown_net(struct net *net)
 
 	nfsd4_client_tracking_exit(net);
 	nfs4_state_destroy_net(net);
-	rhltable_destroy(&nfs4_file_rhltable);
 #ifdef CONFIG_NFSD_V4_2_INTER_SSC
 	nfsd4_ssc_shutdown_umount(nn);
 #endif
@@ -8228,6 +8227,7 @@ void
 nfs4_state_shutdown(void)
 {
 	nfsd4_destroy_callback_queue();
+	rhltable_destroy(&nfs4_file_rhltable);
 }
 
Quoted 4 lines

static void

Signature · 1 line
2.39.1

--
Chuck Lever

author maintainer
#2 lore raw
Quoted 11 lines · Chuck Lever III
Quoted 7 lines · Jeff Layton

The nfs4_file table is global, so shutting it down when a containerized nfsd is shut down is wrong and can lead to double-frees. Tear down the nfs4_file_rhltable in nfs4_state_shutdown instead of nfs4_state_shutdown_net.

D'oh!

Quoted 7 lines
Quoted 4 lines
Fixes d47b295e8d76 (NFSD: Use rhashtable for managing nfs4_file objects)

Thanks to you and JianHong. Applied to nfsd-fixes.

Thanks for grabbing it quickly. It'd be great to get this in before v6.2 ships...

Quoted 34 lines
Quoted 24 lines

---
fs/nfsd/nfs4state.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4state.c +1 -1
index af22dfdc6fcc..a202be19f26f 100644
@@ -8218,7 +8218,6 @@ nfs4_state_shutdown_net(struct net *net)
 
 	nfsd4_client_tracking_exit(net);
 	nfs4_state_destroy_net(net);
-	rhltable_destroy(&nfs4_file_rhltable);
 #ifdef CONFIG_NFSD_V4_2_INTER_SSC
 	nfsd4_ssc_shutdown_umount(nn);
 #endif
@@ -8228,6 +8227,7 @@ void
 nfs4_state_shutdown(void)
 {
 	nfsd4_destroy_callback_queue();
+	rhltable_destroy(&nfs4_file_rhltable);
 }
 
Quoted 4 lines

static void

Signature · 1 line
2.39.1

--
Chuck Lever

Signature · 1 line
Jeff Layton <[email protected]>