Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1724967pxb; Wed, 12 Jan 2022 23:46:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwx1IIcqvf1RMoXbGHU/TrpE+STkUidpAqBkJ0n1MZk65MwsI5nA11z6QDqlYCcve/8lx61 X-Received: by 2002:a17:907:7211:: with SMTP id dr17mr2638787ejc.204.1642060001078; Wed, 12 Jan 2022 23:46:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642060001; cv=none; d=google.com; s=arc-20160816; b=x0eRWMgUKwEp2bzTYrLp5PPJsuwkD0J2Y6fI82jX818uVgealE+9c0rZTIlg6VGfTi lYjlB6Q3Rs1iTvvohT+gojAylL7qLkGQCdcC/jaVdgdPN9dtkF44/MaBbINw/XjPaP4z rJoFmscy/TBFukJRYLkkdrh4lqyWc6gJkkKI/mGND6ttRbycNVNlAR/zLGDyAGPaSPWx tv6QKJ2ESAJwgo1ATEtenOlqtznfT6A/DcPXdY7leE48vURpTTAPCpcsZytMaAYbx0qx med7/DvMnWr/8rCsEbklI9cXKFI2LruKZXxHqXTzDlJ0uCsjQM1+HVzMgHdL81v4pFav Z5tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VzIhrDGbujHD1bDEJMfS4SklRgGqkhYNXnMSPUm4yiY=; b=SIcVGWbwjJzyPzk7XsXLPV+ETQbY2yYM4bbzha6Fxk06Gen76Yxk9USEMcb4k96oFZ FAtBiBQkQh0o1riAZHq7F7h7rf/nRBOVJmfEHsgxRTh2/XRcc6JBhEOY23L78mTE/XD+ ozvQV5ZgQ0eKmzHF54UA2H7dU0bpzDK+1g+uoBcwnVnGc+sLAMb+Ol78mvxQ+l21aMZE KNc/uOVRIfpnDV0utZMNmqgzem3ZByeX2VssKdRL+1LQcOfFhtUjZlSVix/opUeKHKlo 0lF8Fgt9ulB7fHYz4X28IvzjCaOK/MYSgcZePXlp3QH8wlS9hIjGvTsTD3qfh9rEmSHw X8qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jJpkYToj; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k23si1062040eds.509.2022.01.12.23.46.12; Wed, 12 Jan 2022 23:46:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jJpkYToj; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232041AbiAMD0s (ORCPT + 99 others); Wed, 12 Jan 2022 22:26:48 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42864 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232022AbiAMD0p (ORCPT ); Wed, 12 Jan 2022 22:26:45 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 20D2Ra6n034568; Thu, 13 Jan 2022 03:26:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=VzIhrDGbujHD1bDEJMfS4SklRgGqkhYNXnMSPUm4yiY=; b=jJpkYToja4+V9ng2uECFMacAmXhDhYocZ7YgusJYpPMXjSDeROswwJMnzkNqzqFArm5h mw2yCVrFDyVO+2kkaIlbWo3vwMMpE6gPBk6f3Zt2QdKv8riAuXhQtxZHShUd08pHAp8I Py7j9Z4BcK36P8ZuSPJI/htJzdoEJBezoIbfNDu4Djmwxnm3nB8e4f7j0ToLv8YCWEUn p0Jta6LzNFm75HdI20MtiN1N/6nnUIpYJ5Qr6rLIN6C0JssQmwLLOZ15kfjr3eS5o9NX TcvWOpMpKf/+wqTJu34FPTJD/HvIiXi8ikXJQ075i0hMvtaAWmnAGKk+gr9xG8mwIThZ xA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3djban0s66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 03:26:40 +0000 Received: from m0127361.ppops.net (m0127361.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 20D3Nj4a007761; Thu, 13 Jan 2022 03:26:40 GMT Received: from ppma01fra.de.ibm.com (46.49.7a9f.ip4.static.sl-reverse.com [159.122.73.70]) by mx0a-001b2d01.pphosted.com with ESMTP id 3djban0s5y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 03:26:40 +0000 Received: from pps.filterd (ppma01fra.de.ibm.com [127.0.0.1]) by ppma01fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 20D3CDjx005721; Thu, 13 Jan 2022 03:26:38 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma01fra.de.ibm.com with ESMTP id 3dfwhjhxq7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 13 Jan 2022 03:26:38 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 20D3Qac626083628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 13 Jan 2022 03:26:36 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 12CC3AE053; Thu, 13 Jan 2022 03:26:36 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A1931AE057; Thu, 13 Jan 2022 03:26:35 +0000 (GMT) Received: from localhost (unknown [9.43.54.234]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 13 Jan 2022 03:26:35 +0000 (GMT) From: Ritesh Harjani To: linux-ext4@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Andreas Dilger , tytso@mit.edu, Eric Whitney , Ritesh Harjani Subject: [PATCH 1/6] ext4: Fix error handling in ext4_restore_inline_data() Date: Thu, 13 Jan 2022 08:56:24 +0530 Message-Id: X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: VCC3bMlbKoyJpjAy3oQBiOU8JctRjlai X-Proofpoint-ORIG-GUID: z71xHYioVF_5XxDRLa1uT276K8mvidaK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-01-13_01,2022-01-11_01,2021-12-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxlogscore=999 lowpriorityscore=0 adultscore=0 impostorscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 malwarescore=0 phishscore=0 suspectscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2201130013 Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org While running "./check -I 200 generic/475" it sometimes gives below kernel BUG(). Ideally we should not call ext4_write_inline_data() if ext4_create_inline_data() has failed. [73131.453234] kernel BUG at fs/ext4/inline.c:223! 212 static void ext4_write_inline_data(struct inode *inode, struct ext4_iloc *iloc, 213 void *buffer, loff_t pos, unsigned int len) 214 { <...> 223 BUG_ON(!EXT4_I(inode)->i_inline_off); 224 BUG_ON(pos + len > EXT4_I(inode)->i_inline_size); This patch handles the error and prints out a emergency msg saying potential data loss for the given inode (since we couldn't restore the original inline_data due to some previous error). [ 9571.070313] EXT4-fs (dm-0): error restoring inline_data for inode -- potential data loss! (inode 1703982, error -30) Reported-by: Eric Whitney Signed-off-by: Ritesh Harjani --- fs/ext4/inline.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index 534c0329e110..31741e8a462e 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1135,7 +1135,15 @@ static void ext4_restore_inline_data(handle_t *handle, struct inode *inode, struct ext4_iloc *iloc, void *buf, int inline_size) { - ext4_create_inline_data(handle, inode, inline_size); + int ret; + + ret = ext4_create_inline_data(handle, inode, inline_size); + if (ret) { + ext4_msg(inode->i_sb, KERN_EMERG, + "error restoring inline_data for inode -- potential data loss! (inode %lu, error %d)", + inode->i_ino, ret); + return; + } ext4_write_inline_data(inode, iloc, buf, 0, inline_size); ext4_set_inode_state(inode, EXT4_STATE_MAY_INLINE_DATA); } -- 2.31.1