diff mbox

[v4,35/37] configfs: Introduce config_item_get_unless_zero()

Message ID 20170208222507.25715-36-bart.vanassche@sandisk.com (mailing list archive)
State Superseded
Headers show

Commit Message

Bart Van Assche Feb. 8, 2017, 10:25 p.m. UTC
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
---
 fs/configfs/item.c       | 6 ++++++
 include/linux/configfs.h | 1 +
 2 files changed, 7 insertions(+)

Comments

Nicholas A. Bellinger Feb. 9, 2017, 11:30 a.m. UTC | #1
On Wed, 2017-02-08 at 14:25 -0800, Bart Van Assche wrote:
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Christoph Hellwig <hch@lst.de>
> ---
>  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 {

A reasonable idea, but this needs review from other configfs folks.

Dropping for now.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bart Van Assche Feb. 9, 2017, 5:10 p.m. UTC | #2
On Thu, 2017-02-09 at 03:30 -0800, Nicholas A. Bellinger wrote:
> A reasonable idea, but this needs review from other configfs folks.

Christoph, can you have a look at this patch?

Thanks,

Bart.--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bryant G. Ly Feb. 23, 2017, 5:49 p.m. UTC | #3
> On Wed, 2017-02-08 at 14:25 -0800, Bart Van Assche wrote:
>> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
>> Cc: Christoph Hellwig <hch@lst.de>
>> ---
>>   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 {
> A reasonable idea, but this needs review from other configfs folks.
>
> Dropping for now.
>
> --
> To unsubscribe from this list: send the line "unsubscribe target-devel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
I actually have been testing this patch since we see some hanging in regards to configfs, and so far haven't hit any problems.

We've been running this since this was posted and so far it looks good. So if configfs folks are okay with it, I'd like this patch and target: Introduce target_get_device() and target_put_device() accepted.


-Bryant

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nicholas A. Bellinger March 2, 2017, 7:14 a.m. UTC | #4
Hi Bryant,

On Thu, 2017-02-23 at 11:49 -0600, Bryant G. Ly wrote:
> > On Wed, 2017-02-08 at 14:25 -0800, Bart Van Assche wrote:
> >> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> >> Cc: Christoph Hellwig <hch@lst.de>
> >> ---
> >>   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 {
> > A reasonable idea, but this needs review from other configfs folks.
> >
> > Dropping for now.
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe target-devel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> I actually have been testing this patch since we see some hanging in
> regards to configfs, and so far haven't hit any problems.
> 
> We've been running this since this was posted and so far it looks
> good. So if configfs folks are okay with it, I'd like this patch and
> target: Introduce target_get_device() and target_put_device()
> accepted.
> 

Btw, this particular patch is a prerequisite for avoiding calling
target_depend_item() -> configfs_depend_item() while holding
g_device_mutex in target_core_xcopy.c:target_xcopy_locate_se_dev_e4().

Namely, it only effects EXTENDED_COPY operation when looking up a remote
se_device by EVPD 0x83 device identifiers, and is not related to other
configfs stuff.

If you've got a particular configfs issue, please feel free to post it
to the list and I'll comment in a separate thread.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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 {