Skip to content

Commit c829013

Browse files
Peng TaoTom Haynes
authored andcommitted
nfs41: add NFS_LAYOUT_RETRY_LAYOUTGET to layout header flags
Use it to indicate that LD wants to retry layoutget. LD can set it whenever it wants the common pnfs code to return and retry pnfs path through a new layout. The bit gets cleared when client does a new layoutget, when client closes the file (ROC case), or when kernel needs to evict the inode (non-ROC case). Signed-off-by: Peng Tao <tao.peng@primarydata.com>
1 parent 27b6f53 commit c829013

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

fs/nfs/pnfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@ pnfs_destroy_layout(struct nfs_inode *nfsi)
615615
pnfs_get_layout_hdr(lo);
616616
pnfs_layout_clear_fail_bit(lo, NFS_LAYOUT_RO_FAILED);
617617
pnfs_layout_clear_fail_bit(lo, NFS_LAYOUT_RW_FAILED);
618+
pnfs_clear_retry_layoutget(lo);
618619
spin_unlock(&nfsi->vfs_inode.i_lock);
619620
pnfs_free_lseg_list(&tmp_list);
620621
pnfs_put_layout_hdr(lo);
@@ -1066,6 +1067,7 @@ bool pnfs_roc(struct inode *ino)
10661067
if (!lo || !test_and_clear_bit(NFS_LAYOUT_ROC, &lo->plh_flags) ||
10671068
test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags))
10681069
goto out_nolayout;
1070+
pnfs_clear_retry_layoutget(lo);
10691071
list_for_each_entry_safe(lseg, tmp, &lo->plh_segs, pls_list)
10701072
if (test_bit(NFS_LSEG_ROC, &lseg->pls_flags)) {
10711073
mark_lseg_invalid(lseg, &tmp_list);
@@ -1491,6 +1493,7 @@ pnfs_update_layout(struct inode *ino,
14911493
arg.length = PAGE_CACHE_ALIGN(arg.length);
14921494

14931495
lseg = send_layoutget(lo, ctx, &arg, gfp_flags);
1496+
pnfs_clear_retry_layoutget(lo);
14941497
atomic_dec(&lo->plh_outstanding);
14951498
out_put_layout_hdr:
14961499
if (first) {

fs/nfs/pnfs.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ enum {
9999
NFS_LAYOUT_RETURN_BEFORE_CLOSE, /* Return this layout before close */
100100
NFS_LAYOUT_INVALID_STID, /* layout stateid id is invalid */
101101
NFS_LAYOUT_FIRST_LAYOUTGET, /* Serialize first layoutget */
102+
NFS_LAYOUT_RETRY_LAYOUTGET, /* Retry layoutget */
102103
};
103104

104105
enum layoutdriver_policy_flags {
@@ -350,6 +351,23 @@ nfs4_get_deviceid(struct nfs4_deviceid_node *d)
350351
return d;
351352
}
352353

354+
static inline void pnfs_set_retry_layoutget(struct pnfs_layout_hdr *lo)
355+
{
356+
if (!test_and_set_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags))
357+
atomic_inc(&lo->plh_refcount);
358+
}
359+
360+
static inline void pnfs_clear_retry_layoutget(struct pnfs_layout_hdr *lo)
361+
{
362+
if (test_and_clear_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags))
363+
atomic_dec(&lo->plh_refcount);
364+
}
365+
366+
static inline bool pnfs_should_retry_layoutget(struct pnfs_layout_hdr *lo)
367+
{
368+
return test_bit(NFS_LAYOUT_RETRY_LAYOUTGET, &lo->plh_flags);
369+
}
370+
353371
static inline struct pnfs_layout_segment *
354372
pnfs_get_lseg(struct pnfs_layout_segment *lseg)
355373
{

0 commit comments

Comments
 (0)