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 1/4] locks: minor lease cleanup
Date: Fri, 19 Aug 2011 12:07:48 -0400 [thread overview]
Message-ID: <1313770071-353-1-git-send-email-bfields@redhat.com> (raw)
In-Reply-To: <20110819160416.GC30856-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
Use a helper function, to simplify upcoming changes.
Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: J. Bruce Fields <bfields-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
---
fs/locks.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/fs/locks.c b/fs/locks.c
index 703f545..c528522 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -133,6 +133,11 @@
#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK)
#define IS_LEASE(fl) (fl->fl_flags & FL_LEASE)
+static bool lease_breaking(struct file_lock *fl)
+{
+ return fl->fl_type & F_INPROGRESS;
+}
+
int leases_enable = 1;
int lease_break_time = 45;
@@ -1141,7 +1146,7 @@ static void time_out_leases(struct inode *inode)
struct file_lock *fl;
before = &inode->i_flock;
- while ((fl = *before) && IS_LEASE(fl) && (fl->fl_type & F_INPROGRESS)) {
+ while ((fl = *before) && IS_LEASE(fl) && lease_breaking(fl)) {
if ((fl->fl_break_time == 0)
|| time_before(jiffies, fl->fl_break_time)) {
before = &fl->fl_next;
@@ -1189,7 +1194,7 @@ 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;
- } else if (flock->fl_type & F_INPROGRESS) {
+ } 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) {
@@ -1246,7 +1251,7 @@ restart:
/* Wait for the next lease that has not been broken yet */
for (flock = inode->i_flock; flock && IS_LEASE(flock);
flock = flock->fl_next) {
- if (flock->fl_type & F_INPROGRESS)
+ if (lease_breaking(flock))
goto restart;
}
error = 0;
@@ -2126,7 +2131,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
}
} else if (IS_LEASE(fl)) {
seq_printf(f, "LEASE ");
- if (fl->fl_type & F_INPROGRESS)
+ if (lease_breaking(fl))
seq_printf(f, "BREAKING ");
else if (fl->fl_file)
seq_printf(f, "ACTIVE ");
@@ -2142,7 +2147,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
: (fl->fl_type & LOCK_WRITE) ? "WRITE" : "NONE ");
} else {
seq_printf(f, "%s ",
- (fl->fl_type & F_INPROGRESS)
+ (lease_breaking(fl))
? (fl->fl_type & F_UNLCK) ? "UNLCK" : "READ "
: (fl->fl_type & F_WRLCK) ? "WRITE" : "READ ");
}
--
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: 21+ 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-10 7:56 ` Volker Lendecke
[not found] ` <E1QUwaT-00HRZw-74-dqLtpHMqGvUyWpdLl23E4A@public.gmane.org>
2011-06-10 13:48 ` J. Bruce Fields
[not found] ` <20110610134859.GA27837-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-07-21 0:07 ` J. Bruce Fields
2011-07-21 0:15 ` Jeremy Allison
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
[not found] ` <20110729022911.GA23194-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-07-29 2:29 ` [PATCH 2/3] locks: move F_INPROGRESS from fl_type to fl_flags field J. Bruce Fields
[not found] ` <20110729022941.GB23194-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-07-29 2:30 ` [PATCH 3/3] locks: fix tracking of inprogress lease breaks J. Bruce Fields
2011-08-19 16:04 ` [PATCH] locks: breaking read lease should not block read open J. Bruce Fields
[not found] ` <20110819160416.GC30856-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
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 4/4] locks: setlease cleanup J. Bruce Fields
2011-08-19 16:07 ` [PATCH 3/4] locks: fix tracking of inprogress lease breaks J. Bruce Fields
[not found] ` <20110721000758.GD27871-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-08-19 19:08 ` [PATCH] locks: breaking read lease should not block read open Jamie Lokier
2011-08-21 16:50 ` J. Bruce Fields
[not found] ` <20110821165029.GA9296-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2011-11-21 12:46 ` Jamie Lokier
2011-11-22 21:44 ` J. Bruce Fields
[not found] ` <20111122214441.GB23243-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
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-1-git-send-email-bfields@redhat.com \
--to=bfields-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=Volker.Lendecke-PS7XAnAlDA+VvDNblw4Uiw@public.gmane.org \
--cc=cbodley-vtMw8L3fJ9vSiEDVxGk4TQ@public.gmane.org \
--cc=jra-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=samba-technical-w/Ol4Ecudpl8XjKLYN78aQ@public.gmane.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).