linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: hujianyang <hujianyang@huawei.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: MTD Maling List <linux-mtd@lists.infradead.org>
Subject: Re: [PATCH 2/2] UBIFS: add a log overlap assertion
Date: Tue, 22 Jul 2014 09:35:23 +0800	[thread overview]
Message-ID: <53CDBFDB.6080300@huawei.com> (raw)
In-Reply-To: <1405514528-14649-2-git-send-email-dedekind1@gmail.com>

On 2014/7/16 20:42, Artem Bityutskiy wrote:
> From: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> 
> Add an assertion which checkes that the head of the log never overlaps with the
> tail of the log.
> 
> Suggested-by: hujianyang <hujianyang@huawei.com>
> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
> ---
>  fs/ubifs/misc.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ubifs/misc.h b/fs/ubifs/misc.h
> index ee7cb5e..81bbf79 100644
> --- a/fs/ubifs/misc.h
> +++ b/fs/ubifs/misc.h
> @@ -297,6 +297,7 @@ static inline int ubifs_next_log_lnum(const struct ubifs_info *c, int lnum)
>  	if (lnum > c->log_last)
>  		lnum = UBIFS_LOG_LNUM;
>  
> +	ubifs_assert(lnum != c->ltail_lnum);
>  	return lnum;
>  }
>  
> 

Hi Artem,

I just come back to work today.

I have to tell you this patch seems wrong. I've tested this patch
and saw lots of 'assert_failed()'. We use ubifs_next_log_lnum()
as an iterator to scan the hole log area and the return value of
this function may equal to c->ltail_lnum.

see:
	fixup_free_space() in fs/ubifs/sb.c line 712
	ubifs_log_post_commit() in fs/ubifs/log.c line 520
and so on.


How about my former patch or a new patch like this?


diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c
index 7e818ec..c14628f 100644
--- a/fs/ubifs/log.c
+++ b/fs/ubifs/log.c
@@ -244,6 +244,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;
 	}

@@ -408,6 +409,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;
 	}

-- 
1.8.1.4

  reply	other threads:[~2014-07-22  1:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-16 12:42 [PATCH 1/2] UBIFS: fix free log space calculation Artem Bityutskiy
2014-07-16 12:42 ` [PATCH 2/2] UBIFS: add a log overlap assertion Artem Bityutskiy
2014-07-22  1:35   ` hujianyang [this message]
2014-07-28 16:18     ` Artem Bityutskiy
2014-07-29 10:27       ` hujianyang
2014-08-11  3:21 ` [PATCH 1/2] UBIFS: fix free log space calculation hujianyang
2014-09-08  9:43   ` Artem Bityutskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53CDBFDB.6080300@huawei.com \
    --to=hujianyang@huawei.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).