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/xfs | |
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/xfs')
-rw-r--r-- | fs/xfs/linux-2.6/xfs_super.c | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.c | 11 | ||||
-rw-r--r-- | fs/xfs/xfs_fsops.h | 2 |
3 files changed, 12 insertions, 9 deletions
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c index be846d606ae8..95a971080368 100644 --- a/fs/xfs/linux-2.6/xfs_super.c +++ b/fs/xfs/linux-2.6/xfs_super.c | |||
@@ -1269,14 +1269,14 @@ xfs_fs_remount( | |||
1269 | * need to take care of the metadata. Once that's done write a dummy | 1269 | * need to take care of the metadata. Once that's done write a dummy |
1270 | * record to dirty the log in case of a crash while frozen. | 1270 | * record to dirty the log in case of a crash while frozen. |
1271 | */ | 1271 | */ |
1272 | STATIC void | 1272 | STATIC int |
1273 | xfs_fs_lockfs( | 1273 | xfs_fs_freeze( |
1274 | struct super_block *sb) | 1274 | struct super_block *sb) |
1275 | { | 1275 | { |
1276 | struct xfs_mount *mp = XFS_M(sb); | 1276 | struct xfs_mount *mp = XFS_M(sb); |
1277 | 1277 | ||
1278 | xfs_quiesce_attr(mp); | 1278 | xfs_quiesce_attr(mp); |
1279 | xfs_fs_log_dummy(mp); | 1279 | return -xfs_fs_log_dummy(mp); |
1280 | } | 1280 | } |
1281 | 1281 | ||
1282 | STATIC int | 1282 | STATIC int |
@@ -1557,7 +1557,7 @@ static struct super_operations xfs_super_operations = { | |||
1557 | .put_super = xfs_fs_put_super, | 1557 | .put_super = xfs_fs_put_super, |
1558 | .write_super = xfs_fs_write_super, | 1558 | .write_super = xfs_fs_write_super, |
1559 | .sync_fs = xfs_fs_sync_super, | 1559 | .sync_fs = xfs_fs_sync_super, |
1560 | .write_super_lockfs = xfs_fs_lockfs, | 1560 | .freeze_fs = xfs_fs_freeze, |
1561 | .statfs = xfs_fs_statfs, | 1561 | .statfs = xfs_fs_statfs, |
1562 | .remount_fs = xfs_fs_remount, | 1562 | .remount_fs = xfs_fs_remount, |
1563 | .show_options = xfs_fs_show_options, | 1563 | .show_options = xfs_fs_show_options, |
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 852b6d32e8d0..680d0e0ec932 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -595,17 +595,19 @@ out: | |||
595 | return 0; | 595 | return 0; |
596 | } | 596 | } |
597 | 597 | ||
598 | void | 598 | int |
599 | xfs_fs_log_dummy( | 599 | xfs_fs_log_dummy( |
600 | xfs_mount_t *mp) | 600 | xfs_mount_t *mp) |
601 | { | 601 | { |
602 | xfs_trans_t *tp; | 602 | xfs_trans_t *tp; |
603 | xfs_inode_t *ip; | 603 | xfs_inode_t *ip; |
604 | int error; | ||
604 | 605 | ||
605 | tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1); | 606 | tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1); |
606 | if (xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0)) { | 607 | error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0); |
608 | if (error) { | ||
607 | xfs_trans_cancel(tp, 0); | 609 | xfs_trans_cancel(tp, 0); |
608 | return; | 610 | return error; |
609 | } | 611 | } |
610 | 612 | ||
611 | ip = mp->m_rootip; | 613 | ip = mp->m_rootip; |
@@ -615,9 +617,10 @@ xfs_fs_log_dummy( | |||
615 | xfs_trans_ihold(tp, ip); | 617 | xfs_trans_ihold(tp, ip); |
616 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); | 618 | xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); |
617 | xfs_trans_set_sync(tp); | 619 | xfs_trans_set_sync(tp); |
618 | xfs_trans_commit(tp, 0); | 620 | error = xfs_trans_commit(tp, 0); |
619 | 621 | ||
620 | xfs_iunlock(ip, XFS_ILOCK_EXCL); | 622 | xfs_iunlock(ip, XFS_ILOCK_EXCL); |
623 | return error; | ||
621 | } | 624 | } |
622 | 625 | ||
623 | int | 626 | int |
diff --git a/fs/xfs/xfs_fsops.h b/fs/xfs/xfs_fsops.h index 300d0c9d61ad..88435e0a77c9 100644 --- a/fs/xfs/xfs_fsops.h +++ b/fs/xfs/xfs_fsops.h | |||
@@ -25,6 +25,6 @@ extern int xfs_fs_counts(xfs_mount_t *mp, xfs_fsop_counts_t *cnt); | |||
25 | extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval, | 25 | extern int xfs_reserve_blocks(xfs_mount_t *mp, __uint64_t *inval, |
26 | xfs_fsop_resblks_t *outval); | 26 | xfs_fsop_resblks_t *outval); |
27 | extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags); | 27 | extern int xfs_fs_goingdown(xfs_mount_t *mp, __uint32_t inflags); |
28 | extern void xfs_fs_log_dummy(xfs_mount_t *mp); | 28 | extern int xfs_fs_log_dummy(xfs_mount_t *mp); |
29 | 29 | ||
30 | #endif /* __XFS_FSOPS_H__ */ | 30 | #endif /* __XFS_FSOPS_H__ */ |