linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vfs: don't treat fl_type as a bitmap
@ 2012-08-02 19:46 Jeff Layton
  2012-08-03 23:59 ` J. Bruce Fields
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Layton @ 2012-08-02 19:46 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel

The rules for fl_type are rather convoluted. Typically it's treated as
holding specific values, except in the case of LOCK_MAND, in which case
it can be or'ed with LOCK_READ|LOCK_WRITE.

On some arches F_WRLCK == 2 and F_UNLCK == 3, so and'ing with F_WRLCK will also
catch the F_UNLCK case. It's unlikely in either case here that we'd ever see
F_UNLCK since those shouldn't end up on any lists, but it's still best to be
consistent.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 fs/locks.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index cdcf219..6c92264 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1293,7 +1293,7 @@ EXPORT_SYMBOL(__break_lease);
 void lease_get_mtime(struct inode *inode, struct timespec *time)
 {
 	struct file_lock *flock = inode->i_flock;
-	if (flock && IS_LEASE(flock) && (flock->fl_type & F_WRLCK))
+	if (flock && IS_LEASE(flock) && (flock->fl_type == F_WRLCK))
 		*time = current_fs_time(inode->i_sb);
 	else
 		*time = inode->i_mtime;
@@ -2191,8 +2191,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
 	} else {
 		seq_printf(f, "%s ",
 			       (lease_breaking(fl))
-			       ? (fl->fl_type & F_UNLCK) ? "UNLCK" : "READ "
-			       : (fl->fl_type & F_WRLCK) ? "WRITE" : "READ ");
+			       ? (fl->fl_type == F_UNLCK) ? "UNLCK" : "READ "
+			       : (fl->fl_type == F_WRLCK) ? "WRITE" : "READ ");
 	}
 	if (inode) {
 #ifdef WE_CAN_BREAK_LSLK_NOW
-- 
1.7.11.2


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

* Re: [PATCH] vfs: don't treat fl_type as a bitmap
  2012-08-02 19:46 [PATCH] vfs: don't treat fl_type as a bitmap Jeff Layton
@ 2012-08-03 23:59 ` J. Bruce Fields
  0 siblings, 0 replies; 2+ messages in thread
From: J. Bruce Fields @ 2012-08-03 23:59 UTC (permalink / raw)
  To: Jeff Layton; +Cc: viro, linux-fsdevel

On Thu, Aug 02, 2012 at 03:46:30PM -0400, Jeff Layton wrote:
> The rules for fl_type are rather convoluted. Typically it's treated as
> holding specific values, except in the case of LOCK_MAND, in which case
> it can be or'ed with LOCK_READ|LOCK_WRITE.
> 
> On some arches F_WRLCK == 2 and F_UNLCK == 3, so and'ing with F_WRLCK will also
> catch the F_UNLCK case. It's unlikely in either case here that we'd ever see
> F_UNLCK since those shouldn't end up on any lists, but it's still best to be
> consistent.

Looks good to me--ACK.

(Also ran this through my lease tests just to make sure.)

--b.

> 
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
> ---
>  fs/locks.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/locks.c b/fs/locks.c
> index cdcf219..6c92264 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1293,7 +1293,7 @@ EXPORT_SYMBOL(__break_lease);
>  void lease_get_mtime(struct inode *inode, struct timespec *time)
>  {
>  	struct file_lock *flock = inode->i_flock;
> -	if (flock && IS_LEASE(flock) && (flock->fl_type & F_WRLCK))
> +	if (flock && IS_LEASE(flock) && (flock->fl_type == F_WRLCK))
>  		*time = current_fs_time(inode->i_sb);
>  	else
>  		*time = inode->i_mtime;
> @@ -2191,8 +2191,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
>  	} else {
>  		seq_printf(f, "%s ",
>  			       (lease_breaking(fl))
> -			       ? (fl->fl_type & F_UNLCK) ? "UNLCK" : "READ "
> -			       : (fl->fl_type & F_WRLCK) ? "WRITE" : "READ ");
> +			       ? (fl->fl_type == F_UNLCK) ? "UNLCK" : "READ "
> +			       : (fl->fl_type == F_WRLCK) ? "WRITE" : "READ ");
>  	}
>  	if (inode) {
>  #ifdef WE_CAN_BREAK_LSLK_NOW
> -- 
> 1.7.11.2
> 
> --
> 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

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

end of thread, other threads:[~2012-08-03 23:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-02 19:46 [PATCH] vfs: don't treat fl_type as a bitmap Jeff Layton
2012-08-03 23:59 ` J. Bruce Fields

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).