From: Jeff Layton <jlayton@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: nfs-ganesha-devel@lists.sourceforge.net,
samba-technical@lists.samba.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/5] locks: add definitions for F_RDLCKP and F_WRLCKP
Date: Fri, 11 Oct 2013 08:25:19 -0400 [thread overview]
Message-ID: <1381494322-2426-3-git-send-email-jlayton@redhat.com> (raw)
In-Reply-To: <1381494322-2426-1-git-send-email-jlayton@redhat.com>
No arch seems to use these values for anything, so defining them
globally should be ok. When they are specified, translate them into
their non-P variants, and set the FL_FILP_PRIVATE flag to indicate
that they should get the proper behavior on close.
Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
fs/locks.c | 11 +++++++++++
include/linux/fs.h | 1 +
include/uapi/asm-generic/fcntl.h | 9 +++++++++
3 files changed, 21 insertions(+)
diff --git a/fs/locks.c b/fs/locks.c
index 389382c..086c3b4 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -348,6 +348,17 @@ static int posix_assign_type(struct file_lock *fl, long type)
{
int err;
+ switch(type) {
+ case F_RDLCKP:
+ type = F_RDLCK;
+ fl->fl_flags |= FL_FILP_PRIVATE;
+ break;
+ case F_WRLCKP:
+ type = F_WRLCK;
+ fl->fl_flags |= FL_FILP_PRIVATE;
+ break;
+ }
+
err = assign_type(fl, type);
if (err)
return err;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b46bfa5..df502bf 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -889,6 +889,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 /* only release on close of filp on which it was set */
/*
* Special return value from posix_lock_file() and vfs_lock_file() for
diff --git a/include/uapi/asm-generic/fcntl.h b/include/uapi/asm-generic/fcntl.h
index 95e46c8..0a4be0d 100644
--- a/include/uapi/asm-generic/fcntl.h
+++ b/include/uapi/asm-generic/fcntl.h
@@ -151,6 +151,15 @@ struct f_owner_ex {
#define F_UNLCK 2
#endif
+/*
+ * fd "private" POSIX locks. Usually POSIX locks held by a process are
+ * released on *any* close. If they are acquired using these l_type
+ * values, then they are only released on close of the fd on which they
+ * were acquired, similar to how BSD locks work.
+ */
+#define F_RDLCKP 5
+#define F_WRLCKP 6
+
/* for old implementation of bsd flock () */
#ifndef F_EXLCK
#define F_EXLCK 4 /* or 3 */
--
1.8.3.1
next prev parent reply other threads:[~2013-10-11 12:25 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-11 12:25 [RFC PATCH 0/5] locks: implement "filp-private" (aka UNPOSIX) locks Jeff Layton
2013-10-11 12:25 ` [RFC PATCH 1/5] locks: consolidate checks for compatible filp->f_mode values in setlk handlers Jeff Layton
2013-10-11 12:25 ` Jeff Layton [this message]
2013-10-11 12:25 ` [RFC PATCH 3/5] locks: skip FL_FILP_PRIVATE locks on close unless we're closing the correct filp Jeff Layton
2013-10-11 12:25 ` [RFC PATCH 4/5] locks: handle merging of locks when FL_FILP_PRIVATE is set Jeff Layton
2013-10-11 12:25 ` [RFC PATCH 5/5] locks: show private lock types in /proc/locks Jeff Layton
2013-10-11 13:35 ` [RFC PATCH 0/5] locks: implement "filp-private" (aka UNPOSIX) locks Jeff Layton
2013-10-11 15:20 ` Frank Filz
2013-10-11 15:50 ` Jeff Layton
2013-10-11 17:07 ` Frank Filz
2013-10-11 18:42 ` Jeff Layton
2013-10-11 18:53 ` Frank Filz
2013-10-12 9:10 ` Volker Lendecke
2013-10-11 20:07 ` J. Bruce Fields
2013-10-11 21:36 ` Andreas Dilger
2013-10-11 23:21 ` Jeff Layton
2013-10-11 23:49 ` Jeremy Allison
2013-10-12 0:18 ` Scott Lovenberg
2013-10-12 0:42 ` Jeff Layton
2013-10-12 18:12 ` Frank Filz
2013-10-14 7:24 ` Volker Lendecke
2013-10-14 15:23 ` Frank Filz
2013-10-15 8:56 ` Volker Lendecke
2013-10-12 20:56 ` Scott Lovenberg
2013-10-12 9:20 ` Stefan (metze) Metzmacher
2013-10-12 11:47 ` Jeff Layton
2013-10-12 18:10 ` [Nfs-ganesha-devel] " Frank Filz
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=1381494322-2426-3-git-send-email-jlayton@redhat.com \
--to=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).