move BKL down a little in setfl
Subsystems (2)
PATCH 1/1 move BKL down a little in setfl
Nothing spectacular here, just push the BKL down a little.
fs/fcntl.c +15 -19
@@ -227,23 +227,15 @@ asmlinkage long sys_dup(unsigned int filstatic int setfl (int fd,struct file * filp,unsigned long arg) {struct inode * inode = filp->f_dentry->d_inode; -int error; -/* -* In the case of an append-only file, O_APPEND -* cannot be cleared -*/ +/* O_APPEND cannot be cleared if the file is marked as append-only */ if (!(arg &O_APPEND ) &&IS_APPEND (inode))return -EPERM ; -/* Did FASYNC state change? */ -if ((arg ^ filp->f_flags) &FASYNC ) { -if (filp->f_op && filp->f_op->fasync) { - error = filp->f_op->fasync (fd, filp, (arg &FASYNC ) !=0 ); -if (error <0 ) -return error; - } - } +/* required for strict SunOS emulation */ +if (O_NONBLOCK !=O_NDELAY ) +if (arg &O_NDELAY ) + arg |=O_NONBLOCK ;if (arg &O_DIRECT ) { if (!inode->i_mapping || !inode->i_mapping->a_ops ||
@@ -251,12 +243,18 @@ static int setfl(int fd, struct file * freturn -EINVAL ; } -/* required for strict SunOS emulation */ -if (O_NONBLOCK !=O_NDELAY ) -if (arg &O_NDELAY ) - arg |=O_NONBLOCK ; +lock_kernel (); +if ((arg ^ filp->f_flags) &FASYNC ) { +if (filp->f_op && filp->f_op->fasync) { +int error; + error = filp->f_op->fasync (fd, filp, (arg &FASYNC ) !=0 ); +if (error <0 ) +return error; + } + } filp->f_flags = (arg &SETFL_MASK ) | (filp->f_flags & ~SETFL_MASK ); +unlock_kernel ();return 0 ; }
@@ -283,9 +281,7 @@ static long do_fcntl(unsigned int fd, un err = filp->f_flags;break ;case F_SETFL : -lock_kernel (); err =setfl (fd, filp, arg); -unlock_kernel ();break ;case F_GETLK : err =fcntl_getlk (filp, (struct flock *) arg);
Signature · 1 line
Revolutions do not require corporate support.
Quoted 2 lines · Matthew Wilcox
Nothing spectacular here, just push the BKL down a little.
This exits with the BKL held, as far as I can tell:
fs/fcntl.c static int setfl(int fd, struct file * f · line 252
Quoted 7 lines
fs/fcntl.c +7
-0+lock_kernel (); +if ((arg ^ filp->f_flags) &FASYNC ) { +if (filp->f_op && filp->f_op->fasync) { +int error; + error = filp->f_op->fasync (fd, filp, (arg &FASYNC ) !=0 ); +if (error <0 ) +return error;
^^^^^^^^^^^^
Here.
Linus
Quoted 1 line · Linus Torvalds
This exits with the BKL held, as far as I can tell:
duh, you're right. here's a fixed patch:
fs/fcntl.c +17 -20
@@ -227,23 +227,16 @@ asmlinkage long sys_dup(unsigned int filstatic int setfl (int fd,struct file * filp,unsigned long arg) {struct inode * inode = filp->f_dentry->d_inode; -int error; +int error =0 ; -/* -* In the case of an append-only file, O_APPEND -* cannot be cleared -*/ +/* O_APPEND cannot be cleared if the file is marked as append-only */ if (!(arg &O_APPEND ) &&IS_APPEND (inode))return -EPERM ; -/* Did FASYNC state change? */ -if ((arg ^ filp->f_flags) &FASYNC ) { -if (filp->f_op && filp->f_op->fasync) { - error = filp->f_op->fasync (fd, filp, (arg &FASYNC ) !=0 ); -if (error <0 ) -return error; - } - } +/* required for strict SunOS emulation */ +if (O_NONBLOCK !=O_NDELAY ) +if (arg &O_NDELAY ) + arg |=O_NONBLOCK ;if (arg &O_DIRECT ) { if (!inode->i_mapping || !inode->i_mapping->a_ops ||
@@ -251,13 +244,19 @@ static int setfl(int fd, struct file * freturn -EINVAL ; } -/* required for strict SunOS emulation */ -if (O_NONBLOCK !=O_NDELAY ) -if (arg &O_NDELAY ) - arg |=O_NONBLOCK ; +lock_kernel (); +if ((arg ^ filp->f_flags) &FASYNC ) { +if (filp->f_op && filp->f_op->fasync) { + error = filp->f_op->fasync (fd, filp, (arg &FASYNC ) !=0 ); +if (error <0 ) + goto out; + } + } filp->f_flags = (arg &SETFL_MASK ) | (filp->f_flags & ~SETFL_MASK ); -return 0 ; + out: +unlock_kernel (); +return error; } static long do_fcntl(unsigned int fd, unsigned int cmd,
@@ -283,9 +282,7 @@ static long do_fcntl(unsigned int fd, un err = filp->f_flags;break ;case F_SETFL : -lock_kernel (); err =setfl (fd, filp, arg); -unlock_kernel ();break ;case F_GETLK : err =fcntl_getlk (filp, (struct flock *) arg);
Signature · 1 line
Revolutions do not require corporate support.