From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9C5614649E; Wed, 7 Feb 2024 21:27:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707341272; cv=none; b=YzT2TeHhYrxSp3g/V2U8NNajnPIIm3yUPpo0JNJLnCzABjBtsqRjsGRZM2o5eWt83bCLWQGGwX78/ksVHG18MbiUQurkLfmU31dIIWOCsPeKOULqEG4AMYlYCZq7ydeD7+KEmnZ6ASQnYf61Iv0UYAr8TCkQZP8/C9xc+4aW3Eo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707341272; c=relaxed/simple; bh=bC74HgZ8EoWS6bs2dFatj3magn84sBysuJvDYyjyH1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ViARTToqyQ3rxEFoE9j2BqTELrH6RxLVFSKmdMGDRwufCADKTX/0iUsldWcz51Cs+ZEePMvR804Na6QosywAOOrDC7k7VTH/Wz9fAHlPsuEoK679SeXKn1+ns4nABhGqgG+fCKRyN/bJDvyj8PS9Oulp6hpR4GZqH2X3mDzemo0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XIIPD4/c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XIIPD4/c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACDCAC43390; Wed, 7 Feb 2024 21:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707341271; bh=bC74HgZ8EoWS6bs2dFatj3magn84sBysuJvDYyjyH1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XIIPD4/c868hBQQQu0t9Mn554wzoPUwzXzLTfWoSfzKy+J3DFcKYTXONfei9QEh69 2BBqioYsDnKUKrqWNayqj9rOC1Jr7ldSCtdcg9W7KpRRhZAa7ChIUOgktzcZGxidrf +1Znkv7S9OyTb98jQbs7YVR8CZAsArWRRFDP1KfNmzRQDTXAAgBVJXczCwu5v9FloL gHrmDJnX4LDJQHROldjd93xbijeCZHBgm2FcjsBTi351csTefHmUVwcVxvJ4Wb4L36 nKl4eSRIpulwz1x3BAAG7Z150+fH9UWwqhJrF+ZNor+yI/UR969a2w64wgUKHk/ceE 29U1oqWBAVmFw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Baokun Li , Jan Kara , Theodore Ts'o , Sasha Levin , adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 2/3] ext4: avoid allocating blocks from corrupted group in ext4_mb_find_by_goal() Date: Wed, 7 Feb 2024 16:27:46 -0500 Message-ID: <20240207212747.4783-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240207212747.4783-1-sashal@kernel.org> References: <20240207212747.4783-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 4.19.306 Content-Transfer-Encoding: 8bit From: Baokun Li [ Upstream commit 832698373a25950942c04a512daa652c18a9b513 ] Places the logic for checking if the group's block bitmap is corrupt under the protection of the group lock to avoid allocating blocks from the group with a corrupted block bitmap. Signed-off-by: Baokun Li Reviewed-by: Jan Kara Link: https://lore.kernel.org/r/20240104142040.2835097-8-libaokun1@huawei.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/mballoc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index cf034a38e8ba..245d3acbb842 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c @@ -1839,12 +1839,10 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, if (err) return err; - if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) { - ext4_mb_unload_buddy(e4b); - return 0; - } - ext4_lock_group(ac->ac_sb, group); + if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info))) + goto out; + max = mb_find_extent(e4b, ac->ac_g_ex.fe_start, ac->ac_g_ex.fe_len, &ex); ex.fe_logical = 0xDEADFA11; /* debug value */ @@ -1877,6 +1875,7 @@ int ext4_mb_find_by_goal(struct ext4_allocation_context *ac, ac->ac_b_ex = ex; ext4_mb_use_best_found(ac, e4b); } +out: ext4_unlock_group(ac->ac_sb, group); ext4_mb_unload_buddy(e4b); -- 2.43.0