Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp325908rdb; Tue, 23 Jan 2024 00:13:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqGYr0w2wS56eIZ0k+koO0Jb+1mPGigxUHnHUBgdG6GUDC/V4iDneIsBKZdronTX9nKxDh X-Received: by 2002:a17:903:22c3:b0:1d7:4ae4:915d with SMTP id y3-20020a17090322c300b001d74ae4915dmr3858503plg.46.1705997608434; Tue, 23 Jan 2024 00:13:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705997608; cv=pass; d=google.com; s=arc-20160816; b=gtd51tfRexwMwtw1/7SkLGYnAmeWeOUeu9Q0AyuRAlVuGfyHpdUFq5PO8NT88RxdiG UqV0BicnUnFHXHY4kTALPhCL1P2ZwDP/0N/UeUesYm9idGdj6Wg+9q4bFEY1hu8VdBo0 lrhmJgxWaTaHuxBZMfReHzG2BXCoJ3Nk4EK5ZwsdMPL2D9lwxg+UvzvYa61DNbe8tzFg +dpJgXSf1Y0Xm2AyQ8XKJYH74FtRqfKCXl2zjFMA9LVlll24U3xK3Ilko6QiTKlX+z4/ wVp/3oD+nEGPvsuLC9e9FA4avlZ7yqbekIsij3g2Vzos98QeNNZvB1lVJuPa/aK+8LVJ rHEA== 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=KcINxNqK9poEeYbYdpTS1L5ZKLd+2H3epIO3RsMgjVY=; fh=nDl6znmQbhlaWAOtC9VQsGq/L9X4vKYd1lZnUV6gntg=; b=kOBNEC1TahDbrd/SYsYZBnDS09Z2vGwKO27CHUwdhf78L4Z1j5/iqzwuNRQJvUoGrM VfBh4gj5ExNEe6JjQGEk5E+oh9TOLc7pH+EdArT254eQ8Bz0b03VnAyK+5rJJtD1UL5S m1/fXDTXnNv0nS87eH1L90M9VSbhOuvsMpB3pNyWoTV8IKUQwnk9kCkFf/g2EK43DQcy NFsDU/rlUxJLAmB004WWxxLXy81EFGsEy2AEjtRFqq7VUyp6W18BsJjTe/PXWBLYO1WI 0WQcHwtxXAoDiteRFP51nG+JJWmU+DfjJyxAnni679a1S8L8EoTOK6HkIVhJhxOVh92f gWSw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=CRsXZRir; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-34874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x16-20020a170902ec9000b001d748e1377csi3843262plg.588.2024.01.23.00.13.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 00:13:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34874-linux.lists.archive=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=CRsXZRir; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-34874-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34874-linux.lists.archive=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 15AA5281DBC for ; Tue, 23 Jan 2024 08:13:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 109FE56472; Tue, 23 Jan 2024 08:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CRsXZRir" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 EEC9755E76 for ; Tue, 23 Jan 2024 08:13:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705997596; cv=none; b=UkbM0F8e+Oo6ZmzLBYRLTkWvvdekpO2DZ/EVGjPgrODuTB0g0512kF72eg/1PFsu41M54ZIOxYmncwE+vXQ7jXEEUyh6dpTwvpAmcxgzqpJnXAKtzJ3uRGmrARYHskcFQwc5/+GqGVhKxbVOEgBf7uMxj1bpSR1whhcVR4Cryh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705997596; c=relaxed/simple; bh=/sM8VvHIXE+nip92qpOPQD1wgYBeZzA3gwJx9pdbtjc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HcH7A3AQL66mThhaDS/44RWtcREdISjCw3SNVA4LuFrbybRVtCMCEtpJmK28u4EoqbMvPPg1Z3x/1aUurbaIDrht6l80bj6WNBp05UVjf/NfLFP5g0SXjISCzPCpXhsiUXirTYlVBJb3xJS3v93xp6kEMZKYhPcY8LE0ypfvpzQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CRsXZRir; arc=none smtp.client-ip=209.85.214.170 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-f170.google.com with SMTP id d9443c01a7336-1d76671e5a4so7989525ad.0 for ; Tue, 23 Jan 2024 00:13:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705997594; x=1706602394; 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=KcINxNqK9poEeYbYdpTS1L5ZKLd+2H3epIO3RsMgjVY=; b=CRsXZRir2JdbVood6H4uIFIExAjaPdjqMbYXWfUqU4eJL8moMI26wpcW/ppRY6zEEt AYQw06hThspBQrA4/ujNNf6fPEs0jIMEpBCoWImINTvlfKVbTzZ1JSFIGZBRKGBjW9xD TBdTePhkSSbfZwxulAJFCEEjbE8uNnd78d1KtmYOr+451xPlY4+Cr2hO9N1eU3S1p+oK 4wl8Ai0yz4vp1+EN8ea/csiwTP+2owXw3D2xN3MPPjLEEzizw8oodFi7/922xPOGtSfz qRZ8DNbYf6qIh2YtlK5l/I0nTxEaHBnSn+hA86DmplFhqpyLGRM3e2b5+3GpNluWY8rN RnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705997594; x=1706602394; 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=KcINxNqK9poEeYbYdpTS1L5ZKLd+2H3epIO3RsMgjVY=; b=U4Nioe1XhocWnEf7wHkB9hk9slsRlvUirz6Ydj42OslcZ/MJMESQs6qruEUOOVFAnb QUu9HCxPjK/RNK75Nv4pnNC2NvZaVSlHf8D84RkV5v+nri25De4jatvgIf9o1RdLhYyM emO7soHhsLHQl7WQp+tBHbDg4PaIQ59uvaTG2kAnMe19xngNR/mEZqquEKf/RAqZ+hs6 0oPvc17jvkeiRU1/wUcIbGhO0G6ryUKkIa0U0qmtRBtTxe+VaW506Z0fhRpGfwq5bK81 WjQvY14HPHllnQMn/muYv/d+jfki6fg4UshiKbmWe8eeQKEkv6C+eXN/fAw0zA5a+fsY KLMA== X-Gm-Message-State: AOJu0Yzhkz+a7K8yPgwOC/7p3zjUL9aHcryK5W1LwGgcRGMWe8rx0nkJ FKZlBES/3+VTsDGt2NAq9T4FeF9Tfc+x8wZLysSPn2OhG5HrKyC2 X-Received: by 2002:a17:903:25d5:b0:1d7:808:dcfb with SMTP id jc21-20020a17090325d500b001d70808dcfbmr5123860plb.91.1705997594253; Tue, 23 Jan 2024 00:13:14 -0800 (PST) Received: from localhost.localdomain ([2001:250:4000:8246:d59a:da76:65b9:ef0]) by smtp.gmail.com with ESMTPSA id u9-20020a17090341c900b001d70c6d40f3sm7798578ple.237.2024.01.23.00.13.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 00:13: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 v3] f2fs: fix zoned block device information initialization Date: Tue, 23 Jan 2024 16:12:58 +0800 Message-ID: <20240123081258.700-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 Content-Transfer-Encoding: 8bit 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 | 18 ++++++++++++++++++ 2 files changed, 19 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..aef41b54098c 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2385,6 +2385,16 @@ 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); + err = -EINVAL; + goto restore_opts; + } +#endif + /* flush outstanding errors before changing fs state */ flush_work(&sbi->s_error_work); @@ -3932,6 +3942,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"); -- 2.34.1