mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
Compare commits
5 Commits
dbf8fe85a1
...
c8ebd43345
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8ebd43345 | ||
|
|
1f941b2c23 | ||
|
|
8f9e967830 | ||
|
|
8072e34e13 | ||
|
|
a49a2a1baa |
@ -97,7 +97,6 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
|
|||||||
struct nlm_args *argp = rqstp->rq_argp;
|
struct nlm_args *argp = rqstp->rq_argp;
|
||||||
struct nlm_host *host;
|
struct nlm_host *host;
|
||||||
struct nlm_file *file;
|
struct nlm_file *file;
|
||||||
struct nlm_lockowner *test_owner;
|
|
||||||
__be32 rc = rpc_success;
|
__be32 rc = rpc_success;
|
||||||
|
|
||||||
dprintk("lockd: TEST4 called\n");
|
dprintk("lockd: TEST4 called\n");
|
||||||
@ -107,7 +106,6 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
|
|||||||
if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
|
if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file)))
|
||||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||||
|
|
||||||
test_owner = argp->lock.fl.c.flc_owner;
|
|
||||||
/* Now check for conflicting locks */
|
/* Now check for conflicting locks */
|
||||||
resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock,
|
resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock,
|
||||||
&resp->lock);
|
&resp->lock);
|
||||||
@ -116,7 +114,7 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
|
|||||||
else
|
else
|
||||||
dprintk("lockd: TEST4 status %d\n", ntohl(resp->status));
|
dprintk("lockd: TEST4 status %d\n", ntohl(resp->status));
|
||||||
|
|
||||||
nlmsvc_put_lockowner(test_owner);
|
nlmsvc_release_lockowner(&argp->lock);
|
||||||
nlmsvc_release_host(host);
|
nlmsvc_release_host(host);
|
||||||
nlm_release_file(file);
|
nlm_release_file(file);
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
@ -633,7 +633,13 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mode = lock_to_openmode(&lock->fl);
|
mode = lock_to_openmode(&lock->fl);
|
||||||
error = vfs_test_lock(file->f_file[mode], &lock->fl);
|
locks_init_lock(&conflock->fl);
|
||||||
|
/* vfs_test_lock only uses start, end, and owner, but tests flc_file */
|
||||||
|
conflock->fl.c.flc_file = lock->fl.c.flc_file;
|
||||||
|
conflock->fl.fl_start = lock->fl.fl_start;
|
||||||
|
conflock->fl.fl_end = lock->fl.fl_end;
|
||||||
|
conflock->fl.c.flc_owner = lock->fl.c.flc_owner;
|
||||||
|
error = vfs_test_lock(file->f_file[mode], &conflock->fl);
|
||||||
if (error) {
|
if (error) {
|
||||||
/* We can't currently deal with deferred test requests */
|
/* We can't currently deal with deferred test requests */
|
||||||
if (error == FILE_LOCK_DEFERRED)
|
if (error == FILE_LOCK_DEFERRED)
|
||||||
@ -643,22 +649,19 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lock->fl.c.flc_type == F_UNLCK) {
|
if (conflock->fl.c.flc_type == F_UNLCK) {
|
||||||
ret = nlm_granted;
|
ret = nlm_granted;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n",
|
dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n",
|
||||||
lock->fl.c.flc_type, (long long)lock->fl.fl_start,
|
conflock->fl.c.flc_type, (long long)conflock->fl.fl_start,
|
||||||
(long long)lock->fl.fl_end);
|
(long long)conflock->fl.fl_end);
|
||||||
conflock->caller = "somehost"; /* FIXME */
|
conflock->caller = "somehost"; /* FIXME */
|
||||||
conflock->len = strlen(conflock->caller);
|
conflock->len = strlen(conflock->caller);
|
||||||
conflock->oh.len = 0; /* don't return OH info */
|
conflock->oh.len = 0; /* don't return OH info */
|
||||||
conflock->svid = lock->fl.c.flc_pid;
|
conflock->svid = conflock->fl.c.flc_pid;
|
||||||
conflock->fl.c.flc_type = lock->fl.c.flc_type;
|
locks_release_private(&conflock->fl);
|
||||||
conflock->fl.fl_start = lock->fl.fl_start;
|
|
||||||
conflock->fl.fl_end = lock->fl.fl_end;
|
|
||||||
locks_release_private(&lock->fl);
|
|
||||||
|
|
||||||
ret = nlm_lck_denied;
|
ret = nlm_lck_denied;
|
||||||
out:
|
out:
|
||||||
|
|||||||
@ -117,7 +117,6 @@ __nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
|
|||||||
struct nlm_args *argp = rqstp->rq_argp;
|
struct nlm_args *argp = rqstp->rq_argp;
|
||||||
struct nlm_host *host;
|
struct nlm_host *host;
|
||||||
struct nlm_file *file;
|
struct nlm_file *file;
|
||||||
struct nlm_lockowner *test_owner;
|
|
||||||
__be32 rc = rpc_success;
|
__be32 rc = rpc_success;
|
||||||
|
|
||||||
dprintk("lockd: TEST called\n");
|
dprintk("lockd: TEST called\n");
|
||||||
@ -127,8 +126,6 @@ __nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
|
|||||||
if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
|
if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file)))
|
||||||
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success;
|
||||||
|
|
||||||
test_owner = argp->lock.fl.c.flc_owner;
|
|
||||||
|
|
||||||
/* Now check for conflicting locks */
|
/* Now check for conflicting locks */
|
||||||
resp->status = cast_status(nlmsvc_testlock(rqstp, file, host,
|
resp->status = cast_status(nlmsvc_testlock(rqstp, file, host,
|
||||||
&argp->lock, &resp->lock));
|
&argp->lock, &resp->lock));
|
||||||
@ -138,7 +135,7 @@ __nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp)
|
|||||||
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);
|
||||||
|
|
||||||
nlmsvc_put_lockowner(test_owner);
|
nlmsvc_release_lockowner(&argp->lock);
|
||||||
nlmsvc_release_host(host);
|
nlmsvc_release_host(host);
|
||||||
nlm_release_file(file);
|
nlm_release_file(file);
|
||||||
return rc;
|
return rc;
|
||||||
|
|||||||
12
fs/locks.c
12
fs/locks.c
@ -2236,13 +2236,21 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
|
|||||||
/**
|
/**
|
||||||
* vfs_test_lock - test file byte range lock
|
* vfs_test_lock - test file byte range lock
|
||||||
* @filp: The file to test lock for
|
* @filp: The file to test lock for
|
||||||
* @fl: The lock to test; also used to hold result
|
* @fl: The byte-range in the file to test; also used to hold result
|
||||||
*
|
*
|
||||||
|
* On entry, @fl does not contain a lock, but identifies a range (fl_start, fl_end)
|
||||||
|
* in the file (c.flc_file), and an owner (c.flc_owner) for whom existing locks
|
||||||
|
* should be ignored. c.flc_type and c.flc_flags are ignored.
|
||||||
|
* Both fl_lmops and fl_ops in @fl must be NULL.
|
||||||
* Returns -ERRNO on failure. Indicates presence of conflicting lock by
|
* Returns -ERRNO on failure. Indicates presence of conflicting lock by
|
||||||
* setting conf->fl_type to something other than F_UNLCK.
|
* setting fl->fl_type to something other than F_UNLCK.
|
||||||
|
*
|
||||||
|
* If vfs_test_lock() does find a lock and return it, the caller must
|
||||||
|
* use locks_free_lock() or locks_release_private() on the returned lock.
|
||||||
*/
|
*/
|
||||||
int vfs_test_lock(struct file *filp, struct file_lock *fl)
|
int vfs_test_lock(struct file *filp, struct file_lock *fl)
|
||||||
{
|
{
|
||||||
|
WARN_ON_ONCE(fl->fl_ops || fl->fl_lmops);
|
||||||
WARN_ON_ONCE(filp != fl->c.flc_file);
|
WARN_ON_ONCE(filp != fl->c.flc_file);
|
||||||
if (filp->f_op->lock)
|
if (filp->f_op->lock)
|
||||||
return filp->f_op->lock(filp, F_GETLK, fl);
|
return filp->f_op->lock(filp, F_GETLK, fl);
|
||||||
|
|||||||
@ -1218,13 +1218,15 @@ static void put_deleg_file(struct nfs4_file *fp)
|
|||||||
|
|
||||||
if (nf)
|
if (nf)
|
||||||
nfsd_file_put(nf);
|
nfsd_file_put(nf);
|
||||||
if (rnf)
|
if (rnf) {
|
||||||
|
nfsd_file_put(rnf);
|
||||||
nfs4_file_put_access(fp, NFS4_SHARE_ACCESS_READ);
|
nfs4_file_put_access(fp, NFS4_SHARE_ACCESS_READ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nfsd4_finalize_deleg_timestamps(struct nfs4_delegation *dp, struct file *f)
|
static void nfsd4_finalize_deleg_timestamps(struct nfs4_delegation *dp, struct file *f)
|
||||||
{
|
{
|
||||||
struct iattr ia = { .ia_valid = ATTR_ATIME | ATTR_CTIME | ATTR_MTIME };
|
struct iattr ia = { .ia_valid = ATTR_ATIME | ATTR_CTIME | ATTR_MTIME | ATTR_DELEG };
|
||||||
struct inode *inode = file_inode(f);
|
struct inode *inode = file_inode(f);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -3097,8 +3099,10 @@ static int client_states_open(struct inode *inode, struct file *file)
|
|||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
|
|
||||||
ret = seq_open(file, &states_seq_ops);
|
ret = seq_open(file, &states_seq_ops);
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
drop_client(clp);
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
s = file->private_data;
|
s = file->private_data;
|
||||||
s->private = clp;
|
s->private = clp;
|
||||||
return 0;
|
return 0;
|
||||||
@ -6231,10 +6235,14 @@ nfsd4_add_rdaccess_to_wrdeleg(struct svc_rqst *rqstp, struct nfsd4_open *open,
|
|||||||
fp = stp->st_stid.sc_file;
|
fp = stp->st_stid.sc_file;
|
||||||
spin_lock(&fp->fi_lock);
|
spin_lock(&fp->fi_lock);
|
||||||
__nfs4_file_get_access(fp, NFS4_SHARE_ACCESS_READ);
|
__nfs4_file_get_access(fp, NFS4_SHARE_ACCESS_READ);
|
||||||
fp = stp->st_stid.sc_file;
|
if (!fp->fi_fds[O_RDONLY]) {
|
||||||
fp->fi_fds[O_RDONLY] = nf;
|
fp->fi_fds[O_RDONLY] = nf;
|
||||||
fp->fi_rdeleg_file = nf;
|
nf = NULL;
|
||||||
|
}
|
||||||
|
fp->fi_rdeleg_file = nfsd_file_get(fp->fi_fds[O_RDONLY]);
|
||||||
spin_unlock(&fp->fi_lock);
|
spin_unlock(&fp->fi_lock);
|
||||||
|
if (nf)
|
||||||
|
nfsd_file_put(nf);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user