Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6DDAC4CEC9 for ; Fri, 20 Sep 2019 09:56:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5AF72080F for ; Fri, 20 Sep 2019 09:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437951AbfITJ4y (ORCPT ); Fri, 20 Sep 2019 05:56:54 -0400 Received: from icp-osb-irony-out5.external.iinet.net.au ([203.59.1.221]:6242 "EHLO icp-osb-irony-out5.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408538AbfITJ4y (ORCPT ); Fri, 20 Sep 2019 05:56:54 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A2CyAADfoYRd/zmr0HYNVxwBAQEEAQE?= =?us-ascii?q?HBAEBgVYEAQELAQGEMoQij2cBAQaBEYoahR+MCQkBAQEBAQEBAQE3AQGEOgM?= =?us-ascii?q?CAoMqNwYOAgwBAQEEAQEBAQEFAwGFWIEQARABBAGEcgIBAyMEUhAYDQImAgJ?= =?us-ascii?q?HEAYThRmrBnN/MxqKLoEMKAGBYoo+eIEHgRABM4Mdh0+CWASMcYJlhU1fQpZ?= =?us-ascii?q?HgiyVJQyOBwOLDoQzpQyBek0uCoMnUIF+F44vZoJriHGDUAEB?= X-IPAS-Result: =?us-ascii?q?A2CyAADfoYRd/zmr0HYNVxwBAQEEAQEHBAEBgVYEAQELA?= =?us-ascii?q?QGEMoQij2cBAQaBEYoahR+MCQkBAQEBAQEBAQE3AQGEOgMCAoMqNwYOAgwBA?= =?us-ascii?q?QEEAQEBAQEFAwGFWIEQARABBAGEcgIBAyMEUhAYDQImAgJHEAYThRmrBnN/M?= =?us-ascii?q?xqKLoEMKAGBYoo+eIEHgRABM4Mdh0+CWASMcYJlhU1fQpZHgiyVJQyOBwOLD?= =?us-ascii?q?oQzpQyBek0uCoMnUIF+F44vZoJriHGDUAEB?= X-IronPort-AV: E=Sophos;i="5.64,528,1559491200"; d="scan'208";a="253491597" Received: from unknown (HELO [192.168.1.222]) ([118.208.171.57]) by icp-osb-irony-out5.iinet.net.au with ESMTP; 20 Sep 2019 17:56:51 +0800 Subject: [PATCH v3 15/16] xfs: mount-api - switch to new mount-api From: Ian Kent To: linux-xfs Cc: David Howells , Dave Chinner , Al Viro , Eric Sandeen Date: Fri, 20 Sep 2019 17:56:51 +0800 Message-ID: <156897341138.20210.14820137791764097401.stgit@fedora-28> In-Reply-To: <156897321789.20210.339237101446767141.stgit@fedora-28> References: <156897321789.20210.339237101446767141.stgit@fedora-28> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org The infrastructure needed to use the new mount api is now in place, switch over to use it. Signed-off-by: Ian Kent --- fs/xfs/xfs_super.c | 156 +++++++++++++++++++--------------------------------- 1 file changed, 56 insertions(+), 100 deletions(-) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index eb5dc70658ab..e0c8e9d8a2f6 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1349,26 +1349,6 @@ xfs_quiesce_attr( xfs_log_quiesce(mp); } -STATIC int -xfs_test_remount_options( - struct super_block *sb, - char *options) -{ - int error = 0; - struct xfs_mount *tmp_mp; - - tmp_mp = kmem_zalloc(sizeof(*tmp_mp), KM_MAYFAIL); - if (!tmp_mp) - return -ENOMEM; - - tmp_mp->m_super = sb; - error = xfs_parseargs(tmp_mp, options); - xfs_free_fsname(tmp_mp); - kmem_free(tmp_mp); - - return error; -} - STATIC int xfs_remount_rw( struct xfs_mount *mp) @@ -1472,84 +1452,6 @@ xfs_remount_ro( return 0; } -STATIC int -xfs_fs_remount( - struct super_block *sb, - int *flags, - char *options) -{ - struct xfs_mount *mp = XFS_M(sb); - xfs_sb_t *sbp = &mp->m_sb; - substring_t args[MAX_OPT_ARGS]; - char *p; - int error; - - /* First, check for complete junk; i.e. invalid options */ - error = xfs_test_remount_options(sb, options); - if (error) - return error; - - sync_filesystem(sb); - while ((p = strsep(&options, ",")) != NULL) { - int token; - - if (!*p) - continue; - - token = match_token(p, tokens, args); - switch (token) { - case Opt_inode64: - mp->m_flags &= ~XFS_MOUNT_SMALL_INUMS; - mp->m_maxagi = xfs_set_inode_alloc(mp, sbp->sb_agcount); - break; - case Opt_inode32: - mp->m_flags |= XFS_MOUNT_SMALL_INUMS; - mp->m_maxagi = xfs_set_inode_alloc(mp, sbp->sb_agcount); - break; - default: - /* - * Logically we would return an error here to prevent - * users from believing they might have changed - * mount options using remount which can't be changed. - * - * But unfortunately mount(8) adds all options from - * mtab and fstab to the mount arguments in some cases - * so we can't blindly reject options, but have to - * check for each specified option if it actually - * differs from the currently set option and only - * reject it if that's the case. - * - * Until that is implemented we return success for - * every remount request, and silently ignore all - * options that we can't actually change. - */ -#if 0 - xfs_info(mp, - "mount option \"%s\" not supported for remount", p); - return -EINVAL; -#else - break; -#endif - } - } - - /* ro -> rw */ - if ((mp->m_flags & XFS_MOUNT_RDONLY) && !(*flags & SB_RDONLY)) { - error = xfs_remount_rw(mp); - if (error) - return error; - } - - /* rw -> ro */ - if (!(mp->m_flags & XFS_MOUNT_RDONLY) && (*flags & SB_RDONLY)) { - error = xfs_remount_ro(mp); - if (error) - return error; - } - - return 0; -} - /* * There have been problems in the past with options passed from mount(8). * @@ -2148,7 +2050,6 @@ static const struct super_operations xfs_super_operations = { .freeze_fs = xfs_fs_freeze, .unfreeze_fs = xfs_fs_unfreeze, .statfs = xfs_fs_statfs, - .remount_fs = xfs_fs_remount, .show_options = xfs_fs_show_options, .nr_cached_objects = xfs_fs_nr_cached_objects, .free_cached_objects = xfs_fs_free_cached_objects, @@ -2180,10 +2081,65 @@ static void xfs_fc_free(struct fs_context *fc) kfree(ctx); } +static const struct fs_context_operations xfs_context_ops = { + .parse_param = xfs_parse_param, + .get_tree = xfs_get_tree, + .reconfigure = xfs_reconfigure, + .free = xfs_fc_free, +}; + +/* + * Set up the filesystem mount context. + */ +int xfs_init_fs_context(struct fs_context *fc) +{ + struct xfs_fs_context *ctx; + struct xfs_mount *mp; + + ctx = kzalloc(sizeof(struct xfs_fs_context), GFP_KERNEL); + if (!ctx) + return -ENOMEM; + + mp = xfs_mount_alloc(); + if (!mp) { + kfree(ctx); + return -ENOMEM; + } + + /* + * Set some default flags that could be cleared by the mount option + * parsing. + */ + mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE; + + /* + * These can be overridden by the mount option parsing. + */ + mp->m_logbufs = -1; + mp->m_logbsize = -1; + + /* + * Copy binary VFS mount flags we are interested in. + */ + if (fc->sb_flags & SB_RDONLY) + mp->m_flags |= XFS_MOUNT_RDONLY; + if (fc->sb_flags & SB_DIRSYNC) + mp->m_flags |= XFS_MOUNT_DIRSYNC; + if (fc->sb_flags & SB_SYNCHRONOUS) + mp->m_flags |= XFS_MOUNT_WSYNC; + + fc->fs_private = ctx; + fc->s_fs_info = mp; + fc->ops = &xfs_context_ops; + + return 0; +} + static struct file_system_type xfs_fs_type = { .owner = THIS_MODULE, .name = "xfs", - .mount = xfs_fs_mount, + .init_fs_context = xfs_init_fs_context, + .parameters = &xfs_fs_parameters, .kill_sb = kill_block_super, .fs_flags = FS_REQUIRES_DEV, };