* [PATCH 09/33] configfs: Introduce config_item_get_unless_zero()
[not found] <20170523234854.21452-1-bart.vanassche@sandisk.com>
@ 2017-05-23 23:48 ` Bart Van Assche
2017-05-28 9:33 ` Christoph Hellwig
2017-06-13 23:22 ` Mike Christie
0 siblings, 2 replies; 4+ messages in thread
From: Bart Van Assche @ 2017-05-23 23:48 UTC (permalink / raw)
To: Nicholas Bellinger
Cc: target-devel, Bart Van Assche, Joel Becker, Christoph Hellwig,
linux-fsdevel
This new function is needed to fix a deadlock in the SCSI target
XCOPY implementation.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-fsdevel@vger.kernel.org
---
fs/configfs/item.c | 6 ++++++
include/linux/configfs.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/fs/configfs/item.c b/fs/configfs/item.c
index 8b2a994042dd..e3501b9bbb60 100644
--- a/fs/configfs/item.c
+++ b/fs/configfs/item.c
@@ -138,6 +138,12 @@ struct config_item *config_item_get(struct config_item *item)
}
EXPORT_SYMBOL(config_item_get);
+struct config_item *config_item_get_unless_zero(struct config_item *item)
+{
+ return item && kref_get_unless_zero(&item->ci_kref) ? item : NULL;
+}
+EXPORT_SYMBOL(config_item_get_unless_zero);
+
static void config_item_cleanup(struct config_item *item)
{
struct config_item_type *t = item->ci_type;
diff --git a/include/linux/configfs.h b/include/linux/configfs.h
index 2319b8c108e8..406e16dabc28 100644
--- a/include/linux/configfs.h
+++ b/include/linux/configfs.h
@@ -75,6 +75,7 @@ extern void config_item_init_type_name(struct config_item *item,
struct config_item_type *type);
extern struct config_item * config_item_get(struct config_item *);
+extern struct config_item * config_item_get_unless_zero(struct config_item *);
extern void config_item_put(struct config_item *);
struct config_item_type {
--
2.12.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 09/33] configfs: Introduce config_item_get_unless_zero()
2017-05-23 23:48 ` [PATCH 09/33] configfs: Introduce config_item_get_unless_zero() Bart Van Assche
@ 2017-05-28 9:33 ` Christoph Hellwig
2017-05-28 16:37 ` Bart Van Assche
2017-06-13 23:22 ` Mike Christie
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2017-05-28 9:33 UTC (permalink / raw)
To: Bart Van Assche
Cc: Nicholas Bellinger, target-devel, Joel Becker, Christoph Hellwig,
linux-fsdevel
> +struct config_item *config_item_get_unless_zero(struct config_item *item)
> +{
> + return item && kref_get_unless_zero(&item->ci_kref) ? item : NULL;
> +}
> +EXPORT_SYMBOL(config_item_get_unless_zero);
Style nipick, I'd prefer something like:
if (item && !kref_get_unless_zero(&item->ci_kref))
item = NULL;
return item;
Otherwise this looks fine to me:
Reviewed-by: Christoph Hellwig <hch@lst.de>
or should I pick it up through the configfs tree?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 09/33] configfs: Introduce config_item_get_unless_zero()
2017-05-28 9:33 ` Christoph Hellwig
@ 2017-05-28 16:37 ` Bart Van Assche
0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2017-05-28 16:37 UTC (permalink / raw)
To: hch@infradead.org
Cc: hch@lst.de, jlbec@evilplan.org, target-devel@vger.kernel.org,
nab@linux-iscsi.org, linux-fsdevel@vger.kernel.org
On Sun, 2017-05-28 at 02:33 -0700, Christoph Hellwig wrote:
> > +struct config_item *config_item_get_unless_zero(struct config_item *item)
> > +{
> > + return item && kref_get_unless_zero(&item->ci_kref) ? item : NULL;
> > +}
> > +EXPORT_SYMBOL(config_item_get_unless_zero);
>
> Style nipick, I'd prefer something like:
>
> if (item && !kref_get_unless_zero(&item->ci_kref))
> item = NULL;
> return item;
>
> Otherwise this looks fine to me:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
>
> or should I pick it up through the configfs tree?
Hello Christoph,
If you could pick up this patch (any style) through the configfs tree that would
be great.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 09/33] configfs: Introduce config_item_get_unless_zero()
2017-05-23 23:48 ` [PATCH 09/33] configfs: Introduce config_item_get_unless_zero() Bart Van Assche
2017-05-28 9:33 ` Christoph Hellwig
@ 2017-06-13 23:22 ` Mike Christie
1 sibling, 0 replies; 4+ messages in thread
From: Mike Christie @ 2017-06-13 23:22 UTC (permalink / raw)
To: Bart Van Assche, Nicholas Bellinger
Cc: target-devel, Joel Becker, Christoph Hellwig, linux-fsdevel
On 05/23/2017 06:48 PM, Bart Van Assche wrote:
> This new function is needed to fix a deadlock in the SCSI target
> XCOPY implementation.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Joel Becker <jlbec@evilplan.org>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-fsdevel@vger.kernel.org
Looks ok and test by me.
Reviewed-by: Mike Christie <mchristi@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-06-13 23:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20170523234854.21452-1-bart.vanassche@sandisk.com>
2017-05-23 23:48 ` [PATCH 09/33] configfs: Introduce config_item_get_unless_zero() Bart Van Assche
2017-05-28 9:33 ` Christoph Hellwig
2017-05-28 16:37 ` Bart Van Assche
2017-06-13 23:22 ` Mike Christie
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 NNTP newsgroup(s).