From: <gregkh@linuxfoundation.org>
To: jeff.layton@primarydata.com, bfields@fieldses.org,
gregkh@linuxfoundation.org, william@gandi.net
Cc: <stable@vger.kernel.org>, <stable-commits@vger.kernel.org>
Subject: Patch "locks: new helpers - flock_lock_inode_wait and posix_lock_inode_wait" has been added to the 4.1-stable tree
Date: Fri, 23 Oct 2015 10:42:02 -0700 [thread overview]
Message-ID: <144562212214440@kroah.com> (raw)
This is a note to let you know that I've just added the patch titled
locks: new helpers - flock_lock_inode_wait and posix_lock_inode_wait
to the 4.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
locks-new-helpers-flock_lock_inode_wait-and-posix_lock_inode_wait.patch
and it can be found in the queue-4.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.
>From 29d01b22eaa18d8b46091d3c98c6001c49f78e4a Mon Sep 17 00:00:00 2001
From: Jeff Layton <jeff.layton@primarydata.com>
Date: Sat, 11 Jul 2015 06:43:02 -0400
Subject: locks: new helpers - flock_lock_inode_wait and posix_lock_inode_wait
From: Jeff Layton <jeff.layton@primarydata.com>
commit 29d01b22eaa18d8b46091d3c98c6001c49f78e4a upstream.
Allow callers to pass in an inode instead of a filp.
Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Reviewed-by: "J. Bruce Fields" <bfields@fieldses.org>
Tested-by: "J. Bruce Fields" <bfields@fieldses.org>
Cc: William Dauchy <william@gandi.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/locks.c | 50 ++++++++++++++++++++++++++++++++++++++------------
include/linux/fs.h | 14 ++++++++++++++
2 files changed, 52 insertions(+), 12 deletions(-)
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1163,20 +1163,19 @@ int posix_lock_file(struct file *filp, s
EXPORT_SYMBOL(posix_lock_file);
/**
- * posix_lock_file_wait - Apply a POSIX-style lock to a file
- * @filp: The file to apply the lock to
+ * posix_lock_inode_wait - Apply a POSIX-style lock to a file
+ * @inode: inode of file to which lock request should be applied
* @fl: The lock to be applied
*
- * Add a POSIX style lock to a file.
- * We merge adjacent & overlapping locks whenever possible.
- * POSIX locks are sorted by owner task, then by starting address
+ * Variant of posix_lock_file_wait that does not take a filp, and so can be
+ * used after the filp has already been torn down.
*/
-int posix_lock_file_wait(struct file *filp, struct file_lock *fl)
+int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl)
{
int error;
might_sleep ();
for (;;) {
- error = posix_lock_file(filp, fl, NULL);
+ error = __posix_lock_file(inode, fl, NULL);
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);
@@ -1188,6 +1187,21 @@ int posix_lock_file_wait(struct file *fi
}
return error;
}
+EXPORT_SYMBOL(posix_lock_inode_wait);
+
+/**
+ * posix_lock_file_wait - Apply a POSIX-style lock to a file
+ * @filp: The file to apply the lock to
+ * @fl: The lock to be applied
+ *
+ * Add a POSIX style lock to a file.
+ * We merge adjacent & overlapping locks whenever possible.
+ * POSIX locks are sorted by owner task, then by starting address
+ */
+int posix_lock_file_wait(struct file *filp, struct file_lock *fl)
+{
+ return posix_lock_inode_wait(file_inode(filp), fl);
+}
EXPORT_SYMBOL(posix_lock_file_wait);
/**
@@ -1850,18 +1864,18 @@ int fcntl_setlease(unsigned int fd, stru
}
/**
- * flock_lock_file_wait - Apply a FLOCK-style lock to a file
- * @filp: The file to apply the lock to
+ * flock_lock_inode_wait - Apply a FLOCK-style lock to a file
+ * @inode: inode of the file to apply to
* @fl: The lock to be applied
*
- * Add a FLOCK style lock to a file.
+ * Apply a FLOCK style lock request to an inode.
*/
-int flock_lock_file_wait(struct file *filp, struct file_lock *fl)
+int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl)
{
int error;
might_sleep();
for (;;) {
- error = flock_lock_inode(file_inode(filp), fl);
+ error = flock_lock_inode(inode, fl);
if (error != FILE_LOCK_DEFERRED)
break;
error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);
@@ -1873,7 +1887,19 @@ int flock_lock_file_wait(struct file *fi
}
return error;
}
+EXPORT_SYMBOL(flock_lock_inode_wait);
+/**
+ * flock_lock_file_wait - Apply a FLOCK-style lock to a file
+ * @filp: The file to apply the lock to
+ * @fl: The lock to be applied
+ *
+ * Add a FLOCK style lock to a file.
+ */
+int flock_lock_file_wait(struct file *filp, struct file_lock *fl)
+{
+ return flock_lock_inode_wait(file_inode(filp), fl);
+}
EXPORT_SYMBOL(flock_lock_file_wait);
/**
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1036,11 +1036,13 @@ extern void locks_remove_file(struct fil
extern void locks_release_private(struct file_lock *);
extern void posix_test_lock(struct file *, struct file_lock *);
extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
+extern int posix_lock_inode_wait(struct inode *, struct file_lock *);
extern int posix_lock_file_wait(struct file *, struct file_lock *);
extern int posix_unblock_lock(struct file_lock *);
extern int vfs_test_lock(struct file *, struct file_lock *);
extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
+extern int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl);
extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
extern void lease_get_mtime(struct inode *, struct timespec *time);
@@ -1127,6 +1129,12 @@ static inline int posix_lock_file(struct
return -ENOLCK;
}
+static inline int posix_lock_inode_wait(struct inode *inode,
+ struct file_lock *fl)
+{
+ return -ENOLCK;
+}
+
static inline int posix_lock_file_wait(struct file *filp, struct file_lock *fl)
{
return -ENOLCK;
@@ -1153,6 +1161,12 @@ static inline int vfs_cancel_lock(struct
return 0;
}
+static inline int flock_lock_inode_wait(struct inode *inode,
+ struct file_lock *request)
+{
+ return -ENOLCK;
+}
+
static inline int flock_lock_file_wait(struct file *filp,
struct file_lock *request)
{
Patches currently in stable-queue which might be from jeff.layton@primarydata.com are
queue-4.1/locks-new-helpers-flock_lock_inode_wait-and-posix_lock_inode_wait.patch
queue-4.1/locks-have-flock_lock_file-take-an-inode-pointer-instead-of-a-filp.patch
queue-4.1/locks-inline-posix_lock_file_wait-and-flock_lock_file_wait.patch
queue-4.1/nfs4-have-do_vfs_lock-take-an-inode-pointer.patch
reply other threads:[~2015-10-23 17:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=144562212214440@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=bfields@fieldses.org \
--cc=jeff.layton@primarydata.com \
--cc=stable-commits@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=william@gandi.net \
/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.