All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@sandisk.com>
To: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: <target-devel@vger.kernel.org>,
	Bart Van Assche <bart.vanassche@sandisk.com>,
	Joel Becker <jlbec@evilplan.org>,
	"Christoph Hellwig" <hch@lst.de>, <linux-fsdevel@vger.kernel.org>
Subject: [PATCH 09/33] configfs: Introduce config_item_get_unless_zero()
Date: Tue, 23 May 2017 16:48:30 -0700	[thread overview]
Message-ID: <20170523234854.21452-10-bart.vanassche@sandisk.com> (raw)
In-Reply-To: <20170523234854.21452-1-bart.vanassche@sandisk.com>

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

  parent reply	other threads:[~2017-05-23 23:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20170523234854.21452-1-bart.vanassche@sandisk.com>
2017-05-23 23:48 ` [PATCH 04/33] target: Fix BYTCHK=0 handling for VERIFY and WRITE AND VERIFY commands Bart Van Assche
2017-06-02  4:15   ` Nicholas A. Bellinger
2017-06-02 16:52     ` Bart Van Assche
2017-06-03  5:32       ` Nicholas A. Bellinger
2017-06-03  5:37         ` Nicholas A. Bellinger
2017-06-05 16:49         ` Bart Van Assche
2017-06-05 22:32           ` David Butterfield
2017-06-05 23:17             ` Bart Van Assche
2017-05-23 23:48 ` [PATCH 08/33] target: Fix a deadlock between the XCOPY code and iSCSI session shutdown Bart Van Assche
2017-06-02  4:35   ` Nicholas A. Bellinger
2017-05-23 23:48 ` Bart Van Assche [this message]
2017-05-28  9:33   ` [PATCH 09/33] configfs: Introduce config_item_get_unless_zero() Christoph Hellwig
2017-05-28 16:37     ` Bart Van Assche
2017-06-13 23:22   ` Mike Christie
2017-05-23 23:48 ` [PATCH 15/33] xen/scsiback: Fix a use-after-free Bart Van Assche
2017-05-23 23:48 ` [PATCH 16/33] xen/scsiback: Replace a waitqueue and a counter by a completion Bart Van Assche
2017-05-23 23:48 ` [PATCH 17/33] xen/scsiback: Make TMF processing slightly faster Bart Van Assche
2017-05-23 23:48 ` [PATCH 25/33] target/iscsi: Avoid overflowing the receive buffer Bart Van Assche
2017-05-23 23:48 ` [PATCH 29/33] target/iscsi: Simplify timer manipulation code Bart Van Assche
     [not found] ` <20170523234854.21452-16-bart.vanassche@sandisk.com>
2017-05-26  9:57   ` [PATCH 15/33] xen/scsiback: Fix a use-after-free Juergen Gross
2017-06-03  5:40   ` Nicholas A. Bellinger
     [not found]   ` <1496468455.27407.305.camel@haakon3.risingtidesystems.com>
2017-06-03  7:04     ` Nicholas A. Bellinger
     [not found]     ` <1496473471.27407.317.camel@haakon3.risingtidesystems.com>
2017-06-03  7:06       ` Juergen Gross
     [not found] ` <20170523234854.21452-17-bart.vanassche@sandisk.com>
2017-05-26 10:13   ` [PATCH 16/33] xen/scsiback: Replace a waitqueue and a counter by a completion Juergen Gross
2017-06-03  5:41   ` Nicholas A. Bellinger
     [not found] ` <20170523234854.21452-18-bart.vanassche@sandisk.com>
2017-05-26 10:18   ` [PATCH 17/33] xen/scsiback: Make TMF processing slightly faster Juergen Gross
2017-06-03  5:41   ` Nicholas A. Bellinger

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=20170523234854.21452-10-bart.vanassche@sandisk.com \
    --to=bart.vanassche@sandisk.com \
    --cc=hch@lst.de \
    --cc=jlbec@evilplan.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.