From patchwork Sun Aug 22 07:44:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Artem Bityutskiy X-Patchwork-Id: 62361 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CEB90B70DD for ; Sun, 22 Aug 2010 17:47:01 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1On5Ee-0004Pt-2E; Sun, 22 Aug 2010 07:44:56 +0000 Received: from mail-fx0-f49.google.com ([209.85.161.49]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1On5Ea-0004Mp-U3 for linux-mtd@lists.infradead.org; Sun, 22 Aug 2010 07:44:53 +0000 Received: by fxm12 with SMTP id 12so2981537fxm.36 for ; Sun, 22 Aug 2010 00:44:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:reply-to:to:cc :in-reply-to:references:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=6dwGKtZKs9lz1myiaUz2vsfHdzkxj2n+aeEeZDLyqQA=; b=NvW6nI6vllnmrVsNs3SVUZDvqZ2iuSLFh1xDPKSaVcLbW6AiddilWKc8p74pgi5ekh X1LmFfHkuyCcP4cqDOwIj5M7Mbo20qNqxFSX6N+4mR2RvA9v66kJTGEGO0OxFSxK8qeM OF5EOjsrHFKu3FZqCGWmrAJ0S0xOpdCI0OAh0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:reply-to:to:cc:in-reply-to:references:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; b=V3l9kno81lBiPT6TYeansrtf88xXKBP+kaHUmX25GCVLxdkQfI0rwuUg3b9P+5xvDi 67t0yvSAgFFoed9mPlwvIuBu6tchYPV1sWptMXJZ7TFfd7A6PC3MHx9pa1wEOszvT8Ig 5Yt2OVo+ls+cuoL/Bg2CJdE5ftjr87+gTmaYE= Received: by 10.223.110.73 with SMTP id m9mr2886237fap.25.1282463090596; Sun, 22 Aug 2010 00:44:50 -0700 (PDT) Received: from [192.168.255.16] (a91-152-69-107.elisa-laajakaista.fi [91.152.69.107]) by mx.google.com with ESMTPS id b9sm1926576faq.7.2010.08.22.00.44.48 (version=SSLv3 cipher=RC4-MD5); Sun, 22 Aug 2010 00:44:48 -0700 (PDT) Subject: Re: ubifs : corruption after power cut test From: Artem Bityutskiy To: Matthieu CASTET In-Reply-To: <4C4FDEF5.2040405@parrot.com> References: <4C346D5B.2000609@parrot.com> <4C3C1572.8080501@parrot.com> <4C3C2740.2040105@parrot.com> <4C3C30D1.9030005@parrot.com> <1279031064.31639.90.camel@localhost> <4C3C81E3.3030407@parrot.com> <4C4FDEF5.2040405@parrot.com> Date: Sun, 22 Aug 2010 10:44:46 +0300 Message-ID: <1282463086.16502.38.camel@brekeke> Mime-Version: 1.0 X-Mailer: Evolution 2.30.2 (2.30.2-4.fc13) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100822_034453_323248_EC23CA18 X-CRM114-Status: GOOD ( 19.54 ) X-Spam-Score: 2.1 (++) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (2.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.161.49 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is freemail (dedekind1[at]gmail.com) 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (dedekind1[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: "linux-mtd@lists.infradead.org" X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: dedekind1@gmail.com List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org On Wed, 2010-07-28 at 09:40 +0200, Matthieu CASTET wrote: > I manage to reproduce it with the backtrace [1]. Matthieu, your work-around patch or something very close should certainly be applied to the UBIFS tree, but I still would like to find out what exactly happened in your setup. I see 2 possibilities: 1. An error happened and 'ubifs_garbage_collect()' returned while c->gc_lnum was -1. But in this case we should have switched to R/O mode, and the master node would not be written. But may be for some reasons we did not switch to R/O mode, dunno. 2. More likely scenario: in 'ubifs_rcvry_gc_commit()' we call 'ubifs_garbage_collect_leb()' directly, which can return while c->gc_lnum is -1. And we do not handle this. Would you please be patient enough to reproduce the issue once again with the following patch, which was created against the latest ubifs-2.6.git, but you should be easily able to apply it to your tree. Artem. diff --git a/fs/ubifs/budget.c b/fs/ubifs/budget.c index c8ff0d1..aa433cd 100644 --- a/fs/ubifs/budget.c +++ b/fs/ubifs/budget.c @@ -83,6 +83,10 @@ static int run_gc(struct ubifs_info *c) down_read(&c->commit_sem); lnum = ubifs_garbage_collect(c, 1); up_read(&c->commit_sem); + if (c->gc_lnum == -1) { + ubifs_err("gc_lnum is -1! ubifs_garbage_collect() returned %d", lnum); + dump_stack(); + } if (lnum < 0) return lnum; diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c index 396f24a..0e78832 100644 --- a/fs/ubifs/gc.c +++ b/fs/ubifs/gc.c @@ -807,12 +807,20 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway) goto out; } out_unlock: + if (c->gc_lnum == -1) { + ubifs_err("gc_lnum is -1! ubifs_garbage_collect() is returning %d", ret); + dump_stack(); + } mutex_unlock(&wbuf->io_mutex); return ret; out: ubifs_assert(ret < 0); ubifs_assert(ret != -ENOSPC && ret != -EAGAIN); + if (c->gc_lnum == -1) { + ubifs_err("gc_lnum is -1! ubifs_garbage_collect() is returning %d", ret); + dump_stack(); + } ubifs_wbuf_sync_nolock(wbuf); ubifs_ro_mode(c, ret); mutex_unlock(&wbuf->io_mutex); diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index d321bae..44df514 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -162,6 +162,10 @@ again: mutex_unlock(&wbuf->io_mutex); lnum = ubifs_garbage_collect(c, 0); + if (c->gc_lnum == -1) { + ubifs_err("gc_lnum is -1! ubifs_garbage_collect() returned %d", lnum); + dump_stack(); + } if (lnum < 0) { err = lnum; if (err != -ENOSPC) diff --git a/fs/ubifs/recovery.c b/fs/ubifs/recovery.c index daae9e1..3058256 100644 --- a/fs/ubifs/recovery.c +++ b/fs/ubifs/recovery.c @@ -1126,6 +1126,10 @@ int ubifs_rcvry_gc_commit(struct ubifs_info *c) dbg_rcvry("GC'ing LEB %d", lnum); mutex_lock_nested(&wbuf->io_mutex, wbuf->jhead); err = ubifs_garbage_collect_leb(c, &lp); + if (c->gc_lnum == -1) { + ubifs_err("gc_lnum is -1! ubifs_garbage_collect_leb() returned %d", err); + dump_stack(); + } if (err >= 0) { int err2 = ubifs_wbuf_sync_nolock(wbuf);