nfssvc.c (91d2e9b56cf5c80f9efc530d494968369a8a0e0d) | nfssvc.c (3988a57885eeac05ef89f0ab4d7e47b52fbcf630) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Central processing for nfsd. 4 * 5 * Authors: Olaf Kirch (okir@monad.swb.de) 6 * 7 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> 8 */ --- 332 unchanged lines hidden (view full) --- 341} 342 343static bool nfsd_needs_lockd(struct nfsd_net *nn) 344{ 345 return nfsd_vers(nn, 2, NFSD_TEST) || nfsd_vers(nn, 3, NFSD_TEST); 346} 347 348/** | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Central processing for nfsd. 4 * 5 * Authors: Olaf Kirch (okir@monad.swb.de) 6 * 7 * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> 8 */ --- 332 unchanged lines hidden (view full) --- 341} 342 343static bool nfsd_needs_lockd(struct nfsd_net *nn) 344{ 345 return nfsd_vers(nn, 2, NFSD_TEST) || nfsd_vers(nn, 3, NFSD_TEST); 346} 347 348/** |
349 * nfsd_copy_boot_verifier - Atomically copy a write verifier | 349 * nfsd_copy_write_verifier - Atomically copy a write verifier |
350 * @verf: buffer in which to receive the verifier cookie 351 * @nn: NFS net namespace 352 * 353 * This function provides a wait-free mechanism for copying the | 350 * @verf: buffer in which to receive the verifier cookie 351 * @nn: NFS net namespace 352 * 353 * This function provides a wait-free mechanism for copying the |
354 * namespace's boot verifier without tearing it. | 354 * namespace's write verifier without tearing it. |
355 */ | 355 */ |
356void nfsd_copy_boot_verifier(__be32 verf[2], struct nfsd_net *nn) | 356void nfsd_copy_write_verifier(__be32 verf[2], struct nfsd_net *nn) |
357{ 358 int seq = 0; 359 360 do { 361 read_seqbegin_or_lock(&nn->writeverf_lock, &seq); 362 memcpy(verf, nn->writeverf, sizeof(*verf)); 363 } while (need_seqretry(&nn->writeverf_lock, seq)); 364 done_seqretry(&nn->writeverf_lock, seq); 365} 366 | 357{ 358 int seq = 0; 359 360 do { 361 read_seqbegin_or_lock(&nn->writeverf_lock, &seq); 362 memcpy(verf, nn->writeverf, sizeof(*verf)); 363 } while (need_seqretry(&nn->writeverf_lock, seq)); 364 done_seqretry(&nn->writeverf_lock, seq); 365} 366 |
367static void nfsd_reset_boot_verifier_locked(struct nfsd_net *nn) | 367static void nfsd_reset_write_verifier_locked(struct nfsd_net *nn) |
368{ 369 struct timespec64 now; 370 u64 verf; 371 372 /* 373 * Because the time value is hashed, y2038 time_t overflow 374 * is irrelevant in this usage. 375 */ 376 ktime_get_raw_ts64(&now); 377 verf = siphash_2u64(now.tv_sec, now.tv_nsec, &nn->siphash_key); 378 memcpy(nn->writeverf, &verf, sizeof(nn->writeverf)); 379} 380 381/** | 368{ 369 struct timespec64 now; 370 u64 verf; 371 372 /* 373 * Because the time value is hashed, y2038 time_t overflow 374 * is irrelevant in this usage. 375 */ 376 ktime_get_raw_ts64(&now); 377 verf = siphash_2u64(now.tv_sec, now.tv_nsec, &nn->siphash_key); 378 memcpy(nn->writeverf, &verf, sizeof(nn->writeverf)); 379} 380 381/** |
382 * nfsd_reset_boot_verifier - Generate a new boot verifier | 382 * nfsd_reset_write_verifier - Generate a new write verifier |
383 * @nn: NFS net namespace 384 * 385 * This function updates the ->writeverf field of @nn. This field 386 * contains an opaque cookie that, according to Section 18.32.3 of 387 * RFC 8881, "the client can use to determine whether a server has 388 * changed instance state (e.g., server restart) between a call to 389 * WRITE and a subsequent call to either WRITE or COMMIT. This 390 * cookie MUST be unchanged during a single instance of the NFSv4.1 391 * server and MUST be unique between instances of the NFSv4.1 392 * server." 393 */ | 383 * @nn: NFS net namespace 384 * 385 * This function updates the ->writeverf field of @nn. This field 386 * contains an opaque cookie that, according to Section 18.32.3 of 387 * RFC 8881, "the client can use to determine whether a server has 388 * changed instance state (e.g., server restart) between a call to 389 * WRITE and a subsequent call to either WRITE or COMMIT. This 390 * cookie MUST be unchanged during a single instance of the NFSv4.1 391 * server and MUST be unique between instances of the NFSv4.1 392 * server." 393 */ |
394void nfsd_reset_boot_verifier(struct nfsd_net *nn) | 394void nfsd_reset_write_verifier(struct nfsd_net *nn) |
395{ 396 write_seqlock(&nn->writeverf_lock); | 395{ 396 write_seqlock(&nn->writeverf_lock); |
397 nfsd_reset_boot_verifier_locked(nn); | 397 nfsd_reset_write_verifier_locked(nn); |
398 write_sequnlock(&nn->writeverf_lock); 399} 400 401static int nfsd_startup_net(struct net *net, const struct cred *cred) 402{ 403 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 404 int ret; 405 --- 272 unchanged lines hidden (view full) --- 678 set_max_drc(); 679 /* check if the notifier is already set */ 680 if (atomic_inc_return(&nfsd_notifier_refcount) == 1) { 681 register_inetaddr_notifier(&nfsd_inetaddr_notifier); 682#if IS_ENABLED(CONFIG_IPV6) 683 register_inet6addr_notifier(&nfsd_inet6addr_notifier); 684#endif 685 } | 398 write_sequnlock(&nn->writeverf_lock); 399} 400 401static int nfsd_startup_net(struct net *net, const struct cred *cred) 402{ 403 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 404 int ret; 405 --- 272 unchanged lines hidden (view full) --- 678 set_max_drc(); 679 /* check if the notifier is already set */ 680 if (atomic_inc_return(&nfsd_notifier_refcount) == 1) { 681 register_inetaddr_notifier(&nfsd_inetaddr_notifier); 682#if IS_ENABLED(CONFIG_IPV6) 683 register_inet6addr_notifier(&nfsd_inet6addr_notifier); 684#endif 685 } |
686 nfsd_reset_boot_verifier(nn); | 686 nfsd_reset_write_verifier(nn); |
687 return 0; 688} 689 690int nfsd_nrpools(struct net *net) 691{ 692 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 693 694 if (nn->nfsd_serv == NULL) --- 454 unchanged lines hidden --- | 687 return 0; 688} 689 690int nfsd_nrpools(struct net *net) 691{ 692 struct nfsd_net *nn = net_generic(net, nfsd_net_id); 693 694 if (nn->nfsd_serv == NULL) --- 454 unchanged lines hidden --- |