Re: [RFC PATCH 1/3] Implement generic freeze feature

Christoph Hellwig
2008-04-28T10:37:33Z

On Mon, Apr 28, 2008 at 07:31:23PM +0900, Takashi Sato wrote:
> + /* Initialize semaphore for freeze. */
> + sema_init(&bdev->bd_freeze_sem, 1);

The freezing process is already protected by bd_mount_sem, so I don't
think there's need for another one.

> --- linux-2.6.25.org/fs/buffer.c 2008-04-17 11:49:44.000000000 +0900
> +++ linux-2.6.25-freeze/fs/buffer.c 2008-04-24 20:43:28.000000000 +0900
> @@ -201,6 +201,19 @@ struct super_block *freeze_bdev(struct b
> {
> struct super_block *sb;
>
> + down(&bdev->bd_freeze_sem);
> + sb = get_super_without_lock(bdev);
> +
> + /* If super_block has been already frozen, return. */
> + if (sb && sb->s_frozen != SB_UNFROZEN) {
> + put_super(sb);
> + up(&bdev->bd_freeze_sem);
> + return sb;
> + }
> +
> + if (sb)
> + put_super(sb);
> +
> down(&bdev->bd_mount_sem);
> sb = get_super(bdev);

I think the protection against double freezes would be better done by
using a trylock on bd_mount_sem. In fact after that it could be changed
from a semaphore to a simple test_and_set_bit.
> error = -ENOTTY;
> break;
> +
> + case FIFREEZE: {

This would be better to split intot a small helper ala ioctl_fibmap()

> + case FITHAW: {

Same here.