From patchwork Wed Dec 27 02:18:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10133325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3E1B2605BD for ; Wed, 27 Dec 2017 02:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A9702D887 for ; Wed, 27 Dec 2017 02:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1ED6F2DB64; Wed, 27 Dec 2017 02:20:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 791FE2DB64 for ; Wed, 27 Dec 2017 02:20:10 +0000 (UTC) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBR2HrIP137597; Wed, 27 Dec 2017 02:19:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : from : message-id : date : mime-version : cc : subject : list-id : list-unsubscribe : list-archive : list-post : list-help : list-subscribe : content-type : content-transfer-encoding : sender; s=corp-2017-10-26; bh=srEkt2nUff/H0aeHa/uIClndvHYL/kV5ZIAKeCAa1w0=; b=Z/9YD92rvhhKQybzu8uEoBG2OPMCVrlR1EoxLsfWhjIBdA16ARR6KdmjOuHqL7yg6lOD uKF1nSXk1u8auiOyrASyNXZ4v/22bTZoy30ItwWaBKFdKmKmNFYt7JPRtJ5v5o1QEgxX aCrH6LY3ICWyGwkkhyV+FopFTTrt8bl7nEp940FZXC1/GeUoo6k7qof6XLWgAr5bHnPA Mc/KXP0FUkoZd3VER1uSYPPLVtbXGx4GuxlTKolLoW8LmwsrJi80c2NDua40Kj1c6seI oja7ryWXVinOhHfTFOB+/WoTpvyASO8hGxPjRl0fX6lpr5aRxSTAvrHTHw2RGBcYTjO1 Ug== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2f3802u8xw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 27 Dec 2017 02:19:33 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vBR2JV5L009820 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 27 Dec 2017 02:19:31 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eU1Jb-0008T7-4N; Tue, 26 Dec 2017 18:19:31 -0800 Received: from userv0021.oracle.com ([156.151.31.71]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eU1JA-0008RS-Il for ocfs2-devel@oss.oracle.com; Tue, 26 Dec 2017 18:19:04 -0800 Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vBR2J4aD006155 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL) for ; Wed, 27 Dec 2017 02:19:04 GMT Received: from pps.filterd (userp2040.oracle.com [127.0.0.1]) by userp2040.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBR2I7hM040669 for ; Wed, 27 Dec 2017 02:19:04 GMT Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by userp2040.oracle.com with ESMTP id 2f3psp164j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 27 Dec 2017 02:19:03 +0000 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D15D13B8C762A; Wed, 27 Dec 2017 10:18:47 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.361.1; Wed, 27 Dec 2017 10:18:38 +0800 To: "akpm@linux-foundation.org" , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi From: piaojun Message-ID: <5A4302FA.2010606@huawei.com> Date: Wed, 27 Dec 2017 10:18:34 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGx0cEQpMehcbHhkRCllNF2dmchEKWUkXGnEaEBp3BhsfHHEZHxAadwY YGgYaEQpZXhdobnkRCklGF0VYS0lGT3VaWEVOX0leQ0VEGXVPSxEKQ04XbhpbW39+HHBia25zYk ViaBlMUBxaSWVlG1hIElxsaRIRClhcFx8EGgQbGBgHHEtIS08eHBoFGxoEGxoaBB4SBB8QGx4aH xoRCl5ZF3hPYU9QEQpNXBceHBgRCkxaF2lCTXsRCk1OF2gRCkNaFx4fBBgeEwQYGxgEGxMbEQpC XhcbEQpEXhccEQpESRcfEQpCRhdsQlhpfEJGcHkaHxEKQlwXGhEKQkUXZlxse3BkYnoSfEMRCkJ OF2xCSFlTGk1leHgdEQpCTBdvSxkSEkRZeVsbXxEKQmwXYwVCUmZAYl5ae1IRCkJAF2EcE10BQR hScEBpEQpCWBdifW95AU8YGXBwexEKWlgXGxEKcGcXZxxYfEtLfmd6e1AQHBoRCnBoF2l5eGtcX llbYXpNEB4SEQpwaBdoZmgdaUVJG11iYRAeEhEKcGgXZ2NOfn9HSEFLaHkQGRoRCnBoF2N7HmRk XGhoWGZaEBkaEQpwaBdofmNFeVt9aRNrZRAZGhEKcGcXb2EcWWdSH3oSbBgQGRoRCnBsF2FJeUN 6c0l4Z2xiEBkaEQptfhcaEQpYTRdLESA= X-PDR: PASS X-Source-IP: 45.249.212.191 X-ServerName: szxga05-in.huawei.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8756 signatures=668650 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=143 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=176 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712270027 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH v3] ocfs2: return -EROFS to mount.ocfs2 if inode block is invalid X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8756 signatures=668650 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712270027 X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Jun Piao Reviewed-by: Alex Chen Reviewed-by: Joseph Qi Reviewed-by: Changwei Ge Reviewed-by: Gang He --- fs/ocfs2/super.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 040bbb6..4e4bb27 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -474,9 +474,8 @@ static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb) 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; @@ -505,7 +504,7 @@ static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb) 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;