Re: [PATCH 8/19]: SCST SYSFS interface implementation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joe Eykholt, on 11/10/2010 11:29 PM wrote:
>> Thanks for sharing your thoughts with us. But the question isn't about
>> if it's possible to implement what we need locklessly. The question is
>> in two approaches how to synchronously delete objects with entries on SYSFS:
>>
>> 1. struct object_x {
>> 	...
>> 	struct kobject kobj;
>> 	struct completion *release_completion;
>> };
>>
>> static void x_release(struct kobject *kobj)
>> {
>> 	struct object_x *x;
>> 	struct completion *c;
>>
>> 	x = container_of(kobj, struct object_x, kobj);
>> 	c = x->release_completion;
>> 	kfree(x);
>> 	complete_all(c);
>> }
>>
>> void del_object(struct object_x *x)
>> {
>> 	DECLARE_COMPLETION_ONSTACK(completion);
>>
>> 	...
>> 	x->release_completion = &completion;
>> 	kobject_put(&x->kobj);
>> 	wait_for_completion(&completion);
>> }
>>
>> and
>>
>> 2. struct object_x {
>> 	...
>> 	struct kobject kobj;
>> 	struct completion release_completion;
>> };
>>
>> static void x_release(struct kobject *kobj)
>> {
>> 	struct object_x *x;
>>
>> 	x = container_of(kobj, struct object_x, kobj);
>> 	complete_all(&x->release_completion);
>> }
>>
>> void del_object(struct object_x *x)
>> {
>> 	...
>> 	kobject_put(&x->kobj);
>> 	wait_for_completion(&completion);
>> 	...
>> 	kfree(x);
>> }
> 
> I'll admit I don't understand this all that well, but
> why not just have x_release() (based on (2))
> do free(x), and have del_object
> do the kobject_put(&x->kobj) as its very last thing?
> Then you don't need the completion.

We are discussing _synchronous_ delete of x, so need to wait until
x->kobj released, hence the completion is needed in both cases.

For instance, the sync delete is needed for targets to let the
corresponding target driver be safely unloaded after its target
unregistered.

Vlad
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux