Skip to content

Commit 09844df

Browse files
richardweinbergergregkh
authored andcommitted
ubifs: Check ubifs_wbuf_sync() return code
commit aac1794 upstream. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f1e90bf commit 09844df

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
@@ -1739,8 +1739,11 @@ static void ubifs_remount_ro(struct ubifs_info *c)
17391739

17401740
dbg_save_space_info(c);
17411741

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

17451748
c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY);
17461749
c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS);
@@ -1806,8 +1809,11 @@ static void ubifs_put_super(struct super_block *sb)
18061809
int err;
18071810

18081811
/* Synchronize write-buffers */
1809-
for (i = 0; i < c->jhead_cnt; i++)
1810-
ubifs_wbuf_sync(&c->jheads[i].wbuf);
1812+
for (i = 0; i < c->jhead_cnt; i++) {
1813+
err = ubifs_wbuf_sync(&c->jheads[i].wbuf);
1814+
if (err)
1815+
ubifs_ro_mode(c, err);
1816+
}
18111817

18121818
/*
18131819
* We are being cleanly unmounted which means the

0 commit comments

Comments
 (0)