diff options
author | Trond Myklebust <trondmy@gmail.com> | 2019-04-07 13:59:11 -0400 |
---|---|---|
committer | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2019-04-25 14:18:15 -0400 |
commit | 9fcd5960e88bbdc74a70d9e3a5ab46b489fc4b80 (patch) | |
tree | 6f2b82626a3a59c4af52a6b3e30b81501dfc32ec | |
parent | 154945112dac10b7109d816275f3e4896b0b064e (diff) |
NFS: Add a helper to return a pointer to the open context of a struct nfs_page
Add a helper for when we remove the explicit pointer to the open
context.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r-- | fs/nfs/filelayout/filelayout.c | 4 | ||||
-rw-r--r-- | fs/nfs/flexfilelayout/flexfilelayout.c | 6 | ||||
-rw-r--r-- | fs/nfs/pagelist.c | 8 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 4 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 4 | ||||
-rw-r--r-- | fs/nfs/read.c | 2 | ||||
-rw-r--r-- | fs/nfs/write.c | 20 | ||||
-rw-r--r-- | include/linux/nfs_page.h | 6 |
8 files changed, 31 insertions, 23 deletions
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index 61f46facb39c..21d9f3bfbc81 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c | |||
@@ -917,7 +917,7 @@ filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio, | |||
917 | pnfs_generic_pg_check_layout(pgio); | 917 | pnfs_generic_pg_check_layout(pgio); |
918 | if (!pgio->pg_lseg) { | 918 | if (!pgio->pg_lseg) { |
919 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, | 919 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, |
920 | req->wb_context, | 920 | nfs_req_openctx(req), |
921 | 0, | 921 | 0, |
922 | NFS4_MAX_UINT64, | 922 | NFS4_MAX_UINT64, |
923 | IOMODE_READ, | 923 | IOMODE_READ, |
@@ -944,7 +944,7 @@ filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio, | |||
944 | pnfs_generic_pg_check_layout(pgio); | 944 | pnfs_generic_pg_check_layout(pgio); |
945 | if (!pgio->pg_lseg) { | 945 | if (!pgio->pg_lseg) { |
946 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, | 946 | pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode, |
947 | req->wb_context, | 947 | nfs_req_openctx(req), |
948 | 0, | 948 | 0, |
949 | NFS4_MAX_UINT64, | 949 | NFS4_MAX_UINT64, |
950 | IOMODE_RW, | 950 | IOMODE_RW, |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 9fdbcfd3e39d..9920c52bd0cd 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
@@ -873,7 +873,7 @@ ff_layout_pg_get_read(struct nfs_pageio_descriptor *pgio, | |||
873 | { | 873 | { |
874 | pnfs_put_lseg(pgio->pg_lseg); | 874 | pnfs_put_lseg(pgio->pg_lseg); |
875 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 875 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
876 | req->wb_context, | 876 | nfs_req_openctx(req), |
877 | 0, | 877 | 0, |
878 | NFS4_MAX_UINT64, | 878 | NFS4_MAX_UINT64, |
879 | IOMODE_READ, | 879 | IOMODE_READ, |
@@ -953,7 +953,7 @@ retry: | |||
953 | pnfs_generic_pg_check_layout(pgio); | 953 | pnfs_generic_pg_check_layout(pgio); |
954 | if (!pgio->pg_lseg) { | 954 | if (!pgio->pg_lseg) { |
955 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 955 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
956 | req->wb_context, | 956 | nfs_req_openctx(req), |
957 | 0, | 957 | 0, |
958 | NFS4_MAX_UINT64, | 958 | NFS4_MAX_UINT64, |
959 | IOMODE_RW, | 959 | IOMODE_RW, |
@@ -1010,7 +1010,7 @@ ff_layout_pg_get_mirror_count_write(struct nfs_pageio_descriptor *pgio, | |||
1010 | { | 1010 | { |
1011 | if (!pgio->pg_lseg) { | 1011 | if (!pgio->pg_lseg) { |
1012 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 1012 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
1013 | req->wb_context, | 1013 | nfs_req_openctx(req), |
1014 | 0, | 1014 | 0, |
1015 | NFS4_MAX_UINT64, | 1015 | NFS4_MAX_UINT64, |
1016 | IOMODE_RW, | 1016 | IOMODE_RW, |
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 4a31284f411e..ce6440b79328 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -47,7 +47,7 @@ void nfs_pgheader_init(struct nfs_pageio_descriptor *desc, | |||
47 | 47 | ||
48 | hdr->req = nfs_list_entry(mirror->pg_list.next); | 48 | hdr->req = nfs_list_entry(mirror->pg_list.next); |
49 | hdr->inode = desc->pg_inode; | 49 | hdr->inode = desc->pg_inode; |
50 | hdr->cred = hdr->req->wb_context->cred; | 50 | hdr->cred = nfs_req_openctx(hdr->req)->cred; |
51 | hdr->io_start = req_offset(hdr->req); | 51 | hdr->io_start = req_offset(hdr->req); |
52 | hdr->good_bytes = mirror->pg_count; | 52 | hdr->good_bytes = mirror->pg_count; |
53 | hdr->io_completion = desc->pg_io_completion; | 53 | hdr->io_completion = desc->pg_io_completion; |
@@ -578,7 +578,7 @@ static void nfs_pgio_rpcsetup(struct nfs_pgio_header *hdr, | |||
578 | hdr->args.pgbase = req->wb_pgbase; | 578 | hdr->args.pgbase = req->wb_pgbase; |
579 | hdr->args.pages = hdr->page_array.pagevec; | 579 | hdr->args.pages = hdr->page_array.pagevec; |
580 | hdr->args.count = count; | 580 | hdr->args.count = count; |
581 | hdr->args.context = get_nfs_open_context(req->wb_context); | 581 | hdr->args.context = get_nfs_open_context(nfs_req_openctx(req)); |
582 | hdr->args.lock_context = req->wb_lock_context; | 582 | hdr->args.lock_context = req->wb_lock_context; |
583 | hdr->args.stable = NFS_UNSTABLE; | 583 | hdr->args.stable = NFS_UNSTABLE; |
584 | switch (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) { | 584 | switch (how & (FLUSH_STABLE | FLUSH_COND_STABLE)) { |
@@ -935,9 +935,9 @@ static bool nfs_can_coalesce_requests(struct nfs_page *prev, | |||
935 | struct file_lock_context *flctx; | 935 | struct file_lock_context *flctx; |
936 | 936 | ||
937 | if (prev) { | 937 | if (prev) { |
938 | if (!nfs_match_open_context(req->wb_context, prev->wb_context)) | 938 | if (!nfs_match_open_context(nfs_req_openctx(req), nfs_req_openctx(prev))) |
939 | return false; | 939 | return false; |
940 | flctx = d_inode(req->wb_context->dentry)->i_flctx; | 940 | flctx = d_inode(nfs_req_openctx(req)->dentry)->i_flctx; |
941 | if (flctx != NULL && | 941 | if (flctx != NULL && |
942 | !(list_empty_careful(&flctx->flc_posix) && | 942 | !(list_empty_careful(&flctx->flc_posix) && |
943 | list_empty_careful(&flctx->flc_flock)) && | 943 | list_empty_careful(&flctx->flc_flock)) && |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 7066cd7c7aff..83722e936b4a 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -2436,7 +2436,7 @@ pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *r | |||
2436 | rd_size = nfs_dreq_bytes_left(pgio->pg_dreq); | 2436 | rd_size = nfs_dreq_bytes_left(pgio->pg_dreq); |
2437 | 2437 | ||
2438 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 2438 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
2439 | req->wb_context, | 2439 | nfs_req_openctx(req), |
2440 | req_offset(req), | 2440 | req_offset(req), |
2441 | rd_size, | 2441 | rd_size, |
2442 | IOMODE_READ, | 2442 | IOMODE_READ, |
@@ -2463,7 +2463,7 @@ pnfs_generic_pg_init_write(struct nfs_pageio_descriptor *pgio, | |||
2463 | pnfs_generic_pg_check_range(pgio, req); | 2463 | pnfs_generic_pg_check_range(pgio, req); |
2464 | if (pgio->pg_lseg == NULL) { | 2464 | if (pgio->pg_lseg == NULL) { |
2465 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, | 2465 | pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode, |
2466 | req->wb_context, | 2466 | nfs_req_openctx(req), |
2467 | req_offset(req), | 2467 | req_offset(req), |
2468 | wb_size, | 2468 | wb_size, |
2469 | IOMODE_RW, | 2469 | IOMODE_RW, |
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index c0420b979d88..f15609c003d8 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -459,7 +459,7 @@ static inline bool | |||
459 | pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, | 459 | pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, |
460 | struct nfs_commit_info *cinfo, u32 ds_commit_idx) | 460 | struct nfs_commit_info *cinfo, u32 ds_commit_idx) |
461 | { | 461 | { |
462 | struct inode *inode = d_inode(req->wb_context->dentry); | 462 | struct inode *inode = d_inode(nfs_req_openctx(req)->dentry); |
463 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; | 463 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; |
464 | 464 | ||
465 | if (lseg == NULL || ld->mark_request_commit == NULL) | 465 | if (lseg == NULL || ld->mark_request_commit == NULL) |
@@ -471,7 +471,7 @@ pnfs_mark_request_commit(struct nfs_page *req, struct pnfs_layout_segment *lseg, | |||
471 | static inline bool | 471 | static inline bool |
472 | pnfs_clear_request_commit(struct nfs_page *req, struct nfs_commit_info *cinfo) | 472 | pnfs_clear_request_commit(struct nfs_page *req, struct nfs_commit_info *cinfo) |
473 | { | 473 | { |
474 | struct inode *inode = d_inode(req->wb_context->dentry); | 474 | struct inode *inode = d_inode(nfs_req_openctx(req)->dentry); |
475 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; | 475 | struct pnfs_layoutdriver_type *ld = NFS_SERVER(inode)->pnfs_curr_ld; |
476 | 476 | ||
477 | if (ld == NULL || ld->clear_request_commit == NULL) | 477 | if (ld == NULL || ld->clear_request_commit == NULL) |
diff --git a/fs/nfs/read.c b/fs/nfs/read.c index fad1333dbf71..c799e540ed1e 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c | |||
@@ -92,7 +92,7 @@ EXPORT_SYMBOL_GPL(nfs_pageio_reset_read_mds); | |||
92 | 92 | ||
93 | static void nfs_readpage_release(struct nfs_page *req) | 93 | static void nfs_readpage_release(struct nfs_page *req) |
94 | { | 94 | { |
95 | struct inode *inode = d_inode(req->wb_context->dentry); | 95 | struct inode *inode = d_inode(nfs_req_openctx(req)->dentry); |
96 | 96 | ||
97 | dprintk("NFS: read done (%s/%llu %d@%lld)\n", inode->i_sb->s_id, | 97 | dprintk("NFS: read done (%s/%llu %d@%lld)\n", inode->i_sb->s_id, |
98 | (unsigned long long)NFS_FILEID(inode), req->wb_bytes, | 98 | (unsigned long long)NFS_FILEID(inode), req->wb_bytes, |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 294604784f70..bc5bb9323412 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
@@ -964,7 +964,8 @@ static void | |||
964 | nfs_clear_request_commit(struct nfs_page *req) | 964 | nfs_clear_request_commit(struct nfs_page *req) |
965 | { | 965 | { |
966 | if (test_bit(PG_CLEAN, &req->wb_flags)) { | 966 | if (test_bit(PG_CLEAN, &req->wb_flags)) { |
967 | struct inode *inode = d_inode(req->wb_context->dentry); | 967 | struct nfs_open_context *ctx = nfs_req_openctx(req); |
968 | struct inode *inode = d_inode(ctx->dentry); | ||
968 | struct nfs_commit_info cinfo; | 969 | struct nfs_commit_info cinfo; |
969 | 970 | ||
970 | nfs_init_cinfo_from_inode(&cinfo, inode); | 971 | nfs_init_cinfo_from_inode(&cinfo, inode); |
@@ -1219,7 +1220,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page) | |||
1219 | return 0; | 1220 | return 0; |
1220 | l_ctx = req->wb_lock_context; | 1221 | l_ctx = req->wb_lock_context; |
1221 | do_flush = req->wb_page != page || | 1222 | do_flush = req->wb_page != page || |
1222 | !nfs_match_open_context(req->wb_context, ctx); | 1223 | !nfs_match_open_context(nfs_req_openctx(req), ctx); |
1223 | if (l_ctx && flctx && | 1224 | if (l_ctx && flctx && |
1224 | !(list_empty_careful(&flctx->flc_posix) && | 1225 | !(list_empty_careful(&flctx->flc_posix) && |
1225 | list_empty_careful(&flctx->flc_flock))) { | 1226 | list_empty_careful(&flctx->flc_flock))) { |
@@ -1422,7 +1423,7 @@ static void nfs_redirty_request(struct nfs_page *req) | |||
1422 | /* Bump the transmission count */ | 1423 | /* Bump the transmission count */ |
1423 | req->wb_nio++; | 1424 | req->wb_nio++; |
1424 | nfs_mark_request_dirty(req); | 1425 | nfs_mark_request_dirty(req); |
1425 | set_bit(NFS_CONTEXT_RESEND_WRITES, &req->wb_context->flags); | 1426 | set_bit(NFS_CONTEXT_RESEND_WRITES, &nfs_req_openctx(req)->flags); |
1426 | nfs_end_page_writeback(req); | 1427 | nfs_end_page_writeback(req); |
1427 | nfs_release_request(req); | 1428 | nfs_release_request(req); |
1428 | } | 1429 | } |
@@ -1742,7 +1743,8 @@ void nfs_init_commit(struct nfs_commit_data *data, | |||
1742 | struct nfs_commit_info *cinfo) | 1743 | struct nfs_commit_info *cinfo) |
1743 | { | 1744 | { |
1744 | struct nfs_page *first = nfs_list_entry(head->next); | 1745 | struct nfs_page *first = nfs_list_entry(head->next); |
1745 | struct inode *inode = d_inode(first->wb_context->dentry); | 1746 | struct nfs_open_context *ctx = nfs_req_openctx(first); |
1747 | struct inode *inode = d_inode(ctx->dentry); | ||
1746 | 1748 | ||
1747 | /* Set up the RPC argument and reply structs | 1749 | /* Set up the RPC argument and reply structs |
1748 | * NB: take care not to mess about with data->commit et al. */ | 1750 | * NB: take care not to mess about with data->commit et al. */ |
@@ -1750,7 +1752,7 @@ void nfs_init_commit(struct nfs_commit_data *data, | |||
1750 | list_splice_init(head, &data->pages); | 1752 | list_splice_init(head, &data->pages); |
1751 | 1753 | ||
1752 | data->inode = inode; | 1754 | data->inode = inode; |
1753 | data->cred = first->wb_context->cred; | 1755 | data->cred = ctx->cred; |
1754 | data->lseg = lseg; /* reference transferred */ | 1756 | data->lseg = lseg; /* reference transferred */ |
1755 | /* only set lwb for pnfs commit */ | 1757 | /* only set lwb for pnfs commit */ |
1756 | if (lseg) | 1758 | if (lseg) |
@@ -1763,7 +1765,7 @@ void nfs_init_commit(struct nfs_commit_data *data, | |||
1763 | /* Note: we always request a commit of the entire inode */ | 1765 | /* Note: we always request a commit of the entire inode */ |
1764 | data->args.offset = 0; | 1766 | data->args.offset = 0; |
1765 | data->args.count = 0; | 1767 | data->args.count = 0; |
1766 | data->context = get_nfs_open_context(first->wb_context); | 1768 | data->context = get_nfs_open_context(ctx); |
1767 | data->res.fattr = &data->fattr; | 1769 | data->res.fattr = &data->fattr; |
1768 | data->res.verf = &data->verf; | 1770 | data->res.verf = &data->verf; |
1769 | nfs_fattr_init(&data->fattr); | 1771 | nfs_fattr_init(&data->fattr); |
@@ -1846,8 +1848,8 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data) | |||
1846 | nfs_clear_page_commit(req->wb_page); | 1848 | nfs_clear_page_commit(req->wb_page); |
1847 | 1849 | ||
1848 | dprintk("NFS: commit (%s/%llu %d@%lld)", | 1850 | dprintk("NFS: commit (%s/%llu %d@%lld)", |
1849 | req->wb_context->dentry->d_sb->s_id, | 1851 | nfs_req_openctx(req)->dentry->d_sb->s_id, |
1850 | (unsigned long long)NFS_FILEID(d_inode(req->wb_context->dentry)), | 1852 | (unsigned long long)NFS_FILEID(d_inode(nfs_req_openctx(req)->dentry)), |
1851 | req->wb_bytes, | 1853 | req->wb_bytes, |
1852 | (long long)req_offset(req)); | 1854 | (long long)req_offset(req)); |
1853 | if (status < 0) { | 1855 | if (status < 0) { |
@@ -1871,7 +1873,7 @@ static void nfs_commit_release_pages(struct nfs_commit_data *data) | |||
1871 | /* We have a mismatch. Write the page again */ | 1873 | /* We have a mismatch. Write the page again */ |
1872 | dprintk_cont(" mismatch\n"); | 1874 | dprintk_cont(" mismatch\n"); |
1873 | nfs_mark_request_dirty(req); | 1875 | nfs_mark_request_dirty(req); |
1874 | set_bit(NFS_CONTEXT_RESEND_WRITES, &req->wb_context->flags); | 1876 | set_bit(NFS_CONTEXT_RESEND_WRITES, &nfs_req_openctx(req)->flags); |
1875 | next: | 1877 | next: |
1876 | nfs_unlock_and_release_request(req); | 1878 | nfs_unlock_and_release_request(req); |
1877 | /* Latency breaker */ | 1879 | /* Latency breaker */ |
diff --git a/include/linux/nfs_page.h b/include/linux/nfs_page.h index 8b36800d342d..1ea13e94feb7 100644 --- a/include/linux/nfs_page.h +++ b/include/linux/nfs_page.h | |||
@@ -200,4 +200,10 @@ loff_t req_offset(struct nfs_page *req) | |||
200 | return (((loff_t)req->wb_index) << PAGE_SHIFT) + req->wb_offset; | 200 | return (((loff_t)req->wb_index) << PAGE_SHIFT) + req->wb_offset; |
201 | } | 201 | } |
202 | 202 | ||
203 | static inline struct nfs_open_context * | ||
204 | nfs_req_openctx(struct nfs_page *req) | ||
205 | { | ||
206 | return req->wb_context; | ||
207 | } | ||
208 | |||
203 | #endif /* _LINUX_NFS_PAGE_H */ | 209 | #endif /* _LINUX_NFS_PAGE_H */ |