Message ID | 1433821856-2815280-2-git-send-email-calvinowens@fb.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, Jun 08, 2015 at 08:50:51PM -0700, Calvin Owens wrote: > These objects can be referenced concurrently throughout the driver, we > need a way to make sure threads can't delete them out from under each > other. > > Signed-off-by: Calvin Owens <calvinowens@fb.com> Thsi doesn't make sense without users of the refcount, and should be squashed into the patch actually using the refcounting. -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h index caff8d1..2e7dc33 100644 --- a/drivers/scsi/mpt2sas/mpt2sas_base.h +++ b/drivers/scsi/mpt2sas/mpt2sas_base.h @@ -376,8 +376,24 @@ struct _sas_device { u8 phy; u8 responding; u8 pfa_led_on; + struct kref refcount; }; +static inline void sas_device_get(struct _sas_device *s) +{ + kref_get(&s->refcount); +} + +static inline void sas_device_free(struct kref *r) +{ + kfree(container_of(r, struct _sas_device, refcount)); +} + +static inline void sas_device_put(struct _sas_device *s) +{ + kref_put(&s->refcount, sas_device_free); +} + /** * struct _raid_device - raid volume link list * @list: sas device list
These objects can be referenced concurrently throughout the driver, we need a way to make sure threads can't delete them out from under each other. Signed-off-by: Calvin Owens <calvinowens@fb.com> --- drivers/scsi/mpt2sas/mpt2sas_base.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)