UBIFS: Add log overlap assertions
authorhujianyang <hujianyang@huawei.com>
Wed, 30 Jul 2014 02:37:53 +0000 (10:37 +0800)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 31 Jul 2014 12:52:51 +0000 (15:52 +0300)
We use a circle area to record the log nodes in ubifs. This log area
should not be overlapped. But after researching the code, I found
some conditions may lead log head wraps log ltail. Although we've
fixed the problems discovered, there may be some other issues still
left.

This patch adds assertions where lhead changes to next leb to make
sure ltail is not wrapped.

Signed-off-by: hujianyang <hujianyang@huawei.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
fs/ubifs/log.c

index 518b13685b2a88270691dc27f9a11f69cf65fe6c..a47ddfc9be6b2373c92e2b9eb8e5ab4454be581a 100644 (file)
@@ -240,6 +240,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs)
 
        if (c->lhead_offs > c->leb_size - c->ref_node_alsz) {
                c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
+               ubifs_assert(c->lhead_lnum != c->ltail_lnum);
                c->lhead_offs = 0;
        }
 
@@ -404,6 +405,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum)
        /* Switch to the next log LEB */
        if (c->lhead_offs) {
                c->lhead_lnum = ubifs_next_log_lnum(c, c->lhead_lnum);
+               ubifs_assert(c->lhead_lnum != c->ltail_lnum);
                c->lhead_offs = 0;
        }