Received: by 10.192.165.148 with SMTP id m20csp2475206imm; Sun, 22 Apr 2018 07:49:25 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+x8xGIeHMxF/BiyRcLBAcwXGLH8lERrP5rPoxK0yGYUO+2PYX995tgKjm/z5bVTSs8bQxS X-Received: by 10.99.103.6 with SMTP id b6mr14407253pgc.214.1524408565545; Sun, 22 Apr 2018 07:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524408565; cv=none; d=google.com; s=arc-20160816; b=Kt7/JFnKqlsT9sd6fajzkkDxL9DBffF5Pp4Y7UBCtsyW+cH60ddosJyP9o/aUlZ9mW VHt9yEJTKHCbDG7KnCIc4nJeV5JysXi2LnJxfvmI0QEws0/WqFU4arB8YQTFT0Q23BXN tggfD1+pr3aIUd8bGq+4rVq/ZWqyoDN5cd83ZqzTaI1rHYl2sVbGBisk9PoMcvN7qc3i LB0BRhhISM3P1SXmR8DHexyeBG719hZUEzws7QGn4tCLYBlt9IxBS+o15v3fetsa6JVd VRljCfOd00F56tJtpDA982olyQEt3BFf6W4oLp2qealY71949AHUn3/hmyrsAEVZyTLV 9qZg== 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=vjupF8CSGFDkHxjqiugzMJRaFvTLqjF7OisUli23myI=; b=f9ihQaRw+UMvSRi4AvX3C9m/ERhrYUXzYQw9QpFacTaBxI19kHiGCEZduDwRcD1KDn lQzBfjRNod0nP6TtCtnQoqupoNzxbPfyYmrns7NpcetjwigCRRrNFpMoLFTA+bG2fqLH 7BbiRTDpqbBUGo+43C/GfLhsAbRD+mebWPB4gPOY3qk9A3Ev4EWWjaAZaKu4A5iHCH6i wrmujpkupT674ks4vnoPigbNq3Lw43mZXqdDekn70Qe2ci6buFcBY4fXj8gv906LWgqV tOnIoKcOTT1WDrjKC9hDJ63xvCsejicJjphxVsQoJ6bmLgbxDiGFHbZ/LkTHpiy4BvPo OCew== 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 m2si8462527pgs.590.2018.04.22.07.49.11; Sun, 22 Apr 2018 07:49:25 -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 S1757396AbeDVOry (ORCPT + 99 others); Sun, 22 Apr 2018 10:47:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57218 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932210AbeDVOQG (ORCPT ); Sun, 22 Apr 2018 10:16:06 -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 AD7B5C79; Sun, 22 Apr 2018 14:16:05 +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.4 22/97] ubifs: Check ubifs_wbuf_sync() return code Date: Sun, 22 Apr 2018 15:53:00 +0200 Message-Id: <20180422135306.046611687@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135304.577223025@linuxfoundation.org> References: <20180422135304.577223025@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.4-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 @@ -1728,8 +1728,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); @@ -1795,8 +1798,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