From patchwork Sun May 27 03:16:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changwei Ge X-Patchwork-Id: 10429283 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 93A8D603B5 for ; Sun, 27 May 2018 03:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 744002892B for ; Sun, 27 May 2018 03:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66A0729113; Sun, 27 May 2018 03:19:13 +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=-5.2 required=2.0 tests=BAYES_00,FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher AES256-SHA256 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A1DA2892B for ; Sun, 27 May 2018 03:19:11 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4R3Fakg089537; Sun, 27 May 2018 03:17:31 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2j7084t0rm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 27 May 2018 03:17:31 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4R3HSJP031467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 27 May 2018 03:17:28 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 1fMmBU-0000PG-25; Sat, 26 May 2018 20:17:28 -0700 Received: from userv0022.oracle.com ([156.151.31.74]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1fMmB1-0000O2-I4 for ocfs2-devel@oss.oracle.com; Sat, 26 May 2018 20:17:00 -0700 Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w4R3GwYI016403 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=FAIL) for ; Sun, 27 May 2018 03:16:59 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w4R3E7Gr030061 for ; Sun, 27 May 2018 03:16:58 GMT Received: from apc01-pu1-obe.outbound.protection.outlook.com (mail-oln040092254054.outbound.protection.outlook.com [40.92.254.54]) by userp2030.oracle.com with ESMTP id 2j6wnbg5cd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=OK) for ; Sun, 27 May 2018 03:16:58 +0000 Received: from SG2APC01FT010.eop-APC01.prod.protection.outlook.com (10.152.250.54) by SG2APC01HT126.eop-APC01.prod.protection.outlook.com (10.152.251.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.696.11; Sun, 27 May 2018 03:16:52 +0000 Received: from HK2PR06MB0452.apcprd06.prod.outlook.com (10.152.250.52) by SG2APC01FT010.mail.protection.outlook.com (10.152.250.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.696.11 via Frontend Transport; Sun, 27 May 2018 03:16:52 +0000 Received: from HK2PR06MB0452.apcprd06.prod.outlook.com ([fe80::54f:c47d:f84b:5d1e]) by HK2PR06MB0452.apcprd06.prod.outlook.com ([fe80::54f:c47d:f84b:5d1e%5]) with mapi id 15.20.0797.011; Sun, 27 May 2018 03:16:52 +0000 From: Changwei Ge To: Andrew Morton , "ocfs2-devel@oss.oracle.com" , "mark@fasheh.com" , "jiangqi903@gmail.com" , "junxiao.bi@oracle.com" Thread-Topic: [PATCH] ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry Thread-Index: AQHT9Wko+9GM2Dl5VUCHFgrxEGm0Fw== Date: Sun, 27 May 2018 03:16:52 +0000 Message-ID: Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK2PR02CA0131.apcprd02.prod.outlook.com (2603:1096:202:16::15) To HK2PR06MB0452.apcprd06.prod.outlook.com (2a01:111:e400:a41b::18) x-incomingtopheadermarker: OriginalChecksum:3AC21C7326CCC253D675231E15BD2F0C63A796997F6C987CCE0F3AEE530C3D64; UpperCasedChecksum:04CC2462D101B8032D12CF9E9AA043DF31D537259C7CB8829755C51DADB7381F; SizeAsReceived:7614; Count:48 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [8g6eOc81gdFF8QEUDSN5Olu+1veoZ2Op6To5YuclN74=] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; SG2APC01HT126; 7:Ry+CbXShf917j90kZcSDSb+0qyMNgv0Qrt5B7EhM6qAdu04r/bEgnm1PBnSIX+2a+PQoXEKwZCHdGF8c8x+68UEZfKnwwik6mA/OFQ4bap775m84CA5qAkptjQg1b4ZxTVAEtQY5/fWoWBfVlhv9wmUmhA+EHtEj+doD/GFh/dz8oZTx4VdoibPiNpWSnF25VbH+Wfll0vImw1dGyRybmTS6nPkH0hc1VxAuRfGfTHfJBLbAwhYqgnk906MLvXYm x-incomingheadercount: 48 x-eopattributedmessage: 0 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125466)(1701031045); SRVR:SG2APC01HT126; x-ms-traffictypediagnostic: SG2APC01HT126: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(444000031); SRVR:SG2APC01HT126; BCL:0; PCL:0; RULEID:; SRVR:SG2APC01HT126; x-forefront-prvs: 0685122203 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(199004)(189003)(2201001)(15760500003)(7696005)(106356001)(3660700001)(55016002)(9686003)(86362001)(6436002)(8936002)(305945005)(68736007)(105586002)(39060400002)(81156014)(3280700002)(74316002)(14454004)(81612004)(74482002)(54906003)(104016004)(5250100002)(33656002)(6506007)(25786009)(4326008)(110136005)(99286004)(8676002)(476003)(5660300001)(386003)(6346003)(26005)(59450400001)(102836004)(2900100001)(1857600001)(486006)(82202002)(97736004)(2501003); DIR:OUT; SFP:1901; SCL:1; SRVR:SG2APC01HT126; H:HK2PR06MB0452.apcprd06.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:; received-spf: None (protection.outlook.com: live.cn does not designate permitted sender hosts) x-microsoft-antispam-message-info: eFZlK9gBUyMbga9vNOrC75JboqXHu74C2CL7oG0jkrEz73q4txWTLNetOY8k2bR9OYMUmnsIYNCUzT0NMjpZVl0WE7mVlfImrHDO4yzxaiczAs6u25EXOFA/mHnX1a2eAsTnKNQ+lbkSjC4gG9ymoAcD476enwsbGbhWuiuXo50qRFL3PMzv8Xg8VxIrPrfz MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 75db996b-31f3-460f-1392-08d5c3804ab5 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: d4d70346-2c10-4f39-8c00-e767963926d9 X-MS-Exchange-CrossTenant-Network-Message-Id: 75db996b-31f3-460f-1392-08d5c3804ab5 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: d4d70346-2c10-4f39-8c00-e767963926d9 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 May 2018 03:16:52.4778 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2APC01HT126 X-CLX-Shades: MLX X-CLX-Response: 1TFkXGBgSEQpMehcTGhEKWU0XZ2ZyEQpZSRcacRoQGncGGBoScRsbExAadwY YGgYaEQpZXhdobnkRCklGF0VYS0lGT3VaWEVOX0leQ0VEGXVPSxEKQ04XWRhye0FlS29sY1JHeB tlf0JJU21tYRtnZVt6GlhEZFwRClhcFx8EGgQbGR8HSRoeE04cEkkFGxoEGxoaBB4SBB8QGx4aH xoRCl5ZF3l6EkxsEQpNXBcfEh0RCkxaF2lCTV0RCkxGF2NrEQpDWhceGgQTGAQYHx4EHx4RCkJe FxsRCkReFxMRCkRJFxkRCkJGF2cTbWAbW2VCH359EQpCXBcaEQpCRRdhRlhrHWFQEm9oTxEKQk4 XYHgeW1JaW38dfkARCkJMF29cGXwFRXpQHUhIEQpCbBdkYU9LYEJIEngdZxEKQkAXYl1LEkZLBW xsHEERCkJYF2J9b3kBTxgZcHB7EQpaWBcYEQpwZxdvYRxZZ1IfehJsGBAZGhEKcGgXYV0ZWkceH lkdeBkQGhEKcGgXZmxZeGJZGnhSQn8QGRoRCnBoF2lTaF1fYBlATkl5EBkaEQpwaBdvfH9dX2Zc aUdnYxAaEQpwaBdkWnJNeWZCTX5nUxAZGhEKcGcXbV8dSRoYTX9abHMQGRoRCnBsF21OG29TAUd SSB1zEBkaEQptfhcaEQpYTRdLESA= X-PDR: PASS X-Source-IP: 40.92.254.54 X-ServerName: mail-oln040092254054.outbound.protection.outlook.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 include:spf-a.hotmail.com include:spf-b.hotmail.com include:spf-c.hotmail.com include:spf-d.hotmail.com ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8905 signatures=668702 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=90 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=228 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-1805270038 X-Spam: Clean Cc: "stable@vger.kernel.org" Subject: [Ocfs2-devel] [PATCH] ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry 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=8905 signatures=668702 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-1805270038 X-Virus-Scanned: ClamAV using ClamSMTP From: Changwei Ge Somehow, file system metadata was corrupted, which causes ocfs2_check_dir_entry() to fail in function ocfs2_dir_foreach_blk_el(). According to the original design intention, if above happens we should skip the problematic block and continue to retrieve dir entry. But there is obviouse misuse of brelse around related code. After failure of ocfs2_check_dir_entry(), currunt code just moves to next position and uses the problematic buffer head again and again during which the problematic buffer head is released for multiple times. I suppose, this a serious issue which is long-lived in ocfs2. This may cause other file systems which is also used in a the same host insane. So we should also consider about bakcporting this patch into linux -stable. Suggested-by: Changkuo Shi Signed-off-by: Changwei Ge --- fs/ocfs2/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index b048d4f..c121abb 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -1897,8 +1897,7 @@ static int ocfs2_dir_foreach_blk_el(struct inode *inode, /* On error, skip the f_pos to the next block. */ ctx->pos = (ctx->pos | (sb->s_blocksize - 1)) + 1; - brelse(bh); - continue; + break; } if (le64_to_cpu(de->inode)) { unsigned char d_type = DT_UNKNOWN;