diff options
author | Takashi Sato <t-sato@yk.jp.nec.com> | 2009-01-09 19:40:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-09 19:54:42 -0500 |
commit | c4be0c1dc4cdc37b175579be1460f15ac6495e9a (patch) | |
tree | 716ea88318211ed27cadcebda0fd85c1f8246edb /fs/gfs2 | |
parent | 69347a236b22c3962ea812511495e502dedfd50c (diff) |
filesystem freeze: add error handling of write_super_lockfs/unlockfs
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.
This patch:
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.
Signed-off-by: Takashi Sato <t-sato@yk.jp.nec.com>
Signed-off-by: Masayuki Hamaguchi <m-hamaguchi@ys.jp.nec.com>
Cc: <xfs-masters@oss.sgi.com>
Cc: <linux-ext4@vger.kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Kleikamp <shaggy@austin.ibm.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Alasdair G Kergon <agk@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/ops_super.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c index 777783deddcb..320323d03479 100644 --- a/fs/gfs2/ops_super.c +++ b/fs/gfs2/ops_super.c | |||
@@ -211,18 +211,18 @@ static int gfs2_sync_fs(struct super_block *sb, int wait) | |||
211 | } | 211 | } |
212 | 212 | ||
213 | /** | 213 | /** |
214 | * gfs2_write_super_lockfs - prevent further writes to the filesystem | 214 | * gfs2_freeze - prevent further writes to the filesystem |
215 | * @sb: the VFS structure for the filesystem | 215 | * @sb: the VFS structure for the filesystem |
216 | * | 216 | * |
217 | */ | 217 | */ |
218 | 218 | ||
219 | static void gfs2_write_super_lockfs(struct super_block *sb) | 219 | static int gfs2_freeze(struct super_block *sb) |
220 | { | 220 | { |
221 | struct gfs2_sbd *sdp = sb->s_fs_info; | 221 | struct gfs2_sbd *sdp = sb->s_fs_info; |
222 | int error; | 222 | int error; |
223 | 223 | ||
224 | if (test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) | 224 | if (test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) |
225 | return; | 225 | return -EINVAL; |
226 | 226 | ||
227 | for (;;) { | 227 | for (;;) { |
228 | error = gfs2_freeze_fs(sdp); | 228 | error = gfs2_freeze_fs(sdp); |
@@ -242,17 +242,19 @@ static void gfs2_write_super_lockfs(struct super_block *sb) | |||
242 | fs_err(sdp, "retrying...\n"); | 242 | fs_err(sdp, "retrying...\n"); |
243 | msleep(1000); | 243 | msleep(1000); |
244 | } | 244 | } |
245 | return 0; | ||
245 | } | 246 | } |
246 | 247 | ||
247 | /** | 248 | /** |
248 | * gfs2_unlockfs - reallow writes to the filesystem | 249 | * gfs2_unfreeze - reallow writes to the filesystem |
249 | * @sb: the VFS structure for the filesystem | 250 | * @sb: the VFS structure for the filesystem |
250 | * | 251 | * |
251 | */ | 252 | */ |
252 | 253 | ||
253 | static void gfs2_unlockfs(struct super_block *sb) | 254 | static int gfs2_unfreeze(struct super_block *sb) |
254 | { | 255 | { |
255 | gfs2_unfreeze_fs(sb->s_fs_info); | 256 | gfs2_unfreeze_fs(sb->s_fs_info); |
257 | return 0; | ||
256 | } | 258 | } |
257 | 259 | ||
258 | /** | 260 | /** |
@@ -688,8 +690,8 @@ const struct super_operations gfs2_super_ops = { | |||
688 | .put_super = gfs2_put_super, | 690 | .put_super = gfs2_put_super, |
689 | .write_super = gfs2_write_super, | 691 | .write_super = gfs2_write_super, |
690 | .sync_fs = gfs2_sync_fs, | 692 | .sync_fs = gfs2_sync_fs, |
691 | .write_super_lockfs = gfs2_write_super_lockfs, | 693 | .freeze_fs = gfs2_freeze, |
692 | .unlockfs = gfs2_unlockfs, | 694 | .unfreeze_fs = gfs2_unfreeze, |
693 | .statfs = gfs2_statfs, | 695 | .statfs = gfs2_statfs, |
694 | .remount_fs = gfs2_remount_fs, | 696 | .remount_fs = gfs2_remount_fs, |
695 | .clear_inode = gfs2_clear_inode, | 697 | .clear_inode = gfs2_clear_inode, |