return error;
 }
 
+/**
+ * vfs_test_lock - test file byte range lock
+ * @filp: The file to test lock for
+ * @fl: The lock to test
+ * @conf: Place to return a copy of the conflicting lock, if found
+ *
+ * Returns -ERRNO on failure.  Indicates presence of conflicting lock by
+ * setting conf->fl_type to something other than F_UNLCK.
+ */
+int vfs_test_lock(struct file *filp, struct file_lock *fl)
+{
+       if (filp->f_op && filp->f_op->lock)
+               return filp->f_op->lock(filp, F_GETLK, fl);
+       posix_test_lock(filp, fl);
+       return 0;
+}
+EXPORT_SYMBOL_GPL(vfs_test_lock);
+
 static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
 {
        flock->l_pid = fl->fl_pid;
        if (error)
                goto out;
 
-       if (filp->f_op && filp->f_op->lock) {
-               error = filp->f_op->lock(filp, F_GETLK, &file_lock);
-               if (error < 0)
-                       goto out;
-       } else
-               posix_test_lock(filp, &file_lock);
+       error = vfs_test_lock(filp, &file_lock);
+       if (error)
+               goto out;
  
        flock.l_type = file_lock.fl_type;
        if (file_lock.fl_type != F_UNLCK) {
        if (error)
                goto out;
 
-       if (filp->f_op && filp->f_op->lock) {
-               error = filp->f_op->lock(filp, F_GETLK, &file_lock);
-               if (error < 0)
-                       goto out;
-       } else
-               posix_test_lock(filp, &file_lock);
- 
+       error = vfs_test_lock(filp, &file_lock);
+       if (error)
+               goto out;
+
        flock.l_type = file_lock.fl_type;
        if (file_lock.fl_type != F_UNLCK)
                posix_lock_to_flock64(&flock, &file_lock);
 
 extern int posix_lock_file(struct file *, struct file_lock *);
 extern int posix_lock_file_wait(struct file *, struct file_lock *);
 extern int posix_unblock_lock(struct file *, struct file_lock *);
+extern int vfs_test_lock(struct file *, struct file_lock *);
 extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
 extern int __break_lease(struct inode *inode, unsigned int flags);
 extern void lease_get_mtime(struct inode *, struct timespec *time);