Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp350531ybz; Thu, 30 Apr 2020 23:31:33 -0700 (PDT) X-Google-Smtp-Source: APiQypJQ30pLYmuMqUC3yXyw0fvD95b6XYrgtz7gAyH9C0ydx3PVyURDkRr2Aa0qLWHD3nYxVdZq X-Received: by 2002:aa7:c40e:: with SMTP id j14mr2323843edq.125.1588314693339; Thu, 30 Apr 2020 23:31:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588314693; cv=none; d=google.com; s=arc-20160816; b=FDDTFcymMikmpzDaU+br+rlXiR8IGeUKOgOpNzyFFFVeilx5uwcAGWkzGlW5GtU9A/ 437qYTlaVRKFXRwT9hi7ZLHDdxcIEBEfpUkp8RWoyJSSQFOaAfh4Su0E3IWZeKT1assB AsF1zz+3qtv6ZPENDTxm1Mo1VOjanVnNZfDRg21qz93QZ2C4LHX20o0V5QaiXW/NS7GG zy3dneFM6SDliQhLkmR4KU2M8VpjvdgD8IT09qqjjL7GzwJpZhrih385NDhoAupPCrpN LwloO37pTreqgCtsEkwQXYYWGZP6Iqnecbe+WctDY4oeD+j2vvoNCVl8xdsD4w6rXyEq b+bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=X/X2dkzdLmQfgkQRszSirfaSEhm7mi9ZZsSV2OXGRkM=; b=PSVIhgjEi4KvI5lr/ooL2Lj5Zd3enwPhd9cAg3CBb93bQmEIydyaIpGrA4K0pj5GwP pnZJF8EiUetn3SF7dWQCJRfvKxFrXmW/21nWiR6FDNmhzLxt7p6nyDaVv3FY7Lp5eleX hKp5Np789CWjZXks5/uEoEr7wKLxCQ6V8Pd8XMExJJmFTMwVjybEmC20PS1yPExXm2Sz W4iVJAYN8/KAdQXMYJYSSOTr4iSN00xKFHtZfPOSqfBmHT8RTJ/f0Bw+YLXXuTvFKV9T DdeYQGdyeTW1KKFZKiX+p9pFCmTYxkCJry/QuadaqogXqtAmgRk/dweTdoM5jYQe3Ggp ojRA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 ha13si1183787ejb.390.2020.04.30.23.31.09; Thu, 30 Apr 2020 23:31:33 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728334AbgEAGaq (ORCPT + 99 others); Fri, 1 May 2020 02:30:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30254 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728126AbgEAGaq (ORCPT ); Fri, 1 May 2020 02:30:46 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04162AUh108194; Fri, 1 May 2020 02:30:40 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 30r5cmnj1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 May 2020 02:30:39 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 0416Aqrb009348; Fri, 1 May 2020 06:30:38 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma04ams.nl.ibm.com with ESMTP id 30mcu746rs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 May 2020 06:30:38 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0416UZMA62849094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 May 2020 06:30:35 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 75323A4054; Fri, 1 May 2020 06:30:35 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AAB37A405C; Fri, 1 May 2020 06:30:33 +0000 (GMT) Received: from localhost.localdomain.com (unknown [9.85.81.13]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 1 May 2020 06:30:33 +0000 (GMT) From: Ritesh Harjani To: linux-ext4@vger.kernel.org Cc: "Paul E . McKenney" , linux-fsdevel@vger.kernel.org, Jan Kara , tytso@mit.edu, "Aneesh Kumar K . V" , Ritesh Harjani Subject: [RFC 13/20] ext4: mballoc: Don't BUG if kmalloc or read blk bitmap fail for DOUBLE_CHECK Date: Fri, 1 May 2020 11:59:55 +0530 Message-Id: X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-05-01_01:2020-04-30,2020-05-01 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 mlxscore=0 suspectscore=3 bulkscore=0 priorityscore=1501 mlxlogscore=999 malwarescore=0 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005010040 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Remove the BUG_ON() logic if kmalloc() or ext4_read_block_bitmap() fails. We should simply mark grp->bb_bitmap as NULL if above happens. In fact ext4_read_block_bitmap() may even return an error in case of resize ioctl. Hence remove this BUG_ON logic (fstests ext4/032 may trigger this). --- Should we add a ext4_msg() if any of above fails? Signed-off-by: Ritesh Harjani --- fs/ext4/mballoc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index e32f3675f962..aa22ecf3f827 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -548,13 +548,20 @@ static void mb_group_bb_bitmap_alloc(struct super_block *sb, struct buffer_head *bh; grp->bb_bitmap = kmalloc(sb->s_blocksize, GFP_NOFS); - BUG_ON(grp->bb_bitmap == NULL); + if (!grp->bb_bitmap) + goto out; bh = ext4_read_block_bitmap(sb, group); - BUG_ON(IS_ERR_OR_NULL(bh)); + if (IS_ERR_OR_NULL(bh)) { + kfree(grp->bb_bitmap); + grp->bb_bitmap = NULL; + goto out; + } memcpy(grp->bb_bitmap, bh->b_data, sb->s_blocksize); put_bh(bh); +out: + return; } static void mb_group_bb_bitmap_free(struct ext4_group_info *grp) -- 2.21.0