提交 d682e750 编写于 作者: J Jeff Layton 提交者: J. Bruce Fields

nfsd: serialize nfsdcltrack upcalls for a particular client

In a later patch, we want to add a flag that will allow us to reduce the
need for upcalls. In order to handle that correctly, we'll need to
ensure that racing upcalls for the same client can't occur. In practice
it should be rare for this to occur with a well-behaved client, but it
is possible.

Convert one of the bits in the cl_flags field to be an upcall bitlock,
and use it to ensure that upcalls for the same client are serialized.
Signed-off-by: NJeff Layton <jlayton@primarydata.com>
上级 d4318acd
...@@ -1264,6 +1264,22 @@ nfsd4_umh_cltrack_init(struct net *net) ...@@ -1264,6 +1264,22 @@ nfsd4_umh_cltrack_init(struct net *net)
return ret; return ret;
} }
static void
nfsd4_cltrack_upcall_lock(struct nfs4_client *clp)
{
wait_on_bit_lock(&clp->cl_flags, NFSD4_CLIENT_UPCALL_LOCK,
TASK_UNINTERRUPTIBLE);
}
static void
nfsd4_cltrack_upcall_unlock(struct nfs4_client *clp)
{
smp_mb__before_atomic();
clear_bit(NFSD4_CLIENT_UPCALL_LOCK, &clp->cl_flags);
smp_mb__after_atomic();
wake_up_bit(&clp->cl_flags, NFSD4_CLIENT_UPCALL_LOCK);
}
static void static void
nfsd4_umh_cltrack_create(struct nfs4_client *clp) nfsd4_umh_cltrack_create(struct nfs4_client *clp)
{ {
...@@ -1275,9 +1291,14 @@ nfsd4_umh_cltrack_create(struct nfs4_client *clp) ...@@ -1275,9 +1291,14 @@ nfsd4_umh_cltrack_create(struct nfs4_client *clp)
dprintk("%s: can't allocate memory for upcall!\n", __func__); dprintk("%s: can't allocate memory for upcall!\n", __func__);
return; return;
} }
has_session = nfsd4_cltrack_client_has_session(clp); has_session = nfsd4_cltrack_client_has_session(clp);
grace_start = nfsd4_cltrack_grace_start(nn->boot_time); grace_start = nfsd4_cltrack_grace_start(nn->boot_time);
nfsd4_cltrack_upcall_lock(clp);
nfsd4_umh_cltrack_upcall("create", hexid, has_session, grace_start); nfsd4_umh_cltrack_upcall("create", hexid, has_session, grace_start);
nfsd4_cltrack_upcall_unlock(clp);
kfree(has_session); kfree(has_session);
kfree(grace_start); kfree(grace_start);
kfree(hexid); kfree(hexid);
...@@ -1293,7 +1314,11 @@ nfsd4_umh_cltrack_remove(struct nfs4_client *clp) ...@@ -1293,7 +1314,11 @@ nfsd4_umh_cltrack_remove(struct nfs4_client *clp)
dprintk("%s: can't allocate memory for upcall!\n", __func__); dprintk("%s: can't allocate memory for upcall!\n", __func__);
return; return;
} }
nfsd4_cltrack_upcall_lock(clp);
nfsd4_umh_cltrack_upcall("remove", hexid, NULL, NULL); nfsd4_umh_cltrack_upcall("remove", hexid, NULL, NULL);
nfsd4_cltrack_upcall_unlock(clp);
kfree(hexid); kfree(hexid);
} }
...@@ -1311,7 +1336,11 @@ nfsd4_umh_cltrack_check(struct nfs4_client *clp) ...@@ -1311,7 +1336,11 @@ nfsd4_umh_cltrack_check(struct nfs4_client *clp)
has_session = nfsd4_cltrack_client_has_session(clp); has_session = nfsd4_cltrack_client_has_session(clp);
legacy = nfsd4_cltrack_legacy_recdir(&clp->cl_name); legacy = nfsd4_cltrack_legacy_recdir(&clp->cl_name);
nfsd4_cltrack_upcall_lock(clp);
ret = nfsd4_umh_cltrack_upcall("check", hexid, has_session, legacy); ret = nfsd4_umh_cltrack_upcall("check", hexid, has_session, legacy);
nfsd4_cltrack_upcall_unlock(clp);
kfree(has_session); kfree(has_session);
kfree(legacy); kfree(legacy);
kfree(hexid); kfree(hexid);
......
...@@ -306,6 +306,7 @@ struct nfs4_client { ...@@ -306,6 +306,7 @@ struct nfs4_client {
#define NFSD4_CLIENT_STABLE (2) /* client on stable storage */ #define NFSD4_CLIENT_STABLE (2) /* client on stable storage */
#define NFSD4_CLIENT_RECLAIM_COMPLETE (3) /* reclaim_complete done */ #define NFSD4_CLIENT_RECLAIM_COMPLETE (3) /* reclaim_complete done */
#define NFSD4_CLIENT_CONFIRMED (4) /* client is confirmed */ #define NFSD4_CLIENT_CONFIRMED (4) /* client is confirmed */
#define NFSD4_CLIENT_UPCALL_LOCK (5) /* upcall serialization */
#define NFSD4_CLIENT_CB_FLAG_MASK (1 << NFSD4_CLIENT_CB_UPDATE | \ #define NFSD4_CLIENT_CB_FLAG_MASK (1 << NFSD4_CLIENT_CB_UPDATE | \
1 << NFSD4_CLIENT_CB_KILL) 1 << NFSD4_CLIENT_CB_KILL)
unsigned long cl_flags; unsigned long cl_flags;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册