xfs
[Top] [All Lists]

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

To: Takashi Sato <t-sato@xxxxxxxxxxxxx>
Subject: Re: [RFC PATCH 1/3] Implement generic freeze feature
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Mon, 28 Apr 2008 06:37:19 -0400
Cc: "linux-ext4@xxxxxxxxxxxxxxx" <linux-ext4@xxxxxxxxxxxxxxx>, "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>, "dm-devel@xxxxxxxxxx" <dm-devel@xxxxxxxxxx>, "linux-fsdevel@xxxxxxxxxxxxxxx" <linux-fsdevel@xxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>
In-reply-to: <20080428193123t-sato@mail.jp.nec.com>
References: <20080428193123t-sato@mail.jp.nec.com>
Sender: xfs-bounce@xxxxxxxxxxx
User-agent: Mutt/1.5.17 (2007-11-01)
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.


<Prev in Thread] Current Thread [Next in Thread>