Received: by 10.192.165.148 with SMTP id m20csp2444685imm; Sun, 22 Apr 2018 07:12:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx493bg9A/pyXI2U65TiH/23N67aYcV14zjnDZoI/ou9CJR58zZHgldVw8Yin+YgVDyVJrtR5 X-Received: by 10.98.133.15 with SMTP id u15mr16633094pfd.160.1524406377976; Sun, 22 Apr 2018 07:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524406377; cv=none; d=google.com; s=arc-20160816; b=fCZloRP9B008Y6vIrVwDEaxwCb41dlGUU5dAMWlSGh8lYVpAUCSY87X0j6Z4nCmRsD Fuy3X3zYco9UAKj+rkQWFAME+lOU+7V49vMmaPKC3i/6MYEMsQFfO0e/hXTC/7omYNGW CuSqtjPaBzdalvhg+bn9q6tU5PgLbNTaDq7mdoqn1UzgsfBbka14wV9tOs3nZ14eEpt/ HP5flKBfybTX824GtyVgZp/2xB/xP8WD21EFeJaNQWdqzM9/wKwmP0vaWoCQmFjtYTZe Omwa2Z8BOnn5EGxLvuMV8UwUTlgFnZUY3ODB7Hk71iHqmjz7ZvqarUcuDchZq/+lkU3v BcfQ== 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=Ga5nb4czOgGcogKvQxNDmoRaY5uqUCJLEmf4u4b/x0I=; b=wBAAI4gVXojSX/WuYQgj6CtmW1b+Mxx/X7+qSEdrPCeTZMTGnZLiG5dnZ498B6eblp rpKVVcnsjwT10a8VRqYqQQej7RJ247oL45v/hhyg5sZZihCcLYrIWEu3gfeoVCw1xI8g R4IPrs4FA1lw3PdM1tWH1Qjtx1SJRRmEYrVKCnwl5ar6mB8q4A1RQZMv2QHdz1IRvzwM X3NP/X7NunbX1t88BndB0sU8vDnk4isJJ3De2g+qDhtT013ihyVW8f+Pku5wIaSo55Cy OBHKrxigu9XZ1i8xiDn+kZxNeslv5DPiIy8IXoQ0qWScxuDVlcYDrK+j25rzt4VdO6Nv Aj1g== 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 q24si9061116pff.13.2018.04.22.07.12.43; Sun, 22 Apr 2018 07:12:57 -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 S1756570AbeDVOLq (ORCPT + 99 others); Sun, 22 Apr 2018 10:11:46 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54480 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756539AbeDVOLi (ORCPT ); Sun, 22 Apr 2018 10:11:38 -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 22F6DCB0; Sun, 22 Apr 2018 14:11:36 +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.9 02/95] ubifs: Check ubifs_wbuf_sync() return code Date: Sun, 22 Apr 2018 15:52:31 +0200 Message-Id: <20180422135210.535012308@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135210.432103639@linuxfoundation.org> References: <20180422135210.432103639@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.9-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