From: Trond Myklebust <trond.myklebust@fys.uio.no>
To: "J. Bruce Fields" <bfields@citi.umich.edu>
Cc: linux-fsdevel@vger.kernel.org, nfs@lists.sourceforge.net,
Marc Eshel <eshel@almaden.ibm.com>
Subject: Re: [NFS] [PATCH 2/14] locks: factor out generic/filesystem switch from test_lock
Date: Sat, 03 Feb 2007 16:32:05 -0800 [thread overview]
Message-ID: <1170549125.5749.1.camel@lade.trondhjem.org> (raw)
In-Reply-To: <5cdd83858bf5c75e14742bbd03b462f5ec4997fe.1170479265.git.bfields@citi.umich.edu>
On Sat, 2007-02-03 at 00:33 -0500, J. Bruce Fields wrote:
> From: J. Bruce Fields <bfields@snoopy.citi.umich.edu> - unquoted
>
> Factor out the code that switches between generic and filesystem-specific lock
> methods; eventually we want to call this from lock managers (lockd and nfsd)
> too; currently they only call the generic methods.
>
> This patch does that for test_lock.
>
> Note that this hasn't been necessary until recently, because the few
> filesystems that define ->lock() (nfs, cifs...) aren't exportable via NFS.
> However GFS (and, in the future, other cluster filesystems) need to implement
> their own locking to get cluster-coherent locking, and also want to be able to
> export locking to NFS (lockd and NFSv4).
>
> So we accomplish this by factoring out code such as this and exporting it for
> the use of lockd and nfsd.
>
> Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
> ---
> fs/locks.c | 59 ++++++++++++++++++++++++++-----------------
> include/linux/lockd/bind.h | 2 +
> 2 files changed, 38 insertions(+), 23 deletions(-)
>
> diff --git a/fs/locks.c b/fs/locks.c
> index 4390a95..95246dc 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1611,6 +1611,33 @@ asmlinkage long sys_flock(unsigned int fd, unsigned int cmd)
> return error;
> }
>
> +/**
> + * vfs_test_lock - test file byte range lock
> + * @filp: The file to test lock for
> + * @fl: The lock to test
> + * @conf: Place to return a copy of the conflicting lock, if found
> + *
> + * Returns -ERRNO on failure. Indicates presence of conflicting lock by
> + * setting conf->fl_type to something other than F_UNLCK.
> + */
> +int vfs_test_lock(struct file *filp, struct file_lock *fl, struct file_lock *conf)
> +{
> + int error;
> +
> + conf->fl_type = F_UNLCK;
> + if (filp->f_op && filp->f_op->lock) {
> + __locks_copy_lock(conf, fl);
> + error = filp->f_op->lock(filp, F_GETLK, conf);
> + if (conf->fl_ops && conf->fl_ops->fl_release_private)
> + conf->fl_ops->fl_release_private(conf);
Why are you adding in a "release" call here? Is there any reason why a
GETLK would want to return private data from the filesystem to the VFS?
> + return error;
> + } else {
> + posix_test_lock(filp, fl, conf);
> + return 0;
> + }
> +}
> +EXPORT_SYMBOL(vfs_test_lock);
> +
> /* Report the first existing lock that would conflict with l.
> * This implements the F_GETLK command of fcntl().
> */
> @@ -1631,17 +1658,10 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
> if (error)
> goto out;
>
> - if (filp->f_op && filp->f_op->lock) {
> - error = filp->f_op->lock(filp, F_GETLK, &file_lock);
> - if (file_lock.fl_ops && file_lock.fl_ops->fl_release_private)
> - file_lock.fl_ops->fl_release_private(&file_lock);
> - if (error < 0)
> - goto out;
> - else
> - fl = (file_lock.fl_type == F_UNLCK ? NULL : &file_lock);
> - } else {
> - fl = (posix_test_lock(filp, &file_lock, &cfl) ? &cfl : NULL);
> - }
> + error = vfs_test_lock(filp, &file_lock, &cfl);
> + if (error)
> + goto out;
> + fl = (cfl.fl_type == F_UNLCK ? NULL : &cfl);
>
> flock.l_type = F_UNLCK;
> if (fl != NULL) {
> @@ -1785,18 +1805,11 @@ int fcntl_getlk64(struct file *filp, struct flock64 __user *l)
> if (error)
> goto out;
>
> - if (filp->f_op && filp->f_op->lock) {
> - error = filp->f_op->lock(filp, F_GETLK, &file_lock);
> - if (file_lock.fl_ops && file_lock.fl_ops->fl_release_private)
> - file_lock.fl_ops->fl_release_private(&file_lock);
> - if (error < 0)
> - goto out;
> - else
> - fl = (file_lock.fl_type == F_UNLCK ? NULL : &file_lock);
> - } else {
> - fl = (posix_test_lock(filp, &file_lock, &cfl) ? &cfl : NULL);
> - }
> -
> + error = vfs_test_lock(filp, &file_lock, &cfl);
> + if (error)
> + goto out;
> + fl = (cfl.fl_type == F_UNLCK ? NULL : &cfl);
> +
> flock.l_type = F_UNLCK;
> if (fl != NULL) {
> flock.l_pid = fl->fl_pid;
> diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h
> index 246de1d..f78b24a 100644
> --- a/include/linux/lockd/bind.h
> +++ b/include/linux/lockd/bind.h
> @@ -38,4 +38,6 @@ extern int nlmclnt_proc(struct inode *, int, struct file_lock *);
> extern int lockd_up(int proto);
> extern void lockd_down(void);
>
> +extern int vfs_test_lock(struct file *, struct file_lock *, struct file_lock *);
> +
> #endif /* LINUX_LOCKD_BIND_H */
> --
> 1.5.0.rc1.g72fe
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier.
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> NFS maillist - NFS@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nfs
next prev parent reply other threads:[~2007-02-04 0:32 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <11704808501171-git-send-email->
[not found] ` <11704808502512-git-send-email->
[not found] ` <11704808513862-git-send-email->
[not found] ` <1170480851972-git-send-email->
[not found] ` <11704808513070-git-send-email->
[not found] ` <117048085185-git-send-email->
[not found] ` <11704808513263-git-send-email->
[not found] ` <11704808513185-git-send-email->
[not found] ` <11704808511238-git-send-email->
[not found] ` <11704808513085-git-send-email->
[not found] ` <11704808521765-git-send-email->
[not found] ` <11704808523686-git-send-email->
[not found] ` <ad8373acbb12f165b625f6065bc0ca86f3982b7f.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:33 ` [PATCH 1/14] locks: always unlock on close J. Bruce Fields
2007-02-03 5:33 ` J. Bruce Fields
[not found] ` <5cdd83858bf5c75e14742bbd03b462f5ec4997fe.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:33 ` [PATCH 2/14] locks: factor out generic/filesystem switch from test_lock J. Bruce Fields
2007-02-03 5:33 ` J. Bruce Fields
2007-02-03 8:50 ` Christoph Hellwig
2007-02-04 1:48 ` J. Bruce Fields
2007-02-04 8:41 ` Christoph Hellwig
2007-02-04 0:32 ` Trond Myklebust [this message]
2007-02-04 1:52 ` [NFS] " J. Bruce Fields
[not found] ` <1dd47bf9aeb6f19c82a59efb2f4236f23f73019d.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:33 ` [PATCH 3/14] locks: factor out generic/filesystem switch from setlock code J. Bruce Fields
2007-02-03 5:33 ` J. Bruce Fields
2007-02-03 8:51 ` Christoph Hellwig
2007-02-03 5:16 ` Brad Boyer
2007-02-04 2:27 ` J. Bruce Fields
2007-02-04 8:37 ` Christoph Hellwig
2007-02-03 21:27 ` Brad Boyer
2007-02-04 1:58 ` J. Bruce Fields
[not found] ` <96a0abaf64b433a7e7450e7e35d0baf2c44103db.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 4/14] locks: add locking function that returns conflicting lock J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
2007-02-03 8:54 ` Christoph Hellwig
2007-02-04 2:02 ` J. Bruce Fields
[not found] ` <a4ecb8974d61a5077d24cf42ed2c564b4fa7aadf.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 5/14] locks: add fl_notify arguments for asynchronous lock return J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <fdf19cb6a33a08dd9220cdf2379d712d3c15e66f.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 6/14] locks: add lock cancel command J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <d1c313156428c533721d67f938ca72759b192156.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 7/14] nfsd4: Convert NFSv4 to new lock interface J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <8096fc4eb11f5c5678197fdee8afe0e2780357fc.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 8/14] lockd: save lock state on deferral J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <6f2a40ca33ea2b58e3f515bea9be1e0fa8cda6aa.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 9/14] lockd: handle fl_notify callbacks J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
2007-02-04 0:40 ` [NFS] " Trond Myklebust
2007-02-04 2:10 ` J. Bruce Fields
[not found] ` <19e4ad761534f2afd8045321c950a9336c6b1fc2.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 10/14] lockd: pass cookie in nlmsvc_testlock J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <ecc19d4bdf659f8cd1bbe4783625af5040f0b83a.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 11/14] lockd: handle test_lock deferrals J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <ed8e1981069ef91a62c19a16b37d51c819a5196f.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 12/14] lockd: always preallocate block in nlmsvc_lock() J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <b18934dedc3dd49bd1578256944c8fb756db2a6c.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 13/14] lockd: add code to handle deferred lock requests J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
[not found] ` <6d1e339108dad3e204a1eb53e736a2a0f73dda22.1170479265.git.bfields@citi.umich.edu>
2007-02-03 5:34 ` [PATCH 14/14] gfs2: nfs lock support for gfs2 J. Bruce Fields
2007-02-03 5:34 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1170549125.5749.1.camel@lade.trondhjem.org \
--to=trond.myklebust@fys.uio.no \
--cc=bfields@citi.umich.edu \
--cc=eshel@almaden.ibm.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=nfs@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).