From patchwork Mon Jun 24 02:58:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 11012091 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78D7F76 for ; Mon, 24 Jun 2019 03:08:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6AB5528AF8 for ; Mon, 24 Jun 2019 03:08:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F35328B08; Mon, 24 Jun 2019 03:08:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E538528AF8 for ; Mon, 24 Jun 2019 03:08:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726323AbfFXDIF (ORCPT ); Sun, 23 Jun 2019 23:08:05 -0400 Received: from icp-osb-irony-out1.external.iinet.net.au ([203.59.1.210]:33323 "EHLO icp-osb-irony-out1.external.iinet.net.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbfFXDIF (ORCPT ); Sun, 23 Jun 2019 23:08:05 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2AJAQCVOxBd/3Gu0HYNVxwBAQEEAQEHBAEBgWeELYQWk0kGgRGJeIUXi3cJAQEBAQEBAQEBNwEBAYQ6AwICgwE4EwEDAQEBBAEBAQEEAZB7AgEDIwRNBRAYDQImAgJHEAYThRmiSXF+MxqKEYEMKIFiihN4gQeBETODHYQpgyWCWASOSoUcWz+VCQmCFpN9DIIciwQDEIoILYNjoiiBeU0uCoMngk0Xji1ljWEBK4IlAQE X-IPAS-Result: A2AJAQCVOxBd/3Gu0HYNVxwBAQEEAQEHBAEBgWeELYQWk0kGgRGJeIUXi3cJAQEBAQEBAQEBNwEBAYQ6AwICgwE4EwEDAQEBBAEBAQEEAZB7AgEDIwRNBRAYDQImAgJHEAYThRmiSXF+MxqKEYEMKIFiihN4gQeBETODHYQpgyWCWASOSoUcWz+VCQmCFpN9DIIciwQDEIoILYNjoiiBeU0uCoMngk0Xji1ljWEBK4IlAQE X-IronPort-AV: E=Sophos;i="5.63,410,1557158400"; d="scan'208";a="221015786" Received: from unknown (HELO [192.168.1.222]) ([118.208.174.113]) by icp-osb-irony-out1.iinet.net.au with ESMTP; 24 Jun 2019 10:58:51 +0800 Subject: [PATCH 05/10] xfs: mount-api - add xfs_get_tree() From: Ian Kent To: linux-xfs Cc: Dave Chinner , David Howells , Al Viro Date: Mon, 24 Jun 2019 10:58:50 +0800 Message-ID: <156134513061.2519.15444193018279732348.stgit@fedora-28> In-Reply-To: <156134510205.2519.16185588460828778620.stgit@fedora-28> References: <156134510205.2519.16185588460828778620.stgit@fedora-28> User-Agent: StGit/unknown-version MIME-Version: 1.0 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add the fs_context_operations method .get_tree that validates mount options and fills the super block as previously done by the file_system_type .mount method. Signed-off-by: Ian Kent --- fs/xfs/xfs_super.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index cf8efb465969..0ec0142b94e1 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1629,6 +1629,98 @@ xfs_fs_remount( return 0; } +STATIC int +xfs_validate_params( + struct xfs_mount *mp, + struct xfs_fs_context *ctx, + enum fs_context_purpose purpose) +{ + /* + * no recovery flag requires a read-only mount + */ + if ((mp->m_flags & XFS_MOUNT_NORECOVERY) && + !(mp->m_flags & XFS_MOUNT_RDONLY)) { + xfs_warn(mp, "no-recovery mounts must be read-only."); + return -EINVAL; + } + + if ((mp->m_flags & XFS_MOUNT_NOALIGN) && + (ctx->dsunit || ctx->dswidth)) { + xfs_warn(mp, + "sunit and swidth options incompatible with the noalign option"); + return -EINVAL; + } + +#ifndef CONFIG_XFS_QUOTA + if (XFS_IS_QUOTA_RUNNING(mp)) { + xfs_warn(mp, "quota support not available in this kernel."); + return -EINVAL; + } +#endif + + if ((ctx->dsunit && !ctx->dswidth) || (!ctx->dsunit && ctx->dswidth)) { + xfs_warn(mp, "sunit and swidth must be specified together"); + return -EINVAL; + } + + if (ctx->dsunit && (ctx->dswidth % ctx->dsunit != 0)) { + xfs_warn(mp, + "stripe width (%d) must be a multiple of the stripe unit (%d)", + ctx->dswidth, ctx->dsunit); + return -EINVAL; + } + + if (ctx->dsunit && !(mp->m_flags & XFS_MOUNT_NOALIGN)) { + /* + * At this point the superblock has not been read + * in, therefore we do not know the block size. + * Before the mount call ends we will convert + * these to FSBs. + */ + if (purpose == FS_CONTEXT_FOR_MOUNT) { + mp->m_dalign = ctx->dsunit; + mp->m_swidth = ctx->dswidth; + } + } + + if (mp->m_logbufs != -1 && + mp->m_logbufs != 0 && + (mp->m_logbufs < XLOG_MIN_ICLOGS || + mp->m_logbufs > XLOG_MAX_ICLOGS)) { + xfs_warn(mp, "invalid logbufs value: %d [not %d-%d]", + mp->m_logbufs, XLOG_MIN_ICLOGS, XLOG_MAX_ICLOGS); + return -EINVAL; + } + if (mp->m_logbsize != -1 && + mp->m_logbsize != 0 && + (mp->m_logbsize < XLOG_MIN_RECORD_BSIZE || + mp->m_logbsize > XLOG_MAX_RECORD_BSIZE || + !is_power_of_2(mp->m_logbsize))) { + xfs_warn(mp, + "invalid logbufsize: %d [not 16k,32k,64k,128k or 256k]", + mp->m_logbsize); + return -EINVAL; + } + + if (ctx->iosizelog) { + if (ctx->iosizelog > XFS_MAX_IO_LOG || + ctx->iosizelog < XFS_MIN_IO_LOG) { + xfs_warn(mp, "invalid log iosize: %d [not %d-%d]", + ctx->iosizelog, XFS_MIN_IO_LOG, + XFS_MAX_IO_LOG); + return -EINVAL; + } + + if (purpose == FS_CONTEXT_FOR_MOUNT) { + mp->m_flags |= XFS_MOUNT_DFLT_IOSIZE; + mp->m_readio_log = ctx->iosizelog; + mp->m_writeio_log = ctx->iosizelog; + } + } + + return 0; +} + /* * Second stage of a freeze. The data is already frozen so we only * need to take care of the metadata. Once that's done sync the superblock @@ -2035,6 +2127,52 @@ xfs_fs_fill_super( return error; } +STATIC int +xfs_fill_super( + struct super_block *sb, + struct fs_context *fc) +{ + struct xfs_fs_context *ctx = fc->fs_private; + struct xfs_mount *mp = sb->s_fs_info; + int silent = fc->sb_flags & SB_SILENT; + int error = -ENOMEM; + + mp->m_super = sb; + + /* + * set up the mount name first so all the errors will refer to the + * correct device. + */ + mp->m_fsname = kstrndup(sb->s_id, MAXNAMELEN, GFP_KERNEL); + if (!mp->m_fsname) + return -ENOMEM; + mp->m_fsname_len = strlen(mp->m_fsname) + 1; + + error = xfs_validate_params(mp, ctx, fc->purpose); + if (error) + goto out_free_fsname; + + error = __xfs_fs_fill_super(mp, silent); + if (error) + goto out_free_fsname; + + return 0; + + out_free_fsname: + sb->s_fs_info = NULL; + xfs_free_fsname(mp); + kfree(mp); + + return error; +} + +STATIC int +xfs_get_tree( + struct fs_context *fc) +{ + return vfs_get_block_super(fc, xfs_fill_super); +} + STATIC void xfs_fs_put_super( struct super_block *sb) @@ -2107,6 +2245,7 @@ static const struct super_operations xfs_super_operations = { static const struct fs_context_operations xfs_context_ops = { .parse_param = xfs_parse_param, + .get_tree = xfs_get_tree, }; static struct file_system_type xfs_fs_type = {