提交 dd7663e7 编写于 作者: W Weston Andros Adamson 提交者: Trond Myklebust

pnfs: clean up filelayout_alloc_commit_info

Remove unneeded else statement and clean up how commit info
dataserver buckets are replaced.
Suggested-by: NTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: NWeston Andros Adamson <dros@primarydata.com>
Signed-off-by: NTrond Myklebust <trond.myklebust@primarydata.com>
上级 d72ddcba
...@@ -850,11 +850,15 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg, ...@@ -850,11 +850,15 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
{ {
struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg); struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
struct pnfs_commit_bucket *buckets; struct pnfs_commit_bucket *buckets;
int size; int size, i;
if (fl->commit_through_mds) if (fl->commit_through_mds)
return 0; return 0;
if (cinfo->ds->nbuckets != 0) {
size = (fl->stripe_type == STRIPE_SPARSE) ?
fl->dsaddr->ds_num : fl->dsaddr->stripe_count;
if (cinfo->ds->nbuckets >= size) {
/* This assumes there is only one IOMODE_RW lseg. What /* This assumes there is only one IOMODE_RW lseg. What
* we really want to do is have a layout_hdr level * we really want to do is have a layout_hdr level
* dictionary of <multipath_list4, fh> keys, each * dictionary of <multipath_list4, fh> keys, each
...@@ -864,30 +868,32 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg, ...@@ -864,30 +868,32 @@ filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
return 0; return 0;
} }
size = (fl->stripe_type == STRIPE_SPARSE) ?
fl->dsaddr->ds_num : fl->dsaddr->stripe_count;
buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket), buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket),
gfp_flags); gfp_flags);
if (!buckets) if (!buckets)
return -ENOMEM; return -ENOMEM;
else { for (i = 0; i < size; i++) {
int i; INIT_LIST_HEAD(&buckets[i].written);
INIT_LIST_HEAD(&buckets[i].committing);
}
spin_lock(cinfo->lock); spin_lock(cinfo->lock);
if (cinfo->ds->nbuckets != 0) if (cinfo->ds->nbuckets >= size)
kfree(buckets); goto out;
else { for (i = 0; i < cinfo->ds->nbuckets; i++) {
cinfo->ds->buckets = buckets; list_splice(&cinfo->ds->buckets[i].written,
cinfo->ds->nbuckets = size; &buckets[i].written);
for (i = 0; i < size; i++) { list_splice(&cinfo->ds->buckets[i].committing,
INIT_LIST_HEAD(&buckets[i].written); &buckets[i].committing);
INIT_LIST_HEAD(&buckets[i].committing); buckets[i].wlseg = cinfo->ds->buckets[i].wlseg;
} buckets[i].clseg = cinfo->ds->buckets[i].clseg;
}
spin_unlock(cinfo->lock);
return 0;
} }
swap(cinfo->ds->buckets, buckets);
cinfo->ds->nbuckets = size;
out:
spin_unlock(cinfo->lock);
kfree(buckets);
return 0;
} }
static struct pnfs_layout_segment * static struct pnfs_layout_segment *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册