Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
[cascardo/linux.git] / fs / locks.c
index ca272eb..af1ed74 100644 (file)
@@ -961,7 +961,8 @@ out:
        return error;
 }
 
-static int __posix_lock_file(struct inode *inode, struct file_lock *request, struct file_lock *conflock)
+static int posix_lock_inode(struct inode *inode, struct file_lock *request,
+                           struct file_lock *conflock)
 {
        struct file_lock *fl, *tmp;
        struct file_lock *new_fl = NULL;
@@ -1191,7 +1192,7 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request, str
 int posix_lock_file(struct file *filp, struct file_lock *fl,
                        struct file_lock *conflock)
 {
-       return __posix_lock_file(file_inode(filp), fl, conflock);
+       return posix_lock_inode(file_inode(filp), fl, conflock);
 }
 EXPORT_SYMBOL(posix_lock_file);
 
@@ -1207,7 +1208,7 @@ static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl)
        int error;
        might_sleep ();
        for (;;) {
-               error = __posix_lock_file(inode, fl, NULL);
+               error = posix_lock_inode(inode, fl, NULL);
                if (error != FILE_LOCK_DEFERRED)
                        break;
                error = wait_event_interruptible(fl->fl_wait, !fl->fl_next);
@@ -1257,20 +1258,16 @@ int locks_mandatory_locked(struct file *file)
 
 /**
  * locks_mandatory_area - Check for a conflicting lock
- * @read_write: %FLOCK_VERIFY_WRITE for exclusive access, %FLOCK_VERIFY_READ
- *             for shared
- * @inode:      the file to check
+ * @inode:     the file to check
  * @filp:       how the file was opened (if it was)
- * @offset:     start of area to check
- * @count:      length of area to check
+ * @start:     first byte in the file to check
+ * @end:       lastbyte in the file to check
+ * @type:      %F_WRLCK for a write lock, else %F_RDLCK
  *
  * Searches the inode's list of locks to find any POSIX locks which conflict.
- * This function is called from rw_verify_area() and
- * locks_verify_truncate().
  */
-int locks_mandatory_area(int read_write, struct inode *inode,
-                        struct file *filp, loff_t offset,
-                        size_t count)
+int locks_mandatory_area(struct inode *inode, struct file *filp, loff_t start,
+                        loff_t end, unsigned char type)
 {
        struct file_lock fl;
        int error;
@@ -1282,15 +1279,15 @@ int locks_mandatory_area(int read_write, struct inode *inode,
        fl.fl_flags = FL_POSIX | FL_ACCESS;
        if (filp && !(filp->f_flags & O_NONBLOCK))
                sleep = true;
-       fl.fl_type = (read_write == FLOCK_VERIFY_WRITE) ? F_WRLCK : F_RDLCK;
-       fl.fl_start = offset;
-       fl.fl_end = offset + count - 1;
+       fl.fl_type = type;
+       fl.fl_start = start;
+       fl.fl_end = end;
 
        for (;;) {
                if (filp) {
                        fl.fl_owner = filp;
                        fl.fl_flags &= ~FL_SLEEP;
-                       error = __posix_lock_file(inode, &fl, NULL);
+                       error = posix_lock_inode(inode, &fl, NULL);
                        if (!error)
                                break;
                }
@@ -1298,7 +1295,7 @@ int locks_mandatory_area(int read_write, struct inode *inode,
                if (sleep)
                        fl.fl_flags |= FL_SLEEP;
                fl.fl_owner = current->files;
-               error = __posix_lock_file(inode, &fl, NULL);
+               error = posix_lock_inode(inode, &fl, NULL);
                if (error != FILE_LOCK_DEFERRED)
                        break;
                error = wait_event_interruptible(fl.fl_wait, !fl.fl_next);