mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
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: 44ea8dfce0
("NFS/pnfs: Reference the layout cred in pnfs_prepare_layoutreturn()")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
parent
08bd8dbe88
commit
1bcf34fdac
@ -324,6 +324,21 @@ pnfs_grab_inode_layout_hdr(struct pnfs_layout_hdr *lo)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Compare 2 layout stateid sequence ids, to see which is newer,
|
||||||
|
* taking into account wraparound issues.
|
||||||
|
*/
|
||||||
|
static bool pnfs_seqid_is_newer(u32 s1, u32 s2)
|
||||||
|
{
|
||||||
|
return (s32)(s1 - s2) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pnfs_barrier_update(struct pnfs_layout_hdr *lo, u32 newseq)
|
||||||
|
{
|
||||||
|
if (pnfs_seqid_is_newer(newseq, lo->plh_barrier))
|
||||||
|
lo->plh_barrier = newseq;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode,
|
pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode,
|
||||||
u32 seq)
|
u32 seq)
|
||||||
@ -335,6 +350,7 @@ pnfs_set_plh_return_info(struct pnfs_layout_hdr *lo, enum pnfs_iomode iomode,
|
|||||||
if (seq != 0) {
|
if (seq != 0) {
|
||||||
WARN_ON_ONCE(lo->plh_return_seq != 0 && lo->plh_return_seq != seq);
|
WARN_ON_ONCE(lo->plh_return_seq != 0 && lo->plh_return_seq != seq);
|
||||||
lo->plh_return_seq = seq;
|
lo->plh_return_seq = seq;
|
||||||
|
pnfs_barrier_update(lo, seq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -639,15 +655,6 @@ static int mark_lseg_invalid(struct pnfs_layout_segment *lseg,
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Compare 2 layout stateid sequence ids, to see which is newer,
|
|
||||||
* taking into account wraparound issues.
|
|
||||||
*/
|
|
||||||
static bool pnfs_seqid_is_newer(u32 s1, u32 s2)
|
|
||||||
{
|
|
||||||
return (s32)(s1 - s2) > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
pnfs_should_free_range(const struct pnfs_layout_range *lseg_range,
|
pnfs_should_free_range(const struct pnfs_layout_range *lseg_range,
|
||||||
const struct pnfs_layout_range *recall_range)
|
const struct pnfs_layout_range *recall_range)
|
||||||
@ -984,8 +991,7 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new,
|
|||||||
new_barrier = be32_to_cpu(new->seqid);
|
new_barrier = be32_to_cpu(new->seqid);
|
||||||
else if (new_barrier == 0)
|
else if (new_barrier == 0)
|
||||||
return;
|
return;
|
||||||
if (pnfs_seqid_is_newer(new_barrier, lo->plh_barrier))
|
pnfs_barrier_update(lo, new_barrier);
|
||||||
lo->plh_barrier = new_barrier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -1183,20 +1189,17 @@ pnfs_prepare_layoutreturn(struct pnfs_layout_hdr *lo,
|
|||||||
return false;
|
return false;
|
||||||
set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
|
set_bit(NFS_LAYOUT_RETURN, &lo->plh_flags);
|
||||||
pnfs_get_layout_hdr(lo);
|
pnfs_get_layout_hdr(lo);
|
||||||
|
nfs4_stateid_copy(stateid, &lo->plh_stateid);
|
||||||
|
*cred = get_cred(lo->plh_lc_cred);
|
||||||
if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) {
|
if (test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) {
|
||||||
nfs4_stateid_copy(stateid, &lo->plh_stateid);
|
|
||||||
*cred = get_cred(lo->plh_lc_cred);
|
|
||||||
if (lo->plh_return_seq != 0)
|
if (lo->plh_return_seq != 0)
|
||||||
stateid->seqid = cpu_to_be32(lo->plh_return_seq);
|
stateid->seqid = cpu_to_be32(lo->plh_return_seq);
|
||||||
if (iomode != NULL)
|
if (iomode != NULL)
|
||||||
*iomode = lo->plh_return_iomode;
|
*iomode = lo->plh_return_iomode;
|
||||||
pnfs_clear_layoutreturn_info(lo);
|
pnfs_clear_layoutreturn_info(lo);
|
||||||
return true;
|
} else if (iomode != NULL)
|
||||||
}
|
|
||||||
nfs4_stateid_copy(stateid, &lo->plh_stateid);
|
|
||||||
*cred = get_cred(lo->plh_lc_cred);
|
|
||||||
if (iomode != NULL)
|
|
||||||
*iomode = IOMODE_ANY;
|
*iomode = IOMODE_ANY;
|
||||||
|
pnfs_barrier_update(lo, be32_to_cpu(stateid->seqid));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user