From patchwork Wed Jan 17 18:12:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 862484 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Q96C/Ssk"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="JTV3X3uY"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zMFYP2S45z9sNx for ; Thu, 18 Jan 2018 05:12:25 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=wv6OiouLMtTe71zQ32CBiBVAyPRyJGFausMF1vsISzI=; b=Q96 C/SskMGyB6P4EsqI0VG/TouGiu/FWfkI4UUbrBfdThfU3MVkJD1PU9bJzPDOQRGl0FK1QuFxACcs3 YCE0GoRTC6tZ+g8z5pniKXVqoWxcvTZY7fyvMlt6SbuVBkwCt7XQ59DPKe7Julm92aACazBGTqiR0 Cs4IUCIqYKSVMH3dPs6xkhZQH9yBO2xk2J28jTWCDNGu4POFD9EQddC1XsA3tkVcxKrSWZ59Ef3El +iZdWqIh47G9MNCDgh2Sw6C167acEu0wu129nDXTN/oxKZdRmZxYeLqSTy2xoDt2FJNhfH2xbx61W x2GK3/jSCkns0BaJflql3SRG7r+wMYw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1ebsCE-0000kW-6V; Wed, 17 Jan 2018 18:12:22 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebsCC-0000kL-Tf for linux-mtd@bombadil.infradead.org; Wed, 17 Jan 2018 18:12:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+pUHJPfgTnixXNUQhszH2isUFFVAv1Axj1yws7Ns3R8=; b=JTV3X3uYBWAfkI+5cp+YLfZw+ sU+GbDem8CJ8uaXb1U9Z5sKybp8CqDg423wVwpy9EpOnPR5vo9sJmCqJPg9AdAOIZlYxDVLI915SR KC2PIofydP/7IZD8s8Qvf/wCw1NCr6na99E1+JyuZIrcdzwHZ3SrNEKvPfGfpIwSt1murKTb/v/w0 D1oPBA66bMu/nSDvNLA0j5U+wCI5nuQSvuOPSF3hpLTeWn2RjXgKyLTuIieS0UqOTrqoX4YUJw/e2 7yhUn7GjGO4YXadOKQgo5uNvDq4oxSEjoZZQIDWoZuzf2CyS2TSoEGqECg6II48iVvpmQH1AQOQr1 SPookOEhw==; Received: from lilium.sigma-star.at ([109.75.188.150]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1ebsC9-0003NT-Qb for linux-mtd@lists.infradead.org; Wed, 17 Jan 2018 18:12:19 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id AD31F1818C3EE; Wed, 17 Jan 2018 19:11:51 +0100 (CET) X-Virus-Scanned: amavisd-new at lilium.sigma-star.at From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH] ubifs: Check ubifs_wbuf_sync() return code Date: Wed, 17 Jan 2018 19:12:42 +0100 Message-Id: <20180117181242.26572-1-richard@nod.at> X-Mailer: git-send-email 2.13.6 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180117_181217_865905_6627C499 X-CRM114-Status: GOOD ( 12.55 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , linux-kernel@vger.kernel.org, stable@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If ubifs_wbuf_sync() fails we must not write a master node with the dirty marker cleared. Otherwise it is possible that in case of an IO error while syncing we mark the filesystem as clean and UBIFS refuses to recover upon next mount. Cc: Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") Signed-off-by: Richard Weinberger --- fs/ubifs/super.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 0beb285b143d..468bca452d0a 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1739,8 +1739,11 @@ static void ubifs_remount_ro(struct ubifs_info *c) dbg_save_space_info(c); - for (i = 0; i < c->jhead_cnt; i++) - ubifs_wbuf_sync(&c->jheads[i].wbuf); + for (i = 0; i < c->jhead_cnt; i++) { + err = ubifs_wbuf_sync(&c->jheads[i].wbuf); + if (err) + ubifs_ro_mode(c, err); + } c->mst_node->flags &= ~cpu_to_le32(UBIFS_MST_DIRTY); c->mst_node->flags |= cpu_to_le32(UBIFS_MST_NO_ORPHS); @@ -1806,8 +1809,11 @@ static void ubifs_put_super(struct super_block *sb) int err; /* Synchronize write-buffers */ - for (i = 0; i < c->jhead_cnt; i++) - ubifs_wbuf_sync(&c->jheads[i].wbuf); + for (i = 0; i < c->jhead_cnt; i++) { + err = ubifs_wbuf_sync(&c->jheads[i].wbuf); + if (err) + ubifs_ro_mode(c, err); + } /* * We are being cleanly unmounted which means the