Received: by 10.192.165.148 with SMTP id m20csp2453388imm; Sun, 22 Apr 2018 07:22:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/YR3hUrGHT3U+5xCdoh4YNcQhFM5/IWys0KN8WzkmnYFY4Pfurqeu3cVD6HJkAmZHplVFw X-Received: by 2002:a17:902:70c4:: with SMTP id l4-v6mr17383467plt.382.1524406922239; Sun, 22 Apr 2018 07:22:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524406922; cv=none; d=google.com; s=arc-20160816; b=h56B3HDjDDdidHnq57txgovsjfdzXIMT6vGdZSIsmdRJKxwQ4g1Q87g5QV8GVNe22M uCZ/zzq1Do/KTFcuqOIwP+QdKvwhbi8GzDN1lC6icVUFD3okChaoqFSevuwWYrssMMQB CggPTqA3bs9J6O1j2YSLLUBtUxwgmvKm8U3oe1kEyUfQCukpnT+sgX3Tb4tVVcp+Tv5T EHxBJFuECRC6TbcJpB3IKhh4L92dQdugN2smmJbpDBLo3YX2IEFVGsMPPU0R08HQhQOW S45k9pIKc6ueqfuHTHEuFPV+6BMvxfFaEaQAAAVzWhLCZseyREXhDXaB5dH4ERNXFrVU WSzg== 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=D84Wsv/qOzKnbFRsGxD24AyxHxEmQe3042KSzU5/mrg=; b=WqB8lWaiwI65UOB2DCwC6V0eimljB91HAc4MBljJ1TEBIKxkS44oR002DpYGeIHRou qvn7aT1LHUFRemph9nvnEDujuyxv+4KwoFUmPIpI+D+sGKOU+NoZtGp3xBdbkzNkhrDq 89lycdy3x+Weh8KDbggr0acAY9P7wJi4SMbWwYMnUPmfPcszWTUMGlDJOhLVS6caINlj iMyED8/nEk86ePccQZghkU4BZnsj2vTfux282m1Wx8FVGp5BoQwQ4jwpRlvfV7AKvELY ujMjzs4HXrXPUWv17oX0j8h3N3nSb4ddS3s8UAhjLqyWUiqbbEeWwnEgnPuqex5j6fuF YwCg== 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 d21-v6si9942598plr.352.2018.04.22.07.21.48; Sun, 22 Apr 2018 07:22:02 -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 S1757471AbeDVOUn (ORCPT + 99 others); Sun, 22 Apr 2018 10:20:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60572 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757452AbeDVOUk (ORCPT ); Sun, 22 Apr 2018 10:20:40 -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 6B4EE486; Sun, 22 Apr 2018 14:20:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Richard Weinberger Subject: [PATCH 3.18 07/52] ubifs: Check ubifs_wbuf_sync() return code Date: Sun, 22 Apr 2018 15:53:40 +0200 Message-Id: <20180422135315.576107733@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135315.254787616@linuxfoundation.org> References: <20180422135315.254787616@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 3.18-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 @@ -1726,8 +1726,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); @@ -1794,8 +1797,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