From: Damien Le Moal via Ocfs2-devel <ocfs2-devel@oss.oracle.com>
To: Yangtao Li <frank.li@vivo.com>,
clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com,
jefflexu@linux.alibaba.com, jaegeuk@kernel.org,
trond.myklebust@hammerspace.com, anna@kernel.org,
konishi.ryusuke@gmail.com, mark@fasheh.com, jlbec@evilplan.org,
joseph.qi@linux.alibaba.com, richard@nod.at, djwong@kernel.org,
naohiro.aota@wdc.com, jth@kernel.org, gregkh@linuxfoundation.org,
rafael@kernel.org
Cc: linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
linux-xfs@vger.kernel.org, linux-mtd@lists.infradead.org,
ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org,
linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org
Subject: Re: [Ocfs2-devel] [RESEND, PATCH v2 01/10] kobject: introduce kobject_del_and_put()
Date: Tue, 21 Mar 2023 06:38:58 +0900 [thread overview]
Message-ID: <2229e074-d78e-3bd5-bf06-a53e9ad57d02@opensource.wdc.com> (raw)
In-Reply-To: <20230320184657.56198-1-frank.li@vivo.com>
On 3/21/23 03:46, Yangtao Li wrote:
> There are plenty of using kobject_del() and kobject_put() together
> in the kernel tree. This patch wraps these two calls in a single helper.
>
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
> v2:
> -add kobject_del_and_put() users
> resend patchset to gregkh, Rafael and Damien
> include/linux/kobject.h | 1 +
> lib/kobject.c | 17 +++++++++++++++--
> 2 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/kobject.h b/include/linux/kobject.h
> index bdab370a24f4..782d4bd119f8 100644
> --- a/include/linux/kobject.h
> +++ b/include/linux/kobject.h
> @@ -111,6 +111,7 @@ extern struct kobject *kobject_get(struct kobject *kobj);
> extern struct kobject * __must_check kobject_get_unless_zero(
> struct kobject *kobj);
> extern void kobject_put(struct kobject *kobj);
> +extern void kobject_del_and_put(struct kobject *kobj);
>
> extern const void *kobject_namespace(const struct kobject *kobj);
> extern void kobject_get_ownership(const struct kobject *kobj,
> diff --git a/lib/kobject.c b/lib/kobject.c
> index 6e2f0bee3560..8c0293e37214 100644
> --- a/lib/kobject.c
> +++ b/lib/kobject.c
> @@ -731,6 +731,20 @@ void kobject_put(struct kobject *kobj)
> }
> EXPORT_SYMBOL(kobject_put);
>
> +/**
> + * kobject_del_and_put() - Delete kobject.
> + * @kobj: object.
> + *
> + * Unlink kobject from hierarchy and decrement the refcount.
> + * If refcount is 0, call kobject_cleanup().
> + */
> +void kobject_del_and_put(struct kobject *kobj)
> +{
> + kobject_del(kobj);
> + kobject_put(kobj);
> +}
> +EXPORT_SYMBOL_GPL(kobject_del_and_put);
Why not make this an inline helper defined in include/linux/kobject.h instead of
a new symbol ?
> +
> static void dynamic_kobj_release(struct kobject *kobj)
> {
> pr_debug("kobject: (%p): %s\n", kobj, __func__);
> @@ -874,8 +888,7 @@ void kset_unregister(struct kset *k)
> {
> if (!k)
> return;
> - kobject_del(&k->kobj);
> - kobject_put(&k->kobj);
> + kobject_del_and_put(&k->kobj);
> }
> EXPORT_SYMBOL(kset_unregister);
>
--
Damien Le Moal
Western Digital Research
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel@oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
prev parent reply other threads:[~2023-03-22 17:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 18:46 [Ocfs2-devel] [RESEND, PATCH v2 01/10] kobject: introduce kobject_del_and_put() Yangtao Li via Ocfs2-devel
2023-03-20 21:38 ` Damien Le Moal via Ocfs2-devel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2229e074-d78e-3bd5-bf06-a53e9ad57d02@opensource.wdc.com \
--to=ocfs2-devel@oss.oracle.com \
--cc=anna@kernel.org \
--cc=chao@kernel.org \
--cc=clm@fb.com \
--cc=damien.lemoal@opensource.wdc.com \
--cc=djwong@kernel.org \
--cc=dsterba@suse.com \
--cc=frank.li@vivo.com \
--cc=gregkh@linuxfoundation.org \
--cc=huyue2@coolpad.com \
--cc=jaegeuk@kernel.org \
--cc=jefflexu@linux.alibaba.com \
--cc=jlbec@evilplan.org \
--cc=josef@toxicpanda.com \
--cc=joseph.qi@linux.alibaba.com \
--cc=jth@kernel.org \
--cc=konishi.ryusuke@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-nilfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=naohiro.aota@wdc.com \
--cc=rafael@kernel.org \
--cc=richard@nod.at \
--cc=trond.myklebust@hammerspace.com \
--cc=xiang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).