linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (unknown)
@ 2006-06-13 19:01 Jason Baron
  2006-06-13 19:29 ` (unknown), William A.(Andy) Adamson
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Baron @ 2006-06-13 19:01 UTC (permalink / raw)
  To: matthew; +Cc: linux-fsdevel, jlayton


Hi,

If one tries to do a fcntl(fd, F_SETLEASE, F_RDLCK) on a file that is open 
for writing, the error returned is always -EAGAIN. This seems like the 
wrong error return for the case where 'fd' points to a file_struct that 
has FMODE_WRITE set. No matter how many times one calls the fcntl on that 
'fd' it will fail. Therefore, i think the return value should be -EINVAL 
in this case. The patch below implements this behavior. Some more context 
for this issue can be found at: http://lkml.org/lkml/2005/5/2/20. Patch is 
based on a suggestion from Jeff Layton.

thanks,

-Jason

Signed-off-by: Jason Baron <jbaron@redhat.com>


--- linux-2.6/fs/locks.c.bak	2006-06-13 10:36:58.000000000 -0400
+++ linux-2.6/fs/locks.c	2006-06-13 10:41:19.000000000 -0400
@@ -1338,8 +1338,11 @@
 	lease = *flp;
 
 	error = -EAGAIN;
-	if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
+	if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0)) {
+		if (filp->f_mode & FMODE_WRITE)
+			error = -EINVAL;
 		goto out;
+	}
 	if ((arg == F_WRLCK)
 	    && ((atomic_read(&dentry->d_count) > 1)
 		|| (atomic_read(&inode->i_count) > 1)))

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

end of thread, other threads:[~2006-06-14 15:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-13 19:01 (unknown) Jason Baron
2006-06-13 19:29 ` (unknown), William A.(Andy) Adamson
2006-06-13 19:35   ` setlease return code Jason Baron
2006-06-13 20:09     ` William A.(Andy) Adamson
2006-06-14 15:20       ` Jason Baron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).