NFS: Wait for requests that are locked on the commit list
If a request is on the commit list, but is locked, we will currently skip it, which can lead to livelocking when the commit count doesn't reduce to zero. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
This commit is contained in:
parent
8205b9ce03
commit
2ce209c42c
3 changed files with 29 additions and 8 deletions
|
@ -434,6 +434,7 @@ void nfs_release_request(struct nfs_page *req)
|
||||||
{
|
{
|
||||||
kref_put(&req->wb_kref, nfs_page_group_destroy);
|
kref_put(&req->wb_kref, nfs_page_group_destroy);
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(nfs_release_request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nfs_wait_on_request - Wait for a request to complete.
|
* nfs_wait_on_request - Wait for a request to complete.
|
||||||
|
@ -452,6 +453,7 @@ nfs_wait_on_request(struct nfs_page *req)
|
||||||
return wait_on_bit_io(&req->wb_flags, PG_BUSY,
|
return wait_on_bit_io(&req->wb_flags, PG_BUSY,
|
||||||
TASK_UNINTERRUPTIBLE);
|
TASK_UNINTERRUPTIBLE);
|
||||||
}
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(nfs_wait_on_request);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nfs_generic_pg_test - determine if requests can be coalesced
|
* nfs_generic_pg_test - determine if requests can be coalesced
|
||||||
|
|
|
@ -91,13 +91,23 @@ static int
|
||||||
pnfs_generic_transfer_commit_list(struct list_head *src, struct list_head *dst,
|
pnfs_generic_transfer_commit_list(struct list_head *src, struct list_head *dst,
|
||||||
struct nfs_commit_info *cinfo, int max)
|
struct nfs_commit_info *cinfo, int max)
|
||||||
{
|
{
|
||||||
struct nfs_page *req, *tmp;
|
struct nfs_page *req;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
list_for_each_entry_safe(req, tmp, src, wb_list) {
|
while(!list_empty(src)) {
|
||||||
if (!nfs_lock_request(req))
|
req = list_first_entry(src, struct nfs_page, wb_list);
|
||||||
continue;
|
|
||||||
kref_get(&req->wb_kref);
|
kref_get(&req->wb_kref);
|
||||||
|
if (!nfs_lock_request(req)) {
|
||||||
|
int status;
|
||||||
|
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||||
|
status = nfs_wait_on_request(req);
|
||||||
|
nfs_release_request(req);
|
||||||
|
mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||||
|
if (status < 0)
|
||||||
|
break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
nfs_request_remove_commit_list(req, cinfo);
|
nfs_request_remove_commit_list(req, cinfo);
|
||||||
clear_bit(PG_COMMIT_TO_DS, &req->wb_flags);
|
clear_bit(PG_COMMIT_TO_DS, &req->wb_flags);
|
||||||
nfs_list_add_request(req, dst);
|
nfs_list_add_request(req, dst);
|
||||||
|
|
|
@ -1030,13 +1030,22 @@ int
|
||||||
nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
|
nfs_scan_commit_list(struct list_head *src, struct list_head *dst,
|
||||||
struct nfs_commit_info *cinfo, int max)
|
struct nfs_commit_info *cinfo, int max)
|
||||||
{
|
{
|
||||||
struct nfs_page *req, *tmp;
|
struct nfs_page *req;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
list_for_each_entry_safe(req, tmp, src, wb_list) {
|
while(!list_empty(src)) {
|
||||||
if (!nfs_lock_request(req))
|
req = list_first_entry(src, struct nfs_page, wb_list);
|
||||||
continue;
|
|
||||||
kref_get(&req->wb_kref);
|
kref_get(&req->wb_kref);
|
||||||
|
if (!nfs_lock_request(req)) {
|
||||||
|
int status;
|
||||||
|
mutex_unlock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||||
|
status = nfs_wait_on_request(req);
|
||||||
|
nfs_release_request(req);
|
||||||
|
mutex_lock(&NFS_I(cinfo->inode)->commit_mutex);
|
||||||
|
if (status < 0)
|
||||||
|
break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
nfs_request_remove_commit_list(req, cinfo);
|
nfs_request_remove_commit_list(req, cinfo);
|
||||||
nfs_list_add_request(req, dst);
|
nfs_list_add_request(req, dst);
|
||||||
ret++;
|
ret++;
|
||||||
|
|
Loading…
Reference in a new issue