Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2530786imm; Mon, 28 May 2018 09:51:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLSTfokSmb5WMYx1KNCMiQEDcqmrqGMobax2Rr9kiiL9wM7ja1WjSA9EIRs+9tosSD4TBg1 X-Received: by 2002:a63:ad08:: with SMTP id g8-v6mr627329pgf.74.1527526295014; Mon, 28 May 2018 09:51:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527526294; cv=none; d=google.com; s=arc-20160816; b=C5MEBycC6H6WhYNyb4qi6WsacP8ktLsOAXtaGeaMTQTCT+slE+igMymSg2lSLoX+bX 6b3r/LQa5E/kvKdLxd4p0/hiInksGgZEVbU3qHghv/wTvj7NAE9HhI2RGrWwlMnQTmmr BuhDyVgCkUHhUlpl2sRv+e0ob/A+RO36p/FxqcmSvPXlNqQxxYBMVVBDLwaOnlvOnsbX v8onfQIJaqqyT64MelmDgxL2QcHvMkc06oeYXoMwesIcyMhm2Ycic2Dad3RVabwOxBVk /6QgDa57M4W5BmWo83/6Me8AUKkkKRL+D8R2mjeLdV6VZclBDb4s9DeY4ZaP5lq10bg7 koUA== 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:dkim-signature :arc-authentication-results; bh=oWlY9rQtMh7Hu0aBQfES5TybkewcSwLxm5nfO6UnaVA=; b=UbO9n3yATbzpm46mm/QaXnmz+rddMMCFpEhnRjyTy7c+eMS5C/aciXuqPuId1Myv0V c6AJkptnhh54Uf3KRPH1Is+AlPwuA4LmL2RJqhdJkOHkUDSK3AtC2hw9/ser8YJm8235 ZPMY4VqUOwhqa2a9oKIKJJfX/r4oxvOGdX2+VgAhx1STHfUccrdHpX/nvSHCGFJUBf+0 AuB5ZmRF5CAczrDqlzai0v1w5oqYfPmUSccS7Sp5HF0ZQVW7cx4fwW9giOVHCIQNUg8x jCJTt3Qifu7uh6iQiQtfZxDx/f/Ax8cjTGmh+EXlORD3l9qiebn75C+NX6cfqd6hjqqZ NE5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GGti3/N1; 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 c10-v6si7825780pla.53.2018.05.28.09.50.50; Mon, 28 May 2018 09:51:34 -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; dkim=pass header.i=@kernel.org header.s=default header.b=GGti3/N1; 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 S932210AbeE1KHD (ORCPT + 99 others); Mon, 28 May 2018 06:07:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:54738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754830AbeE1KGt (ORCPT ); Mon, 28 May 2018 06:06:49 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 42E052089D; Mon, 28 May 2018 10:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502008; bh=r0b1RZQQmrug20H5Yp4WiRUBI11ajz95QVWm7qmlxVA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GGti3/N1APSBDUuqmEMbXDWcomAJh1zRk3CY1SYjvKv4Kr5+DPmxTruC8H94+PSuh Al/S+Z1chqbM5XzjxJoYHm3p/CRgM+UCYe+kteFGaN0avEUKWKoK3AA3ZjaED0Z5tK pTnNmdxjNi58dtC8WmGkMjPrI0gtkekSRXHWwq7c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jun Piao , Alex Chen , Joseph Qi , Changwei Ge , Gang He , Mark Fasheh , Joel Becker , Junxiao Bi , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 3.18 027/185] ocfs2: return -EROFS to mount.ocfs2 if inode block is invalid Date: Mon, 28 May 2018 12:01:08 +0200 Message-Id: <20180528100052.199681072@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@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: piaojun [ Upstream commit 025bcbde3634b2c9b316f227fed13ad6ad6817fb ] If metadata is corrupted such as 'invalid inode block', we will get failed by calling 'mount()' and then set filesystem readonly as below: ocfs2_mount ocfs2_initialize_super ocfs2_init_global_system_inodes ocfs2_iget ocfs2_read_locked_inode ocfs2_validate_inode_block ocfs2_error ocfs2_handle_error ocfs2_set_ro_flag(osb, 0); // set readonly In this situation we need return -EROFS to 'mount.ocfs2', so that user can fix it by fsck. And then mount again. In addition, 'mount.ocfs2' should be updated correspondingly as it only return 1 for all errno. And I will post a patch for 'mount.ocfs2' too. Link: http://lkml.kernel.org/r/5A4302FA.2010606@huawei.com Signed-off-by: Jun Piao Reviewed-by: Alex Chen Reviewed-by: Joseph Qi Reviewed-by: Changwei Ge Reviewed-by: Gang He Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -467,9 +467,8 @@ static int ocfs2_init_global_system_inod new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); if (!new) { ocfs2_release_system_inodes(osb); - status = -EINVAL; + status = ocfs2_is_soft_readonly(osb) ? -EROFS : -EINVAL; mlog_errno(status); - /* FIXME: Should ERROR_RO_FS */ mlog(ML_ERROR, "Unable to load system inode %d, " "possibly corrupt fs?", i); goto bail; @@ -498,7 +497,7 @@ static int ocfs2_init_local_system_inode new = ocfs2_get_system_file_inode(osb, i, osb->slot_num); if (!new) { ocfs2_release_system_inodes(osb); - status = -EINVAL; + status = ocfs2_is_soft_readonly(osb) ? -EROFS : -EINVAL; mlog(ML_ERROR, "status=%d, sysfile=%d, slot=%d\n", status, i, osb->slot_num); goto bail;