diff options
Diffstat (limited to 'fs/ubifs/super.c')
-rw-r--r-- | fs/ubifs/super.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index da99da098efd..807bbd3c8b4b 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
@@ -1469,9 +1469,6 @@ static int ubifs_remount_rw(struct ubifs_info *c) | |||
1469 | { | 1469 | { |
1470 | int err, lnum; | 1470 | int err, lnum; |
1471 | 1471 | ||
1472 | if (c->ro_media) | ||
1473 | return -EINVAL; | ||
1474 | |||
1475 | mutex_lock(&c->umount_mutex); | 1472 | mutex_lock(&c->umount_mutex); |
1476 | c->remounting_rw = 1; | 1473 | c->remounting_rw = 1; |
1477 | c->always_chk_crc = 1; | 1474 | c->always_chk_crc = 1; |
@@ -1605,9 +1602,13 @@ out: | |||
1605 | */ | 1602 | */ |
1606 | static void commit_on_unmount(struct ubifs_info *c) | 1603 | static void commit_on_unmount(struct ubifs_info *c) |
1607 | { | 1604 | { |
1608 | struct super_block *sb = c->vfs_sb; | ||
1609 | long long bud_bytes; | 1605 | long long bud_bytes; |
1610 | 1606 | ||
1607 | if (!c->fast_unmount) { | ||
1608 | dbg_gen("skip committing - fast unmount enabled"); | ||
1609 | return; | ||
1610 | } | ||
1611 | |||
1611 | /* | 1612 | /* |
1612 | * This function is called before the background thread is stopped, so | 1613 | * This function is called before the background thread is stopped, so |
1613 | * we may race with ongoing commit, which means we have to take | 1614 | * we may race with ongoing commit, which means we have to take |
@@ -1617,8 +1618,11 @@ static void commit_on_unmount(struct ubifs_info *c) | |||
1617 | bud_bytes = c->bud_bytes; | 1618 | bud_bytes = c->bud_bytes; |
1618 | spin_unlock(&c->buds_lock); | 1619 | spin_unlock(&c->buds_lock); |
1619 | 1620 | ||
1620 | if (!c->fast_unmount && !(sb->s_flags & MS_RDONLY) && bud_bytes) | 1621 | if (bud_bytes) { |
1622 | dbg_gen("run commit"); | ||
1621 | ubifs_run_commit(c); | 1623 | ubifs_run_commit(c); |
1624 | } else | ||
1625 | dbg_gen("journal is empty, do not run commit"); | ||
1622 | } | 1626 | } |
1623 | 1627 | ||
1624 | /** | 1628 | /** |
@@ -1633,6 +1637,8 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1633 | int i, err; | 1637 | int i, err; |
1634 | 1638 | ||
1635 | ubifs_assert(!c->need_recovery); | 1639 | ubifs_assert(!c->need_recovery); |
1640 | ubifs_assert(!c->ro_media); | ||
1641 | |||
1636 | commit_on_unmount(c); | 1642 | commit_on_unmount(c); |
1637 | 1643 | ||
1638 | mutex_lock(&c->umount_mutex); | 1644 | mutex_lock(&c->umount_mutex); |
@@ -1646,16 +1652,17 @@ static void ubifs_remount_ro(struct ubifs_info *c) | |||
1646 | del_timer_sync(&c->jheads[i].wbuf.timer); | 1652 | del_timer_sync(&c->jheads[i].wbuf.timer); |
1647 | } | 1653 | } |
1648 | 1654 | ||
1649 | if (!c->ro_media) { | 1655 | c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); |
1650 | c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); | 1656 | c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); |
1651 | c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); | 1657 | c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum); |
1652 | c->mst_node->gc_lnum = cpu_to_le32(c->gc_lnum); | 1658 | err = ubifs_write_master(c); |
1653 | err = ubifs_write_master(c); | 1659 | if (err) |
1654 | if (err) | 1660 | ubifs_ro_mode(c, err); |
1655 | ubifs_ro_mode(c, err); | 1661 | |
1656 | } | 1662 | err = ubifs_destroy_idx_gc(c); |
1663 | if (err) | ||
1664 | ubifs_ro_mode(c, err); | ||
1657 | 1665 | ||
1658 | ubifs_destroy_idx_gc(c); | ||
1659 | free_wbufs(c); | 1666 | free_wbufs(c); |
1660 | vfree(c->orph_buf); | 1667 | vfree(c->orph_buf); |
1661 | c->orph_buf = NULL; | 1668 | c->orph_buf = NULL; |
@@ -1754,6 +1761,11 @@ static int ubifs_remount_fs(struct super_block *sb, int *flags, char *data) | |||
1754 | } | 1761 | } |
1755 | 1762 | ||
1756 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { | 1763 | if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { |
1764 | if (c->ro_media) { | ||
1765 | ubifs_msg("cannot re-mount R/W, UBIFS is working in " | ||
1766 | "R/O mode"); | ||
1767 | return -EINVAL; | ||
1768 | } | ||
1757 | err = ubifs_remount_rw(c); | 1769 | err = ubifs_remount_rw(c); |
1758 | if (err) | 1770 | if (err) |
1759 | return err; | 1771 | return err; |
@@ -2044,7 +2056,7 @@ static void ubifs_kill_sb(struct super_block *sb) | |||
2044 | * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()' | 2056 | * We do 'commit_on_unmount()' here instead of 'ubifs_put_super()' |
2045 | * in order to be outside BKL. | 2057 | * in order to be outside BKL. |
2046 | */ | 2058 | */ |
2047 | if (sb->s_root) | 2059 | if (sb->s_root && !(sb->s_flags & MS_RDONLY)) |
2048 | commit_on_unmount(c); | 2060 | commit_on_unmount(c); |
2049 | /* The un-mount routine is actually done in put_super() */ | 2061 | /* The un-mount routine is actually done in put_super() */ |
2050 | generic_shutdown_super(sb); | 2062 | generic_shutdown_super(sb); |