Remove the unused bucket array in struct pnfs_ds_commit_info.
Unified · Split
| @@ -217,7 +217,6 @@ static void nfs_direct_req_free(struct kref *kref) · 216 unmodified lines | |||
| 217 | struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref); | 217 | struct nfs_direct_req *dreq = container_of(kref, struct nfs_direct_req, kref); |
| 218 | 218 | ||
| 219 | pnfs_release_ds_info(&dreq->ds_cinfo, dreq->inode); | 219 | pnfs_release_ds_info(&dreq->ds_cinfo, dreq->inode); |
| 220 | nfs_free_pnfs_ds_cinfo(&dreq->ds_cinfo); | ||
| 221 | if (dreq->l_ctx != NULL) | 220 | if (dreq->l_ctx != NULL) |
| 222 | nfs_put_lock_context(dreq->l_ctx); | 221 | nfs_put_lock_context(dreq->l_ctx); |
| 223 | if (dreq->ctx != NULL) | 222 | if (dreq->ctx != NULL) |
| @@ -755,72 +755,12 @@ filelayout_free_lseg(struct pnfs_layout_segment *lseg) · 754 unmodified lines | |||
| 755 | flo = FILELAYOUT_FROM_HDR(lseg->pls_layout); | 755 | flo = FILELAYOUT_FROM_HDR(lseg->pls_layout); |
| 756 | inode = flo->generic_hdr.plh_inode; | 756 | inode = flo->generic_hdr.plh_inode; |
| 757 | spin_lock(&inode->i_lock); | 757 | spin_lock(&inode->i_lock); |
| 758 | flo->commit_info.nbuckets = 0; | ||
| 759 | kfree(flo->commit_info.buckets); | ||
| 760 | flo->commit_info.buckets = NULL; | ||
| 761 | pnfs_generic_ds_cinfo_release_lseg(&flo->commit_info, lseg); | 758 | pnfs_generic_ds_cinfo_release_lseg(&flo->commit_info, lseg); |
| 762 | spin_unlock(&inode->i_lock); | 759 | spin_unlock(&inode->i_lock); |
| 763 | } | 760 | } |
| 764 | _filelayout_free_lseg(fl); | 761 | _filelayout_free_lseg(fl); |
| 765 | } | 762 | } |
| 766 | 763 | ||
| 767 | static int | ||
| 768 | filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg, | ||
| 769 | struct nfs_commit_info *cinfo, | ||
| 770 | gfp_t gfp_flags) | ||
| 771 | { | ||
| 772 | struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); | ||
| 773 | struct pnfs_commit_bucket *buckets; | ||
| 774 | int size, i; | ||
| 775 | |||
| 776 | if (fl->commit_through_mds) | ||
| 777 | return 0; | ||
| 778 | |||
| 779 | size = (fl->stripe_type == STRIPE_SPARSE) ? | ||
| 780 | fl->dsaddr->ds_num : fl->dsaddr->stripe_count; | ||
| 781 | |||
| 782 | if (cinfo->ds->nbuckets >= size) { | ||
| 783 | /* This assumes there is only one IOMODE_RW lseg. What | ||
| 784 | * we really want to do is have a layout_hdr level | ||
| 785 | * dictionary of <multipath_list4, fh> keys, each | ||
| 786 | * associated with a struct list_head, populated by calls | ||
| 787 | * to filelayout_write_pagelist(). | ||
| 788 | * */ | ||
| 789 | return 0; | ||
| 790 | } | ||
| 791 | |||
| 792 | buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket), | ||
| 793 | gfp_flags); | ||
| 794 | if (!buckets) | ||
| 795 | return -ENOMEM; | ||
| 796 | for (i = 0; i < size; i++) { | ||
| 797 | INIT_LIST_HEAD(&buckets[i].written); | ||
| 798 | INIT_LIST_HEAD(&buckets[i].committing); | ||
| 799 | /* mark direct verifier as unset */ | ||
| 800 | buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW; | ||
| 801 | } | ||
| 802 | |||
| 803 | spin_lock(&cinfo->inode->i_lock); | ||
| 804 | if (cinfo->ds->nbuckets >= size) | ||
| 805 | goto out; | ||
| 806 | for (i = 0; i < cinfo->ds->nbuckets; i++) { | ||
| 807 | list_splice(&cinfo->ds->buckets[i].written, | ||
| 808 | &buckets[i].written); | ||
| 809 | list_splice(&cinfo->ds->buckets[i].committing, | ||
| 810 | &buckets[i].committing); | ||
| 811 | buckets[i].direct_verf.committed = | ||
| 812 | cinfo->ds->buckets[i].direct_verf.committed; | ||
| 813 | buckets[i].wlseg = cinfo->ds->buckets[i].wlseg; | ||
| 814 | buckets[i].clseg = cinfo->ds->buckets[i].clseg; | ||
| 815 | } | ||
| 816 | swap(cinfo->ds->buckets, buckets); | ||
| 817 | cinfo->ds->nbuckets = size; | ||
| 818 | out: | ||
| 819 | spin_unlock(&cinfo->inode->i_lock); | ||
| 820 | kfree(buckets); | ||
| 821 | return 0; | ||
| 822 | } | ||
| 823 | |||
| 824 | static struct pnfs_layout_segment * | 764 | static struct pnfs_layout_segment * |
| 825 | filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid, | 765 | filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid, |
| 826 | struct nfs4_layoutget_res *lgr, | 766 | struct nfs4_layoutget_res *lgr, |
| @@ -943,9 +883,6 @@ static void · 116 unmodified lines | |||
| 943 | filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio, | 883 | filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio, |
| 944 | struct nfs_page *req) | 884 | struct nfs_page *req) |
| 945 | { | 885 | { |
| 946 | struct nfs_commit_info cinfo; | ||
| 947 | int status; | ||
| 948 | |||
| 949 | pnfs_generic_pg_check_layout(pgio); | 886 | pnfs_generic_pg_check_layout(pgio); |
| 950 | if (!pgio->pg_lseg) { | 887 | if (!pgio->pg_lseg) { |
| 951 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, | 888 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, |
| @@ -964,17 +901,7 @@ filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio, · 12 unmodified lines | |||
| 964 | 901 | ||
| 965 | /* If no lseg, fall back to write through mds */ | 902 | /* If no lseg, fall back to write through mds */ |
| 966 | if (pgio->pg_lseg == NULL) | 903 | if (pgio->pg_lseg == NULL) |
| 967 | goto out_mds; | 904 | nfs_pageio_reset_write_mds(pgio); |
| 968 | nfs_init_cinfo(&cinfo, pgio->pg_inode, pgio->pg_dreq); | ||
| 969 | status = filelayout_alloc_commit_info(pgio->pg_lseg, &cinfo, GFP_NOFS); | ||
| 970 | if (status < 0) { | ||
| 971 | pnfs_put_lseg(pgio->pg_lseg); | ||
| 972 | pgio->pg_lseg = NULL; | ||
| 973 | goto out_mds; | ||
| 974 | } | ||
| 975 | return; | ||
| 976 | out_mds: | ||
| 977 | nfs_pageio_reset_write_mds(pgio); | ||
| 978 | } | 905 | } |
| 979 | 906 | ||
| 980 | static const struct nfs_pageio_ops filelayout_pg_read_ops = { | 907 | static const struct nfs_pageio_ops filelayout_pg_read_ops = { |
| @@ -550,17 +550,6 @@ out_err_free: · 549 unmodified lines | |||
| 550 | goto out_free_page; | 550 | goto out_free_page; |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | static bool ff_layout_has_rw_segments(struct pnfs_layout_hdr *layout) | ||
| 554 | { | ||
| 555 | struct pnfs_layout_segment *lseg; | ||
| 556 | |||
| 557 | list_for_each_entry(lseg, &layout->plh_segs, pls_list) | ||
| 558 | if (lseg->pls_range.iomode == IOMODE_RW) | ||
| 559 | return true; | ||
| 560 | |||
| 561 | return false; | ||
| 562 | } | ||
| 563 | |||
| 564 | static void | 553 | static void |
| 565 | ff_layout_free_lseg(struct pnfs_layout_segment *lseg) | 554 | ff_layout_free_lseg(struct pnfs_layout_segment *lseg) |
| 566 | { | 555 | { |
| @@ -575,24 +564,12 @@ ff_layout_free_lseg(struct pnfs_layout_segment *lseg) · 8 unmodified lines | |||
| 575 | ffl = FF_LAYOUT_FROM_HDR(lseg->pls_layout); | 564 | ffl = FF_LAYOUT_FROM_HDR(lseg->pls_layout); |
| 576 | inode = ffl->generic_hdr.plh_inode; | 565 | inode = ffl->generic_hdr.plh_inode; |
| 577 | spin_lock(&inode->i_lock); | 566 | spin_lock(&inode->i_lock); |
| 578 | if (!ff_layout_has_rw_segments(lseg->pls_layout)) { | ||
| 579 | ffl->commit_info.nbuckets = 0; | ||
| 580 | kfree(ffl->commit_info.buckets); | ||
| 581 | ffl->commit_info.buckets = NULL; | ||
| 582 | } | ||
| 583 | pnfs_generic_ds_cinfo_release_lseg(&ffl->commit_info, lseg); | 567 | pnfs_generic_ds_cinfo_release_lseg(&ffl->commit_info, lseg); |
| 584 | spin_unlock(&inode->i_lock); | 568 | spin_unlock(&inode->i_lock); |
| 585 | } | 569 | } |
| 586 | _ff_layout_free_lseg(fls); | 570 | _ff_layout_free_lseg(fls); |
| 587 | } | 571 | } |
| 588 | 572 | ||
| 589 | /* Return 1 until we have multiple lsegs support */ | ||
| 590 | static int | ||
| 591 | ff_layout_get_lseg_count(struct nfs4_ff_layout_segment *fls) | ||
| 592 | { | ||
| 593 | return 1; | ||
| 594 | } | ||
| 595 | |||
| 596 | static void | 573 | static void |
| 597 | nfs4_ff_start_busy_timer(struct nfs4_ff_busy_timer *timer, ktime_t now) | 574 | nfs4_ff_start_busy_timer(struct nfs4_ff_busy_timer *timer, ktime_t now) |
| 598 | { | 575 | { |
| @@ -737,52 +714,6 @@ nfs4_ff_layout_stat_io_end_write(struct rpc_task *task, · 138 unmodified lines | |||
| 737 | spin_unlock(&mirror->lock); | 714 | spin_unlock(&mirror->lock); |
| 738 | } | 715 | } |
| 739 | 716 | ||
| 740 | static int | ||
| 741 | ff_layout_alloc_commit_info(struct pnfs_layout_segment *lseg, | ||
| 742 | struct nfs_commit_info *cinfo, | ||
| 743 | gfp_t gfp_flags) | ||
| 744 | { | ||
| 745 | struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg); | ||
| 746 | struct pnfs_commit_bucket *buckets; | ||
| 747 | int size; | ||
| 748 | |||
| 749 | if (cinfo->ds->nbuckets != 0) { | ||
| 750 | /* This assumes there is only one RW lseg per file. | ||
| 751 | * To support multiple lseg per file, we need to | ||
| 752 | * change struct pnfs_commit_bucket to allow dynamic | ||
| 753 | * increasing nbuckets. | ||
| 754 | */ | ||
| 755 | return 0; | ||
| 756 | } | ||
| 757 | |||
| 758 | size = ff_layout_get_lseg_count(fls) * FF_LAYOUT_MIRROR_COUNT(lseg); | ||
| 759 | |||
| 760 | buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket), | ||
| 761 | gfp_flags); | ||
| 762 | if (!buckets) | ||
| 763 | return -ENOMEM; | ||
| 764 | else { | ||
| 765 | int i; | ||
| 766 | |||
| 767 | spin_lock(&cinfo->inode->i_lock); | ||
| 768 | if (cinfo->ds->nbuckets != 0) | ||
| 769 | kfree(buckets); | ||
| 770 | else { | ||
| 771 | cinfo->ds->buckets = buckets; | ||
| 772 | cinfo->ds->nbuckets = size; | ||
| 773 | for (i = 0; i < size; i++) { | ||
| 774 | INIT_LIST_HEAD(&buckets[i].written); | ||
| 775 | INIT_LIST_HEAD(&buckets[i].committing); | ||
| 776 | /* mark direct verifier as unset */ | ||
| 777 | buckets[i].direct_verf.committed = | ||
| 778 | NFS_INVALID_STABLE_HOW; | ||
| 779 | } | ||
| 780 | } | ||
| 781 | spin_unlock(&cinfo->inode->i_lock); | ||
| 782 | return 0; | ||
| 783 | } | ||
| 784 | } | ||
| 785 | |||
| 786 | static void | 717 | static void |
| 787 | ff_layout_mark_ds_unreachable(struct pnfs_layout_segment *lseg, int idx) | 718 | ff_layout_mark_ds_unreachable(struct pnfs_layout_segment *lseg, int idx) |
| 788 | { | 719 | { |
| @@ -944,10 +875,8 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio, · 155 unmodified lines | |||
| 944 | { | 875 | { |
| 945 | struct nfs4_ff_layout_mirror *mirror; | 876 | struct nfs4_ff_layout_mirror *mirror; |
| 946 | struct nfs_pgio_mirror *pgm; | 877 | struct nfs_pgio_mirror *pgm; |
| 947 | struct nfs_commit_info cinfo; | ||
| 948 | struct nfs4_pnfs_ds *ds; | 878 | struct nfs4_pnfs_ds *ds; |
| 949 | int i; | 879 | int i; |
| 950 | int status; | ||
| 951 | 880 | ||
| 952 | retry: | 881 | retry: |
| 953 | pnfs_generic_pg_check_layout(pgio); | 882 | pnfs_generic_pg_check_layout(pgio); |
| @@ -969,11 +898,6 @@ retry: · 15 unmodified lines | |||
| 969 | if (pgio->pg_lseg == NULL) | 898 | if (pgio->pg_lseg == NULL) |
| 970 | goto out_mds; | 899 | goto out_mds; |
| 971 | 900 | ||
| 972 | nfs_init_cinfo(&cinfo, pgio->pg_inode, pgio->pg_dreq); | ||
| 973 | status = ff_layout_alloc_commit_info(pgio->pg_lseg, &cinfo, GFP_NOFS); | ||
| 974 | if (status < 0) | ||
| 975 | goto out_mds; | ||
| 976 | |||
| 977 | /* Use a direct mapping of ds_idx to pgio mirror_idx */ | 901 | /* Use a direct mapping of ds_idx to pgio mirror_idx */ |
| 978 | if (WARN_ON_ONCE(pgio->pg_mirror_count != | 902 | if (WARN_ON_ONCE(pgio->pg_mirror_count != |
| 979 | FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg))) | 903 | FF_LAYOUT_MIRROR_COUNT(pgio->pg_lseg))) |
| @@ -531,9 +531,6 @@ void nfs_clear_pnfs_ds_commit_verifiers(struct pnfs_ds_commit_info *cinfo) · 530 unmodified lines | |||
| 531 | { | 531 | { |
| 532 | struct pnfs_commit_array *array; | 532 | struct pnfs_commit_array *array; |
| 533 | 533 | ||
| 534 | pnfs_bucket_clear_pnfs_ds_commit_verifiers(cinfo->buckets, | ||
| 535 | cinfo->nbuckets); | ||
| 536 | |||
| 537 | rcu_read_lock(); | 534 | rcu_read_lock(); |
| 538 | list_for_each_entry_rcu(array, &cinfo->commits, cinfo_list) | 535 | list_for_each_entry_rcu(array, &cinfo->commits, cinfo_list) |
| 539 | pnfs_bucket_clear_pnfs_ds_commit_verifiers(array->buckets, | 536 | pnfs_bucket_clear_pnfs_ds_commit_verifiers(array->buckets, |
| @@ -292,12 +292,6 @@ int pnfs_generic_scan_commit_lists(struct nfs_commit_info *cinfo, int max) · 291 unmodified lines | |||
| 292 | struct pnfs_commit_array *array; | 292 | struct pnfs_commit_array *array; |
| 293 | int rv = 0, cnt; | 293 | int rv = 0, cnt; |
| 294 | 294 | ||
| 295 | cnt = pnfs_bucket_scan_array(cinfo, fl_cinfo->buckets, | ||
| 296 | fl_cinfo->nbuckets, max); | ||
| 297 | rv += cnt; | ||
| 298 | max -= cnt; | ||
| 299 | if (!max) | ||
| 300 | return rv; | ||
| 301 | rcu_read_lock(); | 295 | rcu_read_lock(); |
| 302 | list_for_each_entry_rcu(array, &fl_cinfo->commits, cinfo_list) { | 296 | list_for_each_entry_rcu(array, &fl_cinfo->commits, cinfo_list) { |
| 303 | if (!array->lseg || !pnfs_get_commit_array(array)) | 297 | if (!array->lseg || !pnfs_get_commit_array(array)) |
| @@ -353,11 +347,6 @@ void pnfs_generic_recover_commit_reqs(struct list_head *dst, · 49 unmodified lines | |||
| 353 | unsigned int nwritten; | 347 | unsigned int nwritten; |
| 354 | 348 | ||
| 355 | lockdep_assert_held(&NFS_I(cinfo->inode)->commit_mutex); | 349 | lockdep_assert_held(&NFS_I(cinfo->inode)->commit_mutex); |
| 356 | nwritten = pnfs_bucket_recover_commit_reqs(dst, | ||
| 357 | fl_cinfo->buckets, | ||
| 358 | fl_cinfo->nbuckets, | ||
| 359 | cinfo); | ||
| 360 | fl_cinfo->nwritten -= nwritten; | ||
| 361 | rcu_read_lock(); | 350 | rcu_read_lock(); |
| 362 | list_for_each_entry_rcu(array, &fl_cinfo->commits, cinfo_list) { | 351 | list_for_each_entry_rcu(array, &fl_cinfo->commits, cinfo_list) { |
| 363 | if (!array->lseg || !pnfs_get_commit_array(array)) | 352 | if (!array->lseg || !pnfs_get_commit_array(array)) |
| @@ -412,10 +401,6 @@ pnfs_generic_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page · 48 unmodified lines | |||
| 412 | struct pnfs_commit_array *array; | 401 | struct pnfs_commit_array *array; |
| 413 | struct nfs_page *req; | 402 | struct nfs_page *req; |
| 414 | 403 | ||
| 415 | req = pnfs_bucket_search_commit_reqs(fl_cinfo->buckets, | ||
| 416 | fl_cinfo->nbuckets, page); | ||
| 417 | if (req) | ||
| 418 | return req; | ||
| 419 | list_for_each_entry(array, &fl_cinfo->commits, cinfo_list) { | 404 | list_for_each_entry(array, &fl_cinfo->commits, cinfo_list) { |
| 420 | req = pnfs_bucket_search_commit_reqs(array->buckets, | 405 | req = pnfs_bucket_search_commit_reqs(array->buckets, |
| 421 | array->nbuckets, page); | 406 | array->nbuckets, page); |
| @@ -550,9 +535,6 @@ pnfs_generic_commit_pagelist(struct inode *inode, struct list_head *mds_pages, · 128 unmodified lines | |||
| 550 | nreq++; | 535 | nreq++; |
| 551 | } | 536 | } |
| 552 | 537 | ||
| 553 | nreq += pnfs_bucket_alloc_ds_commits(&list, fl_cinfo->buckets, | ||
| 554 | fl_cinfo->nbuckets, cinfo); | ||
| 555 | |||
| 556 | nreq += pnfs_alloc_ds_commits_list(&list, fl_cinfo, cinfo); | 538 | nreq += pnfs_alloc_ds_commits_list(&list, fl_cinfo, cinfo); |
| 557 | if (nreq == 0) | 539 | if (nreq == 0) |
| 558 | goto out; | 540 | goto out; |
| @@ -1284,8 +1284,6 @@ struct pnfs_ds_commit_info { · 1283 unmodified lines | |||
| 1284 | struct list_head commits; | 1284 | struct list_head commits; |
| 1285 | unsigned int nwritten; | 1285 | unsigned int nwritten; |
| 1286 | unsigned int ncommitting; | 1286 | unsigned int ncommitting; |
| 1287 | unsigned int nbuckets; | ||
| 1288 | struct pnfs_commit_bucket *buckets; | ||
| 1289 | }; | 1287 | }; |
| 1290 | 1288 | ||
| 1291 | struct nfs41_state_protection { | 1289 | struct nfs41_state_protection { |
| @@ -1396,22 +1394,11 @@ struct nfs41_free_stateid_res { · 104 unmodified lines | |||
| 1396 | unsigned int status; | 1394 | unsigned int status; |
| 1397 | }; | 1395 | }; |
| 1398 | 1396 | ||
| 1399 | static inline void | ||
| 1400 | nfs_free_pnfs_ds_cinfo(struct pnfs_ds_commit_info *cinfo) | ||
| 1401 | { | ||
| 1402 | kfree(cinfo->buckets); | ||
| 1403 | } | ||
| 1404 | |||
| 1405 | #else | 1397 | #else |
| 1406 | 1398 | ||
| 1407 | struct pnfs_ds_commit_info { | 1399 | struct pnfs_ds_commit_info { |
| 1408 | }; | 1400 | }; |
| 1409 | 1401 | ||
| 1410 | static inline void | ||
| 1411 | nfs_free_pnfs_ds_cinfo(struct pnfs_ds_commit_info *cinfo) | ||
| 1412 | { | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | #endif /* CONFIG_NFS_V4_1 */ | 1402 | #endif /* CONFIG_NFS_V4_1 */ |
| 1416 | 1403 | ||
| 1417 | #ifdef CONFIG_NFS_V4_2 | 1404 | #ifdef CONFIG_NFS_V4_2 |