aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@primarydata.com>2014-05-15 11:56:49 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-05-29 11:11:46 -0400
commitdd7663e7000d3408b5a5037ae8f774feaa9c0628 (patch)
treeb8f2422e7179b98b18b7873d39ac4dc3f7e4f8d9
parentd72ddcbab60a70258d0cd5752db3f53824df78d6 (diff)
pnfs: clean up filelayout_alloc_commit_info
Remove unneeded else statement and clean up how commit info dataserver buckets are replaced. Suggested-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Weston Andros Adamson <dros@primarydata.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/nfs4filelayout.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/fs/nfs/nfs4filelayout.c b/fs/nfs/nfs4filelayout.c
index 9319427e43e3..9cea9358fe52 100644
--- a/fs/nfs/nfs4filelayout.c
+++ b/fs/nfs/nfs4filelayout.c
@@ -850,11 +850,15 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
850{ 850{
851 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); 851 struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
852 struct pnfs_commit_bucket *buckets; 852 struct pnfs_commit_bucket *buckets;
853 int size; 853 int size, i;
854 854
855 if (fl->commit_through_mds) 855 if (fl->commit_through_mds)
856 return 0; 856 return 0;
857 if (cinfo->ds->nbuckets != 0) { 857
858 size = (fl->stripe_type == STRIPE_SPARSE) ?
859 fl->dsaddr->ds_num : fl->dsaddr->stripe_count;
860
861 if (cinfo->ds->nbuckets >= size) {
858 /* This assumes there is only one IOMODE_RW lseg. What 862 /* This assumes there is only one IOMODE_RW lseg. What
859 * we really want to do is have a layout_hdr level 863 * we really want to do is have a layout_hdr level
860 * dictionary of <multipath_list4, fh> keys, each 864 * dictionary of <multipath_list4, fh> keys, each
@@ -864,30 +868,32 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
864 return 0; 868 return 0;
865 } 869 }
866 870
867 size = (fl->stripe_type == STRIPE_SPARSE) ?
868 fl->dsaddr->ds_num : fl->dsaddr->stripe_count;
869
870 buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket), 871 buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket),
871 gfp_flags); 872 gfp_flags);
872 if (!buckets) 873 if (!buckets)
873 return -ENOMEM; 874 return -ENOMEM;
874 else { 875 for (i = 0; i < size; i++) {
875 int i; 876 INIT_LIST_HEAD(&buckets[i].written);
877 INIT_LIST_HEAD(&buckets[i].committing);
878 }
876 879
877 spin_lock(cinfo->lock); 880 spin_lock(cinfo->lock);
878 if (cinfo->ds->nbuckets != 0) 881 if (cinfo->ds->nbuckets >= size)
879 kfree(buckets); 882 goto out;
880 else { 883 for (i = 0; i < cinfo->ds->nbuckets; i++) {
881 cinfo->ds->buckets = buckets; 884 list_splice(&cinfo->ds->buckets[i].written,
882 cinfo->ds->nbuckets = size; 885 &buckets[i].written);
883 for (i = 0; i < size; i++) { 886 list_splice(&cinfo->ds->buckets[i].committing,
884 INIT_LIST_HEAD(&buckets[i].written); 887 &buckets[i].committing);
885 INIT_LIST_HEAD(&buckets[i].committing); 888 buckets[i].wlseg = cinfo->ds->buckets[i].wlseg;
886 } 889 buckets[i].clseg = cinfo->ds->buckets[i].clseg;
887 }
888 spin_unlock(cinfo->lock);
889 return 0;
890 } 890 }
891 swap(cinfo->ds->buckets, buckets);
892 cinfo->ds->nbuckets = size;
893out:
894 spin_unlock(cinfo->lock);
895 kfree(buckets);
896 return 0;
891} 897}
892 898
893static struct pnfs_layout_segment * 899static struct pnfs_layout_segment *