vfs: don't treat fl_type as a bitmap
Subsystems (2)
PATCH 1/1 vfs: don't treat fl_type as a bitmap
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.
--- fs/locks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/locks.c +3 -3
@@ -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
Signature · 1 line
1.7.11.2
Quoted 8 lines · Jeff Layton
The rules for
fl_typeare rather convoluted. Typically it's treated as holding specific values, except in the case ofLOCK_MAND, in which case it can be or'ed with LOCK_READ|LOCK_WRITE.On some arches
F_WRLCK== 2 andF_UNLCK== 3, so and'ing withF_WRLCKwill also catch theF_UNLCKcase. It's unlikely in either case here that we'd ever seeF_UNLCKsince 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.
Quoted 37 lines
Signed-off-by Jeff Layton <[email protected]>--- fs/locks.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)fs/locks.c +3
-3@@ -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 Signature · 6 lines
1.7.11.2 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html