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

Configure Feed

Select the types of activity you want to include in your feed.

nfsd: simplify the delayed disposal list code

When queueing a dispose list to the appropriate "freeme" lists, it
pointlessly queues the objects one at a time to an intermediate list.

Remove a few helpers and just open code a list_move to make it more
clear and efficient. Better document the resulting functions with
kerneldoc comments.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

authored by

Jeff Layton and committed by
Chuck Lever
92e4a673 55fcc7d9

+22 -42
+22 -42
fs/nfsd/filecache.c
··· 402 402 } 403 403 } 404 404 405 - static void 406 - nfsd_file_list_remove_disposal(struct list_head *dst, 407 - struct nfsd_fcache_disposal *l) 408 - { 409 - spin_lock(&l->lock); 410 - list_splice_init(&l->freeme, dst); 411 - spin_unlock(&l->lock); 412 - } 413 - 414 - static void 415 - nfsd_file_list_add_disposal(struct list_head *files, struct net *net) 416 - { 417 - struct nfsd_net *nn = net_generic(net, nfsd_net_id); 418 - struct nfsd_fcache_disposal *l = nn->fcache_disposal; 419 - 420 - spin_lock(&l->lock); 421 - list_splice_tail_init(files, &l->freeme); 422 - spin_unlock(&l->lock); 423 - queue_work(nfsd_filecache_wq, &l->work); 424 - } 425 - 426 - static void 427 - nfsd_file_list_add_pernet(struct list_head *dst, struct list_head *src, 428 - struct net *net) 429 - { 430 - struct nfsd_file *nf, *tmp; 431 - 432 - list_for_each_entry_safe(nf, tmp, src, nf_lru) { 433 - if (nf->nf_net == net) 434 - list_move_tail(&nf->nf_lru, dst); 435 - } 436 - } 437 - 405 + /** 406 + * nfsd_file_dispose_list_delayed - move list of dead files to net's freeme list 407 + * @dispose: list of nfsd_files to be disposed 408 + * 409 + * Transfers each file to the "freeme" list for its nfsd_net, to eventually 410 + * be disposed of by the per-net garbage collector. 411 + */ 438 412 static void 439 413 nfsd_file_dispose_list_delayed(struct list_head *dispose) 440 414 { 441 - LIST_HEAD(list); 442 - struct nfsd_file *nf; 443 - 444 415 while(!list_empty(dispose)) { 445 - nf = list_first_entry(dispose, struct nfsd_file, nf_lru); 446 - nfsd_file_list_add_pernet(&list, dispose, nf->nf_net); 447 - nfsd_file_list_add_disposal(&list, nf->nf_net); 416 + struct nfsd_file *nf = list_first_entry(dispose, 417 + struct nfsd_file, nf_lru); 418 + struct nfsd_net *nn = net_generic(nf->nf_net, nfsd_net_id); 419 + struct nfsd_fcache_disposal *l = nn->fcache_disposal; 420 + 421 + spin_lock(&l->lock); 422 + list_move_tail(&nf->nf_lru, &l->freeme); 423 + spin_unlock(&l->lock); 424 + queue_work(nfsd_filecache_wq, &l->work); 448 425 } 449 426 } 450 427 ··· 642 665 * nfsd_file_delayed_close - close unused nfsd_files 643 666 * @work: dummy 644 667 * 645 - * Walk the LRU list and destroy any entries that have not been used since 646 - * the last scan. 668 + * Scrape the freeme list for this nfsd_net, and then dispose of them 669 + * all. 647 670 */ 648 671 static void 649 672 nfsd_file_delayed_close(struct work_struct *work) ··· 652 675 struct nfsd_fcache_disposal *l = container_of(work, 653 676 struct nfsd_fcache_disposal, work); 654 677 655 - nfsd_file_list_remove_disposal(&head, l); 678 + spin_lock(&l->lock); 679 + list_splice_init(&l->freeme, &head); 680 + spin_unlock(&l->lock); 681 + 656 682 nfsd_file_dispose_list(&head); 657 683 } 658 684