aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/file.c
diff options
context:
space:
mode:
authorliubo <liubo2009@cn.fujitsu.com>2011-01-06 06:30:25 -0500
committerChris Mason <chris.mason@oracle.com>2011-01-17 15:13:08 -0500
commitacce952b0263825da32cf10489413dec78053347 (patch)
treed934881f247484d7b6917bebc40828600bb6b76c /fs/btrfs/file.c
parent6f88a4403def422bd8e276ddf6863d6ac71435d2 (diff)
Btrfs: forced readonly mounts on errors
This patch comes from "Forced readonly mounts on errors" ideas. As we know, this is the first step in being more fault tolerant of disk corruptions instead of just using BUG() statements. The major content: - add a framework for generating errors that should result in filesystems going readonly. - keep FS state in disk super block. - make sure that all of resource will be freed and released at umount time. - make sure that fter FS is forced readonly on error, there will be no more disk change before FS is corrected. For this, we should stop write operation. After this patch is applied, the conversion from BUG() to such a framework can happen incrementally. Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/file.c')
-rw-r--r--fs/btrfs/file.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 05df688c96f4..f903433f5bdf 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -892,6 +892,17 @@ static ssize_t btrfs_file_aio_write(struct kiocb *iocb,
892 if (err) 892 if (err)
893 goto out; 893 goto out;
894 894
895 /*
896 * If BTRFS flips readonly due to some impossible error
897 * (fs_info->fs_state now has BTRFS_SUPER_FLAG_ERROR),
898 * although we have opened a file as writable, we have
899 * to stop this write operation to ensure FS consistency.
900 */
901 if (root->fs_info->fs_state & BTRFS_SUPER_FLAG_ERROR) {
902 err = -EROFS;
903 goto out;
904 }
905
895 file_update_time(file); 906 file_update_time(file);
896 BTRFS_I(inode)->sequence++; 907 BTRFS_I(inode)->sequence++;
897 908