Skip to content

Commit 9a9c647

Browse files
Stanislav KinsburskyJ. Bruce Fields
authored andcommitted
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 <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 9b2ef62 commit 9a9c647

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

fs/nfsd/netns.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#define SESSION_HASH_SIZE 512
3636

3737
struct cld_net;
38+
struct nfsd4_client_tracking_ops;
3839

3940
struct nfsd_net {
4041
struct cld_net *cld_net;
@@ -87,6 +88,7 @@ struct nfsd_net {
8788

8889
struct file *rec_file;
8990
bool in_grace;
91+
struct nfsd4_client_tracking_ops *client_tracking_ops;
9092

9193
time_t nfsd4_lease;
9294
time_t nfsd4_grace;

fs/nfsd/nfs4recover.c

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ struct nfsd4_client_tracking_ops {
6363

6464
/* Globals */
6565
static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery";
66-
static struct nfsd4_client_tracking_ops *client_tracking_ops;
6766

6867
static int
6968
nfs4_save_creds(const struct cred **original_creds)
@@ -1262,25 +1261,26 @@ nfsd4_client_tracking_init(struct net *net)
12621261
{
12631262
int status;
12641263
struct path path;
1264+
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
12651265

12661266
/* just run the init if it the method is already decided */
1267-
if (client_tracking_ops)
1267+
if (nn->client_tracking_ops)
12681268
goto do_init;
12691269

12701270
/*
12711271
* First, try a UMH upcall. It should succeed or fail quickly, so
12721272
* there's little harm in trying that first.
12731273
*/
1274-
client_tracking_ops = &nfsd4_umh_tracking_ops;
1275-
status = client_tracking_ops->init(net);
1274+
nn->client_tracking_ops = &nfsd4_umh_tracking_ops;
1275+
status = nn->client_tracking_ops->init(net);
12761276
if (!status)
12771277
return status;
12781278

12791279
/*
12801280
* See if the recoverydir exists and is a directory. If it is,
12811281
* then use the legacy ops.
12821282
*/
1283-
client_tracking_ops = &nfsd4_legacy_tracking_ops;
1283+
nn->client_tracking_ops = &nfsd4_legacy_tracking_ops;
12841284
status = kern_path(nfs4_recoverydir(), LOOKUP_FOLLOW, &path);
12851285
if (!status) {
12861286
status = S_ISDIR(path.dentry->d_inode->i_mode);
@@ -1290,58 +1290,66 @@ nfsd4_client_tracking_init(struct net *net)
12901290
}
12911291

12921292
/* Finally, try to use nfsdcld */
1293-
client_tracking_ops = &nfsd4_cld_tracking_ops;
1293+
nn->client_tracking_ops = &nfsd4_cld_tracking_ops;
12941294
printk(KERN_WARNING "NFSD: the nfsdcld client tracking upcall will be "
12951295
"removed in 3.10. Please transition to using "
12961296
"nfsdcltrack.\n");
12971297
do_init:
1298-
status = client_tracking_ops->init(net);
1298+
status = nn->client_tracking_ops->init(net);
12991299
if (status) {
13001300
printk(KERN_WARNING "NFSD: Unable to initialize client "
13011301
"recovery tracking! (%d)\n", status);
1302-
client_tracking_ops = NULL;
1302+
nn->client_tracking_ops = NULL;
13031303
}
13041304
return status;
13051305
}
13061306

13071307
void
13081308
nfsd4_client_tracking_exit(struct net *net)
13091309
{
1310-
if (client_tracking_ops) {
1311-
if (client_tracking_ops->exit)
1312-
client_tracking_ops->exit(net);
1313-
client_tracking_ops = NULL;
1310+
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
1311+
1312+
if (nn->client_tracking_ops) {
1313+
if (nn->client_tracking_ops->exit)
1314+
nn->client_tracking_ops->exit(net);
1315+
nn->client_tracking_ops = NULL;
13141316
}
13151317
}
13161318

13171319
void
13181320
nfsd4_client_record_create(struct nfs4_client *clp)
13191321
{
1320-
if (client_tracking_ops)
1321-
client_tracking_ops->create(clp);
1322+
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
1323+
1324+
if (nn->client_tracking_ops)
1325+
nn->client_tracking_ops->create(clp);
13221326
}
13231327

13241328
void
13251329
nfsd4_client_record_remove(struct nfs4_client *clp)
13261330
{
1327-
if (client_tracking_ops)
1328-
client_tracking_ops->remove(clp);
1331+
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
1332+
1333+
if (nn->client_tracking_ops)
1334+
nn->client_tracking_ops->remove(clp);
13291335
}
13301336

13311337
int
13321338
nfsd4_client_record_check(struct nfs4_client *clp)
13331339
{
1334-
if (client_tracking_ops)
1335-
return client_tracking_ops->check(clp);
1340+
struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id);
1341+
1342+
if (nn->client_tracking_ops)
1343+
return nn->client_tracking_ops->check(clp);
13361344

13371345
return -EOPNOTSUPP;
13381346
}
13391347

13401348
void
13411349
nfsd4_record_grace_done(struct nfsd_net *nn, time_t boot_time)
13421350
{
1343-
if (client_tracking_ops)
1344-
client_tracking_ops->grace_done(nn, boot_time);
1351+
if (nn->client_tracking_ops)
1352+
nn->client_tracking_ops->grace_done(nn, boot_time);
13451353
}
13461354

13471355
static int

0 commit comments

Comments
 (0)