mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-17 05:45:20 +00:00
lockd: prepare nlm_lockowner for use by the server
The nlm_lockowner structure that the client uses to track locks is generally useful to the server as well. Very similar functions to handle allocation and tracking of the nlm_lockowner will follow. Rename the client functions for clarity. Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
22a46eb440
commit
9de3ec1d57
@ -47,13 +47,14 @@ void nlmclnt_next_cookie(struct nlm_cookie *c)
|
|||||||
c->len=4;
|
c->len=4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nlm_lockowner *nlm_get_lockowner(struct nlm_lockowner *lockowner)
|
static struct nlm_lockowner *
|
||||||
|
nlmclnt_get_lockowner(struct nlm_lockowner *lockowner)
|
||||||
{
|
{
|
||||||
refcount_inc(&lockowner->count);
|
refcount_inc(&lockowner->count);
|
||||||
return lockowner;
|
return lockowner;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nlm_put_lockowner(struct nlm_lockowner *lockowner)
|
void nlmclnt_put_lockowner(struct nlm_lockowner *lockowner)
|
||||||
{
|
{
|
||||||
if (!refcount_dec_and_lock(&lockowner->count, &lockowner->host->h_lock))
|
if (!refcount_dec_and_lock(&lockowner->count, &lockowner->host->h_lock))
|
||||||
return;
|
return;
|
||||||
@ -82,28 +83,28 @@ static inline uint32_t __nlm_alloc_pid(struct nlm_host *host)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nlm_lockowner *__nlm_find_lockowner(struct nlm_host *host, fl_owner_t owner)
|
static struct nlm_lockowner *__nlmclnt_find_lockowner(struct nlm_host *host, fl_owner_t owner)
|
||||||
{
|
{
|
||||||
struct nlm_lockowner *lockowner;
|
struct nlm_lockowner *lockowner;
|
||||||
list_for_each_entry(lockowner, &host->h_lockowners, list) {
|
list_for_each_entry(lockowner, &host->h_lockowners, list) {
|
||||||
if (lockowner->owner != owner)
|
if (lockowner->owner != owner)
|
||||||
continue;
|
continue;
|
||||||
return nlm_get_lockowner(lockowner);
|
return nlmclnt_get_lockowner(lockowner);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct nlm_lockowner *nlm_find_lockowner(struct nlm_host *host, fl_owner_t owner)
|
static struct nlm_lockowner *nlmclnt_find_lockowner(struct nlm_host *host, fl_owner_t owner)
|
||||||
{
|
{
|
||||||
struct nlm_lockowner *res, *new = NULL;
|
struct nlm_lockowner *res, *new = NULL;
|
||||||
|
|
||||||
spin_lock(&host->h_lock);
|
spin_lock(&host->h_lock);
|
||||||
res = __nlm_find_lockowner(host, owner);
|
res = __nlmclnt_find_lockowner(host, owner);
|
||||||
if (res == NULL) {
|
if (res == NULL) {
|
||||||
spin_unlock(&host->h_lock);
|
spin_unlock(&host->h_lock);
|
||||||
new = kmalloc(sizeof(*new), GFP_KERNEL);
|
new = kmalloc(sizeof(*new), GFP_KERNEL);
|
||||||
spin_lock(&host->h_lock);
|
spin_lock(&host->h_lock);
|
||||||
res = __nlm_find_lockowner(host, owner);
|
res = __nlmclnt_find_lockowner(host, owner);
|
||||||
if (res == NULL && new != NULL) {
|
if (res == NULL && new != NULL) {
|
||||||
res = new;
|
res = new;
|
||||||
refcount_set(&new->count, 1);
|
refcount_set(&new->count, 1);
|
||||||
@ -457,7 +458,7 @@ static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl)
|
|||||||
{
|
{
|
||||||
spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
||||||
new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state;
|
new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state;
|
||||||
new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner);
|
new->fl_u.nfs_fl.owner = nlmclnt_get_lockowner(fl->fl_u.nfs_fl.owner);
|
||||||
list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted);
|
list_add_tail(&new->fl_u.nfs_fl.list, &fl->fl_u.nfs_fl.owner->host->h_granted);
|
||||||
spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
||||||
}
|
}
|
||||||
@ -467,7 +468,7 @@ static void nlmclnt_locks_release_private(struct file_lock *fl)
|
|||||||
spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
||||||
list_del(&fl->fl_u.nfs_fl.list);
|
list_del(&fl->fl_u.nfs_fl.list);
|
||||||
spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
spin_unlock(&fl->fl_u.nfs_fl.owner->host->h_lock);
|
||||||
nlm_put_lockowner(fl->fl_u.nfs_fl.owner);
|
nlmclnt_put_lockowner(fl->fl_u.nfs_fl.owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct file_lock_operations nlmclnt_lock_ops = {
|
static const struct file_lock_operations nlmclnt_lock_ops = {
|
||||||
@ -478,7 +479,7 @@ static const struct file_lock_operations nlmclnt_lock_ops = {
|
|||||||
static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host)
|
static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host)
|
||||||
{
|
{
|
||||||
fl->fl_u.nfs_fl.state = 0;
|
fl->fl_u.nfs_fl.state = 0;
|
||||||
fl->fl_u.nfs_fl.owner = nlm_find_lockowner(host, fl->fl_owner);
|
fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host, fl->fl_owner);
|
||||||
INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list);
|
INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list);
|
||||||
fl->fl_ops = &nlmclnt_lock_ops;
|
fl->fl_ops = &nlmclnt_lock_ops;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user