diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-03-25 20:40:38 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@primarydata.com> | 2015-03-27 12:39:36 -0400 |
commit | 67af7611ec57dbcbc96f9d9daa4d3c7b0999aa73 (patch) | |
tree | c6e73a08bf6268767dc7494df5ccbb423288b952 /fs/nfs | |
parent | 29559b11aef072f893cd32280dcec9d7380ca011 (diff) |
NFSv4.1/pnfs: Refactor pnfs_set_layoutcommit()
pnfs_set_layoutcommit() and pnfs_commit_set_layoutcommit() are 100% identical
except for the function arguments. Refactor to eliminate the difference.
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/filelayout/filelayout.c | 5 | ||||
-rw-r--r-- | fs/nfs/flexfilelayout/flexfilelayout.c | 5 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 43 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 3 |
4 files changed, 14 insertions, 42 deletions
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index 5639a2ef671a..a317b007e436 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c | |||
@@ -258,7 +258,8 @@ filelayout_set_layoutcommit(struct nfs_pgio_header *hdr) | |||
258 | hdr->res.verf->committed != NFS_DATA_SYNC) | 258 | hdr->res.verf->committed != NFS_DATA_SYNC) |
259 | return; | 259 | return; |
260 | 260 | ||
261 | pnfs_set_layoutcommit(hdr); | 261 | pnfs_set_layoutcommit(hdr->inode, hdr->lseg, |
262 | hdr->mds_offset + hdr->res.count); | ||
262 | dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, | 263 | dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, |
263 | (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); | 264 | (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); |
264 | } | 265 | } |
@@ -373,7 +374,7 @@ static int filelayout_commit_done_cb(struct rpc_task *task, | |||
373 | } | 374 | } |
374 | 375 | ||
375 | if (data->verf.committed == NFS_UNSTABLE) | 376 | if (data->verf.committed == NFS_UNSTABLE) |
376 | pnfs_commit_set_layoutcommit(data); | 377 | pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb); |
377 | 378 | ||
378 | return 0; | 379 | return 0; |
379 | } | 380 | } |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index edfb27ea4ce2..92d2943e54f8 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
@@ -891,7 +891,8 @@ static int ff_layout_read_done_cb(struct rpc_task *task, | |||
891 | static void | 891 | static void |
892 | ff_layout_set_layoutcommit(struct nfs_pgio_header *hdr) | 892 | ff_layout_set_layoutcommit(struct nfs_pgio_header *hdr) |
893 | { | 893 | { |
894 | pnfs_set_layoutcommit(hdr); | 894 | pnfs_set_layoutcommit(hdr->inode, hdr->lseg, |
895 | hdr->mds_offset + hdr->res.count); | ||
895 | dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, | 896 | dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, |
896 | (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); | 897 | (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); |
897 | } | 898 | } |
@@ -1074,7 +1075,7 @@ static int ff_layout_commit_done_cb(struct rpc_task *task, | |||
1074 | } | 1075 | } |
1075 | 1076 | ||
1076 | if (data->verf.committed == NFS_UNSTABLE) | 1077 | if (data->verf.committed == NFS_UNSTABLE) |
1077 | pnfs_commit_set_layoutcommit(data); | 1078 | pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb); |
1078 | 1079 | ||
1079 | return 0; | 1080 | return 0; |
1080 | } | 1081 | } |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index b96736df98e8..ea83f3c03c65 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -1841,7 +1841,8 @@ void pnfs_ld_write_done(struct nfs_pgio_header *hdr) | |||
1841 | { | 1841 | { |
1842 | trace_nfs4_pnfs_write(hdr, hdr->pnfs_error); | 1842 | trace_nfs4_pnfs_write(hdr, hdr->pnfs_error); |
1843 | if (!hdr->pnfs_error) { | 1843 | if (!hdr->pnfs_error) { |
1844 | pnfs_set_layoutcommit(hdr); | 1844 | pnfs_set_layoutcommit(hdr->inode, hdr->lseg, |
1845 | hdr->mds_offset + hdr->res.count); | ||
1845 | hdr->mds_ops->rpc_call_done(&hdr->task, hdr); | 1846 | hdr->mds_ops->rpc_call_done(&hdr->task, hdr); |
1846 | } else | 1847 | } else |
1847 | pnfs_ld_handle_write_error(hdr); | 1848 | pnfs_ld_handle_write_error(hdr); |
@@ -2099,11 +2100,10 @@ void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg) | |||
2099 | EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); | 2100 | EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); |
2100 | 2101 | ||
2101 | void | 2102 | void |
2102 | pnfs_set_layoutcommit(struct nfs_pgio_header *hdr) | 2103 | pnfs_set_layoutcommit(struct inode *inode, struct pnfs_layout_segment *lseg, |
2104 | loff_t end_pos) | ||
2103 | { | 2105 | { |
2104 | struct inode *inode = hdr->inode; | ||
2105 | struct nfs_inode *nfsi = NFS_I(inode); | 2106 | struct nfs_inode *nfsi = NFS_I(inode); |
2106 | loff_t end_pos = hdr->mds_offset + hdr->res.count; | ||
2107 | bool mark_as_dirty = false; | 2107 | bool mark_as_dirty = false; |
2108 | 2108 | ||
2109 | spin_lock(&inode->i_lock); | 2109 | spin_lock(&inode->i_lock); |
@@ -2114,13 +2114,13 @@ pnfs_set_layoutcommit(struct nfs_pgio_header *hdr) | |||
2114 | __func__, inode->i_ino); | 2114 | __func__, inode->i_ino); |
2115 | } else if (end_pos > nfsi->layout->plh_lwb) | 2115 | } else if (end_pos > nfsi->layout->plh_lwb) |
2116 | nfsi->layout->plh_lwb = end_pos; | 2116 | nfsi->layout->plh_lwb = end_pos; |
2117 | if (!test_and_set_bit(NFS_LSEG_LAYOUTCOMMIT, &hdr->lseg->pls_flags)) { | 2117 | if (!test_and_set_bit(NFS_LSEG_LAYOUTCOMMIT, &lseg->pls_flags)) { |
2118 | /* references matched in nfs4_layoutcommit_release */ | 2118 | /* references matched in nfs4_layoutcommit_release */ |
2119 | pnfs_get_lseg(hdr->lseg); | 2119 | pnfs_get_lseg(lseg); |
2120 | } | 2120 | } |
2121 | spin_unlock(&inode->i_lock); | 2121 | spin_unlock(&inode->i_lock); |
2122 | dprintk("%s: lseg %p end_pos %llu\n", | 2122 | dprintk("%s: lseg %p end_pos %llu\n", |
2123 | __func__, hdr->lseg, nfsi->layout->plh_lwb); | 2123 | __func__, lseg, nfsi->layout->plh_lwb); |
2124 | 2124 | ||
2125 | /* if pnfs_layoutcommit_inode() runs between inode locks, the next one | 2125 | /* if pnfs_layoutcommit_inode() runs between inode locks, the next one |
2126 | * will be a noop because NFS_INO_LAYOUTCOMMIT will not be set */ | 2126 | * will be a noop because NFS_INO_LAYOUTCOMMIT will not be set */ |
@@ -2129,35 +2129,6 @@ pnfs_set_layoutcommit(struct nfs_pgio_header *hdr) | |||
2129 | } | 2129 | } |
2130 | EXPORT_SYMBOL_GPL(pnfs_set_layoutcommit); | 2130 | EXPORT_SYMBOL_GPL(pnfs_set_layoutcommit); |
2131 | 2131 | ||
2132 | void pnfs_commit_set_layoutcommit(struct nfs_commit_data *data) | ||
2133 | { | ||
2134 | struct inode *inode = data->inode; | ||
2135 | struct nfs_inode *nfsi = NFS_I(inode); | ||
2136 | bool mark_as_dirty = false; | ||
2137 | |||
2138 | spin_lock(&inode->i_lock); | ||
2139 | if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { | ||
2140 | nfsi->layout->plh_lwb = data->lwb; | ||
2141 | mark_as_dirty = true; | ||
2142 | dprintk("%s: Set layoutcommit for inode %lu ", | ||
2143 | __func__, inode->i_ino); | ||
2144 | } else if (data->lwb > nfsi->layout->plh_lwb) | ||
2145 | nfsi->layout->plh_lwb = data->lwb; | ||
2146 | if (!test_and_set_bit(NFS_LSEG_LAYOUTCOMMIT, &data->lseg->pls_flags)) { | ||
2147 | /* references matched in nfs4_layoutcommit_release */ | ||
2148 | pnfs_get_lseg(data->lseg); | ||
2149 | } | ||
2150 | spin_unlock(&inode->i_lock); | ||
2151 | dprintk("%s: lseg %p end_pos %llu\n", | ||
2152 | __func__, data->lseg, nfsi->layout->plh_lwb); | ||
2153 | |||
2154 | /* if pnfs_layoutcommit_inode() runs between inode locks, the next one | ||
2155 | * will be a noop because NFS_INO_LAYOUTCOMMIT will not be set */ | ||
2156 | if (mark_as_dirty) | ||
2157 | mark_inode_dirty_sync(inode); | ||
2158 | } | ||
2159 | EXPORT_SYMBOL_GPL(pnfs_commit_set_layoutcommit); | ||
2160 | |||
2161 | void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data) | 2132 | void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data) |
2162 | { | 2133 | { |
2163 | struct nfs_server *nfss = NFS_SERVER(data->args.inode); | 2134 | struct nfs_server *nfss = NFS_SERVER(data->args.inode); |
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index b5654e8da936..66bf5e1cf93d 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -264,8 +264,7 @@ bool pnfs_roc(struct inode *ino); | |||
264 | void pnfs_roc_release(struct inode *ino); | 264 | void pnfs_roc_release(struct inode *ino); |
265 | void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); | 265 | void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); |
266 | bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task); | 266 | bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task); |
267 | void pnfs_set_layoutcommit(struct nfs_pgio_header *); | 267 | void pnfs_set_layoutcommit(struct inode *, struct pnfs_layout_segment *, loff_t); |
268 | void pnfs_commit_set_layoutcommit(struct nfs_commit_data *data); | ||
269 | void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data); | 268 | void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data); |
270 | int pnfs_layoutcommit_inode(struct inode *inode, bool sync); | 269 | int pnfs_layoutcommit_inode(struct inode *inode, bool sync); |
271 | int _pnfs_return_layout(struct inode *); | 270 | int _pnfs_return_layout(struct inode *); |