From mboxrd@z Thu Jan 1 00:00:00 1970 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 C2DB6193 for ; Fri, 1 Mar 2024 00:16:07 +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=1709252169; cv=none; b=lJEUbUduxxNXCtJcy/NUgFE3erc0jfUVRy79FvYtt3gqa1DnoTAAAF2hE6jQDa7Eex+JWGrRHG0FiN37UjYYkEPjWdV9ejU8Fi9MelQUml4cCFrugi4PH69aLkNxixIuwef//gSaLVFZvNwaZ3Fn7nI5QkM6Iin5gOZSvFW9VN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709252169; c=relaxed/simple; bh=65P9PDS7E5AkUmHnQIE8Y9IKjd96NlmVkV1ln3OPtqU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=UOAQWTbtpFSCU1C/a6Gjh/x8covbJ9xaeFauCg1erA2IJrnbmt83wwKuuNDEl86cHeCNqNRufjkOZY3Q2OfGfCYSDxDO4zjNjeqRD7c+T8Vy+hZfVe1+F/kj7FuvfTQAY2YtNHQ+q1GV7ARQW6DqdBDU66BssZKxsFQkMYZ5zVQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=enbJKUxL; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none 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="enbJKUxL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709252166; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BMNf8GeVYKIL640A/NSletvr9BoIxy8WmTXXpn1NJWo=; b=enbJKUxLAEd0uWg18iks42nQJEGMlT0PHY5XY/ckj16HovgEjhKfNIwB69TbCeD/iysNMi P8A72vwM/1/ZMepAMH9WnDRTAcHZkDLtHtmhXyivROUY4ORrwtQ6klQWOQLSAzEgJcYYn8 zHcI3cB7UEq2JT36KuTZVCDJAbCdtck= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-377-571euNIsM_iI1GJUBDumow-1; Thu, 29 Feb 2024 19:16:05 -0500 X-MC-Unique: 571euNIsM_iI1GJUBDumow-1 Received: by mail-io1-f70.google.com with SMTP id ca18e2360f4ac-7c79b0aac56so161230639f.0 for ; Thu, 29 Feb 2024 16:16:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709252164; x=1709856964; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=BMNf8GeVYKIL640A/NSletvr9BoIxy8WmTXXpn1NJWo=; b=eDORhnMukOTRAAMQ2r+ebFQxUCy6T4/PUxIirgNDuMyRYiAMVfLJajOpQAu5jr5i7L UQGKoeRtdi4/MrQZhrEL2h4JGML4O62AwoSdbDrlb/OPjv0dWIagUOuokgJiYE1IMU36 DDTq8eC+3mWbUIH+IAj1f9T5eZSknUod9JwqzDWQS0MEK0FIvfQYz8rFnN94lpl9Owt7 hEmmIj2o/6usdRnvrWiFO0xniQmkHqOpya75DkLpu3Cm+/Dsb+nw4KW7fiUd1+RbE5d7 oNONpBt3lkf1zeWJlnWxDR0Uu4v6BilpCl9WWlK1K6lv6G/U91ky/f0uwqjqkxVYxFfT R89Q== X-Forwarded-Encrypted: i=1; AJvYcCU832v1w2kWBySgpyjTHC1pp2tDqxRmNliLCOW2CIDaIUh9+EBMa6VYxEAeL8/6JfI/zMn3qMaD0Cm3YLPMp4QzqtyNub8264X1gHcStQ== X-Gm-Message-State: AOJu0Yy/XH1FtUYx8pODTpK+aY8RVK2wbGoXOq9St2jvlKBd+OIpYRJq IUwbLMhtczY7PK4OrKA2tGfvvrIcCjLhmbXVUO1o32vxJC9C2t0BW43a4BEkizAzz/kHzwUANBa 6Re72M6WYSm8ZCynZ+7VW6LmDXICpqkXSTtxs1XvrW96uEicYJ+F42IPSwpp1GlNwhvmsBq8= X-Received: by 2002:a92:c24f:0:b0:365:27e7:4b60 with SMTP id k15-20020a92c24f000000b0036527e74b60mr275690ilo.21.1709252164120; Thu, 29 Feb 2024 16:16:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IFjBN+xXcqq+5a+EmH8odfKUA67Y/nVEXdlykKhOr4CArbqLxCCI7ob+CPByDP0BXhT1C9EbA== X-Received: by 2002:a92:c24f:0:b0:365:27e7:4b60 with SMTP id k15-20020a92c24f000000b0036527e74b60mr275670ilo.21.1709252163729; Thu, 29 Feb 2024 16:16:03 -0800 (PST) Received: from [10.0.0.71] (sandeen.net. [63.231.237.45]) by smtp.gmail.com with ESMTPSA id a16-20020a92d110000000b00365843633bcsm602448ilb.83.2024.02.29.16.16.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 16:16:03 -0800 (PST) Message-ID: <68be6a82-f093-41d4-9467-4b4694e8c5f3@redhat.com> Date: Thu, 29 Feb 2024 18:16:02 -0600 Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] qnx6: convert qnx6 to use the new mount api Content-Language: en-US To: Bill O'Donnell , linux-fsdevel@vger.kernel.org Cc: al@alarsen.net, brauner@kernel.org References: <20240229191317.805034-1-bodonnel@redhat.com> From: Eric Sandeen In-Reply-To: <20240229191317.805034-1-bodonnel@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/29/24 1:13 PM, Bill O'Donnell wrote: > Convert the qnx6 filesystem to use the new mount API. > > Untested, since there is no qnx6 fs image readily available. > > Signed-off-by: Bill O'Donnell > --- > fs/qnx6/inode.c | 119 +++++++++++++++++++++++++++++------------------- > 1 file changed, 72 insertions(+), 47 deletions(-) > > diff --git a/fs/qnx6/inode.c b/fs/qnx6/inode.c > index a286c545717f..0df5a92a8b65 100644 > --- a/fs/qnx6/inode.c > +++ b/fs/qnx6/inode.c > @@ -19,11 +19,12 @@ > #include > #include > #include > -#include > #include > #include I *think* you can lose this include too but not a big deal. > #include > #include > +#include > +#include > #include "qnx6.h" > > static const struct super_operations qnx6_sops; > @@ -31,7 +32,7 @@ static const struct super_operations qnx6_sops; > static void qnx6_put_super(struct super_block *sb); > static struct inode *qnx6_alloc_inode(struct super_block *sb); > static void qnx6_free_inode(struct inode *inode); > -static int qnx6_remount(struct super_block *sb, int *flags, char *data); > +static int qnx6_reconfigure(struct fs_context *fc); > static int qnx6_statfs(struct dentry *dentry, struct kstatfs *buf); > static int qnx6_show_options(struct seq_file *seq, struct dentry *root); > > @@ -40,7 +41,6 @@ static const struct super_operations qnx6_sops = { > .free_inode = qnx6_free_inode, > .put_super = qnx6_put_super, > .statfs = qnx6_statfs, > - .remount_fs = qnx6_remount, > .show_options = qnx6_show_options, > }; > > @@ -54,10 +54,12 @@ static int qnx6_show_options(struct seq_file *seq, struct dentry *root) > return 0; > } > > -static int qnx6_remount(struct super_block *sb, int *flags, char *data) > +static int qnx6_reconfigure(struct fs_context *fc) > { > + struct super_block *sb = fc->root->d_sb; > + > sync_filesystem(sb); > - *flags |= SB_RDONLY; > + fc->sb_flags |= SB_RDONLY; > return 0; > } > > @@ -222,35 +224,36 @@ enum { > Opt_err > }; > > -static const match_table_t tokens = { > - {Opt_mmifs, "mmi_fs"}, > - {Opt_err, NULL} > +struct qnx6_context { > + unsigned long s_mount_opts; > +}; s_mount_opts seems to be a write-only variable. It's set in qnx6_parse_param() but nothing ever reads it? > + > +static const struct fs_parameter_spec qnx6_param_spec[] = { > + fsparam_flag ("mmi_fs", Opt_mmifs), > + {} > }; > > -static int qnx6_parse_options(char *options, struct super_block *sb) > +static int qnx6_parse_param(struct fs_context *fc, struct fs_parameter *param) > { > - char *p; > - struct qnx6_sb_info *sbi = QNX6_SB(sb); > - substring_t args[MAX_OPT_ARGS]; > - > - if (!options) > - return 1; > - > - while ((p = strsep(&options, ",")) != NULL) { > - int token; > - if (!*p) > - continue; > - > - token = match_token(p, tokens, args); > - switch (token) { > - case Opt_mmifs: > - set_opt(sbi->s_mount_opt, MMI_FS); > - break; > - default: > - return 0; > - } > + struct qnx6_context *ctx = fc->fs_private; > + struct fs_parse_result result; > + int opt; > + > + opt = fs_parse(fc, qnx6_param_spec, param, &result); > + if (opt < 0) > + return opt; > + > + switch (opt) { > + case Opt_err: > + ctx->s_mount_opts |= result.uint_32; > + break; Not sure what's going on here. Opt_err is not associated with any valid mount option. > + case Opt_mmifs: > + ctx->s_mount_opts |= QNX6_MOUNT_MMI_FS; > + break; This sets QNX6_MOUNT_MMI_FS into ctx->s_mount_opts but it looks like nothing ever reads it back out of the context. In qnx6_fill_super uptream, this handles the case where the mmi_fs option was set: if (test_opt(s, MMI_FS)) { sb1 = qnx6_mmi_fill_super(s, silent); if (sb1) goto mmi_success; else goto outnobh; } Under the new mount api, the mmi_fs state needs to be saved in the filesystem context when it's parsed, then tested here, to do the right thing in fill_super when that option has been set. > + default: > + return -EINVAL; > } > - return 1; > + return 0; > } > > static struct buffer_head *qnx6_check_first_superblock(struct super_block *s, > @@ -293,22 +296,24 @@ static struct buffer_head *qnx6_check_first_superblock(struct super_block *s, > static struct inode *qnx6_private_inode(struct super_block *s, > struct qnx6_root_node *p); > > -static int qnx6_fill_super(struct super_block *s, void *data, int silent) > +static int qnx6_fill_super(struct super_block *s, struct fs_context *fc) > { > struct buffer_head *bh1 = NULL, *bh2 = NULL; > struct qnx6_super_block *sb1 = NULL, *sb2 = NULL; > struct qnx6_sb_info *sbi; > + > struct inode *root; > const char *errmsg; > struct qnx6_sb_info *qs; > int ret = -EINVAL; > u64 offset; > int bootblock_offset = QNX6_BOOTBLOCK_SIZE; > + int silent = fc->sb_flags & SB_SILENT; > > - qs = kzalloc(sizeof(struct qnx6_sb_info), GFP_KERNEL); > - if (!qs) > + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); > + if (!sbi) > return -ENOMEM; > - s->s_fs_info = qs; > + s->s_fs_info = sbi; Not sure what this change is for. The existing code is a little odd, it allocates *qs as a struct qnx6_sb_info and assigns it to s->s_fs_info, then reads it back out of s->s_fs_info via QNX6_SB(s) and assigns that to *sbi; I don't see any real reason for that dance, it's 2 pointers w/ the same value. But, with your change *qs is never initialized, and yet this: outnobh: kfree(qs); remains, which would free the uninitialized pointer variable. I don't think any of the above needs to change for this conversion. -Eric > /* Superblock always is 512 Byte long */ > if (!sb_set_blocksize(s, QNX6_SUPERBLOCK_SIZE)) { > @@ -316,11 +321,6 @@ static int qnx6_fill_super(struct super_block *s, void *data, int silent) > goto outnobh; > } > > - /* parse the mount-options */ > - if (!qnx6_parse_options((char *) data, s)) { > - pr_err("invalid mount options.\n"); > - goto outnobh; > - } > if (test_opt(s, MMI_FS)) { > sb1 = qnx6_mmi_fill_super(s, silent); > if (sb1) > @@ -632,18 +632,43 @@ static void destroy_inodecache(void) > kmem_cache_destroy(qnx6_inode_cachep); > } > > -static struct dentry *qnx6_mount(struct file_system_type *fs_type, > - int flags, const char *dev_name, void *data) > +static int qnx6_get_tree(struct fs_context *fc) > { > - return mount_bdev(fs_type, flags, dev_name, data, qnx6_fill_super); > + return get_tree_bdev(fc, qnx6_fill_super); > +} > + > +static void qnx6_free_fc(struct fs_context *fc) > +{ > + kfree(fc->fs_private); > +} > + > +static const struct fs_context_operations qnx6_context_ops = { > + .parse_param = qnx6_parse_param, > + .get_tree = qnx6_get_tree, > + .reconfigure = qnx6_reconfigure, > + .free = qnx6_free_fc, > +}; > + > +static int qnx6_init_fs_context(struct fs_context *fc) > +{ > + struct qnx6_context *ctx; > + > + ctx = kzalloc(sizeof(struct qnx6_context), GFP_KERNEL); > + if (!ctx) > + return -ENOMEM; > + fc->ops = &qnx6_context_ops; > + fc->fs_private = ctx; > + > + return 0; > } > > static struct file_system_type qnx6_fs_type = { > - .owner = THIS_MODULE, > - .name = "qnx6", > - .mount = qnx6_mount, > - .kill_sb = kill_block_super, > - .fs_flags = FS_REQUIRES_DEV, > + .owner = THIS_MODULE, > + .name = "qnx6", > + .kill_sb = kill_block_super, > + .fs_flags = FS_REQUIRES_DEV, > + .init_fs_context = qnx6_init_fs_context, > + .parameters = qnx6_param_spec, > }; > MODULE_ALIAS_FS("qnx6"); >