Received: by 10.192.165.148 with SMTP id m20csp2426327imm; Sun, 22 Apr 2018 06:56:26 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Y2HJhGhInYn+AHFNmmEkVsunYI84Oc2vFJx8bJzGEA4wFTPYtrY3CHUmy1t7esBkrdlR7 X-Received: by 10.101.68.205 with SMTP id g13mr13921274pgs.387.1524405386494; Sun, 22 Apr 2018 06:56:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524405386; cv=none; d=google.com; s=arc-20160816; b=N6gjgWU+UXdNOlcQkO/JkrDHxjL7GoUJglzqMuzpXZR/Qgf4cVTtlq2jcWPbWFx83w j3cye1XFonWWxCzQVcpodr6+g23fcNOq7grmBo1cGwVBglxkSLxVcWL1m8/4q/3kjfHO KB5ipVV8Y39Dwrr8ctJaRkSxAuuKn4754e54C3+swCQJutd0y3GHmkUe6G9d5B1SdEIs IIw3BN8hhfUV2BsGudoOYLHitUz/4lCiuzft0R0yIifNgRn+pKfg/5bUNMAwfDmZTojJ BnN+8PJ4iErtHA0BGyHb+iQsMFf/ilLb2pVBiE5zhguYWrwYd7KFEIpeQpP5gb+s+it4 b08Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=ARX8y2tGvar0WtTMFt71ufjkoVpWB0qK9wdtJLchgQY=; b=dzjosSoFvc2ldGzcaEpNFaN5EQY2b0k7igAJXrpgtjzUYfOLrB/XqUAhp4nLAWBmF8 SNy5cKBdT436u/KFLmoH/fjc0ggMUlHYp3xBbHcDKwQNnMx7NjMZMifzFu8SC1odHxWL fmVWUdJoPeNqK9D+yUshwli1EKLtjvYiZ/1uc3TMvGKnI0uZOPdZ09ss6lX1ULT+TeP0 cjO4iKj1luTh2LpypDbrMfNgUiJlus56Iel5QhoZxAXnMO7a+6MArecAjl5aiREtP55y mqic3iUAymjkrTbNA9rJ6xzzJgYNJSQuDeFK/u81fQThBBCIKiYeP5Xy6RXCVj6u1SYY Jtyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n1-v6si9483315pll.89.2018.04.22.06.56.12; Sun, 22 Apr 2018 06:56:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753390AbeDVNy5 (ORCPT + 99 others); Sun, 22 Apr 2018 09:54:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44296 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752550AbeDVNys (ORCPT ); Sun, 22 Apr 2018 09:54:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 86A6A727; Sun, 22 Apr 2018 13:54:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Weinberger Subject: [PATCH 4.16 004/196] ubifs: Check ubifs_wbuf_sync() return code Date: Sun, 22 Apr 2018 15:50:24 +0200 Message-Id: <20180422135104.464853640@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Richard Weinberger commit aac17948a7ce01fb60b9ee6cf902967a47b3ce26 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- fs/ubifs/super.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -1737,8 +1737,11 @@ static void ubifs_remount_ro(struct ubif 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); @@ -1804,8 +1807,11 @@ static void ubifs_put_super(struct super 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