Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp723171lqe; Sun, 7 Apr 2024 00:22:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUkTSNhqDsljl96/bCHFkfHQkuyhDNNy0ZgNp5MaP8L9cixUsY0WWKZTh1GImzVRadYFdcUmJ4brUKt3TfHvv66AeFVGyrwM5gfMuNSug== X-Google-Smtp-Source: AGHT+IGNVvdDoutylyPvI8V5a2O2c2lVvexwFwuGtXZnnk20PscQfHnxC4ef4hMd7y7UtxMwcRyL X-Received: by 2002:a05:6a21:3482:b0:1a7:6458:a2ff with SMTP id yo2-20020a056a21348200b001a76458a2ffmr273520pzb.17.1712474576315; Sun, 07 Apr 2024 00:22:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712474576; cv=pass; d=google.com; s=arc-20160816; b=dfZRcCbuyfCI2vZCytL9CygpnKF2UuOlU/H8mqPRK4F4danGHaXQG3vQyrFpJodI5M 7yZYyGtVmST7k5fcjBKQ32fuxGQyLrmJgiaCGu9OjBnGdeZNZhAROubO5dqA5ZabJSr8 0aO1XI1DV1WUqpXqo35LvxhBHheavVKMpBuPBR+HRJdPTDL9bcvADLls95BVPwWRS+tR SNuemZFPOyEqkM4fc9AAXFWnryOcKO9X0Z0/8XFQTtbx+gUGweqjoyjtzgGoLQSU4yrf xEicyY7+8bqkxBPXdklM9opI+/GdXANvp2BSqKYTQfSBrmCzP8SkRiHa83phwG2gsGNP Lrjg== 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=hn/EVwmRvh2jWhHsuYDIEQKDDZf2Qvrh24VJMTUywb8=; fh=VfPYPJ3Q1h0BDrezPZRyiEkkKgoT6SLSJIX+TBYfkOg=; b=Axqu39Yt6rB1U406pzirlvnkCXdemfNJeHXM53qTmUhZegoIVTGcRGX+H92OERVLYO OwhnwRS8jZpJ5oSo1M3tB5seAax5YEgKRgOp+t/HDMlNkEgTL0daKSFGaOp8R4E9aFLl 65Whi9T7v5+g2cM0zqzDTl1S6Q8sD0WMWDZ0fUaMdbIn4IkvCyW9WVNoulmZP9TFc3G3 TGzV2gm5M5l3nclHku+tUiT1juYEanfEpoX37ABTLT7EGdPfIQtnewS4IDyvDOt/SLCw sm6lsxYJ8so6ciPplhZa+yl6ZyxuO+Smilfxme35Sfl/qjBKvA4o5iBHteWcfMMvWgdv c88Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SQ+0NAeL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134218-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134218-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d10-20020a170903230a00b001e3d8aedf12si2314217plh.229.2024.04.07.00.22.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Apr 2024 00:22:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134218-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SQ+0NAeL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-134218-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134218-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 85FB5B22F1C for ; Sun, 7 Apr 2024 07:21:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48B3D1773D; Sun, 7 Apr 2024 07:21:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SQ+0NAeL" 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 75BBC171D2 for ; Sun, 7 Apr 2024 07:21:32 +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=1712474492; cv=none; b=SWRCKCwZEQ/3NT6F0i++7qwbZsdTnvjRDZhzbyEPm/wFSt/GnQJ4ucINjqpQbmiKh0/41iq/PzRi67/Za+TySWo+Nq2qfdlynUT75W52PwnXXU8E/dS/6NvNF3oY+dwQ0jwpETBwVLUhOYuUi6TzvyvpbHJ29FJ/01nTZbSLte0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712474492; c=relaxed/simple; bh=sTsz2yC68gF80nOn+mrSl6qAbn+Ba4y6BK10ybpuh4M=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ozWRZ+dvGmz9yGizY7nG2m/Cy6YTpoCBOD/7wkxpF0XK9PlLm1aNZ5Hy3I2ZYpj+agi5gTO+JQvHNFSSgqv1VACyR8pHyd4TzUUHy3wMVhtq3MPQGalW5jjp5Mg/NFfgRc9mIrd/SKCnQzi3HIqDZx72PjWgkn/btLc/Tr8gn08= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SQ+0NAeL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7155AC433F1; Sun, 7 Apr 2024 07:21:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712474492; bh=sTsz2yC68gF80nOn+mrSl6qAbn+Ba4y6BK10ybpuh4M=; h=From:To:Cc:Subject:Date:From; b=SQ+0NAeLk4GLSCbVM8kSPhXchCX7IyQRx8jlpHKFJxRan3nFoITvLbWB5ywR/k5Xd /iQNI3d3k3VzZNOOxx+QXSlbMhSYqJMleRi1k7iATKo3Ntt8SjBqc5Trvj6YZawavH J9Ck3otcNhWdMN4mW6bOZ05JaXqDkwp3yzvQUQwSve4z12aOSe0Pq78VjCWZhObMnZ z7cONDgKUtMVHn0YAJKWAYGi6Wu1i0xDcB7Lkekwkm4j4fUs16QkiLVha1Z4YB/j5n +6Zv1CtpY+6GODRK5dfOCWwWA0HdUqGMMPyJXi37zDkWwQAZVGfxsXLWcBHyQ8ULmj RDrwmUQrzEWJw== 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 v7] f2fs: fix zoned block device information initialization Date: Sun, 7 Apr 2024 15:21:23 +0800 Message-Id: <20240407072123.3484300-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 --- v7: - check f2fs_sb_has_blkzoned() instead of multiple-device condition in f2fs_remount(). 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 ba6288e870c5..fdf358c7f808 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2324,6 +2324,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_sb_has_blkzoned(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); @@ -3866,11 +3877,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)) @@ -4191,6 +4215,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