LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/3] freeze feature ver 1.14
@ 2008-10-27 12:58 Takashi Sato
  2009-01-02  5:22 ` Eric Sandeen
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Sato @ 2008-10-27 12:58 UTC (permalink / raw)
  To: Andrew Morton, Christoph Hellwig, linux-fsdevel, dm-devel, viro,
	linux-ext4, xfs, mtk.manpages, axboe
  Cc: linux-kernel

Hi, 

We need to discuss about the timeout feature more,
so I send patches only of the generic freeze feature.

I've addressed the comment from Shaggy,
combined patches that were divided into each filesystems into one patch 
because of the avoidance of a bisection.

Currently, ext3 in mainline Linux doesn't have the freeze feature which
suspends write requests.  So, we cannot take a backup which keeps
the filesystem's consistency with the storage device's features
(snapshot and replication) while it is mounted.
In many case, a commercial filesystem (e.g. VxFS) has
the freeze feature and it would be used to get the consistent backup.
If Linux's standard filesystem ext3 has the freeze feature, we can do it
without a commercial filesystem.

So I have implemented the ioctls of the freeze feature.
I think we can take the consistent backup with the following steps.
1. Freeze the filesystem with the freeze ioctl.
2. Separate the replication volume or create the snapshot
   with the storage device's feature.
3. Unfreeze the filesystem with the unfreeze ioctl.
4. Take the backup from the separated replication volume
   or the snapshot.

[PATCH 1/3] Add error handling of write_super_lockfs and unlockfs
  VFS:
  Changed the type of write_super_lockfs and unlockfs from "void"
  to "int" so that they can return an error. 
  Rename write_super_lockfs and unlockfs of the super block operation
  freeze_fs and unfreeze_fs to avoid a confusion.

  ext3, ext4, xfs, gfs2, jfs:
  Changed the type of write_super_lockfs and unlockfs from "void"
  to "int" so that write_super_lockfs returns an error if needed,
  and unlockfs always returns 0.

  reiserfs:
  Changed the type of write_super_lockfs and unlockfs from "void"
  to "int" so that they always return 0 (success) to keep a current behavior.

[PATCH 2/3] Implement generic freeze feature
  The ioctls for the generic freeze feature are below.
  o Freeze the filesystem
    int ioctl(int fd, int FIFREEZE, arg)
      fd: The file descriptor of the mountpoint
      FIFREEZE: request code for the freeze
      arg: Ignored
      Return value: 0 if the operation succeeds. Otherwise, -1

  o Unfreeze the filesystem
    int ioctl(int fd, int FITHAW, arg)
      fd: The file descriptor of the mountpoint
      FITHAW: request code for unfreeze
      arg: Ignored
      Return value: 0 if the operation succeeds. Otherwise, -1
      Error number: If the filesystem has already been unfrozen,
                    errno is set to EINVAL.

[PATCH 3/3] Remove XFS specific ioctl interfaces for freeze feature
  It removes XFS specific ioctl interfaces and request codes
  for freeze feature.
  This patch has been supplied by David Chinner.

Any comments are very welcome.

Cheers, Takashi

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 0/3] freeze feature ver 1.14
  2008-10-27 12:58 [PATCH 0/3] freeze feature ver 1.14 Takashi Sato
@ 2009-01-02  5:22 ` Eric Sandeen
  2009-01-02  9:47   ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2009-01-02  5:22 UTC (permalink / raw)
  To: Takashi Sato
  Cc: Andrew Morton, Christoph Hellwig, linux-fsdevel, dm-devel, viro,
	linux-ext4, xfs, mtk.manpages, axboe, linux-kernel

In lieu of the timeout feature which was originally proposed, how
about access to an emergency un-freeze via magic sysrq, maybe
piggy-backed on emergency sync... something like this (not
tested or even built yet...), would this be a good compromise to
help save people from frozen roots?

-Eric

Index: linux-2.6/drivers/char/sysrq.c
===================================================================
--- linux-2.6.orig/drivers/char/sysrq.c
+++ linux-2.6/drivers/char/sysrq.c
@@ -151,6 +151,7 @@ static struct sysrq_key_op sysrq_reboot_
 
 static void sysrq_handle_sync(int key, struct tty_struct *tty)
 {
+	emergency_thaw();
 	emergency_sync();
 }
 static struct sysrq_key_op sysrq_sync_op = {
Index: linux-2.6/drivers/md/dm.c
===================================================================
--- linux-2.6.orig/drivers/md/dm.c
+++ linux-2.6/drivers/md/dm.c
@@ -1477,7 +1477,7 @@ static void unlock_fs(struct mapped_devi
 	if (!test_bit(DMF_FROZEN, &md->flags))
 		return;
 
-	thaw_bdev(md->suspended_bdev, md->frozen_sb);
+	thaw_bdev(md->suspended_bdev, md->frozen_sb, 0);
 	md->frozen_sb = NULL;
 	clear_bit(DMF_FROZEN, &md->flags);
 }
Index: linux-2.6/fs/buffer.c
===================================================================
--- linux-2.6.orig/fs/buffer.c
+++ linux-2.6/fs/buffer.c
@@ -259,13 +259,29 @@ struct super_block *freeze_bdev(struct b
 EXPORT_SYMBOL(freeze_bdev);
 
 /**
+ * emergency_thaw -- force thaw every filesystem
+ *
+ * Used for emergency unfreeze of all filesystems via SysRq
+ */
+void emergency_thaw(void)
+{
+	struct super_block *sb;
+
+	list_for_each_entry(sb, &super_blocks, s_list) {
+		if (sb->s_bdev)
+			(void)thaw_bdev(sb->s_bdev, sb, 1);
+	}
+}
+
+/**
  * thaw_bdev  -- unlock filesystem
  * @bdev:	blockdevice to unlock
  * @sb:		associated superblock
+ * force:	force unfreeze regardless of freezer count
  *
  * Unlocks the filesystem and marks it writeable again after freeze_bdev().
  */
-int thaw_bdev(struct block_device *bdev, struct super_block *sb)
+int thaw_bdev(struct block_device *bdev, struct super_block *sb, int force)
 {
 	int error = 0;
 
@@ -275,7 +291,11 @@ int thaw_bdev(struct block_device *bdev,
 		return -EINVAL;
 	}
 
-	bdev->bd_fsfreeze_count--;
+	if (force)
+		bdev->bd_fsfreeze_count = 0;
+	else
+		bdev->bd_fsfreeze_count--;
+
 	if (bdev->bd_fsfreeze_count > 0) {
 		if (sb)
 			drop_super(sb);
Index: linux-2.6/fs/ioctl.c
===================================================================
--- linux-2.6.orig/fs/ioctl.c
+++ linux-2.6/fs/ioctl.c
@@ -449,7 +449,7 @@ static int ioctl_fsthaw(struct file *fil
 		return -EINVAL;
 
 	/* Thaw */
-	return thaw_bdev(sb->s_bdev, sb);
+	return thaw_bdev(sb->s_bdev, sb, 0);
 }
 
 /*
Index: linux-2.6/fs/xfs/xfs_fsops.c
===================================================================
--- linux-2.6.orig/fs/xfs/xfs_fsops.c
+++ linux-2.6/fs/xfs/xfs_fsops.c
@@ -634,7 +634,7 @@ xfs_fs_goingdown(
 
 		if (sb && !IS_ERR(sb)) {
 			xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT);
-			thaw_bdev(sb->s_bdev, sb);
+			thaw_bdev(sb->s_bdev, sb, 0);
 		}
 
 		break;
Index: linux-2.6/include/linux/buffer_head.h
===================================================================
--- linux-2.6.orig/include/linux/buffer_head.h
+++ linux-2.6/include/linux/buffer_head.h
@@ -171,7 +171,8 @@ void __wait_on_buffer(struct buffer_head
 wait_queue_head_t *bh_waitq_head(struct buffer_head *bh);
 int fsync_bdev(struct block_device *);
 struct super_block *freeze_bdev(struct block_device *);
-int thaw_bdev(struct block_device *, struct super_block *);
+void emergency_thaw(void);
+int thaw_bdev(struct block_device *, struct super_block *, int);
 int fsync_super(struct super_block *);
 int fsync_no_super(struct block_device *);
 struct buffer_head *__find_get_block(struct block_device *bdev, sector_t block,



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 0/3] freeze feature ver 1.14
  2009-01-02  5:22 ` Eric Sandeen
@ 2009-01-02  9:47   ` Christoph Hellwig
  0 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2009-01-02  9:47 UTC (permalink / raw)
  To: Eric Sandeen
  Cc: Takashi Sato, Andrew Morton, Christoph Hellwig, linux-fsdevel,
	dm-devel, viro, linux-ext4, xfs, mtk.manpages, axboe,
	linux-kernel

On Thu, Jan 01, 2009 at 11:22:16PM -0600, Eric Sandeen wrote:
> In lieu of the timeout feature which was originally proposed, how
> about access to an emergency un-freeze via magic sysrq, maybe
> piggy-backed on emergency sync... something like this (not
> tested or even built yet...), would this be a good compromise to
> help save people from frozen roots?

Looks sane to me.  But for that we'd need to get the generic freeze bits
in first.  Andrews, as they are in 2.6.28-rc2 do you plan to send them?

Any chance for a general -mm merge plan, btw?


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-01-02  9:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-27 12:58 [PATCH 0/3] freeze feature ver 1.14 Takashi Sato
2009-01-02  5:22 ` Eric Sandeen
2009-01-02  9:47   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).