@@ -299,10 +299,9 @@ static int nfs_pageio_do_add_request(struct nfs_pageio_descriptor *desc,
} else {
put_lseg(desc->pg_lseg);
desc->pg_base = req->wb_pgbase;
- if (desc->pg_test)
- desc->pg_lseg = pnfs_update_layout(desc->pg_inode,
- req->wb_context,
- IOMODE_READ);
+ desc->pg_lseg = pnfs_update_layout(desc->pg_inode,
+ req->wb_context,
+ desc->pg_iomode);
}
nfs_list_remove_request(req);
nfs_list_add_request(req, &desc->pg_list);
@@ -889,6 +889,14 @@ void
pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio,
struct inode *inode)
{
+ pgio->pg_iomode = IOMODE_READ;
+ pnfs_set_pg_test(inode, pgio);
+}
+
+void
+pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode)
+{
+ pgio->pg_iomode = IOMODE_RW;
pnfs_set_pg_test(inode, pgio);
}
@@ -179,6 +179,7 @@ enum pnfs_try_status pnfs_try_to_write_data(struct nfs_write_data *,
enum pnfs_try_status pnfs_try_to_read_data(struct nfs_read_data *,
const struct rpc_call_ops *);
void pnfs_pageio_init_read(struct nfs_pageio_descriptor *, struct inode *);
+void pnfs_pageio_init_write(struct nfs_pageio_descriptor *, struct inode *);
int pnfs_layout_process(struct nfs4_layoutget *lgp);
void pnfs_free_lseg_list(struct list_head *tmp_list);
void pnfs_destroy_layout(struct nfs_inode *);
@@ -297,6 +298,12 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *ino)
pgio->pg_test = NULL;
}
+static inline void
+pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *ino)
+{
+ pgio->pg_test = NULL;
+}
+
#endif /* CONFIG_NFS_V4_1 */
#endif /* FS_NFS_PNFS_H */
@@ -1001,7 +1001,7 @@ static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
{
size_t wsize = NFS_SERVER(inode)->wsize;
- pgio->pg_test = NULL;
+ pnfs_pageio_init_write(pgio, inode);
if (wsize < PAGE_CACHE_SIZE)
nfs_pageio_init(pgio, inode, nfs_flush_multi, wsize, ioflags);
@@ -63,6 +63,7 @@ struct nfs_pageio_descriptor {
int pg_ioflags;
int pg_error;
struct pnfs_layout_segment *pg_lseg;
+ int pg_iomode;
int (*pg_test)(struct nfs_pageio_descriptor *, struct nfs_page *, struct nfs_page *);
};