fl_owner_t cleanup
Subsystems (2)
fl_owner_t has been an opaque cookie for a long time, change the typedef to a void pointer, and clean up the core locks code to remove pointless casts. In the next cycle we can also clean up the various users and eventually remove the typedef.
PATCH 1/2 locks: typedef fl_owner_t to void *
fl_owner_t is a cookie that can store all kinds of different pointers, so don't pretends it points to a file structure.
For now just change the typedef, but as a follow on this will allow to get rids of lots of casts and eventually the typedef itself.
--- include/linux/fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/fs.h +1 -1
@@ -833,7 +833,7 @@ static inline struct file *get_file(struct file *f)* * Lockd stuffs a "host" pointer into this. */ -typedef struct files_struct *fl_owner_t ; +typedef void *fl_owner_t ;struct file_lock_operations {void (*fl_copy_lock)(struct file_lock *,struct file_lock *);
Signature · 1 line
1.9.1
PATCH 2/2 locks: purge fl_owner_t from fs/locks.c
In reply to Christoph Hellwig--- fs/locks.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
fs/locks.c +13 -13
@@ -325,7 +325,7 @@ static int flock_make_lock(struct file *filp, struct file_lock **lock,return -ENOMEM ; fl->fl_file = filp; - fl->fl_owner = (fl_owner_t )filp; + fl->fl_owner = filp; fl->fl_pid = current->tgid; fl->fl_flags =FL_FLOCK ; fl->fl_type = type;
@@ -431,7 +431,7 @@ static int lease_init(struct file *filp, long type, struct file_lock *fl)if (assign_type (fl, type) !=0 )return -EINVAL ; - fl->fl_owner = (fl_owner_t )current->files; + fl->fl_owner = current->files; fl->fl_pid = current->tgid; fl->fl_file = filp;
@@ -1155,7 +1155,6 @@ EXPORT_SYMBOL(posix_lock_file_wait);int locks_mandatory_locked (struct file *file) {struct inode *inode =file_inode (file); -fl_owner_t owner = current->files;struct file_lock *fl;/*
@@ -1165,7 +1164,8 @@ int locks_mandatory_locked(struct file *file)for (fl = inode->i_flock; fl !=NULL ; fl = fl->fl_next) {if (!IS_POSIX (fl))continue ; -if (fl->fl_owner != owner && fl->fl_owner != (fl_owner_t )file) +if (fl->fl_owner != current->files && + fl->fl_owner != file)break ; }spin_unlock (&inode->i_lock);
@@ -1205,7 +1205,7 @@ int locks_mandatory_area(int read_write, struct inode *inode,for (;;) {if (filp) { - fl.fl_owner = (fl_owner_t )filp; + fl.fl_owner = filp; fl.fl_flags &= ~FL_SLEEP ; error =__posix_lock_file (inode, &fl,NULL );if (!error)
@@ -1974,7 +1974,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l) cmd =F_GETLK ; file_lock.fl_flags |=FL_OFDLCK ; - file_lock.fl_owner = (fl_owner_t )filp; + file_lock.fl_owner = filp; } error =vfs_test_lock (filp, &file_lock);
@@ -2129,7 +2129,7 @@ again: cmd =F_SETLK ; file_lock->fl_flags |=FL_OFDLCK ; - file_lock->fl_owner = (fl_owner_t )filp; + file_lock->fl_owner = filp;break ;case F_OFD_SETLKW : error = -EINVAL ;
@@ -2138,7 +2138,7 @@ again: cmd =F_SETLKW ; file_lock->fl_flags |=FL_OFDLCK ; - file_lock->fl_owner = (fl_owner_t )filp; + file_lock->fl_owner = filp;/* Fallthrough */ case F_SETLKW : file_lock->fl_flags |=FL_SLEEP ;
@@ -2196,7 +2196,7 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l) cmd =F_GETLK64 ; file_lock.fl_flags |=FL_OFDLCK ; - file_lock.fl_owner = (fl_owner_t )filp; + file_lock.fl_owner = filp; } error =vfs_test_lock (filp, &file_lock);
@@ -2268,7 +2268,7 @@ again: cmd =F_SETLK64 ; file_lock->fl_flags |=FL_OFDLCK ; - file_lock->fl_owner = (fl_owner_t )filp; + file_lock->fl_owner = filp;break ;case F_OFD_SETLKW : error = -EINVAL ;
@@ -2277,7 +2277,7 @@ again: cmd =F_SETLKW64 ; file_lock->fl_flags |=FL_OFDLCK ; - file_lock->fl_owner = (fl_owner_t )filp; + file_lock->fl_owner = filp;/* Fallthrough */ case F_SETLKW64 : file_lock->fl_flags |=FL_SLEEP ;
@@ -2350,11 +2350,11 @@ void locks_remove_file(struct file *filp)if (!inode->i_flock)return ; -locks_remove_posix (filp, (fl_owner_t )filp); +locks_remove_posix (filp, filp);if (filp->f_op->flock) {struct file_lock fl = { - .fl_owner = (fl_owner_t )filp, + .fl_owner = filp, .fl_pid = current->tgid, .fl_file = filp, .fl_flags =FL_FLOCK ,
Signature · 1 line
1.9.1
Quoted 5 lines · On Sun, 13 Jul 2014 17:00:36 +0200 Christoph Hellwig <[email protected]> wrote:
fl_owner_thas been an opaque cookie for a long time, change the typedef to a void pointer, and clean up the core locks code to remove pointless casts. In the next cycle we can also clean up the various users and eventually remove the typedef.
Looks good to me. Thanks for getting this started. Merged into my linux-next branch for eventual merge into 3.17.
Signature · 1 line
Jeff Layton <[email protected]>