Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4385982pxj; Tue, 8 Jun 2021 13:02:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfQgcuenzcyHPOfubmxjWRhS7ybg+mcn0wEJ+Gd368tfsBnFKWan1fH2cSgBckKNwaX8Zk X-Received: by 2002:a17:906:530e:: with SMTP id h14mr25267927ejo.165.1623182540360; Tue, 08 Jun 2021 13:02:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623182540; cv=none; d=google.com; s=arc-20160816; b=lf/BT+wsMm3dBomH3grU8WkOFMf75ldLwxFVnLF6cZkkEJoj1gDimLfyJL8kTh9wnq YZyWVw0ALsN+u08OLF89MCOAJHjy6VY7pZHY1vleIPFtnUuz1OUwDEyM3oagMiuFzvQ9 N31mlPDTc74ucnD2+u9pYnchVRqagLR6x3ELFJFcprFq+8aKEO92Hfs+R50WP2SkTn05 1N+BzVgg7okI02WV4G60L6SVswlHE/Zp4haLvp4CGQ+uGNz5oLulc6QBI50zZdhwiOzH EiURO1dWX+bDSik9mzl+pvqEwhn3IXieiUxUBQKN1ZOIaG2xzyDxLuzBlRfTveawtyGj DgpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ujEDos81NUbHnHXtpykY5JrCoGurJBkkkPFV1HlWdwc=; b=HVP4LRD2fowaS9rXa8PqeipdctZVYFKL/6OhX9zCjsttI+opnILSiK6JKMcYGvKvld o7EQW1wAnof/z0EsVsd9TmHO0QVCACK69m0uhCGhV0eJtPuUu4X4n8V7vpGWxqgf23RH a1lroOCrPk9HwonJwTI/Txj/C2/wJzSMOqhHhbH03LLw35tTJvmROqZyHNz0TarR8PsS kdEo/wOi1/Kf7ToLom4ybd05DmS4S3IG2O+u3toMcmBir65MuWp1SG+Fk8h8y/lYbGRz iUaQYyntEHkOyb+7/ny1rVMi8CHsN3OMH3QA/LI/jDSdtfX/nCGPSHktJu2uXdEn0Mnb yxsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nOgpzEGh; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t8si489538edi.510.2021.06.08.12.59.51; Tue, 08 Jun 2021 13:02:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nOgpzEGh; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234498AbhFHUBk (ORCPT + 99 others); Tue, 8 Jun 2021 16:01:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbhFHUBk (ORCPT ); Tue, 8 Jun 2021 16:01:40 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43A75C061789 for ; Tue, 8 Jun 2021 12:59:30 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id l7so16264397qtk.5 for ; Tue, 08 Jun 2021 12:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ujEDos81NUbHnHXtpykY5JrCoGurJBkkkPFV1HlWdwc=; b=nOgpzEGh6U3+xuM89PoENzYnpNXGq2wJEbAv5Ylk1xFaVGhZBn4mblhoQL2lFgN4n9 XOfQckW766jcwEbfJuZIQr5RkUHDMxoMb1DalmuJZD8fi9V5VRfs9a9JXgqX4JU3T+o+ stjX4uLWRXaZDhwS1Yc9WCzSj5uJRG4HxaeCHR/6JCa36aOg+UiCkwB3tpMmRhQThNZg fnXCOCfe44+zmxrEysHucl8Jwp6Fdx7n1qErpx57frrI1HwqvsI24yrQpw/lHis2K5Tn AQ4MSsEBVOr6NyX0IvKlhanwPbZ/mN/EDthDHJMYZdSVBZeHlTJUapbhBNF2HuZ4sCT0 AMvA== 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=ujEDos81NUbHnHXtpykY5JrCoGurJBkkkPFV1HlWdwc=; b=bRRy6ybLHAxp5/Z+YEwlG7bzRKiKjiw4jJ+18wxOAwEaotJ/EWN0161JKvHVegcMmm +woWAu2Q1wJRt6WLl4Jv/sPRUn81IVQe057WON+Vtzl2qD10JyHcqIn+CzuY8yLRlR1T h0ZhjFVgpw4H+fcolFn+i+UOYRgViMSKEUkKhAnyVkXRbCKBl5voxj4JVSUfqgrZyErC DaDoEjTnKo2UTG877QP90wTmE+xps03yA5mOyVi6/PRIakVjqYtC7bffneZLYVccexOd Zg++qgM4Wnb+tpNIKIJk9TyrK8FzYNQHAevGw3PEZnCH+fxJxUxONB8WeFH6EtlGj/uZ rniA== X-Gm-Message-State: AOAM532DuaeCS0KBxOGM/de3jnc3dj7ShZTRp3lyIAT6qgF7O+q0C7P5 kO/delE1/7IaKDC16mOTlc8= X-Received: by 2002:ac8:12c6:: with SMTP id b6mr22824258qtj.352.1623182369461; Tue, 08 Jun 2021 12:59:29 -0700 (PDT) Received: from kolga-mac-1.vpn.netapp.com (nat-216-240-30-25.netapp.com. [216.240.30.25]) by smtp.gmail.com with ESMTPSA id j127sm12952765qke.90.2021.06.08.12.59.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Jun 2021 12:59:27 -0700 (PDT) From: Olga Kornievskaia To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org Subject: [PATCH v10 02/13] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Date: Tue, 8 Jun 2021 15:59:11 -0400 Message-Id: <20210608195922.88655-3-olga.kornievskaia@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210608195922.88655-1-olga.kornievskaia@gmail.com> References: <20210608195922.88655-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Olga Kornievskaia For network namespace separation. Signed-off-by: Anna Schumaker Signed-off-by: Olga Kornievskaia --- net/sunrpc/sysfs.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 27eda180ac5e..fa03e2ef836a 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -2,19 +2,62 @@ /* * Copyright (c) 2020 Anna Schumaker */ +#include #include static struct kset *rpc_sunrpc_kset; +static struct kobject *rpc_sunrpc_client_kobj; + +static void rpc_sysfs_object_release(struct kobject *kobj) +{ + kfree(kobj); +} + +static const struct kobj_ns_type_operations * +rpc_sysfs_object_child_ns_type(struct kobject *kobj) +{ + return &net_ns_type_operations; +} + +static struct kobj_type rpc_sysfs_object_type = { + .release = rpc_sysfs_object_release, + .sysfs_ops = &kobj_sysfs_ops, + .child_ns_type = rpc_sysfs_object_child_ns_type, +}; + +static struct kobject *rpc_sysfs_object_alloc(const char *name, + struct kset *kset, + struct kobject *parent) +{ + struct kobject *kobj; + + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (kobj) { + kobj->kset = kset; + if (kobject_init_and_add(kobj, &rpc_sysfs_object_type, + parent, "%s", name) == 0) + return kobj; + kobject_put(kobj); + } + return NULL; +} int rpc_sysfs_init(void) { rpc_sunrpc_kset = kset_create_and_add("sunrpc", NULL, kernel_kobj); if (!rpc_sunrpc_kset) return -ENOMEM; + rpc_sunrpc_client_kobj = rpc_sysfs_object_alloc("client", rpc_sunrpc_kset, NULL); + if (!rpc_sunrpc_client_kobj) { + kset_unregister(rpc_sunrpc_kset); + rpc_sunrpc_client_kobj = NULL; + return -ENOMEM; + } return 0; } void rpc_sysfs_exit(void) { + kobject_put(rpc_sunrpc_client_kobj); kset_unregister(rpc_sunrpc_kset); } -- 2.27.0