mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
pNFS: Enable per-layout segment commit structures
Enable adding and lookup of per-layout segment commits in filelayout and flexfilelayout. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
parent
a9901899b6
commit
ba827c9abb
4 changed files with 117 additions and 6 deletions
|
@ -118,6 +118,66 @@ pnfs_free_commit_array(struct pnfs_commit_array *p)
|
|||
}
|
||||
EXPORT_SYMBOL_GPL(pnfs_free_commit_array);
|
||||
|
||||
static struct pnfs_commit_array *
|
||||
pnfs_find_commit_array_by_lseg(struct pnfs_ds_commit_info *fl_cinfo,
|
||||
struct pnfs_layout_segment *lseg)
|
||||
{
|
||||
struct pnfs_commit_array *array;
|
||||
|
||||
list_for_each_entry_rcu(array, &fl_cinfo->commits, cinfo_list) {
|
||||
if (array->lseg == lseg)
|
||||
return array;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct pnfs_commit_array *
|
||||
pnfs_add_commit_array(struct pnfs_ds_commit_info *fl_cinfo,
|
||||
struct pnfs_commit_array *new,
|
||||
struct pnfs_layout_segment *lseg)
|
||||
{
|
||||
struct pnfs_commit_array *array;
|
||||
|
||||
array = pnfs_find_commit_array_by_lseg(fl_cinfo, lseg);
|
||||
if (array)
|
||||
return array;
|
||||
new->lseg = lseg;
|
||||
refcount_set(&new->refcount, 1);
|
||||
list_add_rcu(&new->cinfo_list, &fl_cinfo->commits);
|
||||
list_add(&new->lseg_list, &lseg->pls_commits);
|
||||
return new;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pnfs_add_commit_array);
|
||||
|
||||
static void
|
||||
pnfs_setup_ds_info(struct pnfs_ds_commit_info *fl_cinfo,
|
||||
struct pnfs_layout_segment *lseg)
|
||||
{
|
||||
struct inode *inode = lseg->pls_layout->plh_inode;
|
||||
struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld;
|
||||
|
||||
if (ld->setup_ds_info != NULL)
|
||||
ld->setup_ds_info(fl_cinfo, lseg);
|
||||
}
|
||||
|
||||
static struct pnfs_commit_array *
|
||||
pnfs_lookup_commit_array(struct pnfs_ds_commit_info *fl_cinfo,
|
||||
struct pnfs_layout_segment *lseg)
|
||||
{
|
||||
struct pnfs_commit_array *array;
|
||||
|
||||
rcu_read_lock();
|
||||
array = pnfs_find_commit_array_by_lseg(fl_cinfo, lseg);
|
||||
if (!array) {
|
||||
rcu_read_unlock();
|
||||
pnfs_setup_ds_info(fl_cinfo, lseg);
|
||||
rcu_read_lock();
|
||||
array = pnfs_find_commit_array_by_lseg(fl_cinfo, lseg);
|
||||
}
|
||||
rcu_read_unlock();
|
||||
return array;
|
||||
}
|
||||
|
||||
static void
|
||||
pnfs_release_commit_array_locked(struct pnfs_commit_array *array)
|
||||
{
|
||||
|
@ -1082,17 +1142,18 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
|
|||
u32 ds_commit_idx)
|
||||
{
|
||||
struct list_head *list;
|
||||
struct pnfs_commit_array *array;
|
||||
struct pnfs_commit_bucket *buckets;
|
||||
|
||||
mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||
buckets = cinfo->ds->buckets;
|
||||
array = pnfs_lookup_commit_array(cinfo->ds, lseg);
|
||||
if (!array)
|
||||
goto out_resched;
|
||||
buckets = array->buckets;
|
||||
list = &buckets[ds_commit_idx].written;
|
||||
if (list_empty(list)) {
|
||||
if (!pnfs_is_valid_lseg(lseg)) {
|
||||
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||
cinfo->completion_ops->resched_write(cinfo, req);
|
||||
return;
|
||||
}
|
||||
if (!pnfs_is_valid_lseg(lseg))
|
||||
goto out_resched;
|
||||
/* Non-empty buckets hold a reference on the lseg. That ref
|
||||
* is normally transferred to the COMMIT call and released
|
||||
* there. It could also be released if the last req is pulled
|
||||
|
@ -1108,6 +1169,10 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
|
|||
nfs_request_add_commit_list_locked(req, list, cinfo);
|
||||
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||
nfs_mark_page_unstable(req->wb_page, cinfo);
|
||||
return;
|
||||
out_resched:
|
||||
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||
cinfo->completion_ops->resched_write(cinfo, req);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue