From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 04435C46467 for ; Mon, 16 Jan 2023 16:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233280AbjAPQbd (ORCPT ); Mon, 16 Jan 2023 11:31:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233272AbjAPQaz (ORCPT ); Mon, 16 Jan 2023 11:30:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C5D244AF for ; Mon, 16 Jan 2023 08:19:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 15A15B8105F for ; Mon, 16 Jan 2023 16:19:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6631CC433EF; Mon, 16 Jan 2023 16:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673885950; bh=wByV7T4846QB3zGIo5wH2q+RBJTpEl7k//NVRMdWRXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ulIc3vsb0RExTiJryCXLb+BG5BSApAziguKBpLsuWaYTaCEzMQFgPRx+Aar31gbVi pPPaXYBjkZBJ0ukdALceqN3Nx/d7jVTPKBEWq1FBRbB90/1vwUKadrhQLSNs9UP8Kd Jw/quS+Qf66XX6eMCY9GtUPfcpGm2nH/xtjWAALo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dongdong Zhang , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 5.4 245/658] f2fs: fix normal discard process Date: Mon, 16 Jan 2023 16:45:33 +0100 Message-Id: <20230116154920.772332986@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154909.645460653@linuxfoundation.org> References: <20230116154909.645460653@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dongdong Zhang [ Upstream commit b5f1a218ae5e4339130d6e733f0e63d623e09a2c ] In the DPOLICY_BG mode, there is a conflict between the two conditions "i + 1 < dpolicy->granularity" and "i < DEFAULT_DISCARD_GRANULARITY". If i = 15, the first condition is false, it will enter the second condition and dispatch all small granularity discards in function __issue_discard_cmd_orderly. The restrictive effect of the first condition to small discards will be invalidated. These two conditions should align. Fixes: 20ee4382322c ("f2fs: issue small discard by LBA order") Signed-off-by: Dongdong Zhang Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 7759323bd775..e43b57755a7f 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1486,7 +1486,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi, if (i + 1 < dpolicy->granularity) break; - if (i < DEFAULT_DISCARD_GRANULARITY && dpolicy->ordered) + if (i + 1 < DEFAULT_DISCARD_GRANULARITY && dpolicy->ordered) return __issue_discard_cmd_orderly(sbi, dpolicy); pend_list = &dcc->pend_list[i]; -- 2.35.1