mirror of
https://github.com/torvalds/linux.git
synced 2024-11-11 14:42:24 +00:00
nfsd: make NFSv4 recovery client tracking options per net
Pointer to client tracking operations - client_tracking_ops - have to be containerized, because different environment can support different trackers (for example, legacy tracker currently is not suported in container). Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
9b2ef62b15
commit
9a9c6478a8
@ -35,6 +35,7 @@
|
|||||||
#define SESSION_HASH_SIZE 512
|
#define SESSION_HASH_SIZE 512
|
||||||
|
|
||||||
struct cld_net;
|
struct cld_net;
|
||||||
|
struct nfsd4_client_tracking_ops;
|
||||||
|
|
||||||
struct nfsd_net {
|
struct nfsd_net {
|
||||||
struct cld_net *cld_net;
|
struct cld_net *cld_net;
|
||||||
@ -87,6 +88,7 @@ struct nfsd_net {
|
|||||||
|
|
||||||
struct file *rec_file;
|
struct file *rec_file;
|
||||||
bool in_grace;
|
bool in_grace;
|
||||||
|
struct nfsd4_client_tracking_ops *client_tracking_ops;
|
||||||
|
|
||||||
time_t nfsd4_lease;
|
time_t nfsd4_lease;
|
||||||
time_t nfsd4_grace;
|
time_t nfsd4_grace;
|
||||||
|
@ -63,7 +63,6 @@ struct nfsd4_client_tracking_ops {
|
|||||||
|
|
||||||
/* Globals */
|
/* Globals */
|
||||||
static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery";
|
static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery";
|
||||||
static struct nfsd4_client_tracking_ops *client_tracking_ops;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nfs4_save_creds(const struct cred **original_creds)
|
nfs4_save_creds(const struct cred **original_creds)
|
||||||
@ -1262,17 +1261,18 @@ nfsd4_client_tracking_init(struct net *net)
|
|||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
struct path path;
|
struct path path;
|
||||||
|
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
|
||||||
|
|
||||||
/* just run the init if it the method is already decided */
|
/* just run the init if it the method is already decided */
|
||||||
if (client_tracking_ops)
|
if (nn->client_tracking_ops)
|
||||||
goto do_init;
|
goto do_init;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First, try a UMH upcall. It should succeed or fail quickly, so
|
* First, try a UMH upcall. It should succeed or fail quickly, so
|
||||||
* there's little harm in trying that first.
|
* there's little harm in trying that first.
|
||||||
*/
|
*/
|
||||||
client_tracking_ops = &nfsd4_umh_tracking_ops;
|
nn->client_tracking_ops = &nfsd4_umh_tracking_ops;
|
||||||
status = client_tracking_ops->init(net);
|
status = nn->client_tracking_ops->init(net);
|
||||||
if (!status)
|
if (!status)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@ -1280,7 +1280,7 @@ nfsd4_client_tracking_init(struct net *net)
|
|||||||
* See if the recoverydir exists and is a directory. If it is,
|
* See if the recoverydir exists and is a directory. If it is,
|
||||||
* then use the legacy ops.
|
* then use the legacy ops.
|
||||||
*/
|
*/
|
||||||
client_tracking_ops = &nfsd4_legacy_tracking_ops;
|
nn->client_tracking_ops = &nfsd4_legacy_tracking_ops;
|
||||||
status = kern_path(nfs4_recoverydir(), LOOKUP_FOLLOW, &path);
|
status = kern_path(nfs4_recoverydir(), LOOKUP_FOLLOW, &path);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
status = S_ISDIR(path.dentry->d_inode->i_mode);
|
status = S_ISDIR(path.dentry->d_inode->i_mode);
|
||||||
@ -1290,16 +1290,16 @@ nfsd4_client_tracking_init(struct net *net)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, try to use nfsdcld */
|
/* Finally, try to use nfsdcld */
|
||||||
client_tracking_ops = &nfsd4_cld_tracking_ops;
|
nn->client_tracking_ops = &nfsd4_cld_tracking_ops;
|
||||||
printk(KERN_WARNING "NFSD: the nfsdcld client tracking upcall will be "
|
printk(KERN_WARNING "NFSD: the nfsdcld client tracking upcall will be "
|
||||||
"removed in 3.10. Please transition to using "
|
"removed in 3.10. Please transition to using "
|
||||||
"nfsdcltrack.\n");
|
"nfsdcltrack.\n");
|
||||||
do_init:
|
do_init:
|
||||||
status = client_tracking_ops->init(net);
|
status = nn->client_tracking_ops->init(net);
|
||||||
if (status) {
|
if (status) {
|
||||||
printk(KERN_WARNING "NFSD: Unable to initialize client "
|
printk(KERN_WARNING "NFSD: Unable to initialize client "
|
||||||
"recovery tracking! (%d)\n", status);
|
"recovery tracking! (%d)\n", status);
|
||||||
client_tracking_ops = NULL;
|
nn->client_tracking_ops = NULL;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -1307,32 +1307,40 @@ do_init:
|
|||||||
void
|
void
|
||||||
nfsd4_client_tracking_exit(struct net *net)
|
nfsd4_client_tracking_exit(struct net *net)
|
||||||
{
|
{
|
||||||
if (client_tracking_ops) {
|
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
|
||||||
if (client_tracking_ops->exit)
|
|
||||||
client_tracking_ops->exit(net);
|
if (nn->client_tracking_ops) {
|
||||||
client_tracking_ops = NULL;
|
if (nn->client_tracking_ops->exit)
|
||||||
|
nn->client_tracking_ops->exit(net);
|
||||||
|
nn->client_tracking_ops = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nfsd4_client_record_create(struct nfs4_client *clp)
|
nfsd4_client_record_create(struct nfs4_client *clp)
|
||||||
{
|
{
|
||||||
if (client_tracking_ops)
|
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
|
||||||
client_tracking_ops->create(clp);
|
|
||||||
|
if (nn->client_tracking_ops)
|
||||||
|
nn->client_tracking_ops->create(clp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nfsd4_client_record_remove(struct nfs4_client *clp)
|
nfsd4_client_record_remove(struct nfs4_client *clp)
|
||||||
{
|
{
|
||||||
if (client_tracking_ops)
|
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
|
||||||
client_tracking_ops->remove(clp);
|
|
||||||
|
if (nn->client_tracking_ops)
|
||||||
|
nn->client_tracking_ops->remove(clp);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
nfsd4_client_record_check(struct nfs4_client *clp)
|
nfsd4_client_record_check(struct nfs4_client *clp)
|
||||||
{
|
{
|
||||||
if (client_tracking_ops)
|
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
|
||||||
return client_tracking_ops->check(clp);
|
|
||||||
|
if (nn->client_tracking_ops)
|
||||||
|
return nn->client_tracking_ops->check(clp);
|
||||||
|
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
}
|
}
|
||||||
@ -1340,8 +1348,8 @@ nfsd4_client_record_check(struct nfs4_client *clp)
|
|||||||
void
|
void
|
||||||
nfsd4_record_grace_done(struct nfsd_net *nn, time_t boot_time)
|
nfsd4_record_grace_done(struct nfsd_net *nn, time_t boot_time)
|
||||||
{
|
{
|
||||||
if (client_tracking_ops)
|
if (nn->client_tracking_ops)
|
||||||
client_tracking_ops->grace_done(nn, boot_time);
|
nn->client_tracking_ops->grace_done(nn, boot_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user