Commit 2d56d3c4 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'server-cluster-locking-api' of git://linux-nfs.org/~bfields/linux

* 'server-cluster-locking-api' of git://linux-nfs.org/~bfields/linux:
  gfs2: nfs lock support for gfs2
  lockd: add code to handle deferred lock requests
  lockd: always preallocate block in nlmsvc_lock()
  lockd: handle test_lock deferrals
  lockd: pass cookie in nlmsvc_testlock
  lockd: handle fl_grant callbacks
  lockd: save lock state on deferral
  locks: add fl_grant callback for asynchronous lock return
  nfsd4: Convert NFSv4 to new lock interface
  locks: add lock cancel command
  locks: allow {vfs,posix}_lock_file to return conflicting lock
  locks: factor out generic/filesystem switch from setlock code
  locks: factor out generic/filesystem switch from test_lock
  locks: give posix_test_lock same interface as ->lock
  locks: make ->lock release private data before returning in GETLK case
  locks: create posix-to-flock helper functions
  locks: trivial removal of unnecessary parentheses
parents 0f9008ef 586759f0
...@@ -738,8 +738,7 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl) ...@@ -738,8 +738,7 @@ static int fuse_file_lock(struct file *file, int cmd, struct file_lock *fl)
if (cmd == F_GETLK) { if (cmd == F_GETLK) {
if (fc->no_lock) { if (fc->no_lock) {
if (!posix_test_lock(file, fl, fl)) posix_test_lock(file, fl);
fl->fl_type = F_UNLCK;
err = 0; err = 0;
} else } else
err = fuse_getlk(file, fl); err = fuse_getlk(file, fl);
......
...@@ -25,6 +25,15 @@ struct plock_op { ...@@ -25,6 +25,15 @@ struct plock_op {
struct gdlm_plock_info info; struct gdlm_plock_info info;
}; };
struct plock_xop {
struct plock_op xop;
void *callback;
void *fl;
void *file;
struct file_lock flc;
};
static inline void set_version(struct gdlm_plock_info *info) static inline void set_version(struct gdlm_plock_info *info)
{ {
info->version[0] = GDLM_PLOCK_VERSION_MAJOR; info->version[0] = GDLM_PLOCK_VERSION_MAJOR;
...@@ -64,12 +73,14 @@ int gdlm_plock(void *lockspace, struct lm_lockname *name, ...@@ -64,12 +73,14 @@ int gdlm_plock(void *lockspace, struct lm_lockname *name,
{ {
struct gdlm_ls *ls = lockspace; struct gdlm_ls *ls = lockspace;
struct plock_op *op; struct plock_op *op;
struct plock_xop *xop;
int rv; int rv;
op = kzalloc(sizeof(*op), GFP_KERNEL); xop = kzalloc(sizeof(*xop), GFP_KERNEL);
if (!op) if (!xop)
return -ENOMEM; return -ENOMEM;
op = &xop->xop;
op->info.optype = GDLM_PLOCK_OP_LOCK; op->info.optype = GDLM_PLOCK_OP_LOCK;
op->info.pid = fl->fl_pid; op->info.pid = fl->fl_pid;
op->info.ex = (fl->fl_type == F_WRLCK); op->info.ex = (fl->fl_type == F_WRLCK);
...@@ -79,9 +90,21 @@ int gdlm_plock(void *lockspace, struct lm_lockname *name, ...@@ -79,9 +90,21 @@ int gdlm_plock(void *lockspace, struct lm_lockname *name,
op->info.start = fl->fl_start; op->info.start = fl->fl_start;
op->info.end = fl->fl_end; op->info.end = fl->fl_end;
op->info.owner = (__u64)(long) fl->fl_owner; op->info.owner = (__u64)(long) fl->fl_owner;
if (fl->fl_lmops && fl->fl_lmops->fl_grant) {
xop->callback = fl->fl_lmops->fl_grant;
locks_init_lock(&xop->flc);
locks_copy_lock(&xop->flc, fl);
xop->fl = fl;
xop->file = file;
} else
xop->callback = NULL;
send_op(op); send_op(op);
wait_event(recv_wq, (op->done != 0));
if (xop->callback == NULL)
wait_event(recv_wq, (op->done != 0));
else
return -EINPROGRESS;
spin_lock(&ops_lock); spin_lock(&ops_lock);
if (!list_empty(&op->list)) { if (!list_empty(&op->list)) {
...@@ -99,7 +122,63 @@ int gdlm_plock(void *lockspace, struct lm_lockname *name, ...@@ -99,7 +122,63 @@ int gdlm_plock(void *lockspace, struct lm_lockname *name,
(unsigned long long)name->ln_number); (unsigned long long)name->ln_number);
} }
kfree(op); kfree(xop);
return rv;
}
/* Returns failure iff a succesful lock operation should be canceled */
static int gdlm_plock_callback(struct plock_op *op)
{
struct file *file;
struct file_lock *fl;
struct file_lock *flc;
int (*notify)(void *, void *, int) = NULL;
struct plock_xop *xop = (struct plock_xop *)op;
int rv = 0;
spin_lock(&ops_lock);
if (!list_empty(&op->list)) {
printk(KERN_INFO "plock op on list\n");
list_del(&op->list);
}
spin_unlock(&ops_lock);
/* check if the following 2 are still valid or make a copy */
file = xop->file;
flc = &xop->flc;
fl = xop->fl;
notify = xop->callback;
if (op->info.rv) {
notify(flc, NULL, op->info.rv);
goto out;
}
/* got fs lock; bookkeep locally as well: */
flc->fl_flags &= ~FL_SLEEP;
if (posix_lock_file(file, flc, NULL)) {
/*
* This can only happen in the case of kmalloc() failure.
* The filesystem's own lock is the authoritative lock,
* so a failure to get the lock locally is not a disaster.
* As long as GFS cannot reliably cancel locks (especially
* in a low-memory situation), we're better off ignoring
* this failure than trying to recover.
*/
log_error("gdlm_plock: vfs lock error file %p fl %p",
file, fl);
}
rv = notify(flc, NULL, 0);
if (rv) {
/* XXX: We need to cancel the fs lock here: */
printk("gfs2 lock granted after lock request failed;"
" dangling lock!\n");
goto out;
}
out:
kfree(xop);
return rv; return rv;
} }
...@@ -138,6 +217,9 @@ int gdlm_punlock(void *lockspace, struct lm_lockname *name, ...@@ -138,6 +217,9 @@ int gdlm_punlock(void *lockspace, struct lm_lockname *name,
rv = op->info.rv; rv = op->info.rv;
if (rv == -ENOENT)
rv = 0;
kfree(op); kfree(op);
return rv; return rv;
} }
...@@ -161,6 +243,7 @@ int gdlm_plock_get(void *lockspace, struct lm_lockname *name, ...@@ -161,6 +243,7 @@ int gdlm_plock_get(void *lockspace, struct lm_lockname *name,
op->info.start = fl->fl_start; op->info.start = fl->fl_start;
op->info.end = fl->fl_end; op->info.end = fl->fl_end;
send_op(op); send_op(op);
wait_event(recv_wq, (op->done != 0)); wait_event(recv_wq, (op->done != 0));
...@@ -173,9 +256,10 @@ int gdlm_plock_get(void *lockspace, struct lm_lockname *name, ...@@ -173,9 +256,10 @@ int gdlm_plock_get(void *lockspace, struct lm_lockname *name,
rv = op->info.rv; rv = op->info.rv;
if (rv == 0) fl->fl_type = F_UNLCK;
fl->fl_type = F_UNLCK; if (rv == -ENOENT)
else if (rv > 0) { rv = 0;
else if (rv == 0 && op->info.pid != fl->fl_pid) {
fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK; fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK;
fl->fl_pid = op->info.pid; fl->fl_pid = op->info.pid;
fl->fl_start = op->info.start; fl->fl_start = op->info.start;
...@@ -243,9 +327,14 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count, ...@@ -243,9 +327,14 @@ static ssize_t dev_write(struct file *file, const char __user *u, size_t count,
} }
spin_unlock(&ops_lock); spin_unlock(&ops_lock);
if (found) if (found) {
wake_up(&recv_wq); struct plock_xop *xop;
else xop = (struct plock_xop *)op;
if (xop->callback)
count = gdlm_plock_callback(op);
else
wake_up(&recv_wq);
} else
printk(KERN_INFO "gdlm dev_write no op %x %llx\n", info.fsid, printk(KERN_INFO "gdlm dev_write no op %x %llx\n", info.fsid,
(unsigned long long)info.number); (unsigned long long)info.number);
return count; return count;
......
...@@ -164,13 +164,7 @@ static void nolock_unhold_lvb(void *lock, char *lvb) ...@@ -164,13 +164,7 @@ static void nolock_unhold_lvb(void *lock, char *lvb)
static int nolock_plock_get(void *lockspace, struct lm_lockname *name, static int nolock_plock_get(void *lockspace, struct lm_lockname *name,
struct file *file, struct file_lock *fl) struct file *file, struct file_lock *fl)
{ {
struct file_lock tmp; posix_test_lock(file, fl);
int ret;
ret = posix_test_lock(file, fl, &tmp);
fl->fl_type = F_UNLCK;
if (ret)
memcpy(fl, &tmp, sizeof(struct file_lock));
return 0; return 0;
} }
......
...@@ -513,18 +513,18 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) ...@@ -513,18 +513,18 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl)
if (sdp->sd_args.ar_localflocks) { if (sdp->sd_args.ar_localflocks) {
if (IS_GETLK(cmd)) { if (IS_GETLK(cmd)) {
struct file_lock tmp; posix_test_lock(file, fl);
int ret;
ret = posix_test_lock(file, fl, &tmp);
fl->fl_type = F_UNLCK;
if (ret)
memcpy(fl, &tmp, sizeof(struct file_lock));
return 0; return 0;
} else { } else {
return posix_lock_file_wait(file, fl); return posix_lock_file_wait(file, fl);
} }
} }
if (cmd == F_CANCELLK) {
/* Hack: */
cmd = F_SETLK;
fl->fl_type = F_UNLCK;
}
if (IS_GETLK(cmd)) if (IS_GETLK(cmd))
return gfs2_lm_plock_get(sdp, &name, file, fl); return gfs2_lm_plock_get(sdp, &name, file, fl);
else if (fl->fl_type == F_UNLCK) else if (fl->fl_type == F_UNLCK)
......
...@@ -99,7 +99,9 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, ...@@ -99,7 +99,9 @@ nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
/* Now check for conflicting locks */ /* Now check for conflicting locks */
resp->status = nlmsvc_testlock(file, &argp->lock, &resp->lock); resp->status = nlmsvc_testlock(rqstp, file, &argp->lock, &resp->lock, &resp->cookie);
if (resp->status == nlm_drop_reply)
return rpc_drop_reply;
dprintk("lockd: TEST4 status %d\n", ntohl(resp->status)); dprintk("lockd: TEST4 status %d\n", ntohl(resp->status));
nlm_release_host(host); nlm_release_host(host);
...@@ -143,6 +145,8 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, ...@@ -143,6 +145,8 @@ nlm4svc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
/* Now try to lock the file */ /* Now try to lock the file */
resp->status = nlmsvc_lock(rqstp, file, &argp->lock, resp->status = nlmsvc_lock(rqstp, file, &argp->lock,
argp->block, &argp->cookie); argp->block, &argp->cookie);
if (resp->status == nlm_drop_reply)
return rpc_drop_reply;
dprintk("lockd: LOCK status %d\n", ntohl(resp->status)); dprintk("lockd: LOCK status %d\n", ntohl(resp->status));
nlm_release_host(host); nlm_release_host(host);
......
This diff is collapsed.
...@@ -33,6 +33,7 @@ cast_to_nlm(__be32 status, u32 vers) ...@@ -33,6 +33,7 @@ cast_to_nlm(__be32 status, u32 vers)
case nlm_lck_denied_nolocks: case nlm_lck_denied_nolocks:
case nlm_lck_blocked: case nlm_lck_blocked:
case nlm_lck_denied_grace_period: case nlm_lck_denied_grace_period:
case nlm_drop_reply:
break; break;
case nlm4_deadlock: case nlm4_deadlock:
status = nlm_lck_denied; status = nlm_lck_denied;
...@@ -127,7 +128,9 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp, ...@@ -127,7 +128,9 @@ nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_args *argp,
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
/* Now check for conflicting locks */ /* Now check for conflicting locks */
resp->status = cast_status(nlmsvc_testlock(file, &argp->lock, &resp->lock)); resp->status = cast_status(nlmsvc_testlock(rqstp, file, &argp->lock, &resp->lock, &resp->cookie));
if (resp->status == nlm_drop_reply)
return rpc_drop_reply;
dprintk("lockd: TEST status %d vers %d\n", dprintk("lockd: TEST status %d vers %d\n",
ntohl(resp->status), rqstp->rq_vers); ntohl(resp->status), rqstp->rq_vers);
...@@ -172,6 +175,8 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, ...@@ -172,6 +175,8 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp,
/* Now try to lock the file */ /* Now try to lock the file */
resp->status = cast_status(nlmsvc_lock(rqstp, file, &argp->lock, resp->status = cast_status(nlmsvc_lock(rqstp, file, &argp->lock,
argp->block, &argp->cookie)); argp->block, &argp->cookie));
if (resp->status == nlm_drop_reply)
return rpc_drop_reply;
dprintk("lockd: LOCK status %d\n", ntohl(resp->status)); dprintk("lockd: LOCK status %d\n", ntohl(resp->status));
nlm_release_host(host); nlm_release_host(host);
......
...@@ -182,7 +182,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file, ...@@ -182,7 +182,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file,
lock.fl_type = F_UNLCK; lock.fl_type = F_UNLCK;
lock.fl_start = 0; lock.fl_start = 0;
lock.fl_end = OFFSET_MAX; lock.fl_end = OFFSET_MAX;
if (posix_lock_file(file->f_file, &lock) < 0) { if (vfs_lock_file(file->f_file, F_SETLK, &lock, NULL) < 0) {
printk("lockd: unlock failure in %s:%d\n", printk("lockd: unlock failure in %s:%d\n",
__FILE__, __LINE__); __FILE__, __LINE__);
return 1; return 1;
......
This diff is collapsed.
...@@ -391,17 +391,12 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -391,17 +391,12 @@ static ssize_t nfs_file_write(struct kiocb *iocb, const struct iovec *iov,
static int do_getlk(struct file *filp, int cmd, struct file_lock *fl) static int do_getlk(struct file *filp, int cmd, struct file_lock *fl)
{ {
struct file_lock cfl;
struct inode *inode = filp->f_mapping->host; struct inode *inode = filp->f_mapping->host;
int status = 0; int status = 0;
lock_kernel(); lock_kernel();
/* Try local locking first */ /* Try local locking first */
if (posix_test_lock(filp, fl, &cfl)) { if (posix_test_lock(filp, fl)) {
fl->fl_start = cfl.fl_start;
fl->fl_end = cfl.fl_end;
fl->fl_type = cfl.fl_type;
fl->fl_pid = cfl.fl_pid;
goto out; goto out;
} }
......
...@@ -3017,6 +3017,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock ...@@ -3017,6 +3017,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock
case -NFS4ERR_DENIED: case -NFS4ERR_DENIED:
status = 0; status = 0;
} }
request->fl_ops->fl_release_private(request);
out: out:
up_read(&clp->cl_sem); up_read(&clp->cl_sem);
return status; return status;
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <linux/nfsd/xdr4.h> #include <linux/nfsd/xdr4.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/lockd/bind.h>
#define NFSDDBG_FACILITY NFSDDBG_PROC #define NFSDDBG_FACILITY NFSDDBG_PROC
...@@ -2657,6 +2658,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2657,6 +2658,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct file_lock conflock; struct file_lock conflock;
__be32 status = 0; __be32 status = 0;
unsigned int strhashval; unsigned int strhashval;
unsigned int cmd;
int err; int err;
dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n", dprintk("NFSD: nfsd4_lock: start=%Ld length=%Ld\n",
...@@ -2739,10 +2741,12 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2739,10 +2741,12 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
case NFS4_READ_LT: case NFS4_READ_LT:
case NFS4_READW_LT: case NFS4_READW_LT:
file_lock.fl_type = F_RDLCK; file_lock.fl_type = F_RDLCK;
cmd = F_SETLK;
break; break;
case NFS4_WRITE_LT: case NFS4_WRITE_LT:
case NFS4_WRITEW_LT: case NFS4_WRITEW_LT:
file_lock.fl_type = F_WRLCK; file_lock.fl_type = F_WRLCK;
cmd = F_SETLK;
break; break;
default: default:
status = nfserr_inval; status = nfserr_inval;
...@@ -2769,9 +2773,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2769,9 +2773,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
/* XXX?: Just to divert the locks_release_private at the start of /* XXX?: Just to divert the locks_release_private at the start of
* locks_copy_lock: */ * locks_copy_lock: */
conflock.fl_ops = NULL; locks_init_lock(&conflock);
conflock.fl_lmops = NULL; err = vfs_lock_file(filp, cmd, &file_lock, &conflock);
err = posix_lock_file_conf(filp, &file_lock, &conflock);
switch (-err) { switch (-err) {
case 0: /* success! */ case 0: /* success! */
update_stateid(&lock_stp->st_stateid); update_stateid(&lock_stp->st_stateid);
...@@ -2788,7 +2791,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2788,7 +2791,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
status = nfserr_deadlock; status = nfserr_deadlock;
break; break;
default: default:
dprintk("NFSD: nfsd4_lock: posix_lock_file_conf() failed! status %d\n",err); dprintk("NFSD: nfsd4_lock: vfs_lock_file() failed! status %d\n",err);
status = nfserr_resource; status = nfserr_resource;
break; break;
} }
...@@ -2813,7 +2816,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2813,7 +2816,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
struct inode *inode; struct inode *inode;
struct file file; struct file file;
struct file_lock file_lock; struct file_lock file_lock;
struct file_lock conflock; int error;
__be32 status; __be32 status;
if (nfs4_in_grace()) if (nfs4_in_grace())
...@@ -2869,18 +2872,23 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2869,18 +2872,23 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
nfs4_transform_lock_offset(&file_lock); nfs4_transform_lock_offset(&file_lock);
/* posix_test_lock uses the struct file _only_ to resolve the inode. /* vfs_test_lock uses the struct file _only_ to resolve the inode.
* since LOCKT doesn't require an OPEN, and therefore a struct * since LOCKT doesn't require an OPEN, and therefore a struct
* file may not exist, pass posix_test_lock a struct file with * file may not exist, pass vfs_test_lock a struct file with
* only the dentry:inode set. * only the dentry:inode set.
*/ */
memset(&file, 0, sizeof (struct file)); memset(&file, 0, sizeof (struct file));
file.f_path.dentry = cstate->current_fh.fh_dentry; file.f_path.dentry = cstate->current_fh.fh_dentry;
status = nfs_ok; status = nfs_ok;
if (posix_test_lock(&file, &file_lock, &conflock)) { error = vfs_test_lock(&file, &file_lock);
if (error) {
status = nfserrno(error);
goto out;
}
if (file_lock.fl_type != F_UNLCK) {
status = nfserr_denied; status = nfserr_denied;
nfs4_set_lock_denied(&conflock, &lockt->lt_denied); nfs4_set_lock_denied(&file_lock, &lockt->lt_denied);
} }
out: out:
nfs4_unlock_state(); nfs4_unlock_state();
...@@ -2933,9 +2941,9 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -2933,9 +2941,9 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
/* /*
* Try to unlock the file in the VFS. * Try to unlock the file in the VFS.
*/ */
err = posix_lock_file(filp, &file_lock); err = vfs_lock_file(filp, F_SETLK, &file_lock, NULL);
if (err) { if (err) {
dprintk("NFSD: nfs4_locku: posix_lock_file failed!\n"); dprintk("NFSD: nfs4_locku: vfs_lock_file failed!\n");
goto out_nfserr; goto out_nfserr;
} }
/* /*
......
...@@ -3,6 +3,10 @@ ...@@ -3,6 +3,10 @@
#include <asm/fcntl.h> #include <asm/fcntl.h>
/* Cancel a blocking posix lock; internal use only until we expose an
* asynchronous lock api to userspace: */
#define F_CANCELLK (F_LINUX_SPECIFIC_BASE+5)
#define F_SETLEASE (F_LINUX_SPECIFIC_BASE+0) #define F_SETLEASE (F_LINUX_SPECIFIC_BASE+0)
#define F_GETLEASE (F_LINUX_SPECIFIC_BASE+1) #define F_GETLEASE (F_LINUX_SPECIFIC_BASE+1)
......
...@@ -786,6 +786,7 @@ struct file_lock_operations { ...@@ -786,6 +786,7 @@ struct file_lock_operations {
struct lock_manager_operations { struct lock_manager_operations {
int (*fl_compare_owner)(struct file_lock *, struct file_lock *); int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
void (*fl_notify)(struct file_lock *); /* unblock callback */ void (*fl_notify)(struct file_lock *); /* unblock callback */
int (*fl_grant)(struct file_lock *, struct file_lock *, int);
void (*fl_copy_lock)(struct file_lock *, struct file_lock *); void (*fl_copy_lock)(struct file_lock *, struct file_lock *);
void (*fl_release_private)(struct file_lock *); void (*fl_release_private)(struct file_lock *);
void (*fl_break)(struct file_lock *); void (*fl_break)(struct file_lock *);
...@@ -857,11 +858,13 @@ extern void locks_init_lock(struct file_lock *); ...@@ -857,11 +858,13 @@ extern void locks_init_lock(struct file_lock *);
extern void locks_copy_lock(struct file_lock *, struct file_lock *); extern void locks_copy_lock(struct file_lock *, struct file_lock *);
extern void locks_remove_posix(struct file *, fl_owner_t); extern void locks_remove_posix(struct file *, fl_owner_t);
extern void locks_remove_flock(struct file *); extern void locks_remove_flock(struct file *);
extern int posix_test_lock(struct file *, struct file_lock *, struct file_lock *); extern int posix_test_lock(struct file *, struct file_lock *);
extern int posix_lock_file_conf(struct file *, struct file_lock *, struct file_lock *); extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
extern int posix_lock_file(struct file *, struct file_lock *);
extern int posix_lock_file_wait(struct file *, struct file_lock *); extern int posix_lock_file_wait(struct file *, struct file_lock *);
extern int posix_unblock_lock(struct file *, struct file_lock *); extern int posix_unblock_lock(struct file *, struct file_lock *);
extern int vfs_test_lock(struct file *, struct file_lock *);
extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
extern int __break_lease(struct inode *inode, unsigned int flags); extern int __break_lease(struct inode *inode, unsigned int flags);
extern void lease_get_mtime(struct inode *, struct timespec *time); extern void lease_get_mtime(struct inode *, struct timespec *time);
......
...@@ -119,6 +119,9 @@ struct nlm_file { ...@@ -119,6 +119,9 @@ struct nlm_file {
* couldn't be granted because of a conflicting lock). * couldn't be granted because of a conflicting lock).
*/ */
#define NLM_NEVER (~(unsigned long) 0) #define NLM_NEVER (~(unsigned long) 0)
/* timeout on non-blocking call: */
#define NLM_TIMEOUT (7 * HZ)
struct nlm_block { struct nlm_block {
struct kref b_count; /* Reference count */ struct kref b_count; /* Reference count */
struct list_head b_list; /* linked list of all blocks */ struct list_head b_list; /* linked list of all blocks */
...@@ -130,6 +133,13 @@ struct nlm_block { ...@@ -130,6 +133,13 @@ struct nlm_block {
unsigned int b_id; /* block id */ unsigned int b_id; /* block id */
unsigned char b_granted; /* VFS granted lock */ unsigned char b_granted; /* VFS granted lock */
struct nlm_file * b_file; /* file in question */ struct nlm_file * b_file; /* file in question */
struct cache_req * b_cache_req; /* deferred request handling */
struct file_lock * b_fl; /* set for GETLK */
struct cache_deferred_req * b_deferred_req;
unsigned int b_flags; /* block flags */
#define B_QUEUED 1 /* lock queued */
#define B_GOT_CALLBACK 2 /* got lock or conflicting lock */
#define B_TIMED_OUT 4 /* filesystem too slow to respond */
}; };
/* /*
...@@ -185,8 +195,8 @@ typedef int (*nlm_host_match_fn_t)(struct nlm_host *cur, struct nlm_host *ref) ...@@ -185,8 +195,8 @@ typedef int (*nlm_host_match_fn_t)(struct nlm_host *cur, struct nlm_host *ref)
__be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *, __be32 nlmsvc_lock(struct svc_rqst *, struct nlm_file *,
struct nlm_lock *, int, struct nlm_cookie *); struct nlm_lock *, int, struct nlm_cookie *);
__be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *); __be32 nlmsvc_unlock(struct nlm_file *, struct nlm_lock *);
__be32 nlmsvc_testlock(struct nlm_file *, struct nlm_lock *, __be32 nlmsvc_testlock(struct svc_rqst *, struct nlm_file *,
struct nlm_lock *); struct nlm_lock *, struct nlm_lock *, struct nlm_cookie *);
__be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *); __be32 nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
unsigned long nlmsvc_retry_blocked(void); unsigned long nlmsvc_retry_blocked(void);
void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *, void nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment