Re: [PATCH 2/4] Use f_lock to protect f_flags

From: Christoph Hellwig
Date: Sun Feb 08 2009 - 04:03:22 EST


On Sat, Feb 07, 2009 at 01:06:55PM -0700, Jonathan Corbet wrote:
> Traditionally, changes to struct file->f_flags have been done under BKL
> protection, or with no protection at all. This patch causes all f_flags
> changes after file open/creation time to be done under protection of
> f_lock. This allows the removal of some BKL usage and fixes a number of
> longstanding (if microscopic) races.

Looks good to me.


Reviewed-by: Christoph Hellwig <hch@xxxxxx>

One comments only tangentially related to the patch:


> diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
> index bc84e12..224f271 100644
> --- a/drivers/char/tty_io.c
> +++ b/drivers/char/tty_io.c
> @@ -2162,13 +2162,12 @@ static int fionbio(struct file *file, int __user *p)
> if (get_user(nonblock, p))
> return -EFAULT;
>
> - /* file->f_flags is still BKL protected in the fs layer - vomit */
> - lock_kernel();
> + spin_lock(&file->f_lock);
> if (nonblock)
> file->f_flags |= O_NONBLOCK;
> else
> file->f_flags &= ~O_NONBLOCK;
> - unlock_kernel();
> + spin_unlock(&file->f_lock);
> return 0;
> }

Why is this code there at all? It's a duplicate of
fs/ioctl.c:ioctl_fionbio minus the sparc special case, and from looking
at the flow in fs/ioctl.c I'm pretty sure FIONBIO never gets handed to
the chardev ioctl methods..

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/