2.5.5-pre1 fcntl_[gs]etlk* cleanup
Subsystems (2)
PATCH 1/1 2.5.5-pre1 fcntl_[gs]etlk* cleanup
Hi Linus,
The sys_fcntl() code does fget(fd) upon entry. Later during the F_GETLK, F_SETLK, F_GETLK64 and F_SETLK64 code paths, the fd is looked up again, rather than using the filp that is already known. AFAICT this is not necessary. The patch below addresses this.
- fcntl_getlk, fcntl_setlk, fcntl_setlk64, and fcntl_getlk64 now take filp
- collapse F_SETLK64 and F_SETLKW64 cases to one fall through case.
- removed unused -EINVAL assignment in fcntl_setlk and fcntl_setlk64
This patch compiles, boots and runs fine. Please consider applying.
thanks,
-chris
fs/fcntl.c +4 -6
@@ -296,11 +296,11 @@unlock_kernel ();break ;case F_GETLK : - err =fcntl_getlk (fd, (struct flock *) arg); + err =fcntl_getlk (filp, (struct flock *) arg);break ;case F_SETLK :case F_SETLKW : - err =fcntl_setlk (fd, cmd, (struct flock *) arg); + err =fcntl_setlk (filp, cmd, (struct flock *) arg);break ;case F_GETOWN :/*
@@ -382,13 +382,11 @@switch (cmd) {case F_GETLK64 : - err =fcntl_getlk64 (fd, (struct flock64 *) arg); + err =fcntl_getlk64 (filp, (struct flock64 *) arg);break ;case F_SETLK64 : - err =fcntl_setlk64 (fd, cmd, (struct flock64 *) arg); -break ;case F_SETLKW64 : - err =fcntl_setlk64 (fd, cmd, (struct flock64 *) arg); + err =fcntl_setlk64 (filp, cmd, (struct flock64 *) arg);break ;default : err =do_fcntl (fd, cmd, arg, filp);
fs/locks.c +29 -67
255 lines not on this page · raw message
include/linux/fs.h +4 -4
@@ -580,11 +580,11 @@#include <linux/fcntl.h> -extern int fcntl_getlk (unsigned int ,struct flock *); -extern int fcntl_setlk (unsigned int ,unsigned int ,struct flock *); +extern int fcntl_getlk (struct file *,struct flock *); +extern int fcntl_setlk (struct file *,unsigned int ,struct flock *); -extern int fcntl_getlk64 (unsigned int ,struct flock64 *); -extern int fcntl_setlk64 (unsigned int ,unsigned int ,struct flock64 *); +extern int fcntl_getlk64 (struct file *,struct flock64 *); +extern int fcntl_setlk64 (struct file *,unsigned int ,struct flock64 *);/* fs/locks.c */ extern void locks_init_lock (struct file_lock *);