From patchwork Tue Dec 26 02:11:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10132783 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 24B4060211 for ; Tue, 26 Dec 2017 02:14:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDA662EA3F for ; Tue, 26 Dec 2017 02:14:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D08902EA4C; Tue, 26 Dec 2017 02:14:34 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ABA582EA3F for ; Tue, 26 Dec 2017 02:14:29 +0000 (UTC) Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vBQ2DoXW006327 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 26 Dec 2017 02:13:51 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vBQ2Dj28017171 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 26 Dec 2017 02:13:45 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 1eTekS-00076k-Rg; Mon, 25 Dec 2017 18:13:44 -0800 Received: from aserv0021.oracle.com ([141.146.126.233]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1eTejL-00070Y-CT for ocfs2-devel@oss.oracle.com; Mon, 25 Dec 2017 18:12:35 -0800 Received: from userp2040.oracle.com (userp2040.oracle.com [156.151.31.90]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vBQ2CYBU021094 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL) for ; Tue, 26 Dec 2017 02:12:35 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 vBQ2CYe8038263 for ; Tue, 26 Dec 2017 02:12:34 GMT Authentication-Results: oracle.com; spf=pass smtp.mailfrom=piaojun@huawei.com Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) by userp2040.oracle.com with ESMTP id 2f2wejj8gt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 26 Dec 2017 02:12:34 +0000 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E4638B89C6775; Tue, 26 Dec 2017 10:12:18 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.361.1; Tue, 26 Dec 2017 10:12:14 +0800 To: "akpm@linux-foundation.org" , Mark Fasheh , Joel Becker , Junxiao Bi , Joseph Qi From: piaojun Message-ID: <5A41AFE2.5010506@huawei.com> Date: Tue, 26 Dec 2017 10:11:46 +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: 1TFkXGx0bEQpMehcbHhkRCllNF2dmchEKWUkXGnEaEBp3BhsfG3EZGxAadwY YGgYaEQpZXhdobnkRCklGF0VYS0lGT3VaWEVOX0leQ0VEGXVPSxEKQ04XZhx+B2BafGdjemIZS2 xCRV1HSV1zeFt6bx97TWRQXh8RClhcFx8EGgQbGBgHHEtIS08eHBoFGxoEGxoaBB4SBB8QGx4aH xoRCl5ZF3hOG3leEQpNXBcZEhwRCkxaF2hpQk17EQpDWhceHwQYHhMEGBsYBBsTGhEKQl4XGxEK RF4XHBEKREkXGREKQkYXZxNtYBtbZUIffn0RCkJcFxoRCkJFF2ZcbHtwZGJ6EnxDEQpCThdsQkh ZUxpNZXh4HREKQkwXb0sZEhJEWXlbG18RCkJsF2MFQlJmQGJeWntSEQpCQBdna14ScGhPb09nYh EKQlgXYn1veQFPGBlwcHsRClpYFxsRCnBoF2QTZ0d6U19PeHlBEBkaEQpwaBdhXVBsGEhHclNBW BAZGhEKcGgXZEtDb0VPe0BifxMQGRoRCnBoF29yHU5aRGhETG8BEBkaEQpwaBdjRERDTUhOTEBk fRAZGhEKcGwXYUl5Q3pzSXhnbGIQGRoRCm1+FxoRClhNF0sRIA== X-PDR: PASS X-ServerName: szxga04-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=8755 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=171 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-1712260028 Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH] ocfs2: return -EROFS to upper 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-Source-IP: userv0021.oracle.com [156.151.31.71] X-Virus-Scanned: ClamAV using ClamSMTP If metadata is corrupted such as 'invalid inode block', we will get failed by calling 'mount()' as below: ocfs2_mount ocfs2_initialize_super ocfs2_init_global_system_inodes : return -EINVAL if inode is NULL ocfs2_get_system_file_inode _ocfs2_get_system_file_inode : return NULL if inode is errno ocfs2_iget ocfs2_read_locked_inode ocfs2_validate_inode_block In this situation we need return -EROFS to upper application, so that user can fix it by fsck. And then mount again. Signed-off-by: Jun Piao Reviewed-by: Alex Chen --- fs/ocfs2/super.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 040bbb6..dea21a7 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -474,7 +474,10 @@ 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; + if (ocfs2_is_soft_readonly(osb)) + status = -EROFS; + else + status = -EINVAL; mlog_errno(status); /* FIXME: Should ERROR_RO_FS */ mlog(ML_ERROR, "Unable to load system inode %d, " @@ -505,7 +508,10 @@ 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; + if (ocfs2_is_soft_readonly(osb)) + status = -EROFS; + else + status = -EINVAL; mlog(ML_ERROR, "status=%d, sysfile=%d, slot=%d\n", status, i, osb->slot_num); goto bail;