mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
nfs: fold nfs_folio_find_and_lock_request into nfs_lock_and_join_requests
Fold nfs_folio_find_and_lock_request into the only caller to prepare for changes to this code. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
9eb7c484db
commit
c3f2235782
1 changed files with 27 additions and 41 deletions
|
@ -194,38 +194,6 @@ static struct nfs_page *nfs_folio_find_head_request(struct folio *folio)
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nfs_page *nfs_folio_find_and_lock_request(struct folio *folio)
|
|
||||||
{
|
|
||||||
struct inode *inode = folio->mapping->host;
|
|
||||||
struct nfs_page *head;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
retry:
|
|
||||||
head = nfs_folio_find_head_request(folio);
|
|
||||||
if (!head)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
while (!nfs_lock_request(head)) {
|
|
||||||
ret = nfs_wait_on_request(head);
|
|
||||||
if (ret < 0)
|
|
||||||
return ERR_PTR(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ensure that nobody removed the request before we locked it */
|
|
||||||
if (head != folio->private) {
|
|
||||||
nfs_unlock_and_release_request(head);
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = nfs_cancel_remove_inode(head, inode);
|
|
||||||
if (ret < 0) {
|
|
||||||
nfs_unlock_and_release_request(head);
|
|
||||||
return ERR_PTR(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
return head;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Adjust the file length if we're writing beyond the end */
|
/* Adjust the file length if we're writing beyond the end */
|
||||||
static void nfs_grow_file(struct folio *folio, unsigned int offset,
|
static void nfs_grow_file(struct folio *folio, unsigned int offset,
|
||||||
unsigned int count)
|
unsigned int count)
|
||||||
|
@ -532,26 +500,44 @@ static struct nfs_page *nfs_lock_and_join_requests(struct folio *folio)
|
||||||
struct nfs_commit_info cinfo;
|
struct nfs_commit_info cinfo;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
nfs_init_cinfo_from_inode(&cinfo, inode);
|
|
||||||
/*
|
/*
|
||||||
* A reference is taken only on the head request which acts as a
|
* A reference is taken only on the head request which acts as a
|
||||||
* reference to the whole page group - the group will not be destroyed
|
* reference to the whole page group - the group will not be destroyed
|
||||||
* until the head reference is released.
|
* until the head reference is released.
|
||||||
*/
|
*/
|
||||||
head = nfs_folio_find_and_lock_request(folio);
|
retry:
|
||||||
if (IS_ERR_OR_NULL(head))
|
head = nfs_folio_find_head_request(folio);
|
||||||
return head;
|
if (!head)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
while (!nfs_lock_request(head)) {
|
||||||
|
ret = nfs_wait_on_request(head);
|
||||||
|
if (ret < 0)
|
||||||
|
return ERR_PTR(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ensure that nobody removed the request before we locked it */
|
||||||
|
if (head != folio->private) {
|
||||||
|
nfs_unlock_and_release_request(head);
|
||||||
|
goto retry;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = nfs_cancel_remove_inode(head, inode);
|
||||||
|
if (ret < 0)
|
||||||
|
goto out_unlock;
|
||||||
|
|
||||||
/* lock each request in the page group */
|
/* lock each request in the page group */
|
||||||
ret = nfs_page_group_lock_subrequests(head);
|
ret = nfs_page_group_lock_subrequests(head);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
nfs_unlock_and_release_request(head);
|
goto out_unlock;
|
||||||
return ERR_PTR(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
nfs_init_cinfo_from_inode(&cinfo, inode);
|
||||||
nfs_join_page_group(head, &cinfo, inode);
|
nfs_join_page_group(head, &cinfo, inode);
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
|
|
||||||
|
out_unlock:
|
||||||
|
nfs_unlock_and_release_request(head);
|
||||||
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nfs_write_error(struct nfs_page *req, int error)
|
static void nfs_write_error(struct nfs_page *req, int error)
|
||||||
|
|
Loading…
Add table
Reference in a new issue