pNFS/NFSv4: Update the layout barrier when we schedule a layoutreturn

When we're scheduling a layoutreturn, we need to ignore any further
incoming layouts with sequence ids that are going to be affected by the
layout return.

Fixes: 44ea8dfce021 ("NFS/pnfs: Reference the layout cred in pnfs_prepare_layoutreturn()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>

+21 -18
+21 -18
fs/nfs/pnfs.c
··· 324 324 return NULL; 325 325 } 326 326 327 + /* 328 + * Compare 2 layout stateid sequence ids, to see which is newer, 329 + * taking into account wraparound issues. 330 + */ 331 + static bool pnfs_seqid_is_newer(u32 s1, u32 s2) 332 + { 333 + return (s32)(s1 - s2) > 0; 334 + } 335 + 336 + static void pnfs_barrier_update(struct pnfs_layout_hdr *lo, u32 newseq) 337 + { 338 + if (pnfs_seqid_is_newer(newseq, lo->plh_barrier)) 339 + lo->plh_barrier = newseq; 340 + } 341 + 327 342 static void 328 343 pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode, 329 344 u32 seq) ··· 350 335 if (seq != 0) { 351 336 WARN_ON_ONCE(lo->plh_return_seq != 0 && lo->plh_return_seq != seq); 352 337 lo->plh_return_seq = seq; 338 + pnfs_barrier_update(lo, seq); 353 339 } 354 340 } 355 341 ··· 653 637 rv = 1; 654 638 } 655 639 return rv; 656 - } 657 - 658 - /* 659 - * Compare 2 layout stateid sequence ids, to see which is newer, 660 - * taking into account wraparound issues. 661 - */ 662 - static bool pnfs_seqid_is_newer(u32 s1, u32 s2) 663 - { 664 - return (s32)(s1 - s2) > 0; 665 640 } 666 641 667 642 static bool ··· 991 984 new_barrier = be32_to_cpu(new->seqid); 992 985 else if (new_barrier == 0) 993 986 return; 994 - if (pnfs_seqid_is_newer(new_barrier, lo->plh_barrier)) 995 - lo->plh_barrier = new_barrier; 987 + pnfs_barrier_update(lo, new_barrier); 996 988 } 997 989 998 990 static bool ··· 1189 1183 return false; 1190 1184 set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags); 1191 1185 pnfs_get_layout_hdr(lo); 1186 + nfs4_stateid_copy(stateid, &lo->plh_stateid); 1187 + *cred = get_cred(lo->plh_lc_cred); 1192 1188 if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) { 1193 - nfs4_stateid_copy(stateid, &lo->plh_stateid); 1194 - *cred = get_cred(lo->plh_lc_cred); 1195 1189 if (lo->plh_return_seq != 0) 1196 1190 stateid->seqid = cpu_to_be32(lo->plh_return_seq); 1197 1191 if (iomode != NULL) 1198 1192 *iomode = lo->plh_return_iomode; 1199 1193 pnfs_clear_layoutreturn_info(lo); 1200 - return true; 1201 - } 1202 - nfs4_stateid_copy(stateid, &lo->plh_stateid); 1203 - *cred = get_cred(lo->plh_lc_cred); 1204 - if (iomode != NULL) 1194 + } else if (iomode != NULL) 1205 1195 *iomode = IOMODE_ANY; 1196 + pnfs_barrier_update(lo, be32_to_cpu(stateid->seqid)); 1206 1197 return true; 1207 1198 } 1208 1199