From: "J. Bruce Fields" <bfields@fieldses.org>
To: Jeff Layton <jlayton@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
nfs-ganesha-devel@lists.sourceforge.net,
samba-technical@lists.samba.org
Subject: Re: [RFC PATCH v2 4/5] locks: show private lock types in /proc/locks
Date: Wed, 20 Nov 2013 15:04:11 -0500 [thread overview]
Message-ID: <20131120200411.GC7387@fieldses.org> (raw)
In-Reply-To: <20131120200056.GB7387@fieldses.org>
On Wed, Nov 20, 2013 at 03:00:56PM -0500, bfields wrote:
> On Wed, Nov 20, 2013 at 11:45:05AM -0500, Jeff Layton wrote:
> > Show "private" locks in /proc/locks with a 'P' suffix. This does mean
> > that we need to widen the column by one character.
> >
> > Also, tighten up the check in locks_remove_filp() to ensure that only
> > IS_FILP_PVT locks are removed there.
>
> So that part belongs in the previous patch?
I think it's that previous patch that actually "turns on" the new user
interface (so after that patch userspace will get a lock instead of
-EINVAL or whatever).
Might be safest to delay doing that until the end of the series so as
not to expose any partial implementation.
--b.
>
> --b.
>
> >
> > Signed-off-by: Jeff Layton <jlayton@redhat.com>
> > ---
> > fs/locks.c | 15 +++++++++++----
> > include/linux/fs.h | 1 +
> > 2 files changed, 12 insertions(+), 4 deletions(-)
> >
> > diff --git a/fs/locks.c b/fs/locks.c
> > index 3b278a6..d5fb853 100644
> > --- a/fs/locks.c
> > +++ b/fs/locks.c
> > @@ -135,6 +135,7 @@
> > #define IS_POSIX(fl) (fl->fl_flags & FL_POSIX)
> > #define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK)
> > #define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG))
> > +#define IS_FILP_PVT(fl) (fl->fl_flags & FL_FILP_PRIVATE)
> >
> > static bool lease_breaking(struct file_lock *fl)
> > {
> > @@ -357,14 +358,17 @@ static int posix_assign_type(struct file_lock *fl, long type)
> > case F_RDLCKP:
> > type = F_RDLCK;
> > fl->fl_owner = (fl_owner_t)fl->fl_file;
> > + fl->fl_flags |= FL_FILP_PRIVATE;
> > break;
> > case F_WRLCKP:
> > type = F_WRLCK;
> > fl->fl_owner = (fl_owner_t)fl->fl_file;
> > + fl->fl_flags |= FL_FILP_PRIVATE;
> > break;
> > case F_UNLCKP:
> > type = F_UNLCK;
> > fl->fl_owner = (fl_owner_t)fl->fl_file;
> > + fl->fl_flags |= FL_FILP_PRIVATE;
> > break;
> > }
> >
> > @@ -2245,7 +2249,8 @@ void locks_remove_filp(struct file *filp)
> >
> > while ((fl = *before) != NULL) {
> > if (fl->fl_file == filp) {
> > - if (IS_FLOCK(fl) || IS_POSIX(fl)) {
> > + if (IS_FLOCK(fl) ||
> > + (IS_POSIX(fl) && IS_FILP_PVT(fl))) {
> > locks_delete_lock(before);
> > continue;
> > }
> > @@ -2345,13 +2350,15 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
> > seq_printf(f, "UNKNOWN UNKNOWN ");
> > }
> > if (fl->fl_type & LOCK_MAND) {
> > - seq_printf(f, "%s ",
> > + seq_printf(f, "%s ",
> > (fl->fl_type & LOCK_READ)
> > ? (fl->fl_type & LOCK_WRITE) ? "RW " : "READ "
> > : (fl->fl_type & LOCK_WRITE) ? "WRITE" : "NONE ");
> > + } else if (IS_FILP_PVT(fl)) {
> > + seq_printf(f, "%s ", fl->fl_type == F_WRLCK ? "WRITEP" : "READP ");
> > } else {
> > - seq_printf(f, "%s ",
> > - (lease_breaking(fl))
> > + seq_printf(f, "%s ",
> > + lease_breaking(fl)
> > ? (fl->fl_type == F_UNLCK) ? "UNLCK" : "READ "
> > : (fl->fl_type == F_WRLCK) ? "WRITE" : "READ ");
> > }
> > diff --git a/include/linux/fs.h b/include/linux/fs.h
> > index 2d890ce..9890bac 100644
> > --- a/include/linux/fs.h
> > +++ b/include/linux/fs.h
> > @@ -888,6 +888,7 @@ static inline int file_check_writeable(struct file *filp)
> > #define FL_SLEEP 128 /* A blocking lock */
> > #define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */
> > #define FL_UNLOCK_PENDING 512 /* Lease is being broken */
> > +#define FL_FILP_PRIVATE 1024 /* lock is private to the filp */
> >
> > /*
> > * Special return value from posix_lock_file() and vfs_lock_file() for
> > --
> > 1.8.3.1
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-11-20 20:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-20 16:45 [RFC PATCH v2 0/5] locks: implement "filp-private" (aka UNPOSIX) locks Jeff Layton
2013-11-20 16:45 ` [RFC PATCH v2 1/5] locks: consolidate checks for compatible filp->f_mode values in setlk handlers Jeff Layton
2013-11-21 17:35 ` Christoph Hellwig
2013-11-20 16:45 ` [RFC PATCH v2 2/5] locks: rename locks_remove_flock to locks_remove_filp Jeff Layton
2013-11-21 17:35 ` Christoph Hellwig
2013-11-20 16:45 ` [RFC PATCH v2 3/5] locks: add new "private" lock type that is owned by the filp Jeff Layton
2013-11-20 19:50 ` J. Bruce Fields
2013-11-20 20:00 ` Jeff Layton
2013-12-09 16:46 ` [Nfs-ganesha-devel] " Jeff Layton
2013-12-10 20:35 ` J. Bruce Fields
2013-11-21 17:36 ` Christoph Hellwig
2013-11-20 16:45 ` [RFC PATCH v2 4/5] locks: show private lock types in /proc/locks Jeff Layton
2013-11-20 20:00 ` J. Bruce Fields
2013-11-20 20:03 ` Jeff Layton
2013-11-20 20:04 ` J. Bruce Fields [this message]
2013-11-20 16:45 ` [RFC PATCH v2 5/5] locks: report l_pid as -1 for FL_FILP_PRIVATE locks Jeff Layton
2013-11-20 17:55 ` Frank Filz
2013-11-20 18:57 ` Jeff Layton
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=20131120200411.GC7387@fieldses.org \
--to=bfields@fieldses.org \
--cc=jlayton@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nfs-ganesha-devel@lists.sourceforge.net \
--cc=samba-technical@lists.samba.org \
/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).