Эх сурвалжийг харах

locks: make posix_test_lock() interface more consistent

Since posix_test_lock(), like fcntl() and ->lock(), indicates absence or
presence of a conflict lock by setting fl_type to, respectively, F_UNLCK
or something other than F_UNLCK, the return value is no longer needed.

Signed-off-by: "J. Bruce Fields" <bfields@citi.umich.edu>
J. Bruce Fields 18 жил өмнө
parent
commit
6d34ac199a

+ 4 - 6
fs/locks.c

@@ -659,7 +659,7 @@ static int locks_block_on_timeout(struct file_lock *blocker, struct file_lock *w
 	return result;
 	return result;
 }
 }
 
 
-int
+void
 posix_test_lock(struct file *filp, struct file_lock *fl)
 posix_test_lock(struct file *filp, struct file_lock *fl)
 {
 {
 	struct file_lock *cfl;
 	struct file_lock *cfl;
@@ -671,14 +671,12 @@ posix_test_lock(struct file *filp, struct file_lock *fl)
 		if (posix_locks_conflict(cfl, fl))
 		if (posix_locks_conflict(cfl, fl))
 			break;
 			break;
 	}
 	}
-	if (cfl) {
+	if (cfl)
 		__locks_copy_lock(fl, cfl);
 		__locks_copy_lock(fl, cfl);
-		unlock_kernel();
-		return 1;
-	} else
+	else
 		fl->fl_type = F_UNLCK;
 		fl->fl_type = F_UNLCK;
 	unlock_kernel();
 	unlock_kernel();
-	return 0;
+	return;
 }
 }
 
 
 EXPORT_SYMBOL(posix_test_lock);
 EXPORT_SYMBOL(posix_test_lock);

+ 3 - 1
fs/nfs/file.c

@@ -402,7 +402,9 @@ static int do_getlk(struct file *filp, int cmd, struct file_lock *fl)
 
 
 	lock_kernel();
 	lock_kernel();
 	/* Try local locking first */
 	/* Try local locking first */
-	if (posix_test_lock(filp, fl)) {
+	posix_test_lock(filp, fl);
+	if (fl->fl_type != F_UNLCK) {
+		/* found a conflict */
 		goto out;
 		goto out;
 	}
 	}
 
 

+ 1 - 1
include/linux/fs.h

@@ -862,7 +862,7 @@ extern void locks_init_lock(struct file_lock *);
 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
 extern void locks_copy_lock(struct file_lock *, struct file_lock *);
 extern void locks_remove_posix(struct file *, fl_owner_t);
 extern void locks_remove_posix(struct file *, fl_owner_t);
 extern void locks_remove_flock(struct file *);
 extern void locks_remove_flock(struct file *);
-extern int posix_test_lock(struct file *, 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_file(struct file *, struct file_lock *, struct file_lock *);
 extern int posix_lock_file_wait(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 posix_unblock_lock(struct file *, struct file_lock *);