From: "J. Bruce Fields" <bfields@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: Jeremy Allison <jra@samba.org>,
samba-technical@lists.samba.org, linux-nfs@vger.kernel.org,
Volker Lendecke <Volker.Lendecke@SerNet.DE>,
Casey Bodley <cbodley@citi.umich.edu>,
"J. Bruce Fields" <bfields@redhat.com>
Subject: [PATCH 2/4] locks: move F_INPROGRESS from fl_type to fl_flags field
Date: Fri, 19 Aug 2011 12:07:49 -0400 [thread overview]
Message-ID: <1313770071-353-2-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <20110819160416.GC30856@fieldses.org>
F_INPROGRESS isn't exposed to userspace. To me it makes more sense in
fl_flags....
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
---
arch/alpha/include/asm/fcntl.h | 2 --
fs/locks.c | 14 ++++++++------
include/asm-generic/fcntl.h | 5 -----
include/linux/fs.h | 3 ++-
4 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/arch/alpha/include/asm/fcntl.h b/arch/alpha/include/asm/fcntl.h
index 1b71ca7..6d9e805 100644
--- a/arch/alpha/include/asm/fcntl.h
+++ b/arch/alpha/include/asm/fcntl.h
@@ -51,8 +51,6 @@
#define F_EXLCK 16 /* or 3 */
#define F_SHLCK 32 /* or 4 */
-#define F_INPROGRESS 64
-
#include <asm-generic/fcntl.h>
#endif
diff --git a/fs/locks.c b/fs/locks.c
index c528522..c421541 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -135,7 +135,7 @@
static bool lease_breaking(struct file_lock *fl)
{
- return fl->fl_type & F_INPROGRESS;
+ return fl->fl_flags & FL_INPROGRESS;
}
int leases_enable = 1;
@@ -1132,6 +1132,7 @@ int lease_modify(struct file_lock **before, int arg)
if (error)
return error;
+ fl->fl_flags &= ~FL_INPROGRESS;
locks_wake_up_blocks(fl);
if (arg == F_UNLCK)
locks_delete_lock(before);
@@ -1152,7 +1153,7 @@ static void time_out_leases(struct inode *inode)
before = &fl->fl_next;
continue;
}
- lease_modify(before, fl->fl_type & ~F_INPROGRESS);
+ lease_modify(before, fl->fl_type);
if (fl == *before) /* lease_modify may have freed fl */
before = &fl->fl_next;
}
@@ -1193,13 +1194,13 @@ int __break_lease(struct inode *inode, unsigned int mode)
if (want_write) {
/* If we want write access, we have to revoke any lease. */
- future = F_UNLCK | F_INPROGRESS;
+ future = F_UNLCK;
} else if (lease_breaking(flock)) {
/* If the lease is already being broken, we just leave it */
future = flock->fl_type;
} else if (flock->fl_type & F_WRLCK) {
/* Downgrade the exclusive lease to a read-only lease. */
- future = F_RDLCK | F_INPROGRESS;
+ future = F_RDLCK;
} else {
/* the existing lease was read-only, so we can read too. */
goto out;
@@ -1221,6 +1222,7 @@ int __break_lease(struct inode *inode, unsigned int mode)
for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next) {
if (fl->fl_type != future) {
fl->fl_type = future;
+ fl->fl_flags |= FL_INPROGRESS;
fl->fl_break_time = break_time;
/* lease must have lmops break callback */
fl->fl_lmops->lm_break(fl);
@@ -1319,7 +1321,7 @@ int fcntl_getlease(struct file *filp)
for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl);
fl = fl->fl_next) {
if (fl->fl_file == filp) {
- type = fl->fl_type & ~F_INPROGRESS;
+ type = fl->fl_type;
break;
}
}
@@ -1384,7 +1386,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
before = &fl->fl_next) {
if (fl->fl_file == filp)
my_before = before;
- else if (fl->fl_type == (F_INPROGRESS | F_UNLCK))
+ else if ((fl->fl_type == F_UNLCK) && lease_breaking(fl))
/*
* Someone is in the process of opening this
* file for writing so we may not take an
diff --git a/include/asm-generic/fcntl.h b/include/asm-generic/fcntl.h
index 84793c7..9e5b035 100644
--- a/include/asm-generic/fcntl.h
+++ b/include/asm-generic/fcntl.h
@@ -145,11 +145,6 @@ struct f_owner_ex {
#define F_SHLCK 8 /* or 4 */
#endif
-/* for leases */
-#ifndef F_INPROGRESS
-#define F_INPROGRESS 16
-#endif
-
/* operations for bsd flock(), also used by the kernel implementation */
#define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 178cdb4..327fdd4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1065,6 +1065,7 @@ static inline int file_check_writeable(struct file *filp)
#define FL_LEASE 32 /* lease held on this file */
#define FL_CLOSE 64 /* unlock on close */
#define FL_SLEEP 128 /* A blocking lock */
+#define FL_INPROGRESS 256 /* Lease is being broken */
/*
* Special return value from posix_lock_file() and vfs_lock_file() for
@@ -1111,7 +1112,7 @@ struct file_lock {
struct list_head fl_link; /* doubly linked list of all locks */
struct list_head fl_block; /* circular list of blocked processes */
fl_owner_t fl_owner;
- unsigned char fl_flags;
+ unsigned int fl_flags;
unsigned char fl_type;
unsigned int fl_pid;
struct pid *fl_nspid;
--
1.7.4.1
WARNING: multiple messages have this Message-ID (diff)
From: "J. Bruce Fields" <bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Jeremy Allison <jra-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>,
samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.org,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Volker Lendecke
<Volker.Lendecke-PS7XAnAlDA+VvDNblw4Uiw@public.gmane.org>,
Casey Bodley <cbodley-vtMw8L3fJ9vSiEDVxGk4TQ@public.gmane.org>,
"J. Bruce Fields"
<bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 2/4] locks: move F_INPROGRESS from fl_type to fl_flags field
Date: Fri, 19 Aug 2011 12:07:49 -0400 [thread overview]
Message-ID: <1313770071-353-2-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <20110819160416.GC30856-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
F_INPROGRESS isn't exposed to userspace. To me it makes more sense in
fl_flags....
Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: J. Bruce Fields <bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
arch/alpha/include/asm/fcntl.h | 2 --
fs/locks.c | 14 ++++++++------
include/asm-generic/fcntl.h | 5 -----
include/linux/fs.h | 3 ++-
4 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/arch/alpha/include/asm/fcntl.h b/arch/alpha/include/asm/fcntl.h
index 1b71ca7..6d9e805 100644
--- a/arch/alpha/include/asm/fcntl.h
+++ b/arch/alpha/include/asm/fcntl.h
@@ -51,8 +51,6 @@
#define F_EXLCK 16 /* or 3 */
#define F_SHLCK 32 /* or 4 */
-#define F_INPROGRESS 64
-
#include <asm-generic/fcntl.h>
#endif
diff --git a/fs/locks.c b/fs/locks.c
index c528522..c421541 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -135,7 +135,7 @@
static bool lease_breaking(struct file_lock *fl)
{
- return fl->fl_type & F_INPROGRESS;
+ return fl->fl_flags & FL_INPROGRESS;
}
int leases_enable = 1;
@@ -1132,6 +1132,7 @@ int lease_modify(struct file_lock **before, int arg)
if (error)
return error;
+ fl->fl_flags &= ~FL_INPROGRESS;
locks_wake_up_blocks(fl);
if (arg == F_UNLCK)
locks_delete_lock(before);
@@ -1152,7 +1153,7 @@ static void time_out_leases(struct inode *inode)
before = &fl->fl_next;
continue;
}
- lease_modify(before, fl->fl_type & ~F_INPROGRESS);
+ lease_modify(before, fl->fl_type);
if (fl == *before) /* lease_modify may have freed fl */
before = &fl->fl_next;
}
@@ -1193,13 +1194,13 @@ int __break_lease(struct inode *inode, unsigned int mode)
if (want_write) {
/* If we want write access, we have to revoke any lease. */
- future = F_UNLCK | F_INPROGRESS;
+ future = F_UNLCK;
} else if (lease_breaking(flock)) {
/* If the lease is already being broken, we just leave it */
future = flock->fl_type;
} else if (flock->fl_type & F_WRLCK) {
/* Downgrade the exclusive lease to a read-only lease. */
- future = F_RDLCK | F_INPROGRESS;
+ future = F_RDLCK;
} else {
/* the existing lease was read-only, so we can read too. */
goto out;
@@ -1221,6 +1222,7 @@ int __break_lease(struct inode *inode, unsigned int mode)
for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next) {
if (fl->fl_type != future) {
fl->fl_type = future;
+ fl->fl_flags |= FL_INPROGRESS;
fl->fl_break_time = break_time;
/* lease must have lmops break callback */
fl->fl_lmops->lm_break(fl);
@@ -1319,7 +1321,7 @@ int fcntl_getlease(struct file *filp)
for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl);
fl = fl->fl_next) {
if (fl->fl_file == filp) {
- type = fl->fl_type & ~F_INPROGRESS;
+ type = fl->fl_type;
break;
}
}
@@ -1384,7 +1386,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
before = &fl->fl_next) {
if (fl->fl_file == filp)
my_before = before;
- else if (fl->fl_type == (F_INPROGRESS | F_UNLCK))
+ else if ((fl->fl_type == F_UNLCK) && lease_breaking(fl))
/*
* Someone is in the process of opening this
* file for writing so we may not take an
diff --git a/include/asm-generic/fcntl.h b/include/asm-generic/fcntl.h
index 84793c7..9e5b035 100644
--- a/include/asm-generic/fcntl.h
+++ b/include/asm-generic/fcntl.h
@@ -145,11 +145,6 @@ struct f_owner_ex {
#define F_SHLCK 8 /* or 4 */
#endif
-/* for leases */
-#ifndef F_INPROGRESS
-#define F_INPROGRESS 16
-#endif
-
/* operations for bsd flock(), also used by the kernel implementation */
#define LOCK_SH 1 /* shared lock */
#define LOCK_EX 2 /* exclusive lock */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 178cdb4..327fdd4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1065,6 +1065,7 @@ static inline int file_check_writeable(struct file *filp)
#define FL_LEASE 32 /* lease held on this file */
#define FL_CLOSE 64 /* unlock on close */
#define FL_SLEEP 128 /* A blocking lock */
+#define FL_INPROGRESS 256 /* Lease is being broken */
/*
* Special return value from posix_lock_file() and vfs_lock_file() for
@@ -1111,7 +1112,7 @@ struct file_lock {
struct list_head fl_link; /* doubly linked list of all locks */
struct list_head fl_block; /* circular list of blocked processes */
fl_owner_t fl_owner;
- unsigned char fl_flags;
+ unsigned int fl_flags;
unsigned char fl_type;
unsigned int fl_pid;
struct pid *fl_nspid;
--
1.7.4.1
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-08-19 16:07 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-09 23:16 [PATCH] locks: breaking read lease should not block read open J. Bruce Fields
2011-06-09 23:16 ` J. Bruce Fields
2011-06-10 7:56 ` Volker Lendecke
2011-06-10 7:56 ` Volker Lendecke
2011-06-10 13:48 ` J. Bruce Fields
2011-06-10 13:48 ` J. Bruce Fields
2011-07-21 0:07 ` J. Bruce Fields
2011-07-21 0:07 ` J. Bruce Fields
2011-07-21 0:15 ` Jeremy Allison
2011-07-21 0:15 ` Jeremy Allison
2011-07-21 16:35 ` J. Bruce Fields
2011-07-21 16:35 ` J. Bruce Fields
2011-07-29 2:27 ` J. Bruce Fields
2011-07-29 2:29 ` [PATCH 1/3] locks: minor lease cleanup J. Bruce Fields
2011-07-29 2:29 ` [PATCH 2/3] locks: move F_INPROGRESS from fl_type to fl_flags field J. Bruce Fields
2011-07-29 2:29 ` J. Bruce Fields
2011-07-29 2:30 ` [PATCH 3/3] locks: fix tracking of inprogress lease breaks J. Bruce Fields
2011-07-29 2:30 ` J. Bruce Fields
2011-08-19 16:04 ` [PATCH] locks: breaking read lease should not block read open J. Bruce Fields
2011-08-19 16:07 ` [PATCH 1/4] locks: minor lease cleanup J. Bruce Fields
2011-08-19 16:07 ` J. Bruce Fields
2011-08-19 16:07 ` J. Bruce Fields [this message]
2011-08-19 16:07 ` [PATCH 2/4] locks: move F_INPROGRESS from fl_type to fl_flags field J. Bruce Fields
2011-08-19 16:07 ` [PATCH 3/4] locks: fix tracking of inprogress lease breaks J. Bruce Fields
2011-08-19 16:07 ` [PATCH 4/4] locks: setlease cleanup J. Bruce Fields
2011-08-19 16:07 ` J. Bruce Fields
2011-08-19 19:08 ` [PATCH] locks: breaking read lease should not block read open Jamie Lokier
2011-08-19 19:08 ` Jamie Lokier
2011-08-21 16:50 ` J. Bruce Fields
2011-11-21 12:46 ` Jamie Lokier
2011-11-21 12:46 ` Jamie Lokier
2011-11-22 21:44 ` J. Bruce Fields
2011-11-23 0:30 ` Jamie Lokier
2011-11-23 0:30 ` Jamie Lokier
2011-11-23 19:08 ` 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=1313770071-353-2-git-send-email-bfields@redhat.com \
--to=bfields@redhat.com \
--cc=Volker.Lendecke@SerNet.DE \
--cc=cbodley@citi.umich.edu \
--cc=jra@samba.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.