Commit 6dd85e83 authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

NFS: Add a helper to convert a struct nfs_page into an inode

Replace all the open coded calls to page_file_mapping(req->wb_page)->host.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 8e0bdc70
...@@ -426,7 +426,7 @@ nfs_page_group_init(struct nfs_page *req, struct nfs_page *prev) ...@@ -426,7 +426,7 @@ nfs_page_group_init(struct nfs_page *req, struct nfs_page *prev)
* has extra ref from the write/commit path to handle handoff * has extra ref from the write/commit path to handle handoff
* between write and commit lists. */ * between write and commit lists. */
if (test_bit(PG_INODE_REF, &prev->wb_head->wb_flags)) { if (test_bit(PG_INODE_REF, &prev->wb_head->wb_flags)) {
inode = page_file_mapping(req->wb_page)->host; inode = nfs_page_to_inode(req);
set_bit(PG_INODE_REF, &req->wb_flags); set_bit(PG_INODE_REF, &req->wb_flags);
kref_get(&req->wb_kref); kref_get(&req->wb_kref);
atomic_long_inc(&NFS_I(inode)->nrequests); atomic_long_inc(&NFS_I(inode)->nrequests);
......
...@@ -421,7 +421,7 @@ static void nfs_set_page_writeback(struct page *page) ...@@ -421,7 +421,7 @@ static void nfs_set_page_writeback(struct page *page)
static void nfs_end_page_writeback(struct nfs_page *req) static void nfs_end_page_writeback(struct nfs_page *req)
{ {
struct inode *inode = page_file_mapping(req->wb_page)->host; struct inode *inode = nfs_page_to_inode(req);
struct nfs_server *nfss = NFS_SERVER(inode); struct nfs_server *nfss = NFS_SERVER(inode);
bool is_done; bool is_done;
...@@ -592,8 +592,7 @@ nfs_lock_and_join_requests(struct page *page) ...@@ -592,8 +592,7 @@ nfs_lock_and_join_requests(struct page *page)
static void nfs_write_error(struct nfs_page *req, int error) static void nfs_write_error(struct nfs_page *req, int error)
{ {
trace_nfs_write_error(page_file_mapping(req->wb_page)->host, req, trace_nfs_write_error(nfs_page_to_inode(req), req, error);
error);
nfs_mapping_set_error(req->wb_page, error); nfs_mapping_set_error(req->wb_page, error);
nfs_inode_remove_request(req); nfs_inode_remove_request(req);
nfs_end_page_writeback(req); nfs_end_page_writeback(req);
...@@ -1420,7 +1419,7 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr, ...@@ -1420,7 +1419,7 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr,
*/ */
static void nfs_redirty_request(struct nfs_page *req) static void nfs_redirty_request(struct nfs_page *req)
{ {
struct nfs_inode *nfsi = NFS_I(page_file_mapping(req->wb_page)->host); struct nfs_inode *nfsi = NFS_I(nfs_page_to_inode(req));
/* Bump the transmission count */ /* Bump the transmission count */
req->wb_nio++; req->wb_nio++;
......
...@@ -189,6 +189,19 @@ static inline struct page *nfs_page_to_page(const struct nfs_page *req, ...@@ -189,6 +189,19 @@ static inline struct page *nfs_page_to_page(const struct nfs_page *req,
return folio_page(folio, pgbase >> PAGE_SHIFT); return folio_page(folio, pgbase >> PAGE_SHIFT);
} }
/**
* nfs_page_to_inode - Retrieve an inode for the request
* @req: pointer to a struct nfs_page
*/
static inline struct inode *nfs_page_to_inode(const struct nfs_page *req)
{
struct folio *folio = nfs_page_to_folio(req);
if (folio == NULL)
return page_file_mapping(req->wb_page)->host;
return folio_file_mapping(folio)->host;
}
/** /**
* nfs_page_max_length - Retrieve the maximum possible length for a request * nfs_page_max_length - Retrieve the maximum possible length for a request
* @req: pointer to a struct nfs_page * @req: pointer to a struct nfs_page
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment