mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 10:02:02 +02:00
nvme: add nvme_get_ns_head()
Add a wrapper for getting a reference to the NS head. This would be used in scenarios when we know that getting a reference would not fail. Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: John Garry <john.g.garry@oracle.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
This commit is contained in:
parent
29261f8bb4
commit
a11e0a4cb4
|
|
@ -693,6 +693,11 @@ static void nvme_free_ns_head(struct kref *ref)
|
|||
kfree(head);
|
||||
}
|
||||
|
||||
void nvme_get_ns_head(struct nvme_ns_head *head)
|
||||
{
|
||||
kref_get(&head->ref);
|
||||
}
|
||||
|
||||
bool nvme_tryget_ns_head(struct nvme_ns_head *head)
|
||||
{
|
||||
return kref_get_unless_zero(&head->ref);
|
||||
|
|
|
|||
|
|
@ -797,7 +797,7 @@ int nvme_mpath_alloc_disk(struct nvme_ctrl *ctrl, struct nvme_ns_head *head)
|
|||
set_bit(GD_SUPPRESS_PART_SCAN, &head->disk->state);
|
||||
sprintf(head->disk->disk_name, "nvme%dn%d",
|
||||
ctrl->subsys->instance, head->instance);
|
||||
nvme_tryget_ns_head(head);
|
||||
nvme_get_ns_head(head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -995,6 +995,7 @@ int nvme_delete_ctrl(struct nvme_ctrl *ctrl);
|
|||
void nvme_queue_scan(struct nvme_ctrl *ctrl);
|
||||
int nvme_get_log(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page, u8 lsp, u8 csi,
|
||||
void *log, size_t size, u64 offset);
|
||||
void nvme_get_ns_head(struct nvme_ns_head *head);
|
||||
bool nvme_tryget_ns_head(struct nvme_ns_head *head);
|
||||
void nvme_put_ns_head(struct nvme_ns_head *head);
|
||||
int nvme_cdev_add(const char *name, struct cdev *cdev,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user