pnfs write functionality (wave 4)
Subsystems (2)
cover pnfs write functionality (wave 4)
These apply on top of Andy's most recent wave3 patches.
They can also be found at the branch wave4-submit-1 atgit://linux-nfs.org/~iisaman/linux-pnfs.git
These patches give write functionality to the pnfs file layout driver. The primary limitation is that we have not yet modified the commit code, so we can not yet handle COMMITs to the data server. We get around this for the moment by sending any WRITE to a data server which does not have commit-to-mds set as a SYNCH write. The next patchset will address this limitation.
Fred
PATCH 1/7 NFSv4.1: rearrange nfs_write_rpcsetup
From: Andy Adamson <[email protected]>
Reorder nfs_write_rpcsetup, preparing for a pnfs entry point.
--- fs/nfs/write.c | 82 +++++++++++++++++++++++++++++++------------------------ 1 files changed, 46 insertions(+), 36 deletions(-)
fs/nfs/write.c +46 -36
@@ -782,25 +782,21 @@ static int flush_task_priority(int how)return RPC_PRIORITY_NORMAL ; } -/* -* Set up the argument/result storage required for the RPC call. -*/ -static int nfs_write_rpcsetup (struct nfs_page *req, -struct nfs_write_data *data, -const struct rpc_call_ops *call_ops, -unsigned int count,unsigned int offset, -int how) +static int nfs_initiate_write (struct nfs_write_data *data, +struct rpc_clnt *clnt, +const struct rpc_call_ops *call_ops, +int how) { -struct inode *inode = req->wb_context->path.dentry->d_inode; +struct inode *inode = data->inode;int priority =flush_task_priority (how);struct rpc_task *task;struct rpc_message msg = { .rpc_argp = &data->args, .rpc_resp = &data->res, - .rpc_cred = req->wb_context->cred, + .rpc_cred = data->cred, };struct rpc_task_setup task_setup_data = { - .rpc_client =NFS_CLIENT (inode), + .rpc_client = clnt, .task = &data->task, .rpc_message = &msg, .callback_ops = call_ops,
@@ -811,12 +807,49 @@ static int nfs_write_rpcsetup(struct nfs_page *req, };int ret =0 ; +/* Set up the initial task struct. */ +NFS_PROTO (inode)->write_setup (data, &msg); + +dprintk ("NFS: %5u initiated write call " +"(req %s/%lld, %u bytes @ offset %llu)\n" , + data->task.tk_pid, + inode->i_sb->s_id, + (long long )NFS_FILEID (inode), + data->args.count, + (unsigned long long )data->args.offset); + + task =rpc_run_task (&task_setup_data); +if (IS_ERR (task)) { + ret =PTR_ERR (task); + goto out; + } +if (how &FLUSH_SYNC ) { + ret =rpc_wait_for_completion_task (task); +if (ret ==0 ) + ret = task->tk_status; + } +rpc_put_task (task); +out: +return ret; +} + +/* +* Set up the argument/result storage required for the RPC call. +*/ +static int nfs_write_rpcsetup (struct nfs_page *req, +struct nfs_write_data *data, +const struct rpc_call_ops *call_ops, +unsigned int count,unsigned int offset, +int how) +{ +struct inode *inode = req->wb_context->path.dentry->d_inode; +/* Set up the RPC argument and reply structs * NB: take care not to mess about with data->commit et al. */ data->req = req; data->inode = inode = req->wb_context->path.dentry->d_inode; - data->cred = msg.rpc_cred; + data->cred = req->wb_context->cred; data->args.fh =NFS_FH (inode); data->args.offset =req_offset (req) + offset;
@@ -837,30 +870,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req, data->res.verf = &data->verf;nfs_fattr_init (&data->fattr); -/* Set up the initial task struct. */ -NFS_PROTO (inode)->write_setup (data, &msg); - -dprintk ("NFS: %5u initiated write call " -"(req %s/%lld, %u bytes @ offset %llu)\n" , - data->task.tk_pid, - inode->i_sb->s_id, - (long long )NFS_FILEID (inode), - count, - (unsigned long long )data->args.offset); - - task =rpc_run_task (&task_setup_data); -if (IS_ERR (task)) { - ret =PTR_ERR (task); - goto out; - } -if (how &FLUSH_SYNC ) { - ret =rpc_wait_for_completion_task (task); -if (ret ==0 ) - ret = task->tk_status; - } -rpc_put_task (task); -out: -return ret; +return nfs_initiate_write (data,NFS_CLIENT (inode), call_ops, how); }/* If a nfs_flush_* function fails, it should remove reqs from @head and
Signature · 1 line
1.7.2.1
PATCH 2/7 NFSv4.1: add callback to nfs4_write_done
In reply to Fred IsamanAdd callback that pnfs layout driver can use to do its own handling of data server WRITE response.
--- fs/nfs/nfs4proc.c | 14 ++++++++++---- include/linux/nfs_xdr.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +10 -4
@@ -3122,13 +3122,10 @@ void nfs4_reset_read(struct rpc_task *task, struct nfs_read_data *data) }EXPORT_SYMBOL_GPL (nfs4_reset_read); -static int nfs4_write_done (struct rpc_task *task,struct nfs_write_data *data) +static int nfs4_write_done_cb (struct rpc_task *task,struct nfs_write_data *data) {struct inode *inode = data->inode; -if (!nfs4_sequence_done (task, &data->res.seq_res)) -return -EAGAIN ; -if (nfs4_async_handle_error (task,NFS_SERVER (inode), data->args.context->state) == -EAGAIN ) {nfs_restart_rpc (task,NFS_SERVER (inode)->nfs_client);return -EAGAIN ;
@@ -3140,11 +3137,20 @@ static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data)return 0 ; } +static int nfs4_write_done (struct rpc_task *task,struct nfs_write_data *data) +{ +if (!nfs4_sequence_done (task, &data->res.seq_res)) +return -EAGAIN ; +return data->write_done_cb (task, data); +} +static void nfs4_proc_write_setup (struct nfs_write_data *data,struct rpc_message *msg) {struct nfs_server *server =NFS_SERVER (data->inode); data->args.bitmask = server->cache_consistency_bitmask; +if (!data->write_done_cb) + data->write_done_cb = nfs4_write_done_cb; data->res.server = server; data->timestamp = jiffies;
include/linux/nfs_xdr.h +1 -0
@@ -1038,6 +1038,7 @@ struct nfs_write_data {unsigned int npages;/* Max length of pagevec */ struct nfs_writeargs args;/* argument struct */ struct nfs_writeres res;/* result struct */ +int (*write_done_cb) (struct rpc_task *task,struct nfs_write_data *data);#ifdef CONFIG_NFS_V4 unsigned long timestamp;/* For lease renewal */ #endif
Signature · 1 line
1.7.2.1
PATCH 3/7 NFSv4.1: Send lseg down into nfs_write_rpcsetup
In reply to Fred IsamanWe grab the lseg sent in from the doio function and attach it to each struct nfs_write_data created. This is how the lseg will be sent to the layout driver.
--- fs/nfs/write.c | 7 +++++-- include/linux/nfs_xdr.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-)
fs/nfs/write.c +5 -2
@@ -97,6 +97,7 @@ void nfs_writedata_free(struct nfs_write_data *p)static void nfs_writedata_release (struct nfs_write_data *wdata) { +put_lseg (wdata->lseg);put_nfs_open_context (wdata->args.context);nfs_writedata_free (wdata); }
@@ -840,6 +841,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req,struct nfs_write_data *data, const struct rpc_call_ops *call_ops, unsigned int count, unsigned int offset, + struct pnfs_layout_segment *lseg, int how) { struct inode *inode = req->wb_context->path.dentry->d_inode;
@@ -850,6 +852,7 @@ static int nfs_write_rpcsetup(struct nfs_page *req, data->req = req; data->inode = inode = req->wb_context->path.dentry->d_inode; data->cred = req->wb_context->cred; + data->lseg =get_lseg (lseg); data->args.fh =NFS_FH (inode); data->args.offset =req_offset (req) + offset;
@@ -930,7 +933,7 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsignedif (nbytes < wsize) wsize = nbytes; ret2 =nfs_write_rpcsetup (req, data, &nfs_write_partial_ops, - wsize, offset, how); + wsize, offset, lseg, how);if (ret ==0 ) ret = ret2; offset += wsize;
@@ -978,7 +981,7 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i req =nfs_list_entry (data->pages.next);/* Set up the argument struct */ -return nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , how); +return nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); out_bad:while (!list_empty (head)) { req =nfs_list_entry (head->next);
include/linux/nfs_xdr.h +1 -0
@@ -1038,6 +1038,7 @@ struct nfs_write_data {unsigned int npages;/* Max length of pagevec */ struct nfs_writeargs args;/* argument struct */ struct nfs_writeres res;/* result struct */ +struct pnfs_layout_segment *lseg;int (*write_done_cb) (struct rpc_task *task,struct nfs_write_data *data);#ifdef CONFIG_NFS_V4 unsigned long timestamp;/* For lease renewal */
Signature · 1 line
1.7.2.1
PATCH 4/7 NFSv4.1: trigger LAYOUTGET for writes
In reply to Fred Isaman--- fs/nfs/pnfs.c | 25 +++++++++++++++++++++++++ fs/nfs/pnfs.h | 7 +++++++ fs/nfs/write.c | 32 ++++++++++++++++++++------------ 3 files changed, 52 insertions(+), 12 deletions(-)
fs/nfs/pnfs.c +25 -0
@@ -876,6 +876,31 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) pgio->pg_test = (ld && ld->pg_test) ? pnfs_read_pg_test :NULL ; } +static int pnfs_write_pg_test (struct nfs_pageio_descriptor *pgio, +struct nfs_page *prev, +struct nfs_page *req) +{ +if (pgio->pg_count == prev->wb_bytes) { +/* This is first coelesce call for a series of nfs_pages */ + pgio->pg_lseg =pnfs_update_layout (pgio->pg_inode, + prev->wb_context, +IOMODE_RW ); + } +return NFS_SERVER (pgio->pg_inode)->pnfs_curr_ld->pg_test (pgio, prev, req); +} + +/* +* rsize is already set by caller to MDS rsize. +*/ +void +pnfs_pageio_init_write (struct nfs_pageio_descriptor *pgio,struct inode *inode) +{ +struct pnfs_layoutdriver_type *ld; + + ld =NFS_SERVER (inode)->pnfs_curr_ld; + pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test :NULL ; +} +/* * Call the appropriate parallel I/O subsystem read function. */
fs/nfs/pnfs.h +7 -0
@@ -123,6 +123,7 @@ void unset_pnfs_layoutdriver(struct nfs_server *);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 *);
@@ -235,6 +236,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 */
fs/nfs/write.c +20 -12
@@ -919,6 +919,8 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned }while (nbytes !=0 );atomic_set (&req->wb_complete, requests); +/* We know lseg==NULL */ + lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );ClearPageError (page); offset =0 ; nbytes = count;
@@ -940,6 +942,7 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned nbytes -= wsize; }while (nbytes !=0 ); +put_lseg (lseg);return ret; out_bad:
@@ -965,11 +968,18 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned istruct nfs_page *req;struct page **pages;struct nfs_write_data *data; +int ret; data =nfs_writedata_alloc (npages); -if (!data) - goto out_bad; - +if (!data) { +while (!list_empty (head)) { + req =nfs_list_entry (head->next); +nfs_list_remove_request (req); +nfs_redirty_request (req); + } + ret = -ENOMEM ; + goto out; + } pages = data->pagevec;while (!list_empty (head)) { req =nfs_list_entry (head->next);
@@ -979,16 +989,14 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i *pages++ = req->wb_page; } req =nfs_list_entry (data->pages.next); +if ((!lseg) &&list_is_singular (&data->pages)) + lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );/* Set up the argument struct */ -return nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); - out_bad: -while (!list_empty (head)) { - req =nfs_list_entry (head->next); -nfs_list_remove_request (req); -nfs_redirty_request (req); - } -return -ENOMEM ; + ret =nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); +out: +put_lseg (lseg); +return ret; } static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,
@@ -996,7 +1004,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);
Signature · 1 line
1.7.2.1
Re: [PATCH 4/7] NFSv4.1: trigger LAYOUTGET for writes
Quoted 21 lines · Fred Isaman
Signed-off-by Fred Isaman <[email protected]>--- fs/nfs/pnfs.c | 25 +++++++++++++++++++++++++ fs/nfs/pnfs.h | 7 +++++++ fs/nfs/write.c | 32 ++++++++++++++++++++------------ 3 files changed, 52 insertions(+), 12 deletions(-)fs/nfs/pnfs.c +6
-0@@ -876,6 +876,31 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) pgio->pg_test = (ld && ld->pg_test) ? pnfs_read_pg_test :NULL ; } +static int pnfs_write_pg_test (struct nfs_pageio_descriptor *pgio, +struct nfs_page *prev, +struct nfs_page *req) +{ +if (pgio->pg_count == prev->wb_bytes) { +/* This is first coelesce call for a series of nfs_pages */
fs/nfs/pnfs.c pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) · line 894
Quoted 10 lines
fs/nfs/pnfs.c +10
-0+ pgio->pg_lseg =pnfs_update_layout (pgio->pg_inode, + prev->wb_context, +IOMODE_RW ); + } +return NFS_SERVER (pgio->pg_inode)->pnfs_curr_ld->pg_test (pgio, prev, req); +} + +/* +* rsize is already set by caller to MDS rsize. +*/
This comment is confusing and looks out of place...
Quoted 42 lines
fs/nfs/pnfs.c +9
-0+void +pnfs_pageio_init_write (struct nfs_pageio_descriptor *pgio,struct inode *inode) +{ +struct pnfs_layoutdriver_type *ld; + + ld =NFS_SERVER (inode)->pnfs_curr_ld; + pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test :NULL ; +} +/* * Call the appropriate parallel I/O subsystem read function. */ fs/nfs/pnfs.h +7
-0@@ -123,6 +123,7 @@ void unset_pnfs_layoutdriver(struct nfs_server *);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 *);@@ -235,6 +236,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 */ fs/nfs/write.c +0
-0
fs/nfs/write.c static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned · line 922
Quoted 4 lines
fs/nfs/write.c +1
-0@@ -919,6 +919,8 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned }while (nbytes !=0 );atomic_set (&req->wb_complete, requests); +/* We know lseg==NULL */
Then maybe BUG_ON or WARN_ON(lseg != NULL)?
Quoted 15 lines
fs/nfs/write.c +2
-0+ lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );ClearPageError (page); offset =0 ; nbytes = count;@@ -940,6 +942,7 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned nbytes -= wsize; }while (nbytes !=0 ); +put_lseg (lseg);return ret; out_bad:@@ -965,11 +968,18 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned istruct nfs_page *req;struct page **pages;
fs/nfs/write.c static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i · line 976
Quoted 10 lines
fs/nfs/write.c +4
-3struct nfs_write_data *data; +int ret; data =nfs_writedata_alloc (npages); -if (!data) - goto out_bad; - +if (!data) { +while (!list_empty (head)) { + req =nfs_list_entry (head->next);
nit: it'd be cleaner to define a nfs_list_first_entry helper in nfs_page.h rather than using a combination of list helpers and open code (head->next).
Quoted 18 lines
fs/nfs/write.c +8
-1+nfs_list_remove_request (req); +nfs_redirty_request (req); + } + ret = -ENOMEM ; + goto out; + } pages = data->pagevec;while (!list_empty (head)) { req =nfs_list_entry (head->next);@@ -979,16 +989,14 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i *pages++ = req->wb_page; } req =nfs_list_entry (data->pages.next); +if ((!lseg) &&list_is_singular (&data->pages)) + lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );/* Set up the argument struct */ -return nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how);
fs/nfs/write.c static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i · line 998
Quoted 10 lines
fs/nfs/write.c +3
-7- out_bad: -while (!list_empty (head)) { - req =nfs_list_entry (head->next); -nfs_list_remove_request (req); -nfs_redirty_request (req); - } -return -ENOMEM ; + ret =nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); +out: +put_lseg (lseg);
Shouldn't you do that only if lseg was updated above?
Benny
Quoted 13 lines
fs/nfs/write.c +2
-1+return ret; } static void nfs_pageio_init_write(struct nfs_pageio_descriptor *pgio,@@ -996,7 +1004,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);
Re: [PATCH 4/7] NFSv4.1: trigger LAYOUTGET for writes
Quoted 26 lines · Benny Halevy
Quoted 25 lines · Fred Isaman
Signed-off-by Fred Isaman <[email protected]>---
fs/nfs/pnfs.c | 25 +++++++++++++++++++++++++ fs/nfs/pnfs.h | 7 +++++++ fs/nfs/write.c | 32 ++++++++++++++++++++------------ 3 files changed, 52 insertions(+), 12 deletions(-)fs/nfs/pnfs.c +10
-0@@ -876,6 +876,31 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) pgio->pg_test = (ld && ld->pg_test) ? pnfs_read_pg_test :NULL ; } +static int pnfs_write_pg_test (struct nfs_pageio_descriptor *pgio, +struct nfs_page *prev, +struct nfs_page *req) +{ +if (pgio->pg_count == prev->wb_bytes) { +/* This is first coelesce call for a series of nfs_pages */ + pgio->pg_lseg =pnfs_update_layout (pgio->pg_inode, + prev->wb_context, +IOMODE_RW ); + }
Quoted 8 lines
fs/nfs/pnfs.c pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) · line 894
Quoted 6 lines
fs/nfs/pnfs.c +6
-0+return NFS_SERVER (pgio->pg_inode)->pnfs_curr_ld->pg_test (pgio, prev, req); +} + +/* +* rsize is already set by caller to MDS rsize. +*/ This comment is confusing and looks out of place...
OK. I suggest we remove similar comment in the read code too.
Quoted 46 lines
Quoted 46 lines
fs/nfs/pnfs.c +9
-0+void +pnfs_pageio_init_write (struct nfs_pageio_descriptor *pgio,struct inode *inode) +{ +struct pnfs_layoutdriver_type *ld; + + ld =NFS_SERVER (inode)->pnfs_curr_ld; + pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test :NULL ; +} +/* * Call the appropriate parallel I/O subsystem read function. */ fs/nfs/pnfs.h +7
-0@@ -123,6 +123,7 @@ void unset_pnfs_layoutdriver(struct nfs_server *);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 *);@@ -235,6 +236,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 */ fs/nfs/write.c +0
-0@@ -919,6 +919,8 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned }while (nbytes !=0 );atomic_set (&req->wb_complete, requests);
Quoted 3 lines
fs/nfs/write.c static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned · line 922
Quoted 1 line
fs/nfs/write.c +1
-0+/* We know lseg==NULL */ Then maybe
BUG_ONorWARN_ON(lseg != NULL)?
OK.
Quoted 19 lines
Quoted 19 lines
fs/nfs/write.c +2
-0+ lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );ClearPageError (page); offset =0 ; nbytes = count;@@ -940,6 +942,7 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned nbytes -= wsize; }while (nbytes !=0 ); +put_lseg (lseg);return ret;
out_bad:fs/nfs/write.c +1
-0@@ -965,11 +968,18 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned istruct nfs_page *req;struct page **pages;struct nfs_write_data *data; +int ret;
Quoted 10 lines
fs/nfs/write.c static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i · line 976
Quoted 7 lines
fs/nfs/write.c +3
-3data =nfs_writedata_alloc (npages); -if (!data) - goto out_bad; - +if (!data) { +while (!list_empty (head)) { + req =nfs_list_entry (head->next);nit: it'd be cleaner to define a
nfs_list_first_entryhelper innfs_page.hrather than using a combination of list helpers and open code (head->next).
I would think that would be a separate patch. As this is just a simple move of pre-existing code, it is easier to see what is happening if I leave the copied code the same.
Quoted 17 lines
Quoted 17 lines
fs/nfs/write.c +8
-0+nfs_list_remove_request (req); +nfs_redirty_request (req); + } + ret = -ENOMEM ; + goto out; + } pages = data->pagevec;while (!list_empty (head)) { req =nfs_list_entry (head->next);@@ -979,16 +989,14 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i *pages++ = req->wb_page; } req =nfs_list_entry (data->pages.next); +if ((!lseg) &&list_is_singular (&data->pages)) + lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );
Quoted 15 lines
fs/nfs/write.c static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i · line 998
Quoted 12 lines
fs/nfs/write.c +3
-8/* Set up the argument struct */ -return nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); - out_bad: -while (!list_empty (head)) { - req =nfs_list_entry (head->next); -nfs_list_remove_request (req); -nfs_redirty_request (req); - } -return -ENOMEM ; + ret =nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); +out: +put_lseg (lseg);Shouldn't you do that only if lseg was updated above?
No, this is the put matching the get done in the pg_test function. I'll comment that.
Fred
Re: [PATCH 4/7] NFSv4.1: trigger LAYOUTGET for writes
Quoted 38 lines · Fred Isaman
Quoted 26 lines · Benny Halevy
Quoted 25 lines · Fred Isaman
Signed-off-by Fred Isaman <[email protected]>---
fs/nfs/pnfs.c | 25 +++++++++++++++++++++++++ fs/nfs/pnfs.h | 7 +++++++ fs/nfs/write.c | 32 ++++++++++++++++++++------------ 3 files changed, 52 insertions(+), 12 deletions(-)fs/nfs/pnfs.c +10
-0@@ -876,6 +876,31 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) pgio->pg_test = (ld && ld->pg_test) ? pnfs_read_pg_test :NULL ; } +static int pnfs_write_pg_test (struct nfs_pageio_descriptor *pgio, +struct nfs_page *prev, +struct nfs_page *req) +{ +if (pgio->pg_count == prev->wb_bytes) { +/* This is first coelesce call for a series of nfs_pages */ + pgio->pg_lseg =pnfs_update_layout (pgio->pg_inode, + prev->wb_context, +IOMODE_RW ); + }Quoted 8 lines
fs/nfs/pnfs.c pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode) · line 894
Quoted 6 lines
fs/nfs/pnfs.c +6
-0+return NFS_SERVER (pgio->pg_inode)->pnfs_curr_ld->pg_test (pgio, prev, req); +} + +/* +* rsize is already set by caller to MDS rsize. +*/ This comment is confusing and looks out of place...
Quoted 2 lines
OK. I suggest we remove similar comment in the read code too.
Yeah. Works for me.
Quoted 83 lines
Quoted 46 lines
Quoted 46 lines
fs/nfs/pnfs.c +9
-0+void +pnfs_pageio_init_write (struct nfs_pageio_descriptor *pgio,struct inode *inode) +{ +struct pnfs_layoutdriver_type *ld; + + ld =NFS_SERVER (inode)->pnfs_curr_ld; + pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test :NULL ; +} +/* * Call the appropriate parallel I/O subsystem read function. */ fs/nfs/pnfs.h +7
-0@@ -123,6 +123,7 @@ void unset_pnfs_layoutdriver(struct nfs_server *);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 *);@@ -235,6 +236,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 */ fs/nfs/write.c +0
-0@@ -919,6 +919,8 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned }while (nbytes !=0 );atomic_set (&req->wb_complete, requests);Quoted 3 lines
fs/nfs/write.c static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned · line 922
Quoted 1 line
fs/nfs/write.c +1
-0+/* We know lseg==NULL */ Then maybe
BUG_ONorWARN_ON(lseg != NULL)?OK.
Quoted 19 lines
Quoted 19 lines
fs/nfs/write.c +2
-0+ lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );ClearPageError (page); offset =0 ; nbytes = count;@@ -940,6 +942,7 @@ static int nfs_flush_multi(struct inode *inode, struct list_head *head, unsigned nbytes -= wsize; }while (nbytes !=0 ); +put_lseg (lseg);return ret;
out_bad:fs/nfs/write.c +1
-0@@ -965,11 +968,18 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned istruct nfs_page *req;struct page **pages;struct nfs_write_data *data; +int ret;Quoted 10 lines
fs/nfs/write.c static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i · line 976
Quoted 7 lines
fs/nfs/write.c +3
-3data =nfs_writedata_alloc (npages); -if (!data) - goto out_bad; - +if (!data) { +while (!list_empty (head)) { + req =nfs_list_entry (head->next);nit: it'd be cleaner to define a
nfs_list_first_entryhelper innfs_page.hrather than using a combination of list helpers and open code (head->next).
Quoted 4 lines
I would think that would be a separate patch. As this is just a simple move of pre-existing code, it is easier to see what is happening if I leave the copied code the same.
OK, makes sense.
Benny
Quoted 37 lines
Quoted 17 lines
Quoted 17 lines
fs/nfs/write.c +8
-0+nfs_list_remove_request (req); +nfs_redirty_request (req); + } + ret = -ENOMEM ; + goto out; + } pages = data->pagevec;while (!list_empty (head)) { req =nfs_list_entry (head->next);@@ -979,16 +989,14 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i *pages++ = req->wb_page; } req =nfs_list_entry (data->pages.next); +if ((!lseg) &&list_is_singular (&data->pages)) + lseg =pnfs_update_layout (inode, req->wb_context,IOMODE_RW );Quoted 15 lines
fs/nfs/write.c static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i · line 998
Quoted 12 lines
fs/nfs/write.c +3
-8/* Set up the argument struct */ -return nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); - out_bad: -while (!list_empty (head)) { - req =nfs_list_entry (head->next); -nfs_list_remove_request (req); -nfs_redirty_request (req); - } -return -ENOMEM ; + ret =nfs_write_rpcsetup (req, data, &nfs_write_full_ops, count,0 , lseg, how); +out: +put_lseg (lseg);Shouldn't you do that only if lseg was updated above?
No, this is the put matching the get done in the
pg_testfunction. I'll comment that.Fred
Re: [PATCH 4/7] NFSv4.1: trigger LAYOUTGET for writes
In reply to Benny HalevyQuoted 7 lines · Benny Halevy
Quoted 6 lines · Fred Isaman
fs/nfs/write.c +1
-0@@ -965,11 +968,18 @@ static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned istruct nfs_page *req;struct page **pages;struct nfs_write_data *data; +int ret;
Quoted 10 lines
fs/nfs/write.c static int nfs_flush_one(struct inode *inode, struct list_head *head, unsigned i · line 976
Quoted 7 lines
fs/nfs/write.c +3
-3data =nfs_writedata_alloc (npages); -if (!data) - goto out_bad; - +if (!data) { +while (!list_empty (head)) { + req =nfs_list_entry (head->next);nit: it'd be cleaner to define a
nfs_list_first_entryhelper innfs_page.hrather than using a combination of list helpers and open code (head->next).
No thanks! Let's not add lots of helpers for trivial stuff unless that results in a clear gain in type safety.
Trond
Signature · 6 lines
Trond Myklebust Linux NFS client maintainer NetApp [email protected] www.netapp.com
PATCH 5/7 NFSv4.1: implement generic pnfs layer write switch
In reply to Fred IsamanFrom: Andy Adamson <[email protected]>
--- fs/nfs/nfs4filelayout.c | 7 +++++++ fs/nfs/pnfs.c | 24 ++++++++++++++++++++++++ fs/nfs/pnfs.h | 11 +++++++++++ fs/nfs/write.c | 4 ++++ include/linux/nfs_iostat.h | 1 + include/linux/nfs_xdr.h | 1 + 6 files changed, 48 insertions(+), 0 deletions(-)
fs/nfs/nfs4filelayout.c +7 -0
@@ -236,6 +236,12 @@ filelayout_read_pagelist(struct nfs_read_data *data)return PNFS_ATTEMPTED ; } +static enum pnfs_try_status +filelayout_write_pagelist (struct nfs_write_data *data,int sync) +{ +return PNFS_NOT_ATTEMPTED ; +} +/* * filelayout_check_layout() *
@@ -453,6 +459,7 @@ static struct pnfs_layoutdriver_type filelayout_type = { .free_lseg = filelayout_free_lseg, .pg_test = filelayout_pg_test, .read_pagelist = filelayout_read_pagelist, + .write_pagelist = filelayout_write_pagelist, };static int __init nfs4filelayout_init (void )
fs/nfs/pnfs.c +24 -0
@@ -901,6 +901,30 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode) pgio->pg_test = (ld && ld->pg_test) ? pnfs_write_pg_test :NULL ; } +enum pnfs_try_status +pnfs_try_to_write_data (struct nfs_write_data *wdata, +const struct rpc_call_ops *call_ops,int how) +{ +struct inode *inode = wdata->inode; +enum pnfs_try_status trypnfs; +struct nfs_server *nfss =NFS_SERVER (inode); + + wdata->mds_ops = call_ops; + +dprintk ("%s: Writing ino:%lu %u@%llu (how %d)\n" , __func__, + inode->i_ino, wdata->args.count, wdata->args.offset, how); + + trypnfs = nfss->pnfs_curr_ld->write_pagelist (wdata, how); +if (trypnfs ==PNFS_NOT_ATTEMPTED ) { + wdata->lseg =NULL ; +put_lseg (wdata->lseg); + }else +nfs_inc_stats (inode,NFSIOS_PNFS_WRITE ); + +dprintk ("%s End (trypnfs:%d)\n" , __func__, trypnfs); +return trypnfs; +} +/* * Call the appropriate parallel I/O subsystem read function. */
fs/nfs/pnfs.h +11 -0
@@ -79,6 +79,8 @@ struct pnfs_layoutdriver_type {* I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS */ enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data); +enum pnfs_try_status + (*write_pagelist) (struct nfs_write_data *nfs_data,int how); };struct pnfs_layout_hdr {
@@ -120,6 +122,8 @@ pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, enum pnfs_iomode access_type);void set_pnfs_layoutdriver (struct nfs_server *,u32 id);void unset_pnfs_layoutdriver (struct nfs_server *); +enum pnfs_try_status pnfs_try_to_write_data (struct nfs_write_data *, +const struct rpc_call_ops *,int );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 *);
@@ -200,6 +204,13 @@ pnfs_try_to_read_data(struct nfs_read_data *data,return PNFS_NOT_ATTEMPTED ; } +static inline enum pnfs_try_status +pnfs_try_to_write_data (struct nfs_write_data *data, +const struct rpc_call_ops *call_ops,int how) +{ +return PNFS_NOT_ATTEMPTED ; +} +static inline bool pnfs_roc (struct inode *ino) {
fs/nfs/write.c +4 -0
@@ -873,6 +873,10 @@ static int nfs_write_rpcsetup(struct nfs_page *req, data->res.verf = &data->verf;nfs_fattr_init (&data->fattr); +if (data->lseg && + (pnfs_try_to_write_data (data, call_ops, how) ==PNFS_ATTEMPTED )) +return 0 ; +return nfs_initiate_write (data,NFS_CLIENT (inode), call_ops, how); }
include/linux/nfs_iostat.h +1 -0
@@ -114,6 +114,7 @@ enum nfs_stat_eventcounters {NFSIOS_SHORTWRITE ,NFSIOS_DELAY ,NFSIOS_PNFS_READ , +NFSIOS_PNFS_WRITE , __NFSIOS_COUNTSMAX, };
include/linux/nfs_xdr.h +1 -0
@@ -1039,6 +1039,7 @@ struct nfs_write_data {struct nfs_writeargs args;/* argument struct */ struct nfs_writeres res;/* result struct */ struct pnfs_layout_segment *lseg; +const struct rpc_call_ops *mds_ops;int (*write_done_cb) (struct rpc_task *task,struct nfs_write_data *data);#ifdef CONFIG_NFS_V4 unsigned long timestamp;/* For lease renewal */
Signature · 1 line
1.7.2.1
Re: [PATCH 5/7] NFSv4.1: implement generic pnfs layer write switch
fs/nfs/pnfs.h struct pnfs_layoutdriver_type { · line 83
Quoted 10 lines · Fred Isaman
fs/nfs/pnfs.h +2
-0@@ -79,6 +79,8 @@ struct pnfs_layoutdriver_type {* I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS */ enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data); +enum pnfs_try_status + (*write_pagelist) (struct nfs_write_data *nfs_data,int how);
nit: line break
Quoted 58 lines
fs/nfs/pnfs.h +9
-0};struct pnfs_layout_hdr {@@ -120,6 +122,8 @@ pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, enum pnfs_iomode access_type);void set_pnfs_layoutdriver (struct nfs_server *,u32 id);void unset_pnfs_layoutdriver (struct nfs_server *); +enum pnfs_try_status pnfs_try_to_write_data (struct nfs_write_data *, +const struct rpc_call_ops *,int );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 *);@@ -200,6 +204,13 @@ pnfs_try_to_read_data(struct nfs_read_data *data,return PNFS_NOT_ATTEMPTED ; } +static inline enum pnfs_try_status +pnfs_try_to_write_data (struct nfs_write_data *data, +const struct rpc_call_ops *call_ops,int how) +{ +return PNFS_NOT_ATTEMPTED ; +} +static inline bool pnfs_roc (struct inode *ino) {fs/nfs/write.c +4
-0@@ -873,6 +873,10 @@ static int nfs_write_rpcsetup(struct nfs_page *req, data->res.verf = &data->verf;nfs_fattr_init (&data->fattr); +if (data->lseg && + (pnfs_try_to_write_data (data, call_ops, how) ==PNFS_ATTEMPTED )) +return 0 ; +return nfs_initiate_write (data,NFS_CLIENT (inode), call_ops, how); }include/linux/nfs_iostat.h +1
-0@@ -114,6 +114,7 @@ enum nfs_stat_eventcounters {NFSIOS_SHORTWRITE ,NFSIOS_DELAY ,NFSIOS_PNFS_READ , +NFSIOS_PNFS_WRITE , __NFSIOS_COUNTSMAX, };include/linux/nfs_xdr.h +0
-0
include/linux/nfs_xdr.h struct nfs_write_data { · line 1042
Quoted 4 lines
include/linux/nfs_xdr.h +1
-0@@ -1039,6 +1039,7 @@ struct nfs_write_data {struct nfs_writeargs args;/* argument struct */ struct nfs_writeres res;/* result struct */ struct pnfs_layout_segment *lseg; +const struct rpc_call_ops *mds_ops;
nit: mds_ops is not really used in the patch, just initialized. better introduce it along with its usage in patch 7/7.
Benny
Quoted 3 lines
include/linux/nfs_xdr.h +0
-0int (*write_done_cb) (struct rpc_task *task,struct nfs_write_data *data);#ifdef CONFIG_NFS_V4 unsigned long timestamp;/* For lease renewal */
Re: [PATCH 5/7] NFSv4.1: implement generic pnfs layer write switch
Quoted 13 lines · Benny Halevy
fs/nfs/pnfs.h struct pnfs_layoutdriver_type { · line 83
Quoted 10 lines · Fred Isaman
fs/nfs/pnfs.h +2
-0@@ -79,6 +79,8 @@ struct pnfs_layoutdriver_type {* I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS */ enum pnfs_try_status (*read_pagelist) (struct nfs_read_data *nfs_data); +enum pnfs_try_status + (*write_pagelist) (struct nfs_write_data *nfs_data,int how);nit: line break
OK
Quoted 54 lines
Quoted 54 lines
fs/nfs/pnfs.h +9
-0};struct pnfs_layout_hdr {@@ -120,6 +122,8 @@ pnfs_update_layout(struct inode *ino, struct nfs_open_context *ctx, enum pnfs_iomode access_type);void set_pnfs_layoutdriver (struct nfs_server *,u32 id);void unset_pnfs_layoutdriver (struct nfs_server *); +enum pnfs_try_status pnfs_try_to_write_data (struct nfs_write_data *, +const struct rpc_call_ops *,int );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 *);@@ -200,6 +204,13 @@ pnfs_try_to_read_data(struct nfs_read_data *data,return PNFS_NOT_ATTEMPTED ; } +static inline enum pnfs_try_status +pnfs_try_to_write_data (struct nfs_write_data *data, +const struct rpc_call_ops *call_ops,int how) +{ +return PNFS_NOT_ATTEMPTED ; +} +static inline bool
pnfs_roc(struct inode *ino)
{fs/nfs/write.c +4
-0@@ -873,6 +873,10 @@ static int nfs_write_rpcsetup(struct nfs_page *req, data->res.verf = &data->verf;nfs_fattr_init (&data->fattr); +if (data->lseg && + (pnfs_try_to_write_data (data, call_ops, how) ==PNFS_ATTEMPTED )) +return 0 ; +return nfs_initiate_write (data,NFS_CLIENT (inode), call_ops, how); }include/linux/nfs_iostat.h +1
-0@@ -114,6 +114,7 @@ enum nfs_stat_eventcounters {NFSIOS_SHORTWRITE ,NFSIOS_DELAY ,NFSIOS_PNFS_READ , +NFSIOS_PNFS_WRITE , __NFSIOS_COUNTSMAX, };
Quoted 12 lines
include/linux/nfs_xdr.h struct nfs_write_data { · line 1042
Quoted 9 lines
include/linux/nfs_xdr.h +1
-0@@ -1039,6 +1039,7 @@ struct nfs_write_data {struct nfs_writeargs args;/* argument struct */ struct nfs_writeres res;/* result struct */ struct pnfs_layout_segment *lseg; +const struct rpc_call_ops *mds_ops;nit:
mds_opsis not really used in the patch, just initialized. better introduce it along with its usage in patch 7/7.
OK.
Fred
Quoted 6 lines
Benny
Quoted 3 lines
include/linux/nfs_xdr.h +0
-0int (*write_done_cb) (struct rpc_task *task,struct nfs_write_data *data);#ifdef CONFIG_NFS_V4 unsigned long timestamp;/* For lease renewal */
PATCH 6/7 NFSv4.1: remove GETATTR from ds writes
In reply to Fred IsamanAny WRITE compound directed to a data server needs to have the GETATTR calls suppressed.
--- fs/nfs/nfs4proc.c | 6 +++++- fs/nfs/nfs4xdr.c | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-)
fs/nfs/nfs4proc.c +5 -1
@@ -3148,7 +3148,11 @@ static void nfs4_proc_write_setup(struct nfs_write_data *data, struct rpc_messag {struct nfs_server *server =NFS_SERVER (data->inode); - data->args.bitmask = server->cache_consistency_bitmask; +if (data->lseg) { + data->args.bitmask =NULL ; + data->res.fattr =NULL ; + }else + data->args.bitmask = server->cache_consistency_bitmask;if (!data->write_done_cb) data->write_done_cb = nfs4_write_done_cb; data->res.server = server;
fs/nfs/nfs4xdr.c +5 -3
@@ -2275,7 +2275,8 @@ static void nfs4_xdr_enc_write(struct rpc_rqst *req, struct xdr_stream *xdr,encode_putfh (xdr, args->fh, &hdr);encode_write (xdr, args, &hdr); req->rq_snd_buf.flags |=XDRBUF_WRITE ; -encode_getfattr (xdr, args->bitmask, &hdr); +if (args->bitmask) +encode_getfattr (xdr, args->bitmask, &hdr);encode_nops (&hdr); }
@@ -5694,8 +5695,9 @@ static int nfs4_xdr_dec_write(struct rpc_rqst *rqstp, struct xdr_stream *xdr, status =decode_write (xdr, res);if (status) goto out; -decode_getfattr (xdr, res->fattr, res->server, - !RPC_IS_ASYNC (rqstp->rq_task)); +if (res->fattr) +decode_getfattr (xdr, res->fattr, res->server, + !RPC_IS_ASYNC (rqstp->rq_task));if (!status) status = res->count; out:
Signature · 1 line
1.7.2.1
PATCH 7/7 NFSv4.1: pnfs filelayout driver write
In reply to Fred IsamanAllows the pnfs filelayout driver to write to the data servers.
Note that COMMIT to data servers will be implemented in a future patch. To avoid improper behavior, for the moment any WRITE to a data server that would also require a COMMIT to the data server is sent NFS_FILE_SYNC.
--- fs/nfs/internal.h | 5 ++ fs/nfs/nfs4filelayout.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++- fs/nfs/nfs4proc.c | 17 ++++++++ fs/nfs/write.c | 5 ++- include/linux/nfs_xdr.h | 2 + 5 files changed, 126 insertions(+), 2 deletions(-)
fs/nfs/internal.h +5 -0
@@ -276,6 +276,10 @@ extern int nfs_initiate_read(struct nfs_read_data *data, struct rpc_clnt *clnt,extern void nfs_read_prepare (struct rpc_task *task,void *calldata);/* write.c */ +extern int nfs_initiate_write (struct nfs_write_data *data, +struct rpc_clnt *clnt, +const struct rpc_call_ops *call_ops, +int how);extern void nfs_write_prepare (struct rpc_task *task,void *calldata);#ifdef CONFIG_MIGRATION extern int nfs_migrate_page(struct address_space *,
@@ -291,6 +295,7 @@ extern int nfs4_init_client(struct nfs_client *clp,const char *ip_addr, rpc_authflavor_t authflavour, int noresvport); +extern void nfs4_reset_write (struct rpc_task *task,struct nfs_write_data *data); extern int _nfs4_call_sync(struct nfs_server *server, struct rpc_message *msg, struct nfs4_sequence_args *args,
fs/nfs/nfs4filelayout.c +98 -1
120 lines not on this page · raw message
fs/nfs/nfs4proc.c +17 -0
@@ -3144,6 +3144,23 @@ static int nfs4_write_done(struct rpc_task *task, struct nfs_write_data *data)return data->write_done_cb (task, data); } +/* Reset the the nfs_write_data to send the write to the MDS. */ +void nfs4_reset_write (struct rpc_task *task,struct nfs_write_data *data) +{ +dprintk ("%s Reset task for i/o through\n" , __func__); +put_lseg (data->lseg); + data->lseg =NULL ; + data->ds_clp =NULL ; + data->write_done_cb = nfs4_write_done_cb; + data->args.fh =NFS_FH (data->inode); + data->args.bitmask = data->res.server->cache_consistency_bitmask; + data->args.offset = data->mds_offset; + data->res.fattr = &data->fattr; + task->tk_ops = data->mds_ops; +rpc_task_reset_client (task,NFS_CLIENT (data->inode)); +} +EXPORT_SYMBOL_GPL (nfs4_reset_write); +static void nfs4_proc_write_setup (struct nfs_write_data *data,struct rpc_message *msg) {struct nfs_server *server =NFS_SERVER (data->inode);
fs/nfs/write.c +4 -1
@@ -783,7 +783,7 @@ static int flush_task_priority(int how)return RPC_PRIORITY_NORMAL ; } -static int nfs_initiate_write (struct nfs_write_data *data, +int nfs_initiate_write (struct nfs_write_data *data,struct rpc_clnt *clnt,const struct rpc_call_ops *call_ops,int how)
@@ -833,6 +833,7 @@ static int nfs_initiate_write(struct nfs_write_data *data, out:return ret; } +EXPORT_SYMBOL (nfs_initiate_write);/* * Set up the argument/result storage required for the RPC call.
@@ -1194,6 +1195,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)*/ static unsigned long complain; +/* Note this will print the MDS for a DS write */ if (time_before (complain, jiffies)) { dprintk("NFS: faulty NFS server %s:" " (committed = %d) != (stable = %d)\n",
@@ -1214,6 +1216,7 @@ int nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)/* Was this an NFSv2 write or an NFSv3 stable write? */ if (resp->verf->committed !=NFS_UNSTABLE ) {/* Resend from where the server left off */ + data->mds_offset += resp->count; argp->offset += resp->count; argp->pgbase += resp->count; argp->count -= resp->count;
include/linux/nfs_xdr.h +2 -0
@@ -1039,11 +1039,13 @@ struct nfs_write_data {struct nfs_writeargs args;/* argument struct */ struct nfs_writeres res;/* result struct */ struct pnfs_layout_segment *lseg; +struct nfs_client *ds_clp;/* pNFS data server */ const struct rpc_call_ops *mds_ops;int (*write_done_cb) (struct rpc_task *task,struct nfs_write_data *data);#ifdef CONFIG_NFS_V4 unsigned long timestamp;/* For lease renewal */ #endif +__u64 mds_offset;/* Filelayout dense stripe */ struct page *page_array[NFS_PAGEVEC_SIZE ]; };
Signature · 1 line
1.7.2.1
Re: [PATCH 7/7] NFSv4.1: pnfs filelayout driver write
Quoted 14 lines · Fred Isaman
fs/nfs/write.c +1
-1@@ -783,7 +783,7 @@ static int flush_task_priority(int how) return RPC_PRIORITY_NORMAL; } -static int nfs_initiate_write (struct nfs_write_data *data, +int nfs_initiate_write (struct nfs_write_data *data, struct rpc_clnt *clnt, const struct rpc_call_ops *call_ops, int how)@@ -833,6 +833,7 @@ static int nfs_initiate_write(struct nfs_write_data *data,
Quoted 5 lines
out:
return ret;
}
+EXPORT_SYMBOL(nfs_initiate_write);
This should be EXPORT_SYMBOL_GPL.
Fred