LAYUOTGET invocation rebasing
Subsystems (2)
cover LAYUOTGET invocation rebasing
I have published pnfs-all-latest rebased atop my submitted patches atgit://linux-nfs.org/~isaman/pnfs-block.git in the branch for-benny-20100611.
(Actually, I am uploading now...it is going very slowly.)
These three patches changed significantly in the rebase, so I include them here for review. (Two others nearby vanished entirely.) The basic idea is that fsdata->ok_to_use_pnfs and PG_USE_PNFS can be replaced by checking req->wb_lseg==NULL.
The rebase leaves the blocklayout directory untouched. I've fixed that up with some straightforward SQUASHME patches to come.
Fred
PATCH 1/3 pnfs_post_submit: Restore "pnfs: pnfs_do_flush" part 1
From: Fred Isaman <[email protected]>
This adds the hooks in nfs_write_begin and nfs_write_end needed by the block server
--- fs/nfs/file.c | 15 ++++++++--- fs/nfs/pnfs.c | 43 +++++++++++++++++++++++++++++++ fs/nfs/pnfs.h | 62 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/nfs4_pnfs.h | 7 +++++ 4 files changed, 123 insertions(+), 4 deletions(-)
fs/nfs/file.c +11 -4
@@ -420,8 +420,7 @@ start: ret =nfs_flush_incompatible (file, page, lseg);if (ret) { -unlock_page (page); -page_cache_release (page); + goto out_err; }else if (!once_thru &&nfs_want_read_modify_write (file, page, pos, len)) { once_thru =1 ;
@@ -430,13 +429,19 @@ start:if (!ret) goto start; } - *fsdata = lseg; + ret =pnfs_write_begin (file, page, pos, len, lseg, fsdata); out:if (ret) {put_lseg (lseg); *fsdata =NULL ; }return ret; + + out_err: +unlock_page (page); +page_cache_release (page); + *pagep =NULL ; + goto out; } static int nfs_write_end(struct file *file, struct address_space *mapping,
@@ -445,7 +450,7 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, {unsigned offset = pos & (PAGE_CACHE_SIZE -1 );int status; -struct pnfs_layout_segment *lseg = fsdata; +struct pnfs_layout_segment *lseg; dfprintk(PAGECACHE, "NFS: write_end(%s/%s(%ld), %u@%lld)\n", file->f_path.dentry->d_parent->d_name.name,
@@ -472,10 +477,12 @@ static int nfs_write_end(struct file *file, struct address_space *mapping,zero_user_segment (page, pglen,PAGE_CACHE_SIZE ); } + lseg =nfs4_pull_lseg_from_fsdata (file, fsdata); status =nfs_updatepage (file, page, offset, copied, lseg);unlock_page (page);page_cache_release (page); +pnfs_write_end_cleanup (file, fsdata);put_lseg (lseg);if (status <0 )
fs/nfs/pnfs.c +43 -0
55 lines not on this page · raw message
fs/nfs/pnfs.h +62 -0
98 lines not on this page · raw message
include/linux/nfs4_pnfs.h +7 -0
@@ -30,6 +30,10 @@ struct pnfs_layoutdriver_type {struct layoutdriver_policy_operations *ld_policy_ops; }; +struct pnfs_fsdata { +struct pnfs_layout_segment *lseg; +}; +#if defined(CONFIG_NFS_V4_1 ) static inline struct nfs_inode *
@@ -136,6 +140,9 @@ struct layoutdriver_io_operations { struct page **pages, unsigned int pgbase, unsigned nr_pages, loff_t offset, size_t count, int sync, struct nfs_write_data *nfs_data); +int (*write_begin) (struct pnfs_layout_segment *lseg,struct page *page, +loff_t pos,unsigned count, +struct pnfs_fsdata *fsdata);/* Consistency ops */ /* 2 problems:
Signature · 1 line
1.6.6.1
PATCH 2/3 pnfs_post_submit: Restore "pnfs: pnfs_do_flush" part 2
From: Fred Isaman <[email protected]>
pnfs: pnfs_do_flush
Adds a hook into the "check if request needs flushed" routines. This will be needed to allow driver the ability to prevent comingling of layout driver handled requests and fallback nfs requests.
--- fs/nfs/pnfs.c | 14 ++++++++++++++ fs/nfs/pnfs.h | 24 ++++++++++++++++++++++++ fs/nfs/write.c | 4 ++-- include/linux/nfs4_pnfs.h | 3 +++ 4 files changed, 43 insertions(+), 2 deletions(-)
fs/nfs/pnfs.c +14 -0
@@ -1693,6 +1693,20 @@ out:return status; } +/* Given an nfs request, determine if it should be flushed before proceeding. +* It should default to returning False, returning True only if there is a +* specific reason to flush. +*/ +int _pnfs_do_flush (struct inode *inode,struct nfs_page *req) +{ +struct nfs_server *nfss =NFS_SERVER (inode); +int status =0 ; + +/* Note that lseg==NULL may be useful info for do_flush */ + status = nfss->pnfs_curr_ld->ld_policy_ops->do_flush (req->wb_lseg, req); +return status; +} +enum pnfs_try_status _pnfs_try_to_write_data (struct nfs_write_data *data,const struct rpc_call_ops *call_ops,int how)
fs/nfs/pnfs.h +24 -0
@@ -75,6 +75,7 @@ int _pnfs_write_begin(struct inode *inode, struct page *page, loff_t pos, unsigned len, struct pnfs_layout_segment *lseg, struct pnfs_fsdata **fsdata); +int _pnfs_do_flush (struct inode *inode,struct nfs_page *req);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \ (srv)->pnfs_curr_ld->ld_io_ops && \
@@ -181,6 +182,24 @@ static inline int pnfs_write_begin(struct file *filp, struct page *page,return status; } +/* req may not be locked, so we have to be prepared for req->wb_page being +* set to NULL at any time. +*/ +static inline int pnfs_do_flush (struct nfs_page *req) +{ +struct page *page = req->wb_page; +struct inode *inode; + +if (!page) +return 1 ; + inode = page->mapping->host; + +if (PNFS_EXISTS_LDPOLICY_OP (NFS_SERVER (inode), do_flush)) +return _pnfs_do_flush (inode, req); +else +return 0 ; +} +static inline void pnfs_write_end_cleanup (struct file *filp,void *fsdata) {if (fsdata) {
@@ -291,6 +310,11 @@ pnfs_try_to_commit(struct nfs_write_data *data,return PNFS_NOT_ATTEMPTED ; } +static inline int pnfs_do_flush (struct nfs_page *req) +{ +return 0 ; +} + static inline int pnfs_write_begin(struct file *filp, struct page *page, loff_t pos, unsigned len, struct pnfs_layout_segment *lseg,
fs/nfs/write.c +2 -2
@@ -603,7 +603,7 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode,* have flushed out requests having wrong owners. */ if (offset > rqend || end < req->wb_offset || - req->wb_lseg != lseg) + req->wb_lseg != lseg ||pnfs_do_flush (req)) goto out_flushme;if (nfs_set_page_tag_locked (req))
@@ -710,7 +710,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page,if (req ==NULL )return 0 ; do_flush = req->wb_page != page || req->wb_context != ctx || - req->wb_lseg != lseg; + req->wb_lseg != lseg ||pnfs_do_flush (req);nfs_release_request (req);if (!do_flush)return 0 ;
include/linux/nfs4_pnfs.h +3 -0
@@ -199,6 +199,9 @@ struct layoutdriver_policy_operations {/* test for nfs page cache coalescing */ int (*pg_test)(struct nfs_pageio_descriptor *,struct nfs_page *,struct nfs_page *); +/* Test for pre-write request flushing */ +int (*do_flush)(struct pnfs_layout_segment *lseg,struct nfs_page *req); +/* Retreive the block size of the file system. * If gather_across_stripes == 1, then the file system will gather * requests into the block size.
Signature · 1 line
1.6.6.1
PATCH 3/3 pnfs_post_submit: Restore the pnfs_write_end part of "pnfs: commit and pnfs_write_end"
From: Fred Isaman <[email protected]>
pnfs: commit and pnfs_write_end
Add hooks in the nfs_write_end path, giving a driver the potential for post-copy manipulation of the page.
Whole file semantics are different for COMMIT (0,0) and layouts (0,NFS4_MAX_UINT64).
--- fs/nfs/file.c | 4 ++++ fs/nfs/pnfs.c | 16 +++++++++++++++- fs/nfs/pnfs.h | 23 +++++++++++++++++++++++ include/linux/nfs4_pnfs.h | 3 +++ 4 files changed, 45 insertions(+), 1 deletions(-)
fs/nfs/file.c +4 -0
@@ -478,8 +478,12 @@ static int nfs_write_end(struct file *file, struct address_space *mapping, } lseg =nfs4_pull_lseg_from_fsdata (file, fsdata); + status =pnfs_write_end (file, page, pos, len, copied, lseg); +if (status) + goto out; status =nfs_updatepage (file, page, offset, copied, lseg); + out:unlock_page (page);page_cache_release (page);pnfs_write_end_cleanup (file, fsdata);
fs/nfs/pnfs.c +15 -1
@@ -1693,7 +1693,21 @@ out:return status; } -/* Given an nfs request, determine if it should be flushed before proceeding. +/* Return 0 on succes, negative on failure */ +/* CAREFUL - what happens if copied < len??? */ +int _pnfs_write_end (struct inode *inode,struct page *page, +loff_t pos,unsigned len,unsigned copied, +struct pnfs_layout_segment *lseg) +{ +struct nfs_server *nfss =NFS_SERVER (inode); +int status; + + status = nfss->pnfs_curr_ld->ld_io_ops->write_end (inode, page, + pos, len, copied, lseg); +return status; +} + +/* Given an nfs request, determine if it should be flushed before proceeding. * It should default to returning False, returning True only if there is a * specific reason to flush. */
fs/nfs/pnfs.h +23 -0
@@ -75,6 +75,9 @@ int _pnfs_write_begin(struct inode *inode, struct page *page, loff_t pos, unsigned len, struct pnfs_layout_segment *lseg, struct pnfs_fsdata **fsdata); +int _pnfs_write_end (struct inode *inode,struct page *page, +loff_t pos,unsigned len,unsigned copied, +struct pnfs_layout_segment *lseg);int _pnfs_do_flush (struct inode *inode,struct nfs_page *req);#define PNFS_EXISTS_LDIO_OP (srv, opname) ((srv)->pnfs_curr_ld && \
@@ -200,6 +203,19 @@ static inline int pnfs_do_flush(struct nfs_page *req)return 0 ; } +static inline int pnfs_write_end (struct file *filp,struct page *page, +loff_t pos,unsigned len,unsigned copied, +struct pnfs_layout_segment *lseg) +{ +struct inode *inode = filp->f_dentry->d_inode; +struct nfs_server *nfss =NFS_SERVER (inode); + +if (PNFS_EXISTS_LDIO_OP (nfss, write_end)) +return _pnfs_write_end (inode, page, pos, len, copied, lseg); +else +return 0 ; +} +static inline void pnfs_write_end_cleanup (struct file *filp,void *fsdata) {if (fsdata) {
@@ -324,6 +340,13 @@ static inline int pnfs_write_begin(struct file *filp, struct page *page,return 0 ; } +static inline int pnfs_write_end (struct file *filp,struct page *page, +loff_t pos,unsigned len,unsigned copied, +struct pnfs_layout_segment *lseg) +{ +return 0 ; +} +static inline void pnfs_write_end_cleanup (struct file *filp,void *fsdata) { }
include/linux/nfs4_pnfs.h +3 -0
@@ -143,6 +143,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); +int (*write_end)(struct inode *inode,struct page *page,loff_t pos, +unsigned count,unsigned copied, +struct pnfs_layout_segment *lseg);/* Consistency ops */ /* 2 problems:
Signature · 1 line
1.6.6.1