All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/8] locks: make flock_lock_file take is_conflict callback parm
@ 2013-01-17 16:52 ` Pavel Shilovsky
  0 siblings, 0 replies; 32+ messages in thread
From: Pavel Shilovsky @ 2013-01-17 16:52 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA,
	wine-devel-5vRYHf7vrtgdnm+yROfE0A

This parm demetermines how to check if locks have conflicts.
This let us use flock_lock_file funtions further to add
O_DENY* flags support through flocks.

Signed-off-by: Pavel Shilovsky <piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
---
 fs/locks.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index a94e331..9edfec4 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -697,14 +697,20 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
 	return 0;
 }
 
-/* Try to create a FLOCK lock on filp. We always insert new FLOCK locks
+/*
+ * Try to create a FLOCK lock on filp. We always insert new FLOCK locks
  * after any leases, but before any posix locks.
  *
  * Note that if called with an FL_EXISTS argument, the caller may determine
  * whether or not a lock was successfully freed by testing the return
  * value for -ENOENT.
+ *
+ * Take @is_conflict callback that determines how to check if locks have
+ * conflicts or not.
  */
-static int flock_lock_file(struct file *filp, struct file_lock *request)
+static int
+flock_lock_file(struct file *filp, struct file_lock *request,
+		int (*is_conflict)(struct file_lock *, struct file_lock *))
 {
 	struct file_lock *new_fl = NULL;
 	struct file_lock **before;
@@ -760,7 +766,7 @@ find_conflict:
 			break;
 		if (IS_LEASE(fl))
 			continue;
-		if (!flock_locks_conflict(request, fl))
+		if (!is_conflict(request, fl))
 			continue;
 		error = -EAGAIN;
 		if (!(request->fl_flags & FL_SLEEP))
@@ -1589,7 +1595,7 @@ int flock_lock_file_wait(struct file *filp, struct file_lock *fl)
 	int error;
 	might_sleep();
 	for (;;) {
-		error = flock_lock_file(filp, fl);
+		error = flock_lock_file(filp, fl, flock_locks_conflict);
 		if (error != FILE_LOCK_DEFERRED)
 			break;
 		error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);
-- 
1.8.1.1

^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2013-02-07 17:03 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-17 16:52 [PATCH v2 1/8] locks: make flock_lock_file take is_conflict callback parm Pavel Shilovsky
2013-01-17 16:52 ` Pavel Shilovsky
2013-01-17 16:52 ` [PATCH v2 2/8] fcntl: Introduce new O_DENY* open flags Pavel Shilovsky
2013-01-17 16:52 ` [PATCH v2 3/8] vfs: Add O_DENYREAD/WRITE flags support for open syscall Pavel Shilovsky
     [not found]   ` <1358441584-8783-3-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2013-01-30 22:16     ` J. Bruce Fields
2013-01-30 22:16       ` J. Bruce Fields
     [not found]       ` <20130130221602.GC15584-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2013-02-05 11:45         ` Pavel Shilovsky
2013-02-05 11:45           ` Pavel Shilovsky
2013-02-05 14:35           ` J. Bruce Fields
2013-02-07  9:53             ` Pavel Shilovsky
     [not found]               ` <CAKywueS6oGNu9r_bypu32A89pOoiGb47kjXqw2ZcZQhZK+JV3g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-07 14:18                 ` J. Bruce Fields
2013-02-07 14:18                   ` J. Bruce Fields
     [not found]                   ` <20130207141832.GA3222-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2013-02-07 14:32                     ` Pavel Shilovsky
2013-02-07 14:32                       ` Pavel Shilovsky
     [not found]                       ` <CAKywueTmU_L5cwwJSoUY6753eHf_38VtHadZGt9tcLS59sqmOA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-07 14:41                         ` J. Bruce Fields
2013-02-07 14:41                           ` J. Bruce Fields
     [not found]                           ` <20130207144156.GB3222-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2013-02-07 16:00                             ` Pavel Shilovsky
2013-02-07 16:00                               ` Pavel Shilovsky
     [not found]                               ` <CAKywueShbPd9b+WmJwnfwPR_vzk_atBVRBZNTf-HpS7N2CK+AA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-02-07 16:19                                 ` J. Bruce Fields
2013-02-07 16:19                                   ` J. Bruce Fields
     [not found]                                   ` <20130207161948.GG3222-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2013-02-07 16:50                                     ` Pavel Shilovsky
2013-02-07 16:50                                       ` Pavel Shilovsky
2013-02-07 17:03                                       ` J. Bruce Fields
2013-01-17 16:53 ` [PATCH v2 4/8] CIFS: Add O_DENY* open flags support Pavel Shilovsky
     [not found]   ` <1358441584-8783-4-git-send-email-piastry-7qunaywFIewox3rIn2DAYQ@public.gmane.org>
2013-01-30 22:16     ` J. Bruce Fields
2013-01-30 22:16       ` J. Bruce Fields
     [not found]       ` <20130130221657.GD15584-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2013-02-05 11:54         ` Pavel Shilovsky
2013-02-05 11:54           ` Pavel Shilovsky
2013-01-17 16:53 ` [PATCH v2 5/8] CIFS: Use NT_CREATE_ANDX command for forcemand mounts Pavel Shilovsky
2013-01-17 16:53 ` [PATCH v2 6/8] CIFS: Translate SHARING_VIOLATION to -ETXTBSY error code for SMB2 Pavel Shilovsky
2013-01-17 16:53 ` [PATCH v2 7/8] NFSv4: Add O_DENY* open flags support Pavel Shilovsky
2013-01-17 16:53 ` [PATCH v2 8/8] NFSD: Pass share reservations flags to VFS Pavel Shilovsky

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.