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 A7412267F6C; Tue, 8 Apr 2025 11:11:22 +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=1744110682; cv=none; b=tSYs3Vmg0LdalCeXqQ/22N+vOOb9raSJzyFzfjIp3gL6Ewdfruj+HHN3t6kUym8iJuknidMeT3hfXYXM07jhg9Zr2m/fcmbEGBDrRTUt+jWN7zAkTek2qjXFnyBLQhZ5PKVHmHY1m3uSK/OTkoV8NUJF616ta/qo/+B5SDJpnRg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744110682; c=relaxed/simple; bh=Q+qxuiFV6aqvWEuL33zTh6Jkz3/H/3twnTNEFnJOw5o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tIYt1vVNrU8JFp7dvMNgLjiQ3E+prW3KO92HTmWKDE6lDwJALJdU5njSUAFDm9CPOeCn3Atv3ZZ+1K1uv1uD5Z5W52Xw28cJKyZYwy6y+RunLJqDTU/MRfHM95S3nnX1bFkAgwBEDeRAAAv/ksXZ9omrzqtZ1lMxmreaYLOIdro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ddNiKv9p; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ddNiKv9p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA8AEC4CEE5; Tue, 8 Apr 2025 11:11:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744110682; bh=Q+qxuiFV6aqvWEuL33zTh6Jkz3/H/3twnTNEFnJOw5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ddNiKv9p84lLk9qkxKLlI0rds8gsz98/Qca77HkaPb5klfVzs6auTSWuX3ra1QrK3 /KGAejo42BfU/O5plKggdMqRcbPkHZH0xFNa+QEPoJ224b1X3pc4fEDZffntZbqwbe TsUasdBF0QaEjIl4qWVhQwW3piYD9u9J0ezGTDu0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daeho Jeong , Yohan Joung , Chao Yu , Jaegeuk Kim , Sasha Levin Subject: [PATCH 6.14 127/731] f2fs: fix to set .discard_granularity correctly Date: Tue, 8 Apr 2025 12:40:24 +0200 Message-ID: <20250408104917.234032613@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104914.247897328@linuxfoundation.org> References: <20250408104914.247897328@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chao Yu [ Upstream commit 1b60b23975d6d81703826e3797738e471c3009c6 ] commit 4f993264fe29 ("f2fs: introduce discard_unit mount option") introduced a bug, when we enable discard_unit=section option, it will set .discard_granularity to BLKS_PER_SEC(), however discard granularity only supports [1, 512], once section size is not equal to segment size, it will cause issue_discard_thread() in DPOLICY_BG mode will not select discard entry w/ any granularity to issue. Fixes: 4f993264fe29 ("f2fs: introduce discard_unit mount option") Reviewed-by: Daeho Jeong Signed-off-by: Yohan Joung Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/segment.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 6ebe25eafafa5..2b415926641f0 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -2320,10 +2320,9 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) dcc->discard_granularity = DEFAULT_DISCARD_GRANULARITY; dcc->max_ordered_discard = DEFAULT_MAX_ORDERED_DISCARD_GRANULARITY; dcc->discard_io_aware = DPOLICY_IO_AWARE_ENABLE; - if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SEGMENT) + if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SEGMENT || + F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SECTION) dcc->discard_granularity = BLKS_PER_SEG(sbi); - else if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SECTION) - dcc->discard_granularity = BLKS_PER_SEC(sbi); INIT_LIST_HEAD(&dcc->entry_list); for (i = 0; i < MAX_PLIST_NUM; i++) -- 2.39.5