diff options
author | Weston Andros Adamson <dros@primarydata.com> | 2014-06-09 11:48:35 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2014-06-24 18:47:00 -0400 |
commit | d45f60c67848b9f19160692581d78e5b4757a000 (patch) | |
tree | 5f31965abe5bd21e73eae10454db74fe6ce901e9 /fs/nfs/pagelist.c | |
parent | 823b0c9d9800e712374cda89ac3565bd29f6701b (diff) |
nfs: merge nfs_pgio_data into _header
struct nfs_pgio_data only exists as a member of nfs_pgio_header, but is
passed around everywhere, because there used to be multiple _data structs
per _header. Many of these functions then use the _data to find a pointer
to the _header. This patch cleans this up by merging the nfs_pgio_data
structure into nfs_pgio_header and passing nfs_pgio_header around instead.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Weston Andros Adamson <dros@primarydata.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs/pagelist.c')
-rw-r--r-- | fs/nfs/pagelist.c | 120 |
1 files changed, 58 insertions, 62 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 5e70918f6c95..ecb3d4cdbc85 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -484,8 +484,7 @@ EXPORT_SYMBOL_GPL(nfs_pgio_header_free); | |||
484 | static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, | 484 | static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, |
485 | unsigned int pagecount) | 485 | unsigned int pagecount) |
486 | { | 486 | { |
487 | if (nfs_pgarray_set(&hdr->data.page_array, pagecount)) { | 487 | if (nfs_pgarray_set(&hdr->page_array, pagecount)) { |
488 | hdr->data.header = hdr; | ||
489 | atomic_inc(&hdr->refcnt); | 488 | atomic_inc(&hdr->refcnt); |
490 | return true; | 489 | return true; |
491 | } | 490 | } |
@@ -493,16 +492,14 @@ static bool nfs_pgio_data_init(struct nfs_pgio_header *hdr, | |||
493 | } | 492 | } |
494 | 493 | ||
495 | /** | 494 | /** |
496 | * nfs_pgio_data_destroy - Properly free pageio data | 495 | * nfs_pgio_data_destroy - Properly release pageio data |
497 | * @data: The data to destroy | 496 | * @hdr: The header with data to destroy |
498 | */ | 497 | */ |
499 | void nfs_pgio_data_destroy(struct nfs_pgio_data *data) | 498 | void nfs_pgio_data_destroy(struct nfs_pgio_header *hdr) |
500 | { | 499 | { |
501 | struct nfs_pgio_header *hdr = data->header; | 500 | put_nfs_open_context(hdr->args.context); |
502 | 501 | if (hdr->page_array.pagevec != hdr->page_array.page_array) | |
503 | put_nfs_open_context(data->args.context); | 502 | kfree(hdr->page_array.pagevec); |
504 | if (data->page_array.pagevec != data->page_array.page_array) | ||
505 | kfree(data->page_array.pagevec); | ||
506 | if (atomic_dec_and_test(&hdr->refcnt)) | 503 | if (atomic_dec_and_test(&hdr->refcnt)) |
507 | hdr->completion_ops->completion(hdr); | 504 | hdr->completion_ops->completion(hdr); |
508 | } | 505 | } |
@@ -510,31 +507,31 @@ EXPORT_SYMBOL_GPL(nfs_pgio_data_destroy); | |||
510 | 507 | ||
511 | /** | 508 | /** |
512 | * nfs_pgio_rpcsetup - Set up arguments for a pageio call | 509 | * nfs_pgio_rpcsetup - Set up arguments for a pageio call |
513 | * @data: The pageio data | 510 | * @hdr: The pageio hdr |
514 | * @count: Number of bytes to read | 511 | * @count: Number of bytes to read |
515 | * @offset: Initial offset | 512 | * @offset: Initial offset |
516 | * @how: How to commit data (writes only) | 513 | * @how: How to commit data (writes only) |
517 | * @cinfo: Commit information for the call (writes only) | 514 | * @cinfo: Commit information for the call (writes only) |
518 | */ | 515 | */ |
519 | static void nfs_pgio_rpcsetup(struct nfs_pgio_data *data, | 516 | static void nfs_pgio_rpcsetup(struct nfs_pgio_header *hdr, |
520 | unsigned int count, unsigned int offset, | 517 | unsigned int count, unsigned int offset, |
521 | int how, struct nfs_commit_info *cinfo) | 518 | int how, struct nfs_commit_info *cinfo) |
522 | { | 519 | { |
523 | struct nfs_page *req = data->header->req; | 520 | struct nfs_page *req = hdr->req; |
524 | 521 | ||
525 | /* Set up the RPC argument and reply structs | 522 | /* Set up the RPC argument and reply structs |
526 | * NB: take care not to mess about with data->commit et al. */ | 523 | * NB: take care not to mess about with hdr->commit et al. */ |
527 | 524 | ||
528 | data->args.fh = NFS_FH(data->header->inode); | 525 | hdr->args.fh = NFS_FH(hdr->inode); |
529 | data->args.offset = req_offset(req) + offset; | 526 | hdr->args.offset = req_offset(req) + offset; |
530 | /* pnfs_set_layoutcommit needs this */ | 527 | /* pnfs_set_layoutcommit needs this */ |
531 | data->mds_offset = data->args.offset; | 528 | hdr->mds_offset = hdr->args.offset; |
532 | data->args.pgbase = req->wb_pgbase + offset; | 529 | hdr->args.pgbase = req->wb_pgbase + offset; |
533 | data->args.pages = data->page_array.pagevec; | 530 | hdr->args.pages = hdr->page_array.pagevec; |
534 | data->args.count = count; | 531 | hdr->args.count = count; |
535 | data->args.context = get_nfs_open_context(req->wb_context); | 532 | hdr->args.context = get_nfs_open_context(req->wb_context); |
536 | data->args.lock_context = req->wb_lock_context; | 533 | hdr->args.lock_context = req->wb_lock_context; |
537 | data->args.stable = NFS_UNSTABLE; | 534 | hdr->args.stable = NFS_UNSTABLE; |
538 | switch (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) { | 535 | switch (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) { |
539 | case 0: | 536 | case 0: |
540 | break; | 537 | break; |
@@ -542,59 +539,60 @@ static void nfs_pgio_rpcsetup(struct nfs_pgio_data *data, | |||
542 | if (nfs_reqs_to_commit(cinfo)) | 539 | if (nfs_reqs_to_commit(cinfo)) |
543 | break; | 540 | break; |
544 | default: | 541 | default: |
545 | data->args.stable = NFS_FILE_SYNC; | 542 | hdr->args.stable = NFS_FILE_SYNC; |
546 | } | 543 | } |
547 | 544 | ||
548 | data->res.fattr = &data->fattr; | 545 | hdr->res.fattr = &hdr->fattr; |
549 | data->res.count = count; | 546 | hdr->res.count = count; |
550 | data->res.eof = 0; | 547 | hdr->res.eof = 0; |
551 | data->res.verf = &data->writeverf; | 548 | hdr->res.verf = &hdr->writeverf; |
552 | nfs_fattr_init(&data->fattr); | 549 | nfs_fattr_init(&hdr->fattr); |
553 | } | 550 | } |
554 | 551 | ||
555 | /** | 552 | /** |
556 | * nfs_pgio_prepare - Prepare pageio data to go over the wire | 553 | * nfs_pgio_prepare - Prepare pageio hdr to go over the wire |
557 | * @task: The current task | 554 | * @task: The current task |
558 | * @calldata: pageio data to prepare | 555 | * @calldata: pageio header to prepare |
559 | */ | 556 | */ |
560 | static void nfs_pgio_prepare(struct rpc_task *task, void *calldata) | 557 | static void nfs_pgio_prepare(struct rpc_task *task, void *calldata) |
561 | { | 558 | { |
562 | struct nfs_pgio_data *data = calldata; | 559 | struct nfs_pgio_header *hdr = calldata; |
563 | int err; | 560 | int err; |
564 | err = NFS_PROTO(data->header->inode)->pgio_rpc_prepare(task, data); | 561 | err = NFS_PROTO(hdr->inode)->pgio_rpc_prepare(task, hdr); |
565 | if (err) | 562 | if (err) |
566 | rpc_exit(task, err); | 563 | rpc_exit(task, err); |
567 | } | 564 | } |
568 | 565 | ||
569 | int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_data *data, | 566 | int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr, |
570 | const struct rpc_call_ops *call_ops, int how, int flags) | 567 | const struct rpc_call_ops *call_ops, int how, int flags) |
571 | { | 568 | { |
569 | struct inode *inode = hdr->inode; | ||
572 | struct rpc_task *task; | 570 | struct rpc_task *task; |
573 | struct rpc_message msg = { | 571 | struct rpc_message msg = { |
574 | .rpc_argp = &data->args, | 572 | .rpc_argp = &hdr->args, |
575 | .rpc_resp = &data->res, | 573 | .rpc_resp = &hdr->res, |
576 | .rpc_cred = data->header->cred, | 574 | .rpc_cred = hdr->cred, |
577 | }; | 575 | }; |
578 | struct rpc_task_setup task_setup_data = { | 576 | struct rpc_task_setup task_setup_data = { |
579 | .rpc_client = clnt, | 577 | .rpc_client = clnt, |
580 | .task = &data->task, | 578 | .task = &hdr->task, |
581 | .rpc_message = &msg, | 579 | .rpc_message = &msg, |
582 | .callback_ops = call_ops, | 580 | .callback_ops = call_ops, |
583 | .callback_data = data, | 581 | .callback_data = hdr, |
584 | .workqueue = nfsiod_workqueue, | 582 | .workqueue = nfsiod_workqueue, |
585 | .flags = RPC_TASK_ASYNC | flags, | 583 | .flags = RPC_TASK_ASYNC | flags, |
586 | }; | 584 | }; |
587 | int ret = 0; | 585 | int ret = 0; |
588 | 586 | ||
589 | data->header->rw_ops->rw_initiate(data, &msg, &task_setup_data, how); | 587 | hdr->rw_ops->rw_initiate(hdr, &msg, &task_setup_data, how); |
590 | 588 | ||
591 | dprintk("NFS: %5u initiated pgio call " | 589 | dprintk("NFS: %5u initiated pgio call " |
592 | "(req %s/%llu, %u bytes @ offset %llu)\n", | 590 | "(req %s/%llu, %u bytes @ offset %llu)\n", |
593 | data->task.tk_pid, | 591 | hdr->task.tk_pid, |
594 | data->header->inode->i_sb->s_id, | 592 | inode->i_sb->s_id, |
595 | (unsigned long long)NFS_FILEID(data->header->inode), | 593 | (unsigned long long)NFS_FILEID(inode), |
596 | data->args.count, | 594 | hdr->args.count, |
597 | (unsigned long long)data->args.offset); | 595 | (unsigned long long)hdr->args.offset); |
598 | 596 | ||
599 | task = rpc_run_task(&task_setup_data); | 597 | task = rpc_run_task(&task_setup_data); |
600 | if (IS_ERR(task)) { | 598 | if (IS_ERR(task)) { |
@@ -621,21 +619,21 @@ static int nfs_pgio_error(struct nfs_pageio_descriptor *desc, | |||
621 | struct nfs_pgio_header *hdr) | 619 | struct nfs_pgio_header *hdr) |
622 | { | 620 | { |
623 | set_bit(NFS_IOHDR_REDO, &hdr->flags); | 621 | set_bit(NFS_IOHDR_REDO, &hdr->flags); |
624 | nfs_pgio_data_destroy(&hdr->data); | 622 | nfs_pgio_data_destroy(hdr); |
625 | desc->pg_completion_ops->error_cleanup(&desc->pg_list); | 623 | desc->pg_completion_ops->error_cleanup(&desc->pg_list); |
626 | return -ENOMEM; | 624 | return -ENOMEM; |
627 | } | 625 | } |
628 | 626 | ||
629 | /** | 627 | /** |
630 | * nfs_pgio_release - Release pageio data | 628 | * nfs_pgio_release - Release pageio data |
631 | * @calldata: The pageio data to release | 629 | * @calldata: The pageio header to release |
632 | */ | 630 | */ |
633 | static void nfs_pgio_release(void *calldata) | 631 | static void nfs_pgio_release(void *calldata) |
634 | { | 632 | { |
635 | struct nfs_pgio_data *data = calldata; | 633 | struct nfs_pgio_header *hdr = calldata; |
636 | if (data->header->rw_ops->rw_release) | 634 | if (hdr->rw_ops->rw_release) |
637 | data->header->rw_ops->rw_release(data); | 635 | hdr->rw_ops->rw_release(hdr); |
638 | nfs_pgio_data_destroy(data); | 636 | nfs_pgio_data_destroy(hdr); |
639 | } | 637 | } |
640 | 638 | ||
641 | /** | 639 | /** |
@@ -676,22 +674,22 @@ EXPORT_SYMBOL_GPL(nfs_pageio_init); | |||
676 | /** | 674 | /** |
677 | * nfs_pgio_result - Basic pageio error handling | 675 | * nfs_pgio_result - Basic pageio error handling |
678 | * @task: The task that ran | 676 | * @task: The task that ran |
679 | * @calldata: Pageio data to check | 677 | * @calldata: Pageio header to check |
680 | */ | 678 | */ |
681 | static void nfs_pgio_result(struct rpc_task *task, void *calldata) | 679 | static void nfs_pgio_result(struct rpc_task *task, void *calldata) |
682 | { | 680 | { |
683 | struct nfs_pgio_data *data = calldata; | 681 | struct nfs_pgio_header *hdr = calldata; |
684 | struct inode *inode = data->header->inode; | 682 | struct inode *inode = hdr->inode; |
685 | 683 | ||
686 | dprintk("NFS: %s: %5u, (status %d)\n", __func__, | 684 | dprintk("NFS: %s: %5u, (status %d)\n", __func__, |
687 | task->tk_pid, task->tk_status); | 685 | task->tk_pid, task->tk_status); |
688 | 686 | ||
689 | if (data->header->rw_ops->rw_done(task, data, inode) != 0) | 687 | if (hdr->rw_ops->rw_done(task, hdr, inode) != 0) |
690 | return; | 688 | return; |
691 | if (task->tk_status < 0) | 689 | if (task->tk_status < 0) |
692 | nfs_set_pgio_error(data->header, task->tk_status, data->args.offset); | 690 | nfs_set_pgio_error(hdr, task->tk_status, hdr->args.offset); |
693 | else | 691 | else |
694 | data->header->rw_ops->rw_result(task, data); | 692 | hdr->rw_ops->rw_result(task, hdr); |
695 | } | 693 | } |
696 | 694 | ||
697 | /* | 695 | /* |
@@ -707,7 +705,6 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, | |||
707 | { | 705 | { |
708 | struct nfs_page *req; | 706 | struct nfs_page *req; |
709 | struct page **pages; | 707 | struct page **pages; |
710 | struct nfs_pgio_data *data; | ||
711 | struct list_head *head = &desc->pg_list; | 708 | struct list_head *head = &desc->pg_list; |
712 | struct nfs_commit_info cinfo; | 709 | struct nfs_commit_info cinfo; |
713 | 710 | ||
@@ -715,9 +712,8 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, | |||
715 | desc->pg_count))) | 712 | desc->pg_count))) |
716 | return nfs_pgio_error(desc, hdr); | 713 | return nfs_pgio_error(desc, hdr); |
717 | 714 | ||
718 | data = &hdr->data; | ||
719 | nfs_init_cinfo(&cinfo, desc->pg_inode, desc->pg_dreq); | 715 | nfs_init_cinfo(&cinfo, desc->pg_inode, desc->pg_dreq); |
720 | pages = data->page_array.pagevec; | 716 | pages = hdr->page_array.pagevec; |
721 | while (!list_empty(head)) { | 717 | while (!list_empty(head)) { |
722 | req = nfs_list_entry(head->next); | 718 | req = nfs_list_entry(head->next); |
723 | nfs_list_remove_request(req); | 719 | nfs_list_remove_request(req); |
@@ -730,7 +726,7 @@ int nfs_generic_pgio(struct nfs_pageio_descriptor *desc, | |||
730 | desc->pg_ioflags &= ~FLUSH_COND_STABLE; | 726 | desc->pg_ioflags &= ~FLUSH_COND_STABLE; |
731 | 727 | ||
732 | /* Set up the argument struct */ | 728 | /* Set up the argument struct */ |
733 | nfs_pgio_rpcsetup(data, desc->pg_count, 0, desc->pg_ioflags, &cinfo); | 729 | nfs_pgio_rpcsetup(hdr, desc->pg_count, 0, desc->pg_ioflags, &cinfo); |
734 | desc->pg_rpc_callops = &nfs_pgio_common_ops; | 730 | desc->pg_rpc_callops = &nfs_pgio_common_ops; |
735 | return 0; | 731 | return 0; |
736 | } | 732 | } |
@@ -751,7 +747,7 @@ static int nfs_generic_pg_pgios(struct nfs_pageio_descriptor *desc) | |||
751 | ret = nfs_generic_pgio(desc, hdr); | 747 | ret = nfs_generic_pgio(desc, hdr); |
752 | if (ret == 0) | 748 | if (ret == 0) |
753 | ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode), | 749 | ret = nfs_initiate_pgio(NFS_CLIENT(hdr->inode), |
754 | &hdr->data, desc->pg_rpc_callops, | 750 | hdr, desc->pg_rpc_callops, |
755 | desc->pg_ioflags, 0); | 751 | desc->pg_ioflags, 0); |
756 | if (atomic_dec_and_test(&hdr->refcnt)) | 752 | if (atomic_dec_and_test(&hdr->refcnt)) |
757 | hdr->completion_ops->completion(hdr); | 753 | hdr->completion_ops->completion(hdr); |