Received: by 10.192.165.156 with SMTP id m28csp723087imm; Thu, 19 Apr 2018 06:34:28 -0700 (PDT) X-Google-Smtp-Source: AIpwx48+wV+05AAEDsuaeiXWRfs4IFSlI/PNfrs9WIMDfZYhywwW2auucmqcV5pK7105s1/dVnlc X-Received: by 10.98.36.76 with SMTP id r73mr5916292pfj.108.1524144868214; Thu, 19 Apr 2018 06:34:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524144868; cv=none; d=google.com; s=arc-20160816; b=AsZrk+XY81/gVoeaO8TgB1ktzFB+Dy+iNG/NSR+SnJWq8g/t9ny3l+JEBzFF4ZKWE8 tdvHc3pIoFOiB4gwM9USrxUmzMb7cpsshppsgzZQPn4Ox2WCa8jFiV/Lme05Wfogh0OY 9LLGQi/lUhtKvN2j55XCm76j6tqfK8sdZyiteHexPdOsX3toCYF8dE4TEG5TGSnhJduh 6YMzCyD5VuUE58EUCVjPMzQu8nFT2Yu0Ys8Kn+412amf5uRGmeEwg63cZN1koDp7KeUz d1mKMAU/53ra/5rIjLM3HJH6e4mzZ9aePyRWWqpgZHu8y1N0tPzYFPcx9HD9p7r5SVSn y3UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:arc-authentication-results; bh=8o/fD2WGZXvPy1NrnIzXwpI3IizKW6nCW8W21/PUya4=; b=EjGsvmzmpRC4eaue3j+39euOWGQZiFmF6V7HTY0Yp4v5/CDSWRjkrSy8m07eEFTX8/ H2dXFIvdxesqr6xyjo6hbtv7yRsPUhEkZsIhJh929rLFxbdX+VkxJU3LHRvXNLDWqEcG uUccwrp4i1Enda5ySH1+D5qMY5W2aMtJ+UVKfn/rPpMrCU/dhRKBFiWWg0jTeSfNViwL 07cQyI7APEsJP4+3ZR9sd9TYao60nfUG76GlDrBsND1Cpi94So2hZI8QAvez7zOYrlOX O69PWkE96G4s345SaPEc7kyUn915igDVgJptom/1l54MWQmfkMEvEx8cD0z8jJoGLoy/ 4Wkw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a98-v6si3611750pla.239.2018.04.19.06.34.14; Thu, 19 Apr 2018 06:34:28 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753365AbeDSNcp (ORCPT + 99 others); Thu, 19 Apr 2018 09:32:45 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:34714 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753270AbeDSNco (ORCPT ); Thu, 19 Apr 2018 09:32:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 78DC48182D27; Thu, 19 Apr 2018 13:32:43 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-121-60.rdu2.redhat.com [10.10.121.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7C6CE6F9E6; Thu, 19 Apr 2018 13:32:42 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH 14/24] cpuset: Use fs_context [ver #7] From: David Howells To: viro@zeniv.linux.org.uk Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, Tejun Heo , linux-afs@lists.infradead.org Date: Thu, 19 Apr 2018 14:32:42 +0100 Message-ID: <152414476200.23902.10569978915645391342.stgit@warthog.procyon.org.uk> In-Reply-To: <152414466005.23902.12967974041384198114.stgit@warthog.procyon.org.uk> References: <152414466005.23902.12967974041384198114.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 19 Apr 2018 13:32:43 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 19 Apr 2018 13:32:43 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'dhowells@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make the cpuset filesystem use the filesystem context. This is potentially tricky as the cpuset fs is almost an alias for the cgroup filesystem, but with some special parameters. This can, however, be handled by setting up an appropriate cgroup filesystem and returning the root directory of that as the root dir of this one. Signed-off-by: David Howells cc: Tejun Heo --- kernel/cgroup/cpuset.c | 66 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index 3c8ef37879f0..fce0584f161e 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -315,26 +315,64 @@ static inline bool is_in_v2_mode(void) * users. If someone tries to mount the "cpuset" filesystem, we * silently switch it to mount "cgroup" instead */ -static struct dentry *cpuset_mount(struct file_system_type *fs_type, - int flags, const char *unused_dev_name, - void *data, size_t data_size) +static int cpuset_get_tree(struct fs_context *fc) { - struct file_system_type *cgroup_fs = get_fs_type("cgroup"); - struct dentry *ret = ERR_PTR(-ENODEV); + static const char opts[] = "cpuset,noprefix,release_agent=/sbin/cpuset_release_agent"; + struct file_system_type *cgroup_fs; + struct fs_context *cg_fc; + char *p; + int ret = -ENODEV; + + cgroup_fs = get_fs_type("cgroup"); if (cgroup_fs) { - char mountopts[] = - "cpuset,noprefix," - "release_agent=/sbin/cpuset_release_agent"; - ret = cgroup_fs->mount(cgroup_fs, flags, unused_dev_name, - mountopts, data_size); - put_filesystem(cgroup_fs); + ret = PTR_ERR(cgroup_fs); + goto out; + } + + cg_fc = vfs_new_fs_context(cgroup_fs, NULL, fc->sb_flags, fc->purpose); + put_filesystem(cgroup_fs); + if (IS_ERR(cg_fc)) { + ret = PTR_ERR(cg_fc); + goto out; } + + ret = -ENOMEM; + p = kstrdup(opts, GFP_KERNEL); + if (!p) + goto out_fc; + + ret = generic_parse_monolithic(fc, p, sizeof(opts) - 1); + kfree(p); + if (ret < 0) + goto out_fc; + + ret = vfs_get_tree(cg_fc); + if (ret < 0) + goto out_fc; + + fc->root = dget(cg_fc->root); + ret = 0; + +out_fc: + put_fs_context(cg_fc); +out: return ret; } +static const struct fs_context_operations cpuset_fs_context_ops = { + .get_tree = cpuset_get_tree, +}; + +static int cpuset_init_fs_context(struct fs_context *fc, struct super_block *src_sb) +{ + fc->ops = &cpuset_fs_context_ops; + return 0; +} + static struct file_system_type cpuset_fs_type = { - .name = "cpuset", - .mount = cpuset_mount, + .name = "cpuset", + .fs_context_size = sizeof(struct fs_context), + .init_fs_context = cpuset_init_fs_context, }; /*