From patchwork Thu Jan 3 23:44:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 10747857 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 433B317D2 for ; Thu, 3 Jan 2019 23:44:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32A4E24603 for ; Thu, 3 Jan 2019 23:44:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 264CF2621B; Thu, 3 Jan 2019 23:44:07 +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 C82C324603 for ; Thu, 3 Jan 2019 23:44:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728940AbfACXoF (ORCPT ); Thu, 3 Jan 2019 18:44:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57166 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728937AbfACXoE (ORCPT ); Thu, 3 Jan 2019 18:44:04 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3C675D61B; Thu, 3 Jan 2019 23:44:03 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-120-244.rdu2.redhat.com [10.10.120.244]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD5C719742; Thu, 3 Jan 2019 23:44:02 +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 1/5] cgroup2: Always apply root flags on successful superblock obtainance From: David Howells To: viro@zeniv.linux.org.uk Cc: Andrei Vagin , avagin@gmail.com, dhowells@redhat.com, linux-fsdevel@vger.kernel.org Date: Thu, 03 Jan 2019 23:44:02 +0000 Message-ID: <154655904205.3032.4248425887082198759.stgit@warthog.procyon.org.uk> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 03 Jan 2019 23:44:04 +0000 (UTC) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Always apply the v2 cgroup root flag settings after successfully obtaining a superblock, both when the superblock is new and when an already extant superblock is being shared. Currently there's a bug in commit b3678086951a5 whereby the flags are only changed if the superblock wasn't new. The intention was originally to effect the change for a new superblock by having kernfs_fill_super() call back into the subclassing filesystem, but that never got completed. On further reflection, it's possibly better not to do that so that we don't have to revert the flag change if there's a later failure. This patch is on top of Andrei Vagin's v6 cgroup refcount patch. Fixes: b3678086951a ("kernfs, sysfs, cgroup, intel_rdt: Support fs_context") Reported-by: Al Viro Signed-off-by: David Howells cc: Andrei Vagin --- kernel/cgroup/cgroup.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index a19f0fec9d82..2e5150412ae0 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -2044,12 +2044,9 @@ int cgroup_do_get_tree(struct fs_context *fc) fc->root = nsdentry; } + if (ctx->version == 2) + apply_cgroup_root_flags(ctx->flags); ret = 0; - if (ctx->kfc.new_sb_created) - goto out_cgrp; - apply_cgroup_root_flags(ctx->flags); - return 0; - out_cgrp: return ret; }