* [PATCH] update sb->s_frozen when freezing read-only mounted device, too
@ 2007-09-29 10:09 Akinobu Mita
2007-10-04 20:20 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2007-09-29 10:09 UTC (permalink / raw)
To: linux-kernel; +Cc: xfs, Tim Shimmin, Christoph Hellwig
freeze_bdev() with the device which is mounted as read only
does not change sb->s_frozen from SB_UNFROZEN to SB_FREEZE_TRANS.
Because of this behavior, xfs_freeze can break read-only XFS filesystem.
Because xfs_thaw does nothing for the filesystem whose sb->s_frozen is
SB_UNFROZEN. So freezed readonly XFS filesystem will never be unfreezed.
Then we cannot do any unmount/remount operations for that filesystem.
This patch updates sb->s_frozen when freeze_bdev() is called for read-only
mounted device, too.
Cc: Tim Shimmin <xfs-masters@oss.sgi.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
fs/buffer.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
Index: 2.6-git/fs/buffer.c
===================================================================
--- 2.6-git.orig/fs/buffer.c
+++ 2.6-git/fs/buffer.c
@@ -190,19 +190,22 @@ struct super_block *freeze_bdev(struct b
down(&bdev->bd_mount_sem);
sb = get_super(bdev);
- if (sb && !(sb->s_flags & MS_RDONLY)) {
+ if (sb) {
sb->s_frozen = SB_FREEZE_WRITE;
smp_wmb();
- __fsync_super(sb);
+ if (!(sb->s_flags & MS_RDONLY))
+ __fsync_super(sb);
sb->s_frozen = SB_FREEZE_TRANS;
smp_wmb();
- sync_blockdev(sb->s_bdev);
+ if (!(sb->s_flags & MS_RDONLY)) {
+ sync_blockdev(sb->s_bdev);
- if (sb->s_op->write_super_lockfs)
- sb->s_op->write_super_lockfs(sb);
+ if (sb->s_op->write_super_lockfs)
+ sb->s_op->write_super_lockfs(sb);
+ }
}
sync_blockdev(bdev);
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] update sb->s_frozen when freezing read-only mounted device, too
2007-09-29 10:09 [PATCH] update sb->s_frozen when freezing read-only mounted device, too Akinobu Mita
@ 2007-10-04 20:20 ` Christoph Hellwig
2007-10-05 13:20 ` Akinobu Mita
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2007-10-04 20:20 UTC (permalink / raw)
To: Akinobu Mita, linux-kernel, xfs, Tim Shimmin, Christoph Hellwig
On Sat, Sep 29, 2007 at 07:09:12PM +0900, Akinobu Mita wrote:
> freeze_bdev() with the device which is mounted as read only
> does not change sb->s_frozen from SB_UNFROZEN to SB_FREEZE_TRANS.
>
> Because of this behavior, xfs_freeze can break read-only XFS filesystem.
>
> Because xfs_thaw does nothing for the filesystem whose sb->s_frozen is
> SB_UNFROZEN. So freezed readonly XFS filesystem will never be unfreezed.
> Then we cannot do any unmount/remount operations for that filesystem.
>
> This patch updates sb->s_frozen when freeze_bdev() is called for read-only
> mounted device, too.
I think this fix is valid, but it might be a tad cleaner to just
set s_frozen to SB_FREEZE_TRANS directly in a separate branch, ala:
struct super_block *freeze_bdev(struct block_device *bdev)
{
struct super_block *sb;
down(&bdev->bd_mount_sem);
sb = get_super(bdev);
if (!sb)
goto out;
if (sb->s_flags & MS_RDONLY) {
sb->s_frozen = SB_FREEZE_TRANS;
smp_wmb();
goto out;
}
sb->s_frozen = SB_FREEZE_WRITE;
smp_wmb();
__fsync_super(sb);
sb->s_frozen = SB_FREEZE_TRANS
smp_wmb();
sync_blockdev(sb->s_bdev);
if (sb->s_op->write_super_lockfs)
sb->s_op->write_super_lockfs(sb);
out:
sync_blockdev(bdev);
return sb; /* thaw_bdev releases s->s_umount and bd_mount_sem */
}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] update sb->s_frozen when freezing read-only mounted device, too
2007-10-04 20:20 ` Christoph Hellwig
@ 2007-10-05 13:20 ` Akinobu Mita
2007-10-10 15:20 ` Akinobu Mita
0 siblings, 1 reply; 4+ messages in thread
From: Akinobu Mita @ 2007-10-05 13:20 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, xfs, Tim Shimmin, David Chinner
2007/10/5, Christoph Hellwig <hch@lst.de>:
> On Sat, Sep 29, 2007 at 07:09:12PM +0900, Akinobu Mita wrote:
> > freeze_bdev() with the device which is mounted as read only
> > does not change sb->s_frozen from SB_UNFROZEN to SB_FREEZE_TRANS.
> >
> > Because of this behavior, xfs_freeze can break read-only XFS filesystem.
> >
> > Because xfs_thaw does nothing for the filesystem whose sb->s_frozen is
> > SB_UNFROZEN. So freezed readonly XFS filesystem will never be unfreezed.
> > Then we cannot do any unmount/remount operations for that filesystem.
> >
> > This patch updates sb->s_frozen when freeze_bdev() is called for read-only
> > mounted device, too.
>
> I think this fix is valid, but it might be a tad cleaner to just
> set s_frozen to SB_FREEZE_TRANS directly in a separate branch, ala:
It looks cleaner than mine. I'll resubmit it.
> struct super_block *freeze_bdev(struct block_device *bdev)
> {
> struct super_block *sb;
>
> down(&bdev->bd_mount_sem);
> sb = get_super(bdev);
> if (!sb)
> goto out;
>
> if (sb->s_flags & MS_RDONLY) {
> sb->s_frozen = SB_FREEZE_TRANS;
> smp_wmb();
> goto out;
> }
>
> sb->s_frozen = SB_FREEZE_WRITE;
> smp_wmb();
>
> __fsync_super(sb);
>
> sb->s_frozen = SB_FREEZE_TRANS
> smp_wmb();
>
> sync_blockdev(sb->s_bdev);
>
> if (sb->s_op->write_super_lockfs)
> sb->s_op->write_super_lockfs(sb);
>
> out:
> sync_blockdev(bdev);
> return sb; /* thaw_bdev releases s->s_umount and bd_mount_sem */
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] update sb->s_frozen when freezing read-only mounted device, too
2007-10-05 13:20 ` Akinobu Mita
@ 2007-10-10 15:20 ` Akinobu Mita
0 siblings, 0 replies; 4+ messages in thread
From: Akinobu Mita @ 2007-10-10 15:20 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-kernel, xfs, Tim Shimmin, David Chinner
freeze_bdev() with read-only mounted device(*) does not change sb->s_frozen
from SB_UNFROZEN to SB_FREEZE_TRANS.
Because of this behavior, xfs_freeze can break read-only filesystem.
Because xfs_thaw does nothing for the filesystem whose sb->s_frozen is
SB_UNFROZEN. So frozen read-only XFS filesystem will never be unfrozen.
Thus we cannot do any unmount/remount operations for that filesystem.
This patch updates sb->s_frozen when freeze_bdev() is called for read-only
mounted device, too.
(*) freezing read-only filesystem is not so pointless. Because it can
prevent from someone trying to remount read/write while freezing.
Cc: David Chinner <dgc@sgi.com>
Cc: Tim Shimmin <xfs-masters@oss.sgi.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
fs/buffer.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
Index: 2.6-git/fs/buffer.c
===================================================================
--- 2.6-git.orig/fs/buffer.c
+++ 2.6-git/fs/buffer.c
@@ -190,21 +190,28 @@ struct super_block *freeze_bdev(struct b
down(&bdev->bd_mount_sem);
sb = get_super(bdev);
- if (sb && !(sb->s_flags & MS_RDONLY)) {
- sb->s_frozen = SB_FREEZE_WRITE;
- smp_wmb();
-
- __fsync_super(sb);
+ if (!sb)
+ goto out;
+ if (sb->s_flags & MS_RDONLY) {
sb->s_frozen = SB_FREEZE_TRANS;
smp_wmb();
+ goto out;
+ }
- sync_blockdev(sb->s_bdev);
+ sb->s_frozen = SB_FREEZE_WRITE;
+ smp_wmb();
- if (sb->s_op->write_super_lockfs)
- sb->s_op->write_super_lockfs(sb);
- }
+ __fsync_super(sb);
+
+ sb->s_frozen = SB_FREEZE_TRANS;
+ smp_wmb();
+ sync_blockdev(sb->s_bdev);
+
+ if (sb->s_op->write_super_lockfs)
+ sb->s_op->write_super_lockfs(sb);
+out:
sync_blockdev(bdev);
return sb; /* thaw_bdev releases s->s_umount and bd_mount_sem */
}
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-10-10 15:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-29 10:09 [PATCH] update sb->s_frozen when freezing read-only mounted device, too Akinobu Mita
2007-10-04 20:20 ` Christoph Hellwig
2007-10-05 13:20 ` Akinobu Mita
2007-10-10 15:20 ` Akinobu Mita
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox