From patchwork Tue Jan 16 14:05:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenjie Qi X-Patchwork-Id: 188531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp276912dye; Tue, 16 Jan 2024 06:06:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8D28wFWzJ2yBUU2b7SELk/BHkbUD4zgNbsmvnzLzZW2Y6Ne5qKUgofnewfRTTPi27ZJ03 X-Received: by 2002:a05:6808:221a:b0:3bc:2a41:953 with SMTP id bd26-20020a056808221a00b003bc2a410953mr9559283oib.83.1705413987658; Tue, 16 Jan 2024 06:06:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705413987; cv=none; d=google.com; s=arc-20160816; b=lg9evstgebAjSEAvDAr3MRNr8QYRO7BFFxd9aoNhfhVVmfbGG7bjA1qx0euPUnvL7z MF2pdg+iLE0SIoGUCm9mJJapRMKjLavr2R5oBF7qQI1Me5odnXgN2sr52J1HiBQp6M1F AMRaBSbm09jD2G+MYK9iHlulc/DSU66RdCJj9c0qrW6yfzEk/g9ZpNQIngzxeoGnK9j2 jVz6qGB6/XEnj+ZdFQuXSdxVQ9j4FHGnnNdKatvLrBWCtRqCcQRYiBo3Z8D4ihXYFAhn aUpPGFh2eIgvgho3sorJfFYORdoeNfqLbfo2NG2qYhTgf0bzHyUIHcDS8w59iyYkvpoY BE/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=tBb5M/z14WnWSl+A8E6m6rrdU0AHffCrKzLu1XjUw5E=; fh=nDl6znmQbhlaWAOtC9VQsGq/L9X4vKYd1lZnUV6gntg=; b=jURYJDZAjFfSkA2AZsnhBW2zUjvdYKPpryjrTh0ksnGTc6SqYjTejjw+RWIRGiV7TO dJ3nY2AxKOJ8LcUUz1wwjbAIRPRJ1CEXvrroOIMhqSkHXMzAAOqSFCyGaV/tgpbALcWQ XbSzyrYoZxVo/nr02gqpie7FaAZvoFiaA+qsLJqV/N9BoWyDWKZqTel+mr4ohZxC/QGU aFDXuqTNQfWexWTvrow0yZWiNqznStqpgfr3rsoepftEekcyUzf9aWAgTtGaUCPlEO2f dw4pRzFVzYjbx3N4bu5YDxHqyIx0h7s4rgM4v9BC/SSSVv0hiz44AJAu6ocVf90kkTI9 lCzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m9wXl+Cc; spf=pass (google.com: domain of linux-kernel+bounces-27449-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27449-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e15-20020a056808148f00b003bd3c2f42acsi3927092oiw.21.2024.01.16.06.06.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 06:06:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27449-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=m9wXl+Cc; spf=pass (google.com: domain of linux-kernel+bounces-27449-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27449-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 63149283A31 for ; Tue, 16 Jan 2024 14:06:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9A23B1BDFF; Tue, 16 Jan 2024 14:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m9wXl+Cc" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B41421BDE1 for ; Tue, 16 Jan 2024 14:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1d5dfda4319so6190265ad.0 for ; Tue, 16 Jan 2024 06:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705413974; x=1706018774; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tBb5M/z14WnWSl+A8E6m6rrdU0AHffCrKzLu1XjUw5E=; b=m9wXl+Cc8ySodt0c3ab0sD+q36pTecZ2P9lZTl4N4aVaihssYtcGK9L7QJf6kwogCo amvex91IqDjo7Y4SO8LWlM0FCiw8aJQMn5bITON/42RoT/xLw9rKkOdIt0egWqdwyNNx GS8L/hBkmjIC34dSeMf/8TMWR6LE2hzt9JLyEKiIypbJOSepfov7rugprLClznWs6NGN uDTM/125y7osAsLfXnAMlBTukaktpIA0fCN+RFM6mznf4fHggarcPtfvUP5Q+2eibTQv mK5h7e0SnJEG6GxOxnHjXYh8x+wVEwPDEnaqDvT2O72F2R94T1J8PPPwLRz8EqdLcjT+ Btdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705413974; x=1706018774; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tBb5M/z14WnWSl+A8E6m6rrdU0AHffCrKzLu1XjUw5E=; b=GlsIYxmb/Ey/1QC6yG5MZ9COHyxoHN84gL0ZQ7ZeJVe2vHArkNKyu+vSXG+XhcS2U6 Nm6X9ckVwtkZ7nstNd6jINGPIvR+VGzN3NU1s4v2b8L4Y6e3ovgd9562AS+rJToPKPM9 1btIMhB4Pe5atzUCOAGqnF8fBKb6liL8knhGnNOkQV5/XptfdN9/+ST1qaPk1QjzqRnE sRvPG/orEztVgLhHk47LX/7CSxiLT7X+W10R0XjNFD87KVAd61w1yYjKToaMNVc5hcMj JRhKDYUS4JG4dxfPV4ccPwAmyrJow23hlgIg0Yw6RlNwr8SVvCzH51zQb8MmuTTtIlab M2dA== X-Gm-Message-State: AOJu0Yw6ee9m6LkFrLWETs4naWLxTKZu46d0lzt4gDFaVFv63xYY3Spp 59bYzX80A2lRX4hgayTswrPaweSYFUMBGA== X-Received: by 2002:a17:902:eb8d:b0:1d0:8352:b71c with SMTP id q13-20020a170902eb8d00b001d08352b71cmr4607011plg.5.1705413973801; Tue, 16 Jan 2024 06:06:13 -0800 (PST) Received: from localhost.localdomain ([2001:250:4000:8246:8dd2:f82d:e185:367f]) by smtp.gmail.com with ESMTPSA id mi11-20020a170902fccb00b001d59f061a29sm8245474plb.11.2024.01.16.06.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 06:06:13 -0800 (PST) From: Wenjie Qi To: jaegeuk@kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Cc: hustqwj@hust.edu.cn, Wenjie Qi Subject: [PATCH v2] f2fs: fix zoned block device information initialization Date: Tue, 16 Jan 2024 22:05:13 +0800 Message-ID: <20240116140513.1222-1-qwjhust@gmail.com> X-Mailer: git-send-email 2.43.0.windows.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788256177339325571 X-GMAIL-MSGID: 1788256177339325571 If the max active zones of zoned devices are less than the active logs of F2FS, the device may error due to insufficient zone resources when multiple active logs are being written at the same time. If this value is 0, there is no limit. Signed-off-by: Wenjie Qi --- fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 65294e3b0bef..669f84f6b0e5 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1551,6 +1551,7 @@ struct f2fs_sb_info { #ifdef CONFIG_BLK_DEV_ZONED unsigned int blocks_per_blkz; /* F2FS blocks per zone */ + unsigned int max_active_zones; /* max zone resources of the zoned device */ #endif /* for node-related operations */ diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 206d03c82d96..b65547f4c710 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2385,6 +2385,15 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) if (err) goto restore_opts; +#ifdef CONFIG_BLK_DEV_ZONED + if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) { + f2fs_err(sbi, + "zoned: max active zones %u is too small, need at least %u active zones", + sbi->max_active_zones, F2FS_OPTION(sbi).active_logs); + goto restore_opts; + } +#endif + /* flush outstanding errors before changing fs state */ flush_work(&sbi->s_error_work); @@ -3932,6 +3941,14 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) if (!f2fs_sb_has_blkzoned(sbi)) return 0; + sbi->max_active_zones = bdev_max_active_zones(bdev); + if (sbi->max_active_zones && sbi->max_active_zones < F2FS_OPTION(sbi).active_logs) { + f2fs_err(sbi, + "zoned: max active zones %u is too small, need at least %u active zones", + sbi->max_active_zones, F2FS_OPTION(sbi).active_logs); + return -EINVAL; + } + zone_sectors = bdev_zone_sectors(bdev); if (!is_power_of_2(zone_sectors)) { f2fs_err(sbi, "F2FS does not support non power of 2 zone sizes\n");