From patchwork Tue Oct 22 09:17:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 1181167 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mykernel.net Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=mykernel.net header.i=cgxu519@mykernel.net header.b="KhS+Heno"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 46y7GB5rBYz9sPf for ; Tue, 22 Oct 2019 20:18:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728663AbfJVJSK (ORCPT ); Tue, 22 Oct 2019 05:18:10 -0400 Received: from sender2-of-o52.zoho.com.cn ([163.53.93.247]:21126 "EHLO sender2-of-o52.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730312AbfJVJSK (ORCPT ); Tue, 22 Oct 2019 05:18:10 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1571735883; cv=none; d=zoho.com.cn; s=zohoarc; b=XKm257dJnE9rowdkJA1vNfP24A/MQUOyNGkYMBcJYznlaqGeqNbXjiEdLNerIerd/UeCWRN0GorA3UggYqwgjfUPONMw/2/TSFMv4klmQCWh+QdwzaJIzET+U+D3Ff6KkB/wOUg8bA3o5x1567VvPonEn/bu1UqpCaJTBoO1zBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1571735883; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To:ARC-Authentication-Results; bh=SSeqQAIyu9lTUOzZcdJU7QZGCnYru9Mj3e50DPH0g+o=; b=afh2jBPHeHz4EuYKzs+e8U7BJ9ZH3QuU8dHPEYe8Uh80ATQ/peY4uHNHRaY2FYna0RIm62ivrk3XYNcaJUv9zViWwnRDPnODCCiJXYOsWIXJaWx6XTdaHSO6zeAr/PArgvZAGpoCJs8kAGRpZ1vcMNbNXOEclqSoGft9qWUukm8= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=mykernel.net; spf=pass smtp.mailfrom=cgxu519@mykernel.net; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1571735883; s=zohomail; d=mykernel.net; i=cgxu519@mykernel.net; h=From:To:Cc:Message-ID:Subject:Date:MIME-Version:Content-Transfer-Encoding:Content-Type; l=1082; bh=SSeqQAIyu9lTUOzZcdJU7QZGCnYru9Mj3e50DPH0g+o=; b=KhS+HenoYJwK2iEgtvR13RhTYGSFU8Mk+3gNqWHGLy6HopN6j+pA1E2Z6qPIxs/e MMPeO4xvKWtO91KyOT1uWP8u0+uGD1RgezEyLFgHDsyaORrFxkr2nEVFVmuAlrBeoUx ioulTAN++3z2Ph+JRbR9sKd9AE3i5D3snWNnbPqo= Received: from localhost.localdomain (218.18.229.179 [218.18.229.179]) by mx.zoho.com.cn with SMTPS id 1571735880251635.85345516198; Tue, 22 Oct 2019 17:18:00 +0800 (CST) From: Chengguang Xu To: jack@suse.com Cc: linux-ext4@vger.kernel.org, Chengguang Xu Message-ID: <20191022091738.9160-1-cgxu519@mykernel.net> Subject: [PATCH v2] ext2: add missing brelse in ext2_new_blocks() Date: Tue, 22 Oct 2019 17:17:38 +0800 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-ZohoCNMailClient: External Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org There is a missing brelse of bitmap_bh in the case of retry. Signed-off-by: Chengguang Xu --- v1->v2: - Add comment to explain why the fix is needed. fs/ext2/balloc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 924c1c765306..18e75adcd2f6 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -1313,6 +1313,13 @@ ext2_fsblk_t ext2_new_blocks(struct inode *inode, ext2_fsblk_t goal, if (free_blocks > 0) { grp_target_blk = ((goal - le32_to_cpu(es->s_first_data_block)) % EXT2_BLOCKS_PER_GROUP(sb)); + /* + * In a special case that allocated blocks are in system zone, + * we will retry block allocation due to failing to pass sanity + * check. In this case, the bitmap_bh is non-null pointer and we + * have to release it before calling read_block_bitmap(). + */ + brelse(bitmap_bh); bitmap_bh = read_block_bitmap(sb, group_no); if (!bitmap_bh) goto io_error;