Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp393116yba; Mon, 1 Apr 2019 08:26:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWxPjrqoBYBoaTDMInqfNazL/o3rBpif0WfVyOoL06Ik3M5caDtn60ixyUi3rh6Mqn9wZs X-Received: by 2002:a17:902:8c97:: with SMTP id t23mr17357624plo.110.1554132379544; Mon, 01 Apr 2019 08:26:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554132379; cv=none; d=google.com; s=arc-20160816; b=TyZLU+Lwge/dNumxZG3KbuQ4bl9QqxFphHaIj3c43rhSZZi4B53NvU3wigERB1oUhM xaqqkg+2CoBCjH8xU47E02/jeE87rpwsM3HV0Rz96L1NvSOAqT0h8a0kbcKb8I/F1IDy +ijKzgTIDjcaGuTeqdIqCcV7GxZRuTW+WQQXLkNgtGT5YrlrJbG96wSBFrhfU7TgU8ju rymgwSdDNrEy4i5E0O8y10/dQRKy7bDmCB+J1DPK5vYNPir4Lt6q0p37wyQvW4C+1eeC UJgM3xPLoaAZ+rWesrW5zdICeGNTFSkTDs9sD3oxjvB4TMDpH/kwA6wdSnFeK8CKWo9N hQyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=cAfQG/UEDQ7aTanppXEJl0SxoHiQQ65MZZP0ZhS04EA=; b=BgNa92cKXDq8arw4LpjGyelAuBOsfZdsTbhYTyleDMiYpaK14ixftLYkPQLO2AwRpB zsebdU2WbMDGMAYdSFXX5jRvfEWbwGHtJ7nQhKpbV0w+EEn2VenqN5Ru07Ee/mov8L7T eing5UPpTG8l0YGCJGFuhfNrDzchTxp9KZHL7rtf1yyOo+XAOgeuyE8I8tIM8nPEbkSZ SOcxlyWEngCLxGhZFkTek0yWAvQUFuzFKudJH7TTn0FGAN61rL2p3USqjmRt685OMV1O /a1JLr9+ujLKbj+5ll3KqewgiPHt0oYPpI0vrz7DiRDXupqeczH2Cowm12mg2LZbQNaI 7M4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=YLNhaTYf; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=1fXeqViD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q61si9401524plb.245.2019.04.01.08.26.03; Mon, 01 Apr 2019 08:26:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=YLNhaTYf; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=1fXeqViD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728624AbfDAPZ0 (ORCPT + 99 others); Mon, 1 Apr 2019 11:25:26 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:54036 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726617AbfDAPZY (ORCPT ); Mon, 1 Apr 2019 11:25:24 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id CB6C5134A61; Mon, 1 Apr 2019 11:25:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=ndejXqIJxqzUiIyAycGiXOLl8Ag=; b=YLNhaT YfkwoPLHnkOUK3jepEQtyVPxcxDCaKKlJHVBjHjo+HxiWEJnjCKyTYI/B9EnoEaG DNnauRE/iGjnjCkP82LGL5o3Jcn/UM6uFH7d6aik6p/GhFGYBVC1RFrRcOr/Sccc 9xa5VBOizpXOO+0eSo/FT1sxkbPHr2hlrdimA= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id C1508134A60; Mon, 1 Apr 2019 11:25:17 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=Sga27Msg4oo6+VzgjwJKl6FpIJ7nJxQUh/RmP2YrqDo=; b=1fXeqViDMMyFYU/qirHu6UJ4ss2rJILOHapZ2tM7J73AmLHdhaM56MslbBqcN7iS4mC56k10WRHSjH9l12ra3GlQlE55HQeeXNIVLqDBUVb9VuptWEkB18Zsse8kUmpOf6Q5rQi2Dh4ihJyG09Ky75T54dMk2BCnWiruyCYW1Qc= Received: from yoda.home (unknown [70.82.104.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id 3F284134A5F; Mon, 1 Apr 2019 11:25:17 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id 55C122DA00D8; Mon, 1 Apr 2019 11:25:16 -0400 (EDT) Date: Mon, 1 Apr 2019 11:25:16 -0400 (EDT) From: Nicolas Pitre To: David Howells cc: viro@zeniv.linux.org.uk, linux-mtd@lists.infradead.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 48/68] vfs: Convert cramfs to use the new mount API In-Reply-To: <155373039704.7602.6796835761744428479.stgit@warthog.procyon.org.uk> Message-ID: References: <155372999953.7602.13784796495137723805.stgit@warthog.procyon.org.uk> <155373039704.7602.6796835761744428479.stgit@warthog.procyon.org.uk> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Pobox-Relay-ID: 5A8E4D16-5492-11E9-BFB9-DF19F34BB12D-78420484!pb-smtp2.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Mar 2019, David Howells wrote: > Convert the cramfs filesystem to the new internal mount API as the old > one will be obsoleted and removed. This allows greater flexibility in > communication of mount parameters between userspace, the VFS and the > filesystem. > > See Documentation/filesystems/mount_api.txt for more information. > > Signed-off-by: David Howells > cc: Nicolas Pitre > cc: linux-mtd@lists.infradead.org > cc: linux-block@vger.kernel.org Tested-by: Nicolas Pitre Acked-by: Nicolas Pitre > --- > > fs/cramfs/inode.c | 69 ++++++++++++++++++++++++++++++----------------------- > 1 file changed, 39 insertions(+), 30 deletions(-) > > diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c > index 9352487bd0fc..2ee89a353d64 100644 > --- a/fs/cramfs/inode.c > +++ b/fs/cramfs/inode.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -506,18 +507,19 @@ static void cramfs_kill_sb(struct super_block *sb) > kfree(sbi); > } > > -static int cramfs_remount(struct super_block *sb, int *flags, char *data) > +static int cramfs_reconfigure(struct fs_context *fc) > { > - sync_filesystem(sb); > - *flags |= SB_RDONLY; > + sync_filesystem(fc->root->d_sb); > + fc->sb_flags |= SB_RDONLY; > return 0; > } > > -static int cramfs_read_super(struct super_block *sb, > - struct cramfs_super *super, int silent) > +static int cramfs_read_super(struct super_block *sb, struct fs_context *fc, > + struct cramfs_super *super) > { > struct cramfs_sb_info *sbi = CRAMFS_SB(sb); > unsigned long root_offset; > + bool silent = fc->sb_flags & SB_SILENT; > > /* We don't know the real size yet */ > sbi->size = PAGE_SIZE; > @@ -532,7 +534,7 @@ static int cramfs_read_super(struct super_block *sb, > /* check for wrong endianness */ > if (super->magic == CRAMFS_MAGIC_WEND) { > if (!silent) > - pr_err("wrong endianness\n"); > + errorf(fc, "cramfs: wrong endianness"); > return -EINVAL; > } > > @@ -544,22 +546,22 @@ static int cramfs_read_super(struct super_block *sb, > mutex_unlock(&read_mutex); > if (super->magic != CRAMFS_MAGIC) { > if (super->magic == CRAMFS_MAGIC_WEND && !silent) > - pr_err("wrong endianness\n"); > + errorf(fc, "cramfs: wrong endianness"); > else if (!silent) > - pr_err("wrong magic\n"); > + errorf(fc, "cramfs: wrong magic"); > return -EINVAL; > } > } > > /* get feature flags first */ > if (super->flags & ~CRAMFS_SUPPORTED_FLAGS) { > - pr_err("unsupported filesystem features\n"); > + errorf(fc, "cramfs: unsupported filesystem features"); > return -EINVAL; > } > > /* Check that the root inode is in a sane state */ > if (!S_ISDIR(super->root.mode)) { > - pr_err("root is not a directory\n"); > + errorf(fc, "cramfs: root is not a directory"); > return -EINVAL; > } > /* correct strange, hard-coded permissions of mkcramfs */ > @@ -578,12 +580,12 @@ static int cramfs_read_super(struct super_block *sb, > sbi->magic = super->magic; > sbi->flags = super->flags; > if (root_offset == 0) > - pr_info("empty filesystem"); > + infof(fc, "cramfs: empty filesystem"); > else if (!(super->flags & CRAMFS_FLAG_SHIFTED_ROOT_OFFSET) && > ((root_offset != sizeof(struct cramfs_super)) && > (root_offset != 512 + sizeof(struct cramfs_super)))) > { > - pr_err("bad root offset %lu\n", root_offset); > + errorf(fc, "cramfs: bad root offset %lu", root_offset); > return -EINVAL; > } > > @@ -607,8 +609,7 @@ static int cramfs_finalize_super(struct super_block *sb, > return 0; > } > > -static int cramfs_blkdev_fill_super(struct super_block *sb, void *data, > - int silent) > +static int cramfs_blkdev_fill_super(struct super_block *sb, struct fs_context *fc) > { > struct cramfs_sb_info *sbi; > struct cramfs_super super; > @@ -623,14 +624,13 @@ static int cramfs_blkdev_fill_super(struct super_block *sb, void *data, > for (i = 0; i < READ_BUFFERS; i++) > buffer_blocknr[i] = -1; > > - err = cramfs_read_super(sb, &super, silent); > + err = cramfs_read_super(sb, fc, &super); > if (err) > return err; > return cramfs_finalize_super(sb, &super.root); > } > > -static int cramfs_mtd_fill_super(struct super_block *sb, void *data, > - int silent) > +static int cramfs_mtd_fill_super(struct super_block *sb, struct fs_context *fc) > { > struct cramfs_sb_info *sbi; > struct cramfs_super super; > @@ -652,7 +652,7 @@ static int cramfs_mtd_fill_super(struct super_block *sb, void *data, > > pr_info("checking physical address %pap for linear cramfs image\n", > &sbi->linear_phys_addr); > - err = cramfs_read_super(sb, &super, silent); > + err = cramfs_read_super(sb, fc, &super); > if (err) > return err; > > @@ -947,32 +947,41 @@ static const struct inode_operations cramfs_dir_inode_operations = { > }; > > static const struct super_operations cramfs_ops = { > - .remount_fs = cramfs_remount, > .statfs = cramfs_statfs, > }; > > -static struct dentry *cramfs_mount(struct file_system_type *fs_type, int flags, > - const char *dev_name, void *data) > +static int cramfs_get_tree(struct fs_context *fc) > { > - struct dentry *ret = ERR_PTR(-ENOPROTOOPT); > + int ret = -ENOPROTOOPT; > > if (IS_ENABLED(CONFIG_CRAMFS_MTD)) { > - ret = mount_mtd(fs_type, flags, dev_name, data, > - cramfs_mtd_fill_super); > - if (!IS_ERR(ret)) > + ret = vfs_get_mtd_super(fc, cramfs_mtd_fill_super); > + if (ret < 0) > return ret; > } > - if (IS_ENABLED(CONFIG_CRAMFS_BLOCKDEV)) { > - ret = mount_bdev(fs_type, flags, dev_name, data, > - cramfs_blkdev_fill_super); > - } > + if (IS_ENABLED(CONFIG_CRAMFS_BLOCKDEV)) > + ret = vfs_get_block_super(fc, cramfs_blkdev_fill_super); > return ret; > } > > +static const struct fs_context_operations cramfs_context_ops = { > + .get_tree = cramfs_get_tree, > + .reconfigure = cramfs_reconfigure, > +}; > + > +/* > + * Set up the filesystem mount context. > + */ > +static int cramfs_init_fs_context(struct fs_context *fc) > +{ > + fc->ops = &cramfs_context_ops; > + return 0; > +} > + > static struct file_system_type cramfs_fs_type = { > .owner = THIS_MODULE, > .name = "cramfs", > - .mount = cramfs_mount, > + .init_fs_context = cramfs_init_fs_context, > .kill_sb = cramfs_kill_sb, > .fs_flags = FS_REQUIRES_DEV, > }; > >