diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-09-17 09:44:28 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2010-09-17 10:08:09 -0400 |
commit | 2680d722bf2c5f75225dd9acb3ec9e5a9e2652f4 (patch) | |
tree | af016ede5f300a33ddd3ad66a8c3c0e6bf05774e /fs/ubifs/super.c | |
parent | 8c893a5545ca772744376295690723dcb0b47d96 (diff) |
UBIFS: introduce new flag for RO due to errors
The R/O state may have various reasons:
1. The UBI volume is R/O
2. The FS is mounted R/O
3. The FS switched to R/O mode because of an error
However, in UBIFS we have only one variable which represents cases
1 and 3 - 'c->ro_media'. Indeed, we set this to 1 if we switch to
R/O mode due to an error, and then we test it in many places to
make sure that we stop writing as soon as the error happens.
But this is very unclean. One consequence of this, for example, is
that in 'ubifs_remount_fs()' we use 'c->ro_media' to check whether
we are in R/O mode because on an error, and we print a message
in this case. However, if we are in R/O mode because the media
is R/O, our message is bogus.
This patch introduces new flag - 'c->ro_error' which is set when
we switch to R/O mode because of an error. It also changes all
"if (c->ro_media)" checks to "if (c->ro_error)" checks, because
this is what the checks actually mean. We do not need to check
for 'c->ro_media' because if the UBI volume is in R/O mode, we
do not allow R/W mounting, and now writes can happen. This is
guaranteed by VFS. But it is good to double-check this, so this
patch also adds many "ubifs_assert(!c->ro_media)" checks.
In the 'ubifs_remount_fs()' function this patch makes a bit more
changes - it fixes the error messages as well.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r-- | fs/ubifs/super.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index cd5900b85d38..1cfeec56df91 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1751,10 +1751,10 @@ static void ubifs_put_super(struct super_block *sb) | |||
1751 | ubifs_wbuf_sync(&c->jheads[i].wbuf); | 1751 | ubifs_wbuf_sync(&c->jheads[i].wbuf); |
1752 | 1752 | ||
1753 | /* | 1753 | /* |
1754 | * On fatal errors c->ro_media is set to 1, in which case we do | 1754 | * On fatal errors c->ro_error is set to 1, in which case we do |
1755 | * not write the master node. | 1755 | * not write the master node. |
1756 | */ | 1756 | */ |
1757 | if (!c->ro_media) { | 1757 | if (!c->ro_error) { |
1758 | /* | 1758 | /* |
1759 | * We are being cleanly unmounted which means the | 1759 | * We are being cleanly unmounted which means the |
1760 | * orphans were killed - indicate this in the master | 1760 | * orphans were killed - indicate this in the master |
@@ -1798,16 +1798,20 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) | |||
1798 | } | 1798 | } |
1799 | 1799 | ||
1800 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { | 1800 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { |
1801 | if (c->ro_error) { | ||
1802 | ubifs_msg("cannot re-mount R/W due to prior errors"); | ||
1803 | return -EROFS; | ||
1804 | } | ||
1801 | if (c->ro_media) { | 1805 | if (c->ro_media) { |
1802 | ubifs_msg("cannot re-mount due to prior errors"); | 1806 | ubifs_msg("cannot re-mount R/W - UBI volume is R/O"); |
1803 | return -EROFS; | 1807 | return -EROFS; |
1804 | } | 1808 | } |
1805 | err = ubifs_remount_rw(c); | 1809 | err = ubifs_remount_rw(c); |
1806 | if (err) | 1810 | if (err) |
1807 | return err; | 1811 | return err; |
1808 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { | 1812 | } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { |
1809 | if (c->ro_media) { | 1813 | if (c->ro_error) { |
1810 | ubifs_msg("cannot re-mount due to prior errors"); | 1814 | ubifs_msg("cannot re-mount R/O due to prior errors"); |
1811 | return -EROFS; | 1815 | return -EROFS; |
1812 | } | 1816 | } |
1813 | ubifs_remount_ro(c); | 1817 | ubifs_remount_ro(c); |