Skip to content

Commit 9222b95

Browse files
Stanislav KinsburskyTrond Myklebust
authored andcommitted
NFS: split cache creation and PipeFS registration
This precursor patch splits NFS cache creation and PipeFS registartion. It's required for latter split of NFS DNS resolver cache creation per network namespace context and PipeFS registration/unregistration on MOUNT/UMOUNT events. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent 820f944 commit 9222b95

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

‎fs/nfs/cache_lib.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ int nfs_cache_register(struct cache_detail *cd)
120120
mnt = rpc_get_mount();
121121
if (IS_ERR(mnt))
122122
return PTR_ERR(mnt);
123-
sunrpc_init_cache_detail(cd);
124123
ret = vfs_path_lookup(mnt->mnt_root, mnt, "/cache", 0, &path);
125124
if (ret)
126125
goto err;
@@ -129,7 +128,6 @@ int nfs_cache_register(struct cache_detail *cd)
129128
if (!ret)
130129
return ret;
131130
err:
132-
sunrpc_destroy_cache_detail(cd);
133131
rpc_put_mount();
134132
return ret;
135133
}
@@ -141,3 +139,12 @@ void nfs_cache_unregister(struct cache_detail *cd)
141139
rpc_put_mount();
142140
}
143141

142+
void nfs_cache_init(struct cache_detail *cd)
143+
{
144+
sunrpc_init_cache_detail(cd);
145+
}
146+
147+
void nfs_cache_destroy(struct cache_detail *cd)
148+
{
149+
sunrpc_destroy_cache_detail(cd);
150+
}

‎fs/nfs/cache_lib.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,7 @@ extern struct nfs_cache_defer_req *nfs_cache_defer_req_alloc(void);
2323
extern void nfs_cache_defer_req_put(struct nfs_cache_defer_req *dreq);
2424
extern int nfs_cache_wait_for_upcall(struct nfs_cache_defer_req *dreq);
2525

26+
extern void nfs_cache_init(struct cache_detail *cd);
27+
extern void nfs_cache_destroy(struct cache_detail *cd);
2628
extern int nfs_cache_register(struct cache_detail *cd);
2729
extern void nfs_cache_unregister(struct cache_detail *cd);

‎fs/nfs/dns_resolve.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,21 @@ ssize_t nfs_dns_resolve_name(char *name, size_t namelen,
361361

362362
int nfs_dns_resolver_init(void)
363363
{
364-
return nfs_cache_register(&nfs_dns_resolve);
364+
int err;
365+
366+
nfs_cache_init(&nfs_dns_resolve);
367+
err = nfs_cache_register(&nfs_dns_resolve);
368+
if (err) {
369+
nfs_cache_destroy(&nfs_dns_resolve);
370+
return err;
371+
}
372+
return 0;
365373
}
366374

367375
void nfs_dns_resolver_destroy(void)
368376
{
369377
nfs_cache_unregister(&nfs_dns_resolve);
378+
nfs_cache_destroy(&nfs_dns_resolve);
370379
}
371380

372381
#endif

0 commit comments

Comments
 (0)