Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp253892lqh; Thu, 28 Mar 2024 00:21:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVPAbGoLM/894xvpV1xYuKoglez38uLo8/VxxmJkiMKO+FW6mH2Bh+uskWSflO/uxD7zR/m93vWAIaFkp33clMywzGQ43iOYPEOXdwKuA== X-Google-Smtp-Source: AGHT+IEygCQ4pbonZL9HKZ49XfeMIIlwFiegkNm1+PGfz0JlAjgTvcvn3n6OggQbcruTSbIsvsmy X-Received: by 2002:a05:6808:a03:b0:3c3:923c:4262 with SMTP id n3-20020a0568080a0300b003c3923c4262mr2081068oij.17.1711610513553; Thu, 28 Mar 2024 00:21:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711610513; cv=pass; d=google.com; s=arc-20160816; b=h39vnbgo3G1eTOl3CK0kX2JG3WYAu1zce2YDeoMqkMKy3cmfc1iy4ehPpAmdQrhsdF lPnvaEBGpYxpHCvbjKQIVp7yXdnMzGi2NwKTrFYiRL2z/G7NExGUkZcALxaSm9vOJXje wU1dTWtLBNg+zeIte9OYQh5BxeOPtcvdqAmrdze+hz4isPDKrTDaOlYftvCXhoBDK4j7 zZzCkTyS1oMKQnm/PM90k2Bs5xX89/4fHnyDwuq8VOnQ5HxCxHzC5ArxSsBaMk+EWhH8 +g5IkPK9qCXJjO87TlMTI9ybAmvpwFT1K9niNuWfJJaYT2Uc9ej2qN2t8aLOsolGrcil OaLg== ARC-Message-Signature: i=2; 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=upgLhKHDEDAb3V+ZFIqdhUsafDs9WmlXkWLPKWUL+98=; fh=VfPYPJ3Q1h0BDrezPZRyiEkkKgoT6SLSJIX+TBYfkOg=; b=D3VQ5A+07L7yTpG+6hkEKd0uzHTMmtZfG+bPY8vtjL1wAyz2wo/Es/oD9eYCII1b89 2uAJmzT0cuwAwHc8c74GxqOqBZOB88uP78V0qgq1pENwG4RzJ2BM7vQCAp4L8gT7A69G N4lH2hVB5Gw7agT7dEooLoUHMCkBGBw0/K7ntE78barE1Xi4X4dlUORidCHUUmbWqssL dCf8c4Bbv/IHvYkQPB+om8I2qPAckYui50pXtXSRqxvAR+mMgwXK8xVZulr1EsdwYvfR BKL5zXJSgdU9nUqGqkjv5hSn8QPh7lJXUEZEv35JNcmheWew1K4zncrCfjLvqxoux+2s 7fkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lifRrg5Q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122493-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e14-20020a63aa0e000000b005e430f68ae4si877522pgf.549.2024.03.28.00.21.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 00:21:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122493-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lifRrg5Q; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-122493-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122493-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 0CE9329481C for ; Thu, 28 Mar 2024 07:21:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7582A849C; Thu, 28 Mar 2024 07:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lifRrg5Q" 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 A0AD64F5F2 for ; Thu, 28 Mar 2024 07:21:46 +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=1711610506; cv=none; b=ts0irAAxRClD/FIz+gT+U9dE7KvifY+UwSmlZNbhaa+LHFtLbJLLFn0Gfibdu++ROsu8CraNYlWe0bLhpNz3aSw5Zz/FG4cjTx2ssLNtjFq/AMBk3X8iwB3NNjnL+IDygwLdfRyxbpr6KkSrRgA8BFf8X6ZNvQ3oW5HYpoTz5Z4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711610506; c=relaxed/simple; bh=+c2g+QOTgg3995dvAWPf1MaHsDGDdMPE+6RXTZkhIfU=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=neEnPif2gEKHDtUkcpoHovz8z32ZiuNAB1EO9wXwtofb7AcAvFJfB9Zd6dZqhmkA7TZCJOZJFFRD+7TkNtP4p1YA+5xW9Jc1ay/1mM5Qi3KiUZ8WGgNlGS9StiPmBVsnu54ifriODBe/MdMtL6GczBxVYhDgwKK3TXFVxBat1ew= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lifRrg5Q; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDBE2C433F1; Thu, 28 Mar 2024 07:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711610506; bh=+c2g+QOTgg3995dvAWPf1MaHsDGDdMPE+6RXTZkhIfU=; h=From:To:Cc:Subject:Date:From; b=lifRrg5QafFFOULEjnABkBHqjSe3HGSscym8oS9j8noUEpXmokgf5nu5DkPvMfv1e KnSKru2ZKysI2Td1Zlj9qUtsow7d/Qtd0JD1/Idy8JteuuLfdR4TrTNCM5OAaZ8Qsa 8nh6NGByrO7433qrcNrszUCD/6GZ84aeJwlaIEy3VlaN3BSOGh5xwxmLLm4cUgEZN3 nLEik4Ll6Nn9ZyKPipX4MvpUyRBHHNRG9kmlpYc64k0fI0rC+BvuR6i8N+ZVUvJASQ XeAOB5QOFiTsFxLdrecXzj5ijVMNnGtm+6bqqFwroDqo6BcHLV6Z5qCiutJAdKjk0g 0BWix70blxtgA== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Wenjie Qi , Chao Yu Subject: [PATCH v6] f2fs: fix zoned block device information initialization Date: Thu, 28 Mar 2024 15:21:36 +0800 Message-Id: <20240328072136.3023135-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Wenjie Qi If the max open 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. Signed-off-by: Wenjie Qi Signed-off-by: Chao Yu --- v6: - add check condition to avoid remount failure. fs/f2fs/f2fs.h | 1 + fs/f2fs/super.c | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 0550929dc6e5..694f8a52cb84 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1559,6 +1559,7 @@ struct f2fs_sb_info { #ifdef CONFIG_BLK_DEV_ZONED unsigned int blocks_per_blkz; /* F2FS blocks per zone */ + unsigned int max_open_zones; /* max open zone resources of the zoned device */ #endif /* for node-related operations */ diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 7c45929671ad..642540782471 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2326,6 +2326,17 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data) if (err) goto restore_opts; +#ifdef CONFIG_BLK_DEV_ZONED + if (f2fs_is_multi_device(sbi) && + sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { + f2fs_err(sbi, + "zoned: max open zones %u is too small, need at least %u open zones", + sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); + err = -EINVAL; + goto restore_opts; + } +#endif + /* flush outstanding errors before changing fs state */ flush_work(&sbi->s_error_work); @@ -3868,11 +3879,24 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) sector_t nr_sectors = bdev_nr_sectors(bdev); struct f2fs_report_zones_args rep_zone_arg; u64 zone_sectors; + unsigned int max_open_zones; int ret; if (!f2fs_sb_has_blkzoned(sbi)) return 0; + if (bdev_is_zoned(FDEV(devi).bdev)) { + max_open_zones = bdev_max_open_zones(bdev); + if (max_open_zones && (max_open_zones < sbi->max_open_zones)) + sbi->max_open_zones = max_open_zones; + if (sbi->max_open_zones < F2FS_OPTION(sbi).active_logs) { + f2fs_err(sbi, + "zoned: max open zones %u is too small, need at least %u open zones", + sbi->max_open_zones, F2FS_OPTION(sbi).active_logs); + return -EINVAL; + } + } + zone_sectors = bdev_zone_sectors(bdev); if (sbi->blocks_per_blkz && sbi->blocks_per_blkz != SECTOR_TO_BLOCK(zone_sectors)) @@ -4186,6 +4210,9 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) logical_blksize = bdev_logical_block_size(sbi->sb->s_bdev); sbi->aligned_blksize = true; +#ifdef CONFIG_BLK_DEV_ZONED + sbi->max_open_zones = UINT_MAX; +#endif for (i = 0; i < max_devices; i++) { if (i == 0) -- 2.40.1