diff options
author | Jianchao Wang <jianchao.w.wang@oracle.com> | 2018-02-12 20:54:46 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2018-03-26 08:53:43 -0600 |
commit | 765cc031cddde40bdc279e8e2697571c7956c54e (patch) | |
tree | 7d8beb4bcf2cf6fbe8cebdb600b3633158ce61e6 /drivers/nvme/host/nvme.h | |
parent | 6f8e0d787e3727ed70116e3523f4ecb86887c000 (diff) | |
download | linux-765cc031cddde40bdc279e8e2697571c7956c54e.tar.gz |
nvme: change namespaces_mutext to namespaces_rwsem
namespaces_mutext is used to synchronize the operations on ctrl
namespaces list. Most of the time, it is a read operation.
On the other hand, there are many interfaces in nvme core that
need this lock, such as nvme_wait_freeze, and even more interfaces
will be added. If we use mutex here, circular dependency could be
introduced easily. For example:
context A context B
nvme_xxx nvme_xxx
hold namespaces_mutext require namespaces_mutext
sync context B
So it is better to change it from mutex to rwsem.
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jianchao Wang <jianchao.w.wang@oracle.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/nvme/host/nvme.h')
-rw-r--r-- | drivers/nvme/host/nvme.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 9a3d3540aa6a..29942b1892f7 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -141,7 +141,7 @@ struct nvme_ctrl { struct blk_mq_tag_set *tagset; struct blk_mq_tag_set *admin_tagset; struct list_head namespaces; - struct mutex namespaces_mutex; + struct rw_semaphore namespaces_rwsem; struct device ctrl_device; struct device *device; /* char device */ struct cdev cdev; |