Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+14 -42
+3 -2
fs/nfs/filelayout/filelayout.c
··· 258 258 hdr->res.verf->committed != NFS_DATA_SYNC) 259 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 263 dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, 263 264 (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); 264 265 } ··· 374 373 } 375 374 376 375 if (data->verf.committed == NFS_UNSTABLE) 377 - pnfs_commit_set_layoutcommit(data); 376 + pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb); 378 377 379 378 return 0; 380 379 }
+3 -2
fs/nfs/flexfilelayout/flexfilelayout.c
··· 891 891 static void 892 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 896 dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino, 896 897 (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb); 897 898 } ··· 1075 1074 } 1076 1075 1077 1076 if (data->verf.committed == NFS_UNSTABLE) 1078 - pnfs_commit_set_layoutcommit(data); 1077 + pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb); 1079 1078 1080 1079 return 0; 1081 1080 }
+7 -36
fs/nfs/pnfs.c
··· 1841 1841 { 1842 1842 trace_nfs4_pnfs_write(hdr, hdr->pnfs_error); 1843 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 1846 hdr->mds_ops->rpc_call_done(&hdr->task, hdr); 1846 1847 } else 1847 1848 pnfs_ld_handle_write_error(hdr); ··· 2100 2099 EXPORT_SYMBOL_GPL(pnfs_set_lo_fail); 2101 2100 2102 2101 void 2103 - pnfs_set_layoutcommit(struct nfs_pgio_header *hdr) 2102 + pnfs_set_layoutcommit(struct inode *inode, struct pnfs_layout_segment *lseg, 2103 + loff_t end_pos) 2104 2104 { 2105 - struct inode *inode = hdr->inode; 2106 2105 struct nfs_inode *nfsi = NFS_I(inode); 2107 - loff_t end_pos = hdr->mds_offset + hdr->res.count; 2108 2106 bool mark_as_dirty = false; 2109 2107 2110 2108 spin_lock(&inode->i_lock); ··· 2114 2114 __func__, inode->i_ino); 2115 2115 } else if (end_pos > nfsi->layout->plh_lwb) 2116 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 2118 /* references matched in nfs4_layoutcommit_release */ 2119 - pnfs_get_lseg(hdr->lseg); 2119 + pnfs_get_lseg(lseg); 2120 2120 } 2121 2121 spin_unlock(&inode->i_lock); 2122 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 2125 /* if pnfs_layoutcommit_inode() runs between inode locks, the next one 2126 2126 * will be a noop because NFS_INO_LAYOUTCOMMIT will not be set */ ··· 2128 2128 mark_inode_dirty_sync(inode); 2129 2129 } 2130 2130 EXPORT_SYMBOL_GPL(pnfs_set_layoutcommit); 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 2131 2161 2132 void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data) 2162 2133 {
+1 -2
fs/nfs/pnfs.h
··· 264 264 void pnfs_roc_release(struct inode *ino); 265 265 void pnfs_roc_set_barrier(struct inode *ino, u32 barrier); 266 266 bool pnfs_roc_drain(struct inode *ino, u32 *barrier, struct rpc_task *task); 267 - void pnfs_set_layoutcommit(struct nfs_pgio_header *); 268 - void pnfs_commit_set_layoutcommit(struct nfs_commit_data *data); 267 + void pnfs_set_layoutcommit(struct inode *, struct pnfs_layout_segment *, loff_t); 269 268 void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data); 270 269 int pnfs_layoutcommit_inode(struct inode *inode, bool sync); 271 270 int _pnfs_return_layout(struct inode *);