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

nfsd4: allow nfs4 state startup to fail

The failure here is pretty unlikely, but we should handle it anyway.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>

+17 -8
+12 -5
fs/nfsd/nfs4state.c
··· 4004 4004 4005 4005 /* initialization to perform when the nfsd service is started: */ 4006 4006 4007 - static void 4007 + static int 4008 4008 __nfs4_state_start(void) 4009 4009 { 4010 4010 unsigned long grace_time; ··· 4016 4016 printk(KERN_INFO "NFSD: starting %ld-second grace period\n", 4017 4017 grace_time/HZ); 4018 4018 laundry_wq = create_singlethread_workqueue("nfsd4"); 4019 + if (laundry_wq == NULL) 4020 + return -ENOMEM; 4019 4021 queue_delayed_work(laundry_wq, &laundromat_work, grace_time); 4020 4022 set_max_delegations(); 4023 + return 0; 4021 4024 } 4022 4025 4023 - void 4026 + int 4024 4027 nfs4_state_start(void) 4025 4028 { 4029 + int ret; 4030 + 4026 4031 if (nfs4_init) 4027 - return; 4032 + return 0; 4028 4033 nfsd4_load_reboot_recovery_data(); 4029 - __nfs4_state_start(); 4034 + ret = __nfs4_state_start(); 4035 + if (ret) 4036 + return ret; 4030 4037 nfs4_init = 1; 4031 - return; 4038 + return 0; 4032 4039 } 4033 4040 4034 4041 time_t
+3 -1
fs/nfsd/nfssvc.c
··· 411 411 error = nfsd_racache_init(2*nrservs); 412 412 if (error<0) 413 413 goto out; 414 - nfs4_state_start(); 414 + error = nfs4_state_start(); 415 + if (error) 416 + goto out; 415 417 416 418 nfsd_reset_versions(); 417 419
+2 -2
include/linux/nfsd/nfsd.h
··· 166 166 extern unsigned int max_delegations; 167 167 int nfs4_state_init(void); 168 168 void nfsd4_free_slabs(void); 169 - void nfs4_state_start(void); 169 + int nfs4_state_start(void); 170 170 void nfs4_state_shutdown(void); 171 171 time_t nfs4_lease_time(void); 172 172 void nfs4_reset_lease(time_t leasetime); ··· 174 174 #else 175 175 static inline int nfs4_state_init(void) { return 0; } 176 176 static inline void nfsd4_free_slabs(void) { } 177 - static inline void nfs4_state_start(void) { } 177 + static inline int nfs4_state_start(void) { } 178 178 static inline void nfs4_state_shutdown(void) { } 179 179 static inline time_t nfs4_lease_time(void) { return 0; } 180 180 static inline void nfs4_reset_lease(time_t leasetime) { }