[pnfs] [PATCH 06/11] pnfs: pnfs_modify_new_request
Benny Halevy
bhalevy at panasas.com
Sun Apr 13 10:10:41 EDT 2008
On Apr. 10, 2008, 17:05 +0300, Fred Isaman <iisaman at citi.umich.edu> wrote:
> Add hook into nfs_page initialization to allow for setting of
> PG_USE_PNFS.
>
> Signed-off-by: Fred Isaman <iisaman at citi.umich.edu>
> Signed-off-by: Benny Halevy <bhalevy at panasas.com>
> ---
> fs/nfs/pagelist.c | 1 +
> fs/nfs/pnfs.c | 19 +++++++++++++++++++
> fs/nfs/pnfs.h | 18 ++++++++++++++++++
> include/linux/nfs4_pnfs.h | 3 +++
> 4 files changed, 41 insertions(+), 0 deletions(-)
>
> diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
> index 43634d3..1bd1c13 100644
> --- a/fs/nfs/pagelist.c
> +++ b/fs/nfs/pagelist.c
> @@ -87,6 +87,7 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
> req->wb_bytes = count;
> req->wb_context = get_nfs_open_context(ctx);
> kref_init(&req->wb_kref);
> + pnfs_modify_new_request(inode, req, fsdata);
> return req;
> }
>
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index 7be8bbe..2666100 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -1922,6 +1922,25 @@ out_unlock:
> goto out;
> }
>
> +/* Note that fsdata != NULL */
> +void _pnfs_modify_new_write_request(struct nfs_server *nfss,
Passing nfss can be easily avoided as it can be derived from inode.
> + struct inode *inode, struct nfs_page *req,
inode can be derived from req as well.
> + struct pnfs_fsdata *fsdata)
> +{
> + struct pnfs_layout_segment *lseg = NULL;
> + loff_t pos;
> + unsigned count;
> +
> + pos = ((loff_t)req->wb_index << PAGE_CACHE_SHIFT) + req->wb_offset;
> + count = req->wb_bytes;
> + lseg = pnfs_find_get_lseg(inode, pos, count, IOMODE_RW);
> + if (lseg) {
> + if (fsdata->ok_to_use_pnfs)
> + set_bit(PG_USE_PNFS, &req->wb_flags);
> + put_lseg(lseg);
> + }
> +}
> +
> void pnfs_free_request_data(struct nfs_page *req)
> {
> struct layoutdriver_io_operations *lo;
> diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
> index 0c63fea..e8361cd 100644
> --- a/fs/nfs/pnfs.h
> +++ b/fs/nfs/pnfs.h
> @@ -65,6 +65,9 @@ int _pnfs_write_begin(struct inode *inode, struct nfs_server *nfss,
> unsigned flags, struct pnfs_fsdata **fsdata);
> int _pnfs_do_flush(struct inode *inode, struct nfs_server *nfss,
> struct nfs_page *req, struct pnfs_fsdata *fsdata);
> +void _pnfs_modify_new_write_request(struct nfs_server *nfss,
> + struct inode *inode, struct nfs_page *req,
> + struct pnfs_fsdata *fsdata);
>
> #define PNFS_EXISTS_LDIO_OP(srv, opname) ((srv)->pnfs_curr_ld && \
> (srv)->pnfs_curr_ld->ld_io_ops && \
> @@ -146,6 +149,15 @@ static inline void pnfs_write_end_cleanup(void *fsdata)
> pnfs_free_fsdata((struct pnfs_fsdata *) fsdata);
> }
>
> +static inline void pnfs_modify_new_request(struct inode *inode,
> + struct nfs_page *req,
> + void *fsdata)
> +{
> + struct nfs_server *nfss = NFS_SERVER(inode);
> + if (fsdata)
Are you assuming the if fsdata != NULL new_request must be defined?
If so, this better be documented.
> + _pnfs_modify_new_write_request(nfss, inode, req, fsdata);
else?
Who sets PG_USE_PNFS?
> +}
> +
> #else /* CONFIG_PNFS */
>
> static inline int pnfs_try_to_read_data(struct nfs_read_data *data,
> @@ -182,6 +194,12 @@ static inline void pnfs_write_end_cleanup(void *fsdata)
> {
> }
>
> +static inline void pnfs_modify_new_request(struct inode *inode,
> + struct nfs_page *req,
> + void *fsdata)
> +{
> +}
> +
> #endif /* CONFIG_PNFS */
>
> #endif /* FS_NFS_PNFS_H */
> diff --git a/include/linux/nfs4_pnfs.h b/include/linux/nfs4_pnfs.h
> index 9ed6819..8881739 100644
> --- a/include/linux/nfs4_pnfs.h
> +++ b/include/linux/nfs4_pnfs.h
> @@ -141,6 +141,9 @@ struct layoutdriver_io_operations {
> int (*write_begin) (struct pnfs_layout_segment *lseg, struct page *page,
> loff_t pos, unsigned count,
> struct pnfs_fsdata *fsdata);
> + void (*new_request)(struct pnfs_layout_segment *lseg,
> + struct nfs_page *req, loff_t pos, unsigned count,
> + struct pnfs_fsdata *fsdata);
> void (*free_request_data) (struct nfs_page *);
> void (*free_fsdata) (struct pnfs_fsdata *data);
>
More information about the pNFS
mailing list