Skip to content

Commit 76d4cb6

Browse files
Mike SnitzerAnna Schumaker
authored andcommitted
nfs: probe for LOCALIO when v4 client reconnects to server
Introduce nfs_local_probe_async() for the NFS client to initiate if/when it reconnects with server. For NFSv4 it is a simple matter to call nfs_local_probe_async() from nfs4_do_reclaim (during NFSv4 grace). Signed-off-by: Mike Snitzer <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 779a395 commit 76d4cb6

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

fs/nfs/client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_init)
186186
seqlock_init(&clp->cl_boot_lock);
187187
ktime_get_real_ts64(&clp->cl_nfssvc_boot);
188188
nfs_uuid_init(&clp->cl_uuid);
189+
INIT_WORK(&clp->cl_local_probe_work, nfs_local_probe_async_work);
189190
#endif /* CONFIG_NFS_LOCALIO */
190191

191192
clp->cl_principal = "*";

fs/nfs/internal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode);
456456
#if IS_ENABLED(CONFIG_NFS_LOCALIO)
457457
/* localio.c */
458458
extern void nfs_local_probe(struct nfs_client *);
459+
extern void nfs_local_probe_async(struct nfs_client *);
460+
extern void nfs_local_probe_async_work(struct work_struct *);
459461
extern struct nfsd_file *nfs_local_open_fh(struct nfs_client *,
460462
const struct cred *,
461463
struct nfs_fh *,
@@ -472,6 +474,7 @@ extern bool nfs_server_is_local(const struct nfs_client *clp);
472474

473475
#else /* CONFIG_NFS_LOCALIO */
474476
static inline void nfs_local_probe(struct nfs_client *clp) {}
477+
static inline void nfs_local_probe_async(struct nfs_client *clp) {}
475478
static inline struct nfsd_file *
476479
nfs_local_open_fh(struct nfs_client *clp, const struct cred *cred,
477480
struct nfs_fh *fh, struct nfs_file_localio *nfl,

fs/nfs/localio.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,20 @@ void nfs_local_probe(struct nfs_client *clp)
193193
}
194194
EXPORT_SYMBOL_GPL(nfs_local_probe);
195195

196+
void nfs_local_probe_async_work(struct work_struct *work)
197+
{
198+
struct nfs_client *clp =
199+
container_of(work, struct nfs_client, cl_local_probe_work);
200+
201+
nfs_local_probe(clp);
202+
}
203+
204+
void nfs_local_probe_async(struct nfs_client *clp)
205+
{
206+
queue_work(nfsiod_workqueue, &clp->cl_local_probe_work);
207+
}
208+
EXPORT_SYMBOL_GPL(nfs_local_probe_async);
209+
196210
static inline struct nfsd_file *nfs_local_file_get(struct nfsd_file *nf)
197211
{
198212
return nfs_to->nfsd_file_get(nf);

fs/nfs/nfs4state.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,7 @@ static int nfs4_do_reclaim(struct nfs_client *clp, const struct nfs4_state_recov
19551955
}
19561956
rcu_read_unlock();
19571957
nfs4_free_state_owners(&freeme);
1958+
nfs_local_probe_async(clp);
19581959
if (lost_locks)
19591960
pr_warn("NFS: %s: lost %d locks\n",
19601961
clp->cl_hostname, lost_locks);

include/linux/nfs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct nfs_client {
131131
struct timespec64 cl_nfssvc_boot;
132132
seqlock_t cl_boot_lock;
133133
nfs_uuid_t cl_uuid;
134+
struct work_struct cl_local_probe_work;
134135
#endif /* CONFIG_NFS_LOCALIO */
135136
};
136137

0 commit comments

Comments
 (0)