From mboxrd@z Thu Jan 1 00:00:00 1970 From: "William A.(Andy) Adamson" Subject: (unknown) Date: Tue, 13 Jun 2006 15:29:51 -0400 Message-ID: <20060613192951.950751BD8B@citi.umich.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: matthew@wil.cx, linux-fsdevel@vger.kernel.org, jlayton@redhat.com, andros@citi.umich.edu Return-path: Received: from citi.umich.edu ([141.211.133.111]:2873 "EHLO citi.umich.edu") by vger.kernel.org with ESMTP id S1751181AbWFMT3w (ORCPT ); Tue, 13 Jun 2006 15:29:52 -0400 To: Jason Baron Subject: In-reply-to: Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org hi. from man fcntl EACCES or EAGAIN Operation is prohibited by locks held by other processes. Or, operation is prohibited because the file has been memory-mapped by another process. a process with file open for writing is essentially holding a lock WRT allowing a read lease, so i think EAGAIN is the appropriate error. again from man fcntl EINVAL For F_DUPFD, arg is negative or is greater than the maximum allowable value. For F_SETSIG, arg is not an allowable signal number. the arguments to the fcntl setlease call are correct, not invalid, so this is the wrong error. -->Andy > 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 > > > --- 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))) > - > To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html