Skip to content

Commit aac1794

Browse files
ubifs: Check ubifs_wbuf_sync() return code
If ubifs_wbuf_sync() fails we must not write a master node with the dirty marker cleared. Otherwise it is possible that in case of an IO error while syncing we mark the filesystem as clean and UBIFS refuses to recover upon next mount. Cc: <[email protected]> Fixes: 1e51764 ("UBIFS: add new flash file system") Signed-off-by: Richard Weinberger <[email protected]>
1 parent 0adb328 commit aac1794

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

fs/ubifs/super.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,8 +1737,11 @@ static void ubifs_remount_ro(struct ubifs_info *c)
17371737

17381738
dbg_save_space_info(c);
17391739

1740-
for (i = 0; i < c->jhead_cnt; i++)
1741-
ubifs_wbuf_sync(&c->jheads[i].wbuf);
1740+
for (i = 0; i < c->jhead_cnt; i++) {
1741+
err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
1742+
if (err)
1743+
ubifs_ro_mode(c, err);
1744+
}
17421745

17431746
c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY);
17441747
c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS);
@@ -1804,8 +1807,11 @@ static void ubifs_put_super(struct super_block *sb)
18041807
int err;
18051808

18061809
/* Synchronize write-buffers */
1807-
for (i = 0; i < c->jhead_cnt; i++)
1808-
ubifs_wbuf_sync(&c->jheads[i].wbuf);
1810+
for (i = 0; i < c->jhead_cnt; i++) {
1811+
err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
1812+
if (err)
1813+
ubifs_ro_mode(c, err);
1814+
}
18091815

18101816
/*
18111817
* We are being cleanly unmounted which means the

0 commit comments

Comments
 (0)