From patchwork Fri May 29 07:40:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 11578047 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CA109912 for ; Fri, 29 May 2020 07:57:42 +0000 (UTC) Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 97E83207D4 for ; Fri, 29 May 2020 07:57:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 97E83207D4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=ocfs2-devel-bounces@oss.oracle.com Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7qGpn144126; Fri, 29 May 2020 07:57:31 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 318xe1ry8n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 29 May 2020 07:57:30 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7ri5k183955; Fri, 29 May 2020 07:55:30 GMT Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by userp3020.oracle.com with ESMTP id 31a9ktuw9q-1 (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO); Fri, 29 May 2020 07:55:29 +0000 Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jeZrU-0000JH-Vr; Fri, 29 May 2020 00:55:28 -0700 Received: from userp3030.oracle.com ([156.151.31.80]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1jeZdl-0006c3-Ao for ocfs2-devel@oss.oracle.com; Fri, 29 May 2020 00:41:17 -0700 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7d1P5039658 for ; Fri, 29 May 2020 07:41:16 GMT Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by userp3030.oracle.com with ESMTP id 317ds3wpwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 29 May 2020 07:41:16 +0000 Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 04T7ewSv007504 for ; Fri, 29 May 2020 07:41:16 GMT Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by userp2030.oracle.com with ESMTP id 31akmj1bbj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=OK) for ; Fri, 29 May 2020 07:41:16 +0000 Received: by mail-pl1-f195.google.com with SMTP id y11so755420plt.12 for ; Fri, 29 May 2020 00:41:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ztkbZyMAj8QAP+BJLtRR/lmTCR2M8J8E3LJknwjviqU=; b=YO49MOdT2hBjAe7ezJQSFaulR2zkIkWCy9NhhT2aVroiOmJscDlS//2VzQxdJv26TS E6pye4/C20qkH3QI4IQhyIsWoszk1CYRy0HGGgFbAwRGbDLDpMAVySwgxoiGAXjsiAoC 7dMXW7kjZz3YUWogr+p+j10xwZFGo5osrL4NqrIB3hn0ZHGF8tdfR3BJdJVOOJy2WKtz AzmMdWc/O2hrdflHmUHohSFaYhs8wIgssByJnioYTDCoiZav/XrL3+FubNaotk7KVzNn LPQ9QdrJy5WoAR91TOWsCcD9MLNSohYgK70tkO4jztezNDB6XvvJALtbysrX5WNRRWWc FFjQ== X-Gm-Message-State: AOAM530ctxmpxUob71QqunEhT/nP3xXMyOVsiI3Qtkm/YdfJ7wBq9eHr DNHKo7ovPLRaDAJZdKMYdZM= X-Google-Smtp-Source: ABdhPJwef9VnxevTutof/OWjXxMen8nqP316VSHb8lndoYqWe0y1ALBADBIyXeEXdBPr/HgBfKduig== X-Received: by 2002:a17:902:bd95:: with SMTP id q21mr7959305pls.238.1590738074446; Fri, 29 May 2020 00:41:14 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id e26sm6189878pgl.27.2020.05.29.00.41.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 May 2020 00:41:12 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 10D65418C0; Fri, 29 May 2020 07:41:10 +0000 (UTC) From: Luis Chamberlain To: keescook@chromium.org, yzaikin@google.com, nixiaoming@huawei.com, ebiederm@xmission.com, axboe@kernel.dk, clemens@ladisch.de, arnd@arndb.de, gregkh@linuxfoundation.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, daniel@ffwll.ch, benh@kernel.crashing.org, rdna@fb.com, viro@zeniv.linux.org.uk, mark@fasheh.com, jlbec@evilplan.org, joseph.qi@linux.alibaba.com, vbabka@suse.cz, sfr@canb.auug.org.au, jack@suse.cz, amir73il@gmail.com, rafael@kernel.org, tytso@mit.edu Date: Fri, 29 May 2020 07:40:56 +0000 Message-Id: <20200529074108.16928-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.23.0.rc1 In-Reply-To: <20200529074108.16928-1-mcgrof@kernel.org> References: <20200529074108.16928-1-mcgrof@kernel.org> MIME-Version: 1.0 X-PDR: PASS X-Source-IP: 209.85.214.195 X-ServerName: mail-pl1-f195.google.com X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 redirect=_spf.google.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 phishscore=0 clxscore=186 bulkscore=0 priorityscore=70 adultscore=0 mlxlogscore=473 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 impostorscore=0 lowpriorityscore=0 cotscore=-2147483648 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290059 X-Spam: Clean X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=725 adultscore=0 suspectscore=0 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290060 X-Mailman-Approved-At: Fri, 29 May 2020 00:55:28 -0700 Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, julia.lawall@lip6.fr, Luis Chamberlain , linuxppc-dev@lists.ozlabs.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 01/13] sysctl: add new register_sysctl_subdir() helper X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290062 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9635 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 cotscore=-2147483648 mlxscore=0 bulkscore=0 priorityscore=1501 phishscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005290062 Often enough all we need to do is create a subdirectory so that we can stuff sysctls underneath it. However, *if* that directory was already created early on the boot sequence we really have no need to use the full boiler plate code for it, we can just use local variables to help us guide sysctl to place the new leaf files. So use a helper to do precisely this. Signed-off-by: Luis Chamberlain --- include/linux/sysctl.h | 11 +++++++++++ kernel/sysctl.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h index ddaa06ddd852..58bc978d4f03 100644 --- a/include/linux/sysctl.h +++ b/include/linux/sysctl.h @@ -205,6 +205,9 @@ void unregister_sysctl_table(struct ctl_table_header * table); extern int sysctl_init(void); extern void register_sysctl_init(const char *path, struct ctl_table *table, const char *table_name); +extern struct ctl_table_header *register_sysctl_subdir(const char *base, + const char *subdir, + struct ctl_table *table); void do_sysctl_args(void); extern int pwrsw_enabled; @@ -223,6 +226,14 @@ static inline struct ctl_table_header *register_sysctl_table(struct ctl_table * return NULL; } +static +inline struct ctl_table_header *register_sysctl_subdir(const char *base, + const char *subdir, + struct ctl_table *table) +{ + return NULL; +} + static inline struct ctl_table_header *register_sysctl_paths( const struct ctl_path *path, struct ctl_table *table) { diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 008ac0576ae5..04ff032f2863 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -3195,6 +3195,43 @@ void __init register_sysctl_init(const char *path, struct ctl_table *table, } kmemleak_not_leak(hdr); } + +struct ctl_table_header *register_sysctl_subdir(const char *base, + const char *subdir, + struct ctl_table *table) +{ + struct ctl_table_header *hdr = NULL; + struct ctl_table subdir_table[] = { + { + .procname = subdir, + .mode = 0555, + .child = table, + }, + { } + }; + struct ctl_table base_table[] = { + { + .procname = base, + .mode = 0555, + .child = subdir_table, + }, + { } + }; + + if (!table->procname) + goto out; + + hdr = register_sysctl_table(base_table); + if (unlikely(!hdr)) { + pr_err("failed when creating subdirectory sysctl %s/%s/%s\n", + base, subdir, table->procname); + goto out; + } + kmemleak_not_leak(hdr); +out: + return hdr; +} +EXPORT_SYMBOL_GPL(register_sysctl_subdir); #endif /* CONFIG_SYSCTL */ /* * No sense putting this after each symbol definition, twice,