Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 A501619C546 for ; Thu, 24 Apr 2025 13:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745502675; cv=none; b=ZOnecSGSbYIqqda190gSFyn1w8aMm5vGJYpmkhdfJ65sF9QK/eKFMha3/F94HfC9XC9mb8aTICQwI69qgklinK0RiSpC7KKvP7F5xWqESZlV5zaR6lr+UVrecOHNUPr3Mfiaqs5tJnuvla2Hgzs/2BGmqkNm95GX112lqtdUeiw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745502675; c=relaxed/simple; bh=FDdxhpXnrBpH/SvbX5kGht1dFW7v4D5Ws0rxjL3nxRk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tb/cMiVEHnQ5RW6l8SpJqc1jXlrQ52PH1w+widoP3Aq0HamD/0u2JCMT1kAzNUz/QKhSs3OkYMmI69HuVxbRnPajDBVpG9j7yBCLGPU+LU70L0Wcceb31mQavQ363kpjLsdflVo/CFqL+0bpURiCl1eCGRvKzErTi+d1O8wi0sQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Vz2s2R6s; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Vz2s2R6s" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1745502672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Bv69FtZVhIqPlCqJIqCKQOcHix/aNeySxwjw5nKrkw=; b=Vz2s2R6sR2J1uu/i5ME2ibLTJrJKOAazda2dsTB80cyRkYIpjZ7tG9SdMwDqLZUvwceoG2 YESmAzDwkw41mHr4tLmK3YrXR4xN1Q29Fw33aynSxVbFu2p+IqlNj9tmlzXM5K9/j/yGcW EhD6b+XRm8VJe0giVLnwchY/x/qPoNw= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-303-ZdksyhUJPqKl-x6hzQexJg-1; Thu, 24 Apr 2025 09:51:10 -0400 X-MC-Unique: ZdksyhUJPqKl-x6hzQexJg-1 X-Mimecast-MFC-AGG-ID: ZdksyhUJPqKl-x6hzQexJg_1745502670 Received: by mail-ot1-f69.google.com with SMTP id 46e09a7af769-72e313f527cso928221a34.3 for ; Thu, 24 Apr 2025 06:51:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745502670; x=1746107470; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0Bv69FtZVhIqPlCqJIqCKQOcHix/aNeySxwjw5nKrkw=; b=AHum6Jvpq22/AsJO7QRI/hQcXPozPv2TksPjkCg0qbgU0I2nHTKI4QKcFxyhqFQrgn N0Dl808qCFqDtGgcMVEem4791QxU+nMUh2iqNM/ayW9Vw4y0CnPiThxJBndD6xLos34b YeeoL5TWqvywXlQ5khm2h5qhi6oJ028N0V/ww3eI2Nf0hKdk69ct7EpMELfZZxXCUiFZ UJy/x44uj02CN6Z+CvpWykbUnhBvYVJlsGKvrNuC9UgzmyLck+ovTyS7T7sK381NeSii 4OB8KopR8HK273/hTQiHj8ZevkE7VNoCSVSeNSIEpMFt+xtMNUMGTCc8YGaX79fb4oh0 gQlQ== X-Gm-Message-State: AOJu0YyEpofaJlbwr3fn46HhFveU45upeYhlNqDwKHRK/znUGog5BM5T 9H9Cco2DrYVcjHTKQ7Ngu0GfJzYn7K2f9IQr18nqlSXCh6j1ZIaA7Z5K0phqpvj6s5g9xFFojxk 9SrlvhGkQ/T4cTWBK2EjdD/qcswDTONQMZ0TDr3Yf03+zIAoSwW7mAOSspNtGv8A= X-Gm-Gg: ASbGncu9Dqu9R/KarUKRAWevdF7ZNxg0tkFwS5BF/zwbEhtOxymU1SmJKQ9pXA3F+BX HIEdjd3u6Km+XByvGnVbmqx/YKd3Psh5at+533sN2R5U2UwA4nSYRDHWcGpb3/PLR/BFOiT8aoV XDevJqChH6XlJ40IAwO6mA9bA32XUoEmYduuV+R9p2QyK70uFyWHXKEab1EFQkqmAn0Oio/fyki /jSbhVK7tSaAbTxmeKSJX7pZg9hOO2Z/HSYvyU5byJ1yNcUJKmtAsC3ec+Z1u3dwyL57dUmtUmP /mWyDnPA3iIp4exhsSNliWZtdQLW4LQXplO+4BFAkKNLUEti7x+bOJ8= X-Received: by 2002:a05:6830:25cc:b0:727:24ab:3e4 with SMTP id 46e09a7af769-7304daab00cmr1964042a34.9.1745502669670; Thu, 24 Apr 2025 06:51:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2u4n4Ao3E9wZ9rTZP0fLc4HVjXc56P01ET259Rz7opGpJzDEJQ/LVZ/WOUFiHMSOTHLYvGg== X-Received: by 2002:a05:6830:25cc:b0:727:24ab:3e4 with SMTP id 46e09a7af769-7304daab00cmr1964026a34.9.1745502669294; Thu, 24 Apr 2025 06:51:09 -0700 (PDT) Received: from localhost.localdomain (nwtn-09-2828.dsl.iowatelecom.net. [67.224.43.12]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7304f37b158sm233595a34.49.2025.04.24.06.51.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Apr 2025 06:51:08 -0700 (PDT) From: Eric Sandeen To: linux-f2fs-devel@lists.sourceforge.net Cc: linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org, chao@kernel.org, lihongbo22@huawei.com, Eric Sandeen Subject: [PATCH V3 3/7] f2fs: Allow sbi to be NULL in f2fs_printk Date: Wed, 23 Apr 2025 12:08:47 -0500 Message-ID: <20250423170926.76007-4-sandeen@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423170926.76007-1-sandeen@redhat.com> References: <20250423170926.76007-1-sandeen@redhat.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Hongbo Li At the parsing phase of the new mount api, sbi will not be available. So here allows sbi to be NULL in f2fs log helpers and use that in handle_mount_opt(). Signed-off-by: Hongbo Li [sandeen: forward port] Signed-off-by: Eric Sandeen --- fs/f2fs/super.c | 90 +++++++++++++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 41 deletions(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 20dee7c40d59..35190db4501c 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -323,11 +323,19 @@ void f2fs_printk(struct f2fs_sb_info *sbi, bool limit_rate, vaf.fmt = printk_skip_level(fmt); vaf.va = &args; if (limit_rate) - printk_ratelimited("%c%cF2FS-fs (%s): %pV\n", - KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); + if (sbi) + printk_ratelimited("%c%cF2FS-fs (%s): %pV\n", + KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); + else + printk_ratelimited("%c%cF2FS-fs: %pV\n", + KERN_SOH_ASCII, level, &vaf); else - printk("%c%cF2FS-fs (%s): %pV\n", - KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); + if (sbi) + printk("%c%cF2FS-fs (%s): %pV\n", + KERN_SOH_ASCII, level, sbi->sb->s_id, &vaf); + else + printk("%c%cF2FS-fs: %pV\n", + KERN_SOH_ASCII, level, &vaf); va_end(args); } @@ -737,13 +745,13 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) case Opt_discard: if (result.negated) { if (f2fs_hw_should_discard(sbi)) { - f2fs_warn(sbi, "discard is required for zoned block devices"); + f2fs_warn(NULL, "discard is required for zoned block devices"); return -EINVAL; } clear_opt(sbi, DISCARD); } else { if (!f2fs_hw_support_discard(sbi)) { - f2fs_warn(sbi, "device does not support discard"); + f2fs_warn(NULL, "device does not support discard"); break; } set_opt(sbi, DISCARD); @@ -751,7 +759,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) break; case Opt_noheap: case Opt_heap: - f2fs_warn(sbi, "heap/no_heap options were deprecated"); + f2fs_warn(NULL, "heap/no_heap options were deprecated"); break; #ifdef CONFIG_F2FS_FS_XATTR case Opt_user_xattr: @@ -774,7 +782,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) case Opt_user_xattr: case Opt_inline_xattr: case Opt_inline_xattr_size: - f2fs_info(sbi, "%s options not supported", param->key); + f2fs_info(NULL, "%s options not supported", param->key); break; #endif #ifdef CONFIG_F2FS_FS_POSIX_ACL @@ -786,7 +794,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) break; #else case Opt_acl: - f2fs_info(sbi, "%s options not supported", param->key); + f2fs_info(NULL, "%s options not supported", param->key); break; #endif case Opt_active_logs: @@ -840,7 +848,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) break; case Opt_reserve_root: if (test_opt(sbi, RESERVE_ROOT)) { - f2fs_info(sbi, "Preserve previous reserve_root=%u", + f2fs_info(NULL, "Preserve previous reserve_root=%u", F2FS_OPTION(sbi).root_reserved_blocks); } else { F2FS_OPTION(sbi).root_reserved_blocks = result.int_32; @@ -871,7 +879,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) #else case Opt_fault_injection: case Opt_fault_type: - f2fs_info(sbi, "%s options not supported", param->key); + f2fs_info(NULL, "%s options not supported", param->key); break; #endif case Opt_lazytime: @@ -934,7 +942,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) case Opt_usrjquota: case Opt_grpjquota: case Opt_prjjquota: - f2fs_info(sbi, "quota operations not supported"); + f2fs_info(NULL, "quota operations not supported"); break; #endif case Opt_alloc: @@ -952,7 +960,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) #ifdef CONFIG_FS_ENCRYPTION_INLINE_CRYPT set_opt(sbi, INLINECRYPT); #else - f2fs_info(sbi, "inline encryption not supported"); + f2fs_info(NULL, "inline encryption not supported"); #endif break; case Opt_checkpoint: @@ -992,7 +1000,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) #ifdef CONFIG_F2FS_FS_COMPRESSION case Opt_compress_algorithm: if (!f2fs_sb_has_compression(sbi)) { - f2fs_info(sbi, "Image doesn't support compression"); + f2fs_info(NULL, "Image doesn't support compression"); break; } name = param->string; @@ -1001,7 +1009,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) F2FS_OPTION(sbi).compress_level = 0; F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZO; #else - f2fs_info(sbi, "kernel doesn't support lzo compression"); + f2fs_info(NULL, "kernel doesn't support lzo compression"); #endif } else if (!strncmp(name, "lz4", 3)) { #ifdef CONFIG_F2FS_FS_LZ4 @@ -1010,7 +1018,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) return -EINVAL; F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZ4; #else - f2fs_info(sbi, "kernel doesn't support lz4 compression"); + f2fs_info(NULL, "kernel doesn't support lz4 compression"); #endif } else if (!strncmp(name, "zstd", 4)) { #ifdef CONFIG_F2FS_FS_ZSTD @@ -1019,26 +1027,26 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) return -EINVAL; F2FS_OPTION(sbi).compress_algorithm = COMPRESS_ZSTD; #else - f2fs_info(sbi, "kernel doesn't support zstd compression"); + f2fs_info(NULL, "kernel doesn't support zstd compression"); #endif } else if (!strcmp(name, "lzo-rle")) { #ifdef CONFIG_F2FS_FS_LZORLE F2FS_OPTION(sbi).compress_level = 0; F2FS_OPTION(sbi).compress_algorithm = COMPRESS_LZORLE; #else - f2fs_info(sbi, "kernel doesn't support lzorle compression"); + f2fs_info(NULL, "kernel doesn't support lzorle compression"); #endif } else return -EINVAL; break; case Opt_compress_log_size: if (!f2fs_sb_has_compression(sbi)) { - f2fs_info(sbi, "Image doesn't support compression"); + f2fs_info(NULL, "Image doesn't support compression"); break; } if (result.uint_32 < MIN_COMPRESS_LOG_SIZE || result.uint_32 > MAX_COMPRESS_LOG_SIZE) { - f2fs_err(sbi, + f2fs_err(NULL, "Compress cluster log size is out of range"); return -EINVAL; } @@ -1046,7 +1054,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) break; case Opt_compress_extension: if (!f2fs_sb_has_compression(sbi)) { - f2fs_info(sbi, "Image doesn't support compression"); + f2fs_info(NULL, "Image doesn't support compression"); break; } name = param->string; @@ -1055,7 +1063,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) if (strlen(name) >= F2FS_EXTENSION_LEN || ext_cnt >= COMPRESS_EXT_NUM) { - f2fs_err(sbi, "invalid extension length/number"); + f2fs_err(NULL, "invalid extension length/number"); return -EINVAL; } @@ -1069,7 +1077,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) break; case Opt_nocompress_extension: if (!f2fs_sb_has_compression(sbi)) { - f2fs_info(sbi, "Image doesn't support compression"); + f2fs_info(NULL, "Image doesn't support compression"); break; } name = param->string; @@ -1078,7 +1086,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) if (strlen(name) >= F2FS_EXTENSION_LEN || noext_cnt >= COMPRESS_EXT_NUM) { - f2fs_err(sbi, "invalid extension length/number"); + f2fs_err(NULL, "invalid extension length/number"); return -EINVAL; } @@ -1092,21 +1100,21 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) break; case Opt_compress_chksum: if (!f2fs_sb_has_compression(sbi)) { - f2fs_info(sbi, "Image doesn't support compression"); + f2fs_info(NULL, "Image doesn't support compression"); break; } F2FS_OPTION(sbi).compress_chksum = true; break; case Opt_compress_mode: if (!f2fs_sb_has_compression(sbi)) { - f2fs_info(sbi, "Image doesn't support compression"); + f2fs_info(NULL, "Image doesn't support compression"); break; } F2FS_OPTION(sbi).compress_mode = result.uint_32; break; case Opt_compress_cache: if (!f2fs_sb_has_compression(sbi)) { - f2fs_info(sbi, "Image doesn't support compression"); + f2fs_info(NULL, "Image doesn't support compression"); break; } set_opt(sbi, COMPRESS_CACHE); @@ -1119,7 +1127,7 @@ static int handle_mount_opt(struct fs_context *fc, struct fs_parameter *param) case Opt_compress_chksum: case Opt_compress_mode: case Opt_compress_cache: - f2fs_info(sbi, "compression options not supported"); + f2fs_info(NULL, "compression options not supported"); break; #endif case Opt_atgc: @@ -1204,17 +1212,17 @@ static int f2fs_validate_options(struct f2fs_sb_info *sbi) return -EINVAL; #else if (f2fs_sb_has_quota_ino(sbi) && !f2fs_readonly(sbi->sb)) { - f2fs_info(sbi, "Filesystem with quota feature cannot be mounted RDWR without CONFIG_QUOTA"); + f2fs_info(NULL, "Filesystem with quota feature cannot be mounted RDWR without CONFIG_QUOTA"); return -EINVAL; } if (f2fs_sb_has_project_quota(sbi) && !f2fs_readonly(sbi->sb)) { - f2fs_err(sbi, "Filesystem with project quota feature cannot be mounted RDWR without CONFIG_QUOTA"); + f2fs_err(NULL, "Filesystem with project quota feature cannot be mounted RDWR without CONFIG_QUOTA"); return -EINVAL; } #endif if (!IS_ENABLED(CONFIG_UNICODE) && f2fs_sb_has_casefold(sbi)) { - f2fs_err(sbi, + f2fs_err(NULL, "Filesystem with casefold feature cannot be mounted without CONFIG_UNICODE"); return -EINVAL; } @@ -1228,24 +1236,24 @@ static int f2fs_validate_options(struct f2fs_sb_info *sbi) #ifdef CONFIG_BLK_DEV_ZONED if (F2FS_OPTION(sbi).discard_unit != DISCARD_UNIT_SECTION) { - f2fs_info(sbi, "Zoned block device doesn't need small discard, set discard_unit=section by default"); + f2fs_info(NULL, "Zoned block device doesn't need small discard, set discard_unit=section by default"); F2FS_OPTION(sbi).discard_unit = DISCARD_UNIT_SECTION; } if (F2FS_OPTION(sbi).fs_mode != FS_MODE_LFS) { - f2fs_info(sbi, "Only lfs mode is allowed with zoned block device feature"); + f2fs_info(NULL, "Only lfs mode is allowed with zoned block device feature"); return -EINVAL; } #else - f2fs_err(sbi, "Zoned block device support is not enabled"); + f2fs_err(NULL, "Zoned block device support is not enabled"); return -EINVAL; #endif } #ifdef CONFIG_F2FS_FS_COMPRESSION if (f2fs_test_compress_extension(sbi)) { - f2fs_err(sbi, "invalid compress or nocompress extension"); + f2fs_err(NULL, "invalid compress or nocompress extension"); return -EINVAL; } #endif @@ -1255,11 +1263,11 @@ static int f2fs_validate_options(struct f2fs_sb_info *sbi) if (!f2fs_sb_has_extra_attr(sbi) || !f2fs_sb_has_flexible_inline_xattr(sbi)) { - f2fs_err(sbi, "extra_attr or flexible_inline_xattr feature is off"); + f2fs_err(NULL, "extra_attr or flexible_inline_xattr feature is off"); return -EINVAL; } if (!test_opt(sbi, INLINE_XATTR)) { - f2fs_err(sbi, "inline_xattr_size option should be set with inline_xattr option"); + f2fs_err(NULL, "inline_xattr_size option should be set with inline_xattr option"); return -EINVAL; } @@ -1268,24 +1276,24 @@ static int f2fs_validate_options(struct f2fs_sb_info *sbi) if (F2FS_OPTION(sbi).inline_xattr_size < min_size || F2FS_OPTION(sbi).inline_xattr_size > max_size) { - f2fs_err(sbi, "inline xattr size is out of range: %d ~ %d", + f2fs_err(NULL, "inline xattr size is out of range: %d ~ %d", min_size, max_size); return -EINVAL; } } if (test_opt(sbi, ATGC) && f2fs_lfs_mode(sbi)) { - f2fs_err(sbi, "LFS is not compatible with ATGC"); + f2fs_err(NULL, "LFS is not compatible with ATGC"); return -EINVAL; } if (f2fs_is_readonly(sbi) && test_opt(sbi, FLUSH_MERGE)) { - f2fs_err(sbi, "FLUSH_MERGE not compatible with readonly mode"); + f2fs_err(NULL, "FLUSH_MERGE not compatible with readonly mode"); return -EINVAL; } if (f2fs_sb_has_readonly(sbi) && !f2fs_readonly(sbi->sb)) { - f2fs_err(sbi, "Allow to mount readonly mode only"); + f2fs_err(NULL, "Allow to mount readonly mode only"); return -EROFS; } -- 2.49.0