Skip to content

Commit

Permalink
NFS: Refactor nfs_page_find_head_request()
Browse files Browse the repository at this point in the history
Split out the 2 cases so that we can treat the locking differently.
The issue is that the locking in the pageswapcache cache is highly
linked to the commit list locking.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
  • Loading branch information
trondmypd committed Aug 15, 2017
1 parent bd37d6f commit b30d2f0
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions fs/nfs/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,41 @@ nfs_page_private_request(struct page *page)
* returns matching head request with reference held, or NULL if not found.
*/
static struct nfs_page *
nfs_page_find_head_request_locked(struct nfs_inode *nfsi, struct page *page)
nfs_page_find_private_request(struct page *page)
{
struct inode *inode = page_file_mapping(page)->host;
struct nfs_page *req;

if (!PagePrivate(page))
return NULL;
spin_lock(&inode->i_lock);
req = nfs_page_private_request(page);
if (!req && unlikely(PageSwapCache(page)))
req = nfs_page_search_commits_for_head_request_locked(nfsi,
page);

if (req) {
WARN_ON_ONCE(req->wb_head != req);
kref_get(&req->wb_kref);
}
spin_unlock(&inode->i_lock);
return req;
}

static struct nfs_page *
nfs_page_find_swap_request(struct page *page)
{
struct inode *inode = page_file_mapping(page)->host;
struct nfs_inode *nfsi = NFS_I(inode);
struct nfs_page *req = NULL;
if (!PageSwapCache(page))
return NULL;
spin_lock(&inode->i_lock);
if (PageSwapCache(page)) {
req = nfs_page_search_commits_for_head_request_locked(nfsi,
page);
if (req) {
WARN_ON_ONCE(req->wb_head != req);
kref_get(&req->wb_kref);
}
}
spin_unlock(&inode->i_lock);
return req;
}

Expand All @@ -194,14 +215,11 @@ nfs_page_find_head_request_locked(struct nfs_inode *nfsi, struct page *page)
*/
static struct nfs_page *nfs_page_find_head_request(struct page *page)
{
struct inode *inode = page_file_mapping(page)->host;
struct nfs_page *req = NULL;
struct nfs_page *req;

if (PagePrivate(page) || PageSwapCache(page)) {
spin_lock(&inode->i_lock);
req = nfs_page_find_head_request_locked(NFS_I(inode), page);
spin_unlock(&inode->i_lock);
}
req = nfs_page_find_private_request(page);
if (!req)
req = nfs_page_find_swap_request(page);
return req;
}

Expand Down

0 comments on commit b30d2f0

Please sign in to comment.