From patchwork Mon Nov 12 09:56:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Valente X-Patchwork-Id: 150800 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp2947710ljp; Mon, 12 Nov 2018 01:57:10 -0800 (PST) X-Google-Smtp-Source: AJdET5dI+QBZTL3qpqr1Dj6kAocrUU2w2Qx9HguWTFvoa5wtMxvmbrBhP1/A3SSLrazHIN8iwV5I X-Received: by 2002:a17:902:ab81:: with SMTP id f1-v6mr282971plr.103.1542016630013; Mon, 12 Nov 2018 01:57:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542016630; cv=none; d=google.com; s=arc-20160816; b=bk7LHeaQdbkDjTpHWMsR7yaxfwikYNPLAfKrhySReNXj5un6bqNmptKqWtk4S1Ylx1 H+I7kKM92pJNe8eeaCEiId9jhTlBggofqkeanuw35inobPnjvo41YzGdkSukig9AoMPe 29ifUPeCW7PQf+ZqJt9wSTXuTJMWrvF/ROGKgZ/AxYbDj9LgRyZTSwVLCP8AoxM4A+HB q6Ktjnhc6YWCO5WOVYFPGgQqWDNs/RSiFxK0Xg33xnWL2TkJaWtht8J9+6gqnwZF1oZ4 xWiwQTG7HC8TbbrL38x10bIrgJAz27+5IqZHvqpx5GhhPh+QvmVfEEfoNIDOLbYBeBAa 9UBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gEkvf3D0ybtQ1XCiNuNOR20e0/KEmaDMFTtp87FuqbE=; b=cSh/ajqZzKe9fp8zO38STfDNERqek832xtpbod3tEnL42x6OQs4vV411/46Ua/PtmC QRNigyyAZ6k48/opt6AIQcobcGSFD8KeRZWZV1b+t/8DC5Gyqglkto4NxNMsNRJO8EyX byxwEJJdbfMmWBH8SYIFN+nM/rOE6WXwxHoqICFq0aThU68Uvj/iwZ/vkrmW+bXgAECU 7s7J2tXCjkyKCiFX6ReOPYikqMdE5RLLQJP+UVz+js2/wcbs8CVgOVrDm0QA8vuivvbu bWT7j3KlZj6B69NrLgOyjxIOIBhpijz1e8CvgGpaFxeYqfl1aHm6+wZuB5XX4xwpbUZq 5KbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N8KkHvWq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13-v6si16137413pgj.457.2018.11.12.01.57.09; Mon, 12 Nov 2018 01:57:09 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=N8KkHvWq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728436AbeKLTtf (ORCPT + 32 others); Mon, 12 Nov 2018 14:49:35 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:53820 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728268AbeKLTte (ORCPT ); Mon, 12 Nov 2018 14:49:34 -0500 Received: by mail-wm1-f65.google.com with SMTP id f10-v6so7787163wme.3 for ; Mon, 12 Nov 2018 01:57:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gEkvf3D0ybtQ1XCiNuNOR20e0/KEmaDMFTtp87FuqbE=; b=N8KkHvWqCG3FPBQKMMKSv7Pg/NLzZZA7xMvcJW6U01Wj0GNYTuJeCcya4ODW4IlfDY bjeINPfviBlUjWGw0A/F1Z2j5xFDixkEn+Wq8pjVDa2f0IyCUhwOwJnWnNFIaWBeVVTq d85CwbZ1TDnYV7195SRPVFTFCEtIMsDAzsBRA= 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; bh=gEkvf3D0ybtQ1XCiNuNOR20e0/KEmaDMFTtp87FuqbE=; b=lD60VaFG6xAAtb1WpH992IKiEtaxXhB9pmOzX6udt4FEG1adb7mkbaugKMn7zcczpv 1oj1pB95sHzEP2/W1+xhAVRSORgZonttpFhYsYFsDL7ZS9RMVpLn9YWYIWxiOH/0uxiV DoN+JAeN69d9SKZf9X5KxOpuAMTXagl3tvTRPp/8Eqw2Qewfd6AHlk8idFCZ3MRrmhY+ x1QONpqO3vVM8K/Rx0yKIHXX9L004ffF/ghYVJHJcH9Tduq0xAWSB2GvzGkK5iMsdsMW 4XAMAfFxCX3W2pHwlVj9GWk3cUODet0rGQjbY1b5oX+mA82sFQaiShU6VhPc/8sCXu5L Thbw== X-Gm-Message-State: AGRZ1gIbvnyi+8EclyIZBR4wZEEGpJCVa0WVQxe5VtSqppbxJWuDznp6 jsM2Xffd/ZjWFbz6hheJNzES8w== X-Received: by 2002:a1c:3954:: with SMTP id g81-v6mr6728831wma.139.1542016624983; Mon, 12 Nov 2018 01:57:04 -0800 (PST) Received: from localhost.localdomain ([93.68.220.21]) by smtp.gmail.com with ESMTPSA id r14-v6sm21273089wro.8.2018.11.12.01.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 01:57:04 -0800 (PST) From: Paolo Valente To: Jens Axboe , Greg Kroah-Hartman , Tejun Heo , Li Zefan , Angelo Ruocco , Dennis Zhou , Josef Bacik , Liu Bo , Bart Van Assche , Johannes Weiner Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, ulf.hansson@linaro.org, linus.walleij@linaro.org, broonie@kernel.org, bfq-iosched@googlegroups.com, oleksandr@natalenko.name, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, Jonathan Corbet , Paolo Valente Subject: [PATCH 01/12] kernfs: add function to find kernfs_node without increasing ref counter Date: Mon, 12 Nov 2018 10:56:21 +0100 Message-Id: <20181112095632.69114-2-paolo.valente@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20181112095632.69114-1-paolo.valente@linaro.org> References: <20181112095632.69114-1-paolo.valente@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Angelo Ruocco The kernfs pseudo file system doesn't export any function to only find a node by name, without also getting a reference on it. But in some cases it is useful to just locate a kernfs node, while using it or not depends on some other condition. This commit adds a function to just look for a node, without getting a reference on it. Signed-off-by: Angelo Ruocco Signed-off-by: Paolo Valente --- fs/kernfs/dir.c | 13 +++++++++++++ include/linux/kernfs.h | 7 +++++++ 2 files changed, 20 insertions(+) -- 2.16.1 diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 4ca0b5c18192..0003c665869d 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -892,6 +892,19 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, return parent; } +struct kernfs_node *kernfs_find(struct kernfs_node *parent, + const unsigned char *name) +{ + struct kernfs_node *kn; + + mutex_lock(&kernfs_mutex); + kn = kernfs_find_ns(parent, name, NULL); + mutex_unlock(&kernfs_mutex); + + return kn; +} +EXPORT_SYMBOL_GPL(kernfs_find); + /** * kernfs_find_and_get_ns - find and get kernfs_node with the given name * @parent: kernfs_node to search under diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 5b36b1287a5a..26e69d285964 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h @@ -309,6 +309,8 @@ void pr_cont_kernfs_path(struct kernfs_node *kn); struct kernfs_node *kernfs_get_parent(struct kernfs_node *kn); struct kernfs_node *kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name, const void *ns); +struct kernfs_node *kernfs_find(struct kernfs_node *parent, + const unsigned char *name); struct kernfs_node *kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path, const void *ns); void kernfs_get(struct kernfs_node *kn); @@ -391,6 +393,11 @@ static inline struct kernfs_node * kernfs_find_and_get_ns(struct kernfs_node *parent, const char *name, const void *ns) { return NULL; } + +static inline struct kernfs_node * +kernfs_find(struct kernfs_node *parent, const char *name) +{ return NULL; } + static inline struct kernfs_node * kernfs_walk_and_get_ns(struct kernfs_node *parent, const char *path, const void *ns)