aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2015-03-25 14:14:42 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-03-27 12:39:38 -0400
commit5bb89b4702e22981445ae01af733a57d1cae2018 (patch)
tree4c00a7c47fa2dab958f43a395e71067fe6ee6538 /fs
parent7140171ea9be4143736c35acf6f31b6feb195ca0 (diff)
NFSv4.1/pnfs: Separate out metadata and data consistency for pNFS
The LAYOUTCOMMIT operation means different things to different layout types. For blocks and objects, it is both a data and metadata consistency operation. For files and flexfiles, it is only a metadata consistency operation. This patch separates out the 2 cases, allowing the files/flexfiles layout drivers to optimise away the data consistency calls to layoutcommit. Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/blocklayout/blocklayout.c1
-rw-r--r--fs/nfs/filelayout/filelayout.c1
-rw-r--r--fs/nfs/flexfilelayout/flexfilelayout.c1
-rw-r--r--fs/nfs/nfs4file.c2
-rw-r--r--fs/nfs/objlayout/objio_osd.c2
-rw-r--r--fs/nfs/pnfs.c7
-rw-r--r--fs/nfs/pnfs.h18
-rw-r--r--fs/nfs/pnfs_nfs.c10
-rw-r--r--fs/nfs/write.c13
9 files changed, 47 insertions, 8 deletions
diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c
index 1cac3c175d18..d2554fe140a3 100644
--- a/fs/nfs/blocklayout/blocklayout.c
+++ b/fs/nfs/blocklayout/blocklayout.c
@@ -890,6 +890,7 @@ static struct pnfs_layoutdriver_type blocklayout_type = {
890 .free_deviceid_node = bl_free_deviceid_node, 890 .free_deviceid_node = bl_free_deviceid_node,
891 .pg_read_ops = &bl_pg_read_ops, 891 .pg_read_ops = &bl_pg_read_ops,
892 .pg_write_ops = &bl_pg_write_ops, 892 .pg_write_ops = &bl_pg_write_ops,
893 .sync = pnfs_generic_sync,
893}; 894};
894 895
895static int __init nfs4blocklayout_init(void) 896static int __init nfs4blocklayout_init(void)
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c
index a317b007e436..a46bf6de9ce4 100644
--- a/fs/nfs/filelayout/filelayout.c
+++ b/fs/nfs/filelayout/filelayout.c
@@ -1139,6 +1139,7 @@ static struct pnfs_layoutdriver_type filelayout_type = {
1139 .write_pagelist = filelayout_write_pagelist, 1139 .write_pagelist = filelayout_write_pagelist,
1140 .alloc_deviceid_node = filelayout_alloc_deviceid_node, 1140 .alloc_deviceid_node = filelayout_alloc_deviceid_node,
1141 .free_deviceid_node = filelayout_free_deviceid_node, 1141 .free_deviceid_node = filelayout_free_deviceid_node,
1142 .sync = pnfs_nfs_generic_sync,
1142}; 1143};
1143 1144
1144static int __init nfs4filelayout_init(void) 1145static int __init nfs4filelayout_init(void)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 92d2943e54f8..f3ff66e4fb6a 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1509,6 +1509,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = {
1509 .write_pagelist = ff_layout_write_pagelist, 1509 .write_pagelist = ff_layout_write_pagelist,
1510 .alloc_deviceid_node = ff_layout_alloc_deviceid_node, 1510 .alloc_deviceid_node = ff_layout_alloc_deviceid_node,
1511 .encode_layoutreturn = ff_layout_encode_layoutreturn, 1511 .encode_layoutreturn = ff_layout_encode_layoutreturn,
1512 .sync = pnfs_nfs_generic_sync,
1512}; 1513};
1513 1514
1514static int __init nfs4flexfilelayout_init(void) 1515static int __init nfs4flexfilelayout_init(void)
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c
index befe7a2c6284..866842b048ef 100644
--- a/fs/nfs/nfs4file.c
+++ b/fs/nfs/nfs4file.c
@@ -112,7 +112,7 @@ nfs4_file_fsync(struct file *file, loff_t start, loff_t end, int datasync)
112 mutex_lock(&inode->i_mutex); 112 mutex_lock(&inode->i_mutex);
113 ret = nfs_file_fsync_commit(file, start, end, datasync); 113 ret = nfs_file_fsync_commit(file, start, end, datasync);
114 if (!ret) 114 if (!ret)
115 ret = pnfs_layoutcommit_inode(inode, true); 115 ret = pnfs_sync_inode(inode, !!datasync);
116 mutex_unlock(&inode->i_mutex); 116 mutex_unlock(&inode->i_mutex);
117 /* 117 /*
118 * If nfs_file_fsync_commit detected a server reboot, then 118 * If nfs_file_fsync_commit detected a server reboot, then
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c
index 8b5e0e687d5e..5aaed363556a 100644
--- a/fs/nfs/objlayout/objio_osd.c
+++ b/fs/nfs/objlayout/objio_osd.c
@@ -637,6 +637,8 @@ static struct pnfs_layoutdriver_type objlayout_type = {
637 .pg_read_ops = &objio_pg_read_ops, 637 .pg_read_ops = &objio_pg_read_ops,
638 .pg_write_ops = &objio_pg_write_ops, 638 .pg_write_ops = &objio_pg_write_ops,
639 639
640 .sync = pnfs_generic_sync,
641
640 .free_deviceid_node = objio_free_deviceid_node, 642 .free_deviceid_node = objio_free_deviceid_node,
641 643
642 .encode_layoutcommit = objlayout_encode_layoutcommit, 644 .encode_layoutcommit = objlayout_encode_layoutcommit,
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index c2ce2db771b7..3f0affebcf05 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -2231,6 +2231,13 @@ clear_layoutcommitting:
2231} 2231}
2232EXPORT_SYMBOL_GPL(pnfs_layoutcommit_inode); 2232EXPORT_SYMBOL_GPL(pnfs_layoutcommit_inode);
2233 2233
2234int
2235pnfs_generic_sync(struct inode *inode, bool datasync)
2236{
2237 return pnfs_layoutcommit_inode(inode, true);
2238}
2239EXPORT_SYMBOL_GPL(pnfs_generic_sync);
2240
2234struct nfs4_threshold *pnfs_mdsthreshold_alloc(void) 2241struct nfs4_threshold *pnfs_mdsthreshold_alloc(void)
2235{ 2242{
2236 struct nfs4_threshold *thp; 2243 struct nfs4_threshold *thp;
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
index 66bf5e1cf93d..231eb23c22da 100644
--- a/fs/nfs/pnfs.h
+++ b/fs/nfs/pnfs.h
@@ -155,6 +155,8 @@ struct pnfs_layoutdriver_type {
155 int how, 155 int how,
156 struct nfs_commit_info *cinfo); 156 struct nfs_commit_info *cinfo);
157 157
158 int (*sync)(struct inode *inode, bool datasync);
159
158 /* 160 /*
159 * Return PNFS_ATTEMPTED to indicate the layout code has attempted 161 * Return PNFS_ATTEMPTED to indicate the layout code has attempted
160 * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS 162 * I/O, else return PNFS_NOT_ATTEMPTED to fall back to normal NFS
@@ -267,6 +269,8 @@ bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task);
267void pnfs_set_layoutcommit(struct inode *, struct pnfs_layout_segment *, loff_t); 269void pnfs_set_layoutcommit(struct inode *, struct pnfs_layout_segment *, loff_t);
268void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data); 270void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data);
269int pnfs_layoutcommit_inode(struct inode *inode, bool sync); 271int pnfs_layoutcommit_inode(struct inode *inode, bool sync);
272int pnfs_generic_sync(struct inode *inode, bool datasync);
273int pnfs_nfs_generic_sync(struct inode *inode, bool datasync);
270int _pnfs_return_layout(struct inode *); 274int _pnfs_return_layout(struct inode *);
271int pnfs_commit_and_return_layout(struct inode *); 275int pnfs_commit_and_return_layout(struct inode *);
272void pnfs_ld_write_done(struct nfs_pgio_header *); 276void pnfs_ld_write_done(struct nfs_pgio_header *);
@@ -488,6 +492,14 @@ pnfs_ld_read_whole_page(struct inode *inode)
488 return NFS_SERVER(inode)->pnfs_curr_ld->flags & PNFS_READ_WHOLE_PAGE; 492 return NFS_SERVER(inode)->pnfs_curr_ld->flags & PNFS_READ_WHOLE_PAGE;
489} 493}
490 494
495static inline int
496pnfs_sync_inode(struct inode *inode, bool datasync)
497{
498 if (!pnfs_enabled_sb(NFS_SERVER(inode)))
499 return 0;
500 return NFS_SERVER(inode)->pnfs_curr_ld->sync(inode, datasync);
501}
502
491static inline bool 503static inline bool
492pnfs_layoutcommit_outstanding(struct inode *inode) 504pnfs_layoutcommit_outstanding(struct inode *inode)
493{ 505{
@@ -570,6 +582,12 @@ pnfs_ld_read_whole_page(struct inode *inode)
570 return false; 582 return false;
571} 583}
572 584
585static inline int
586pnfs_sync_inode(struct inode *inode, bool datasync)
587{
588 return 0;
589}
590
573static inline bool 591static inline bool
574pnfs_roc(struct inode *ino) 592pnfs_roc(struct inode *ino)
575{ 593{
diff --git a/fs/nfs/pnfs_nfs.c b/fs/nfs/pnfs_nfs.c
index 54e36b38fb5f..64d2a5932f7b 100644
--- a/fs/nfs/pnfs_nfs.c
+++ b/fs/nfs/pnfs_nfs.c
@@ -868,3 +868,13 @@ pnfs_layout_mark_request_commit(struct nfs_page *req,
868 nfs_request_add_commit_list(req, list, cinfo); 868 nfs_request_add_commit_list(req, list, cinfo);
869} 869}
870EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit); 870EXPORT_SYMBOL_GPL(pnfs_layout_mark_request_commit);
871
872int
873pnfs_nfs_generic_sync(struct inode *inode, bool datasync)
874{
875 if (datasync)
876 return 0;
877 return pnfs_layoutcommit_inode(inode, true);
878}
879EXPORT_SYMBOL_GPL(pnfs_nfs_generic_sync);
880
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 849ed784d6ac..7f933a39f385 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -1840,17 +1840,16 @@ EXPORT_SYMBOL_GPL(nfs_write_inode);
1840 */ 1840 */
1841int nfs_wb_all(struct inode *inode) 1841int nfs_wb_all(struct inode *inode)
1842{ 1842{
1843 struct writeback_control wbc = {
1844 .sync_mode = WB_SYNC_ALL,
1845 .nr_to_write = LONG_MAX,
1846 .range_start = 0,
1847 .range_end = LLONG_MAX,
1848 };
1849 int ret; 1843 int ret;
1850 1844
1851 trace_nfs_writeback_inode_enter(inode); 1845 trace_nfs_writeback_inode_enter(inode);
1852 1846
1853 ret = sync_inode(inode, &wbc); 1847 ret = filemap_write_and_wait(inode->i_mapping);
1848 if (!ret) {
1849 ret = nfs_commit_inode(inode, FLUSH_SYNC);
1850 if (!ret)
1851 pnfs_sync_inode(inode, true);
1852 }
1854 1853
1855 trace_nfs_writeback_inode_exit(inode, ret); 1854 trace_nfs_writeback_inode_exit(inode, ret);
1856 return ret; 1855 return ret;