UBIFS: remove a bit of unneeded code
Subsystems (2)
PATCH 1/2 UBIFS: remove a bit of unneeded code
From: Artem Bityutskiy <[email protected]>
This is a clean-up patch which:
1. Removes explicite 'hrtimer_cancel()' after 'ubifs_wbuf_sync()' in 'ubifs_remount_ro()', because the timers will be canceled by 'ubifs_wbuf_sync()', no need to cancel them for the second time.
2. Remove "if (c->jheads)" check from 'ubifs_put_super()', because at journal heads must always be allocated there, since we checked earlier that we were mounted R/W, and the olny situation when journal heads are not allocated is when mounter or re-mounted R/O.
--- fs/ubifs/super.c | 9 +++------ 1 files changed, 3 insertions(+), 6 deletions(-)
fs/ubifs/super.c +3 -6
@@ -1686,10 +1686,8 @@ static void ubifs_remount_ro(struct ubifs_info *c)dbg_save_space_info (c); -for (i =0 ; i < c->jhead_cnt; i++) { +for (i =0 ; i < c->jhead_cnt; i++)ubifs_wbuf_sync (&c->jheads[i].wbuf); -hrtimer_cancel (&c->jheads[i].wbuf.timer); - } c->mst_node->flags &= ~cpu_to_le32 (UBIFS_MST_DIRTY ); c->mst_node->flags |=cpu_to_le32 (UBIFS_MST_NO_ORPHS );
@@ -1754,9 +1752,8 @@ static void ubifs_put_super(struct super_block *sb)int err;/* Synchronize write-buffers */ -if (c->jheads) -for (i =0 ; i < c->jhead_cnt; i++) -ubifs_wbuf_sync (&c->jheads[i].wbuf); +for (i =0 ; i < c->jhead_cnt; i++) +ubifs_wbuf_sync (&c->jheads[i].wbuf);/* * We are being cleanly unmounted which means the
Signature · 1 line
1.7.2.3
PATCH 2/2 UBIFS: do not forget to cancel timers
From: Artem Bityutskiy <[email protected]>
This is a bug-fix: when we unmount, and we are currently in R/O mode because of an error - we do not sync write-buffers, which means we also do not cancel write-buffer timers we may possibly have armed. This patch fixes the issue.
The issue can easily be reproduced by enabling UBIFS failure debug mode (echo 4 > /sys/module/ubifs/parameters/debug_tsts) and unmounting as soon as a failure happen. At some point the system oopses because we have an armed hrtimer but UBIFS is unmounted already.
--- fs/ubifs/super.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
fs/ubifs/super.c +5 -1
@@ -1772,7 +1772,11 @@ static void ubifs_put_super(struct super_block *sb)*/ ubifs_err ("failed to write master node, " "error %d" , err); - } + }else { +for (i =0 ; i < c->jhead_cnt; i++) +/* Make sure write-buffer timers are canceled */ +hrtimer_cancel (&c->jheads[i].wbuf.timer); + } }ubifs_umount (c);
Signature · 1 line
1.7.2.3