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: Fix setting of layoutcommit last write byte

If the NFS_INO_LAYOUTCOMMIT flag was unset, then we _must_ ensure that
we also reset the last write byte (lwb) for that layout. The current
code depends on us clearing the lwb when we clear NFS_INO_LAYOUTCOMMIT,
which is not the case when we call pnfs_clear_layoutcommit().

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>

+8 -9
+8 -9
fs/nfs/pnfs.c
··· 2108 2108 2109 2109 spin_lock(&inode->i_lock); 2110 2110 if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { 2111 + nfsi->layout->plh_lwb = end_pos; 2111 2112 mark_as_dirty = true; 2112 2113 dprintk("%s: Set layoutcommit for inode %lu ", 2113 2114 __func__, inode->i_ino); 2114 - } 2115 + } else if (end_pos > nfsi->layout->plh_lwb) 2116 + nfsi->layout->plh_lwb = end_pos; 2115 2117 if (!test_and_set_bit(NFS_LSEG_LAYOUTCOMMIT, &hdr->lseg->pls_flags)) { 2116 2118 /* references matched in nfs4_layoutcommit_release */ 2117 2119 pnfs_get_lseg(hdr->lseg); 2118 2120 } 2119 - if (end_pos > nfsi->layout->plh_lwb) 2120 - nfsi->layout->plh_lwb = end_pos; 2121 2121 spin_unlock(&inode->i_lock); 2122 2122 dprintk("%s: lseg %p end_pos %llu\n", 2123 2123 __func__, hdr->lseg, nfsi->layout->plh_lwb); ··· 2137 2137 2138 2138 spin_lock(&inode->i_lock); 2139 2139 if (!test_and_set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags)) { 2140 + nfsi->layout->plh_lwb = data->lwb; 2140 2141 mark_as_dirty = true; 2141 2142 dprintk("%s: Set layoutcommit for inode %lu ", 2142 2143 __func__, inode->i_ino); 2143 - } 2144 + } else if (data->lwb > nfsi->layout->plh_lwb) 2145 + nfsi->layout->plh_lwb = data->lwb; 2144 2146 if (!test_and_set_bit(NFS_LSEG_LAYOUTCOMMIT, &data->lseg->pls_flags)) { 2145 2147 /* references matched in nfs4_layoutcommit_release */ 2146 2148 pnfs_get_lseg(data->lseg); 2147 2149 } 2148 - if (data->lwb > nfsi->layout->plh_lwb) 2149 - nfsi->layout->plh_lwb = data->lwb; 2150 2150 spin_unlock(&inode->i_lock); 2151 2151 dprintk("%s: lseg %p end_pos %llu\n", 2152 2152 __func__, data->lseg, nfsi->layout->plh_lwb); ··· 2216 2216 pnfs_list_write_lseg(inode, &data->lseg_list); 2217 2217 2218 2218 end_pos = nfsi->layout->plh_lwb; 2219 - nfsi->layout->plh_lwb = 0; 2220 2219 2221 2220 nfs4_stateid_copy(&data->args.stateid, &nfsi->layout->plh_stateid); 2222 2221 spin_unlock(&inode->i_lock); ··· 2232 2233 status = ld->prepare_layoutcommit(&data->args); 2233 2234 if (status) { 2234 2235 spin_lock(&inode->i_lock); 2235 - if (end_pos < nfsi->layout->plh_lwb) 2236 + set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags); 2237 + if (end_pos > nfsi->layout->plh_lwb) 2236 2238 nfsi->layout->plh_lwb = end_pos; 2237 2239 spin_unlock(&inode->i_lock); 2238 2240 put_rpccred(data->cred); 2239 - set_bit(NFS_INO_LAYOUTCOMMIT, &nfsi->flags); 2240 2241 goto clear_layoutcommitting; 2241 2242 } 2242 2243 }