[linux] 02/02: locks: __break_lease cleanup in preparation of allowing direct removal of leases
debian-kernel at lists.debian.org
debian-kernel at lists.debian.org
Thu Dec 14 19:51:51 UTC 2017
This is an automated email from the git hooks/post-receive script.
carnil pushed a commit to branch jessie
in repository linux.
commit 69b05d86bfe85058fab490ba2cd48ff4cff10952
Author: Salvatore Bonaccorso <carnil at debian.org>
Date: Mon Dec 4 11:16:30 2017 +0100
locks: __break_lease cleanup in preparation of allowing direct removal of leases
Closes: #883217
---
debian/changelog | 2 +
...ak_lease-cleanup-in-preparation-of-allowi.patch | 130 +++++++++++++++++++++
debian/patches/series | 1 +
3 files changed, 133 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index e9ec398..abb2aa5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
linux (3.16.51-4) UNRELEASED; urgency=medium
* locks: remove i_have_this_lease check from __break_lease
+ * locks: __break_lease cleanup in preparation of allowing direct removal of
+ leases (Closes: #883217)
-- Salvatore Bonaccorso <carnil at debian.org> Mon, 04 Dec 2017 12:17:53 +0100
diff --git a/debian/patches/bugfix/all/locks-__break_lease-cleanup-in-preparation-of-allowi.patch b/debian/patches/bugfix/all/locks-__break_lease-cleanup-in-preparation-of-allowi.patch
new file mode 100644
index 0000000..b52e876
--- /dev/null
+++ b/debian/patches/bugfix/all/locks-__break_lease-cleanup-in-preparation-of-allowi.patch
@@ -0,0 +1,130 @@
+From: Jeff Layton <jlayton at primarydata.com>
+Date: Mon, 1 Sep 2014 14:53:41 -0400
+Subject: locks: __break_lease cleanup in preparation of allowing direct
+ removal of leases
+Origin: https://git.kernel.org/linus/03d12ddf845a4eb874ffa558d65a548aee9b715b
+Bug-Debian: https://bugs.debian.org/883217
+
+Eliminate an unneeded "flock" variable. We can use "fl" as a loop cursor
+everywhere. Add a any_leases_conflict helper function as well to
+consolidate a bit of code.
+
+Signed-off-by: Jeff Layton <jlayton at primarydata.com>
+Reviewed-by: Christoph Hellwig <hch at lst.de>
+[carnil: backport for 3.16:
+ - adjust context
+]
+---
+ fs/locks.c | 49 +++++++++++++++++++++++++------------------------
+ 1 file changed, 25 insertions(+), 24 deletions(-)
+
+--- a/fs/locks.c
++++ b/fs/locks.c
+@@ -1307,6 +1307,20 @@ static bool leases_conflict(struct file_
+ return locks_conflict(breaker, lease);
+ }
+
++static bool
++any_leases_conflict(struct inode *inode, struct file_lock *breaker)
++{
++ struct file_lock *fl;
++
++ lockdep_assert_held(&inode->i_lock);
++
++ for (fl = inode->i_flock ; fl && IS_LEASE(fl); fl = fl->fl_next) {
++ if (leases_conflict(fl, breaker))
++ return true;
++ }
++ return false;
++}
++
+ /**
+ * __break_lease - revoke all outstanding leases on file
+ * @inode: the inode of the file to return
+@@ -1323,10 +1337,9 @@ static bool leases_conflict(struct file_
+ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
+ {
+ int error = 0;
+- struct file_lock *new_fl, *flock;
++ struct file_lock *new_fl;
+ struct file_lock *fl;
+ unsigned long break_time;
+- bool lease_conflict = false;
+ int want_write = (mode & O_ACCMODE) != O_RDONLY;
+
+ new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK);
+@@ -1338,17 +1351,7 @@ int __break_lease(struct inode *inode, u
+
+ time_out_leases(inode);
+
+- flock = inode->i_flock;
+- if ((flock == NULL) || !IS_LEASE(flock))
+- goto out;
+-
+- for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next) {
+- if (leases_conflict(fl, new_fl)) {
+- lease_conflict = true;
+- break;
+- }
+- }
+- if (!lease_conflict)
++ if (!any_leases_conflict(inode, new_fl))
+ goto out;
+
+ break_time = 0;
+@@ -1358,7 +1361,7 @@ int __break_lease(struct inode *inode, u
+ break_time++; /* so that 0 means no break time */
+ }
+
+- for (fl = flock; fl && IS_LEASE(fl); fl = fl->fl_next) {
++ for (fl = inode->i_flock; fl && IS_LEASE(fl); fl = fl->fl_next) {
+ if (!leases_conflict(fl, new_fl))
+ continue;
+ if (want_write) {
+@@ -1367,7 +1370,7 @@ int __break_lease(struct inode *inode, u
+ fl->fl_flags |= FL_UNLOCK_PENDING;
+ fl->fl_break_time = break_time;
+ } else {
+- if (lease_breaking(flock))
++ if (lease_breaking(inode->i_flock))
+ continue;
+ fl->fl_flags |= FL_DOWNGRADE_PENDING;
+ fl->fl_downgrade_time = break_time;
+@@ -1382,12 +1385,12 @@ int __break_lease(struct inode *inode, u
+ }
+
+ restart:
+- break_time = flock->fl_break_time;
++ break_time = inode->i_flock->fl_break_time;
+ if (break_time != 0)
+ break_time -= jiffies;
+ if (break_time == 0)
+ break_time++;
+- locks_insert_block(flock, new_fl);
++ locks_insert_block(inode->i_flock, new_fl);
+ trace_break_lease_block(inode, new_fl);
+ spin_unlock(&inode->i_lock);
+ error = wait_event_interruptible_timeout(new_fl->fl_wait,
+@@ -1396,17 +1399,15 @@ restart:
+ trace_break_lease_unblock(inode, new_fl);
+ locks_delete_block(new_fl);
+ if (error >= 0) {
+- if (error == 0)
+- time_out_leases(inode);
+ /*
+ * Wait for the next conflicting lease that has not been
+ * broken yet
+ */
+- for (flock = inode->i_flock; flock && IS_LEASE(flock);
+- flock = flock->fl_next) {
+- if (leases_conflict(new_fl, flock))
+- goto restart;
+- }
++ if (error == 0)
++ time_out_leases(inode);
++ if (any_leases_conflict(inode, new_fl))
++ goto restart;
++
+ error = 0;
+ }
+
diff --git a/debian/patches/series b/debian/patches/series
index e8686b5..780dbf9 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -255,6 +255,7 @@ bugfix/all/sched-topology-remove-force_sd_overlap.patch
bugfix/all/sched-topology-simplify-build_overlap_sched_groups.patch
bugfix/all/sched-topology-optimize-build_group_mask.patch
bugfix/all/locks-remove-i_have_this_lease-check-from-__break_le.patch
+bugfix/all/locks-__break_lease-cleanup-in-preparation-of-allowi.patch
# memfd_create() & kdbus backport
features/all/kdbus/mm-allow-drivers-to-prevent-new-writable-mappings.patch
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/kernel/linux.git
More information about the Kernel-svn-changes
mailing list