From e71d1a59e757201454fd3cf66ddaceaf961bfb41 Mon Sep 17 00:00:00 2001 From: "wang.bo116@zte.com.cn" Date: Fri, 16 Aug 2013 15:43:36 +0800 Subject: UBIFS: remove unnecessary code in ubifs_garbage_collect In ubifs_garbage_collect,local variable "space_before" calculate twice. In fact, at the beginning of the loop, there is no need to calculate this variable. Calculate it before call "ubifs_garbage_collect_leb" is enough. This patch just remove the unnecessary calculate code. Signed-off-by: wang bo Acked-by: Brian Norris Signed-off-by: Artem Bityutskiy --- fs/ubifs/gc.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'fs/ubifs') diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c index 76ca53cd3eee..9718da86ad01 100644 --- a/fs/ubifs/gc.c +++ b/fs/ubifs/gc.c @@ -668,8 +668,7 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway) ubifs_assert(!wbuf->used); for (i = 0; ; i++) { - int space_before = c->leb_size - wbuf->offs - wbuf->used; - int space_after; + int space_before, space_after; cond_resched(); -- cgit v1.2.3 From 7203db97b7378c2571797c13aa89327a2c487ea1 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 7 Jun 2013 10:17:22 +0800 Subject: UBIFS: fix return code Fix to return -ENOMEM in the kmalloc() and d_make_root() error handling case instead of 0, as done elsewhere in those functions. Signed-off-by: Wei Yongjun Signed-off-by: Artem Bityutskiy --- fs/ubifs/super.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'fs/ubifs') diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 879b9976c12b..01e1ad08d08e 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1629,8 +1629,10 @@ static int ubifs_remount_rw(struct ubifs_info *c) } c->write_reserve_buf = kmalloc(COMPRESSED_DATA_NODE_BUF_SZ, GFP_KERNEL); - if (!c->write_reserve_buf) + if (!c->write_reserve_buf) { + err = -ENOMEM; goto out; + } err = ubifs_lpt_init(c, 0, 1); if (err) @@ -2063,8 +2065,10 @@ static int ubifs_fill_super(struct super_block *sb, void *data, int silent) } sb->s_root = d_make_root(root); - if (!sb->s_root) + if (!sb->s_root) { + err = -ENOMEM; goto out_umount; + } mutex_unlock(&c->umount_mutex); return 0; -- cgit v1.2.3 From 58a4e23703b22c331b01fbd0c12161aadaa6d50b Mon Sep 17 00:00:00 2001 From: Mats Kärrman Date: Wed, 21 Aug 2013 13:24:49 +0000 Subject: UBIFS: correct data corruption range With power-cut emulation, it is possible that sometimes no data at all is corrupted and that confusing messages are printed due to errors in the computation of data corruption range. [1] The start of the range should be [0..len-1], not [0..len]. [2] The end of the range should always be at least 1 greater than the start. Signed-off-by: Mats Karrman Signed-off-by: Artem Bityutskiy --- fs/ubifs/debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/ubifs') diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index 6e025e02ffde..cc1febd8fadf 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c @@ -2563,9 +2563,9 @@ static int corrupt_data(const struct ubifs_info *c, const void *buf, unsigned int from, to, ffs = chance(1, 2); unsigned char *p = (void *)buf; - from = prandom_u32() % (len + 1); - /* Corruption may only span one max. write unit */ - to = min(len, ALIGN(from, c->max_write_size)); + from = prandom_u32() % len; + /* Corruption span max to end of write unit */ + to = min(len, ALIGN(from + 1, c->max_write_size)); ubifs_warn("filled bytes %u-%u with %s", from, to - 1, ffs ? "0xFFs" : "random data"); -- cgit v1.2.3