Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1584321pxf; Fri, 12 Mar 2021 13:22:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxd0K4zrts349X9MbokD8CnRU8Y1NS1e4jtFezVwU6NAeE2fwpuTAzfr6yH3swjCADb15yb X-Received: by 2002:a17:906:73c2:: with SMTP id n2mr10745190ejl.224.1615584154288; Fri, 12 Mar 2021 13:22:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615584154; cv=none; d=google.com; s=arc-20160816; b=ICsDEuX0tA6DRTJbNhwKq3DuQjhB1UTFyQYeBxi/K1X5bhSksyKkqpGloQY+wda3ft s98qtu7EDxZcmfjQ9zfVCIfBMkG+4zKjg9dwz8dtl/DndAKOuQBv81vtQKHDdJOvQR61 vKdF6YltX6u1MmNjNtnIUDeVKrp7s64keiYeBZx0eWEMgmLhPOin/ozdn+6i3kCOUwKl VqK1ZFHMXuIyExjACfqF/L/3iGBldAFJzsP8X7jJptQqciIF32LRbg1ndRcNmfParPr4 HHaHJ4YL26Fkid/DPkgnt54Pre0ZswYb55xCh2PJhQn+nhc/pT1m5gpYqRq4DCrDSMcz 9KJQ== 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:sender :dkim-signature; bh=RtzjEJB5ms/fI+WQZNcMRSa9eOpSN3/2cnTyDn6MbtE=; b=Dcd3pZF16EvC5OW1AGrI+WOkUiZ46EoETEy56zfN93cR9Iz5kIbQ6BbITVMrKiPVm0 xa1FXLQTABuZyadFog13pJCG2JU5GKOj1IB1PI9MN0vCcWEyuFm1ja+gX/U8a/BBkRsr zeedhf1qzE1pc1X8IN9FEcSbSvToCFfLSZ8I4OPANLucqRTFV8clWYlCs75t1hqJ/p/Y rP5baqABOr10SZbqAE5doHNvPmxbJWVp4Y1o0XEpK69Pn7jWKffVQWF5G2EOxdzsA3tm uholG3nRsY1oVooVjmswiVab78SDD0dxtZxwSUoYBmBLml1KoxNxA5nT5619Tb8/TUea o5/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GuhMspjY; 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 t12si4758870ejc.21.2021.03.12.13.21.47; Fri, 12 Mar 2021 13:22:34 -0800 (PST) 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=GuhMspjY; 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 S235195AbhCLVSz (ORCPT + 99 others); Fri, 12 Mar 2021 16:18:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235194AbhCLVSc (ORCPT ); Fri, 12 Mar 2021 16:18:32 -0500 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B0AFC061574 for ; Fri, 12 Mar 2021 13:18:31 -0800 (PST) Received: by mail-qk1-x733.google.com with SMTP id l4so25867389qkl.0 for ; Fri, 12 Mar 2021 13:18:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RtzjEJB5ms/fI+WQZNcMRSa9eOpSN3/2cnTyDn6MbtE=; b=GuhMspjYbQ7uwOjDBLSA9IHXS/hjOWvlH4/ZLcWVgFzxJ5l1Kcvnz1CArZTqPvsvSj 7Dv0+Its/1WcNBzSKpZxXs8UpOLGFfsou9MDSMMsBJUgpoFng/ze3NlhCAHcQlzDqdI/ wy+34IC6uQCRV9j8tRWJW/PenZ9qBut1ME2ZZvdA8e1Ped/ZlAl5IfrrvI6V1rRisqlI MABSHEEqLDeaJ1oj5oLpIeCX6vWRutE+pkABrWR0q2g43wv4bKh3bqgbyHFGDmLv199n KiUp+YHWFvkNpTxra6t8lEeRloBjZoKZBuoFFFhiE1JPfJOXL2DsAMvk5lfEsPZoQ1Og AzAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=RtzjEJB5ms/fI+WQZNcMRSa9eOpSN3/2cnTyDn6MbtE=; b=gW2vLXAoFmhLuGjVEuJI7gPTWs+3l4Cob6XZRDbC3pVTgQPaiyvKzvwWZQvlwRAmJQ uSXVoQulK5TRWC91H4Okj0LI0V82NHjLSJQMy4J37CO/wfWKNuh7ekUy4Burb8dR8xvk BKtTQDWpI3v4Zs0nHKbUFjOfH2NBdULFgYEnJlPUBruEdMRjuzKGdTwjkQzMUgl7j1av HdWRHUvINH25PVXRdei1MnbLc52POPOqHTHHV7YFyBKJ7dFpInhc36bVfK0ZEzJVh5i1 nYFcAHX4uAi3ZsPDTGusn+wag76ZEtfuOn/7ZfJ9FE27hJAMICIATk08/sd7yCxjIVhx G0Sw== X-Gm-Message-State: AOAM533zYG6fnYeNgR44bZAW7UuPLC/1P3BIPOZsbKCFyNTiAP8+fxp5 3098lS67B2Lo0gnE5UinrUGnf8rZtV7oCA== X-Received: by 2002:a37:2e46:: with SMTP id u67mr14947053qkh.488.1615583910304; Fri, 12 Mar 2021 13:18:30 -0800 (PST) Received: from gouda.nowheycreamery.com (c-68-32-74-190.hsd1.mi.comcast.net. [68.32.74.190]) by smtp.gmail.com with ESMTPSA id d24sm5177490qko.54.2021.03.12.13.18.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 13:18:30 -0800 (PST) Sender: Anna Schumaker From: schumaker.anna@gmail.com X-Google-Original-From: Anna.Schumaker@Netapp.com To: linux-nfs@vger.kernel.org Cc: Anna.Schumaker@Netapp.com Subject: [PATCH v3 2/5] sunrpc: Create a client/ subdirectory in the sunrpc sysfs Date: Fri, 12 Mar 2021 16:18:23 -0500 Message-Id: <20210312211826.360959-3-Anna.Schumaker@Netapp.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210312211826.360959-1-Anna.Schumaker@Netapp.com> References: <20210312211826.360959-1-Anna.Schumaker@Netapp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Anna Schumaker For network namespace separation. Signed-off-by: Anna Schumaker --- v3: Rename net/ directory to client/ Rename rpc_client_kobj to rpc_sunrpc_client_kobj s/netns/sysfs/ --- net/sunrpc/sysfs.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c index 27eda180ac5e..350b2b1628e7 100644 --- a/net/sunrpc/sysfs.c +++ b/net/sunrpc/sysfs.c @@ -2,19 +2,60 @@ /* * 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.29.2