Commit 07e266a7 authored by Jason Gunthorpe's avatar Jason Gunthorpe

RDMA/ucma: Remove unnecessary locking of file->ctx_list in close

During the file_operations release function it is already not possible
that write() can be running concurrently, remove the extra locking
around the ctx_list.

Link: https://lore.kernel.org/r/20200818120526.702120-3-leon@kernel.orgSigned-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent ca2968c1
...@@ -1824,12 +1824,17 @@ static int ucma_close(struct inode *inode, struct file *filp) ...@@ -1824,12 +1824,17 @@ static int ucma_close(struct inode *inode, struct file *filp)
struct ucma_file *file = filp->private_data; struct ucma_file *file = filp->private_data;
struct ucma_context *ctx, *tmp; struct ucma_context *ctx, *tmp;
mutex_lock(&file->mut); /*
* ctx_list can only be mutated under the write(), which is no longer
* possible, so no locking needed.
*/
list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) { list_for_each_entry_safe(ctx, tmp, &file->ctx_list, list) {
xa_erase(&ctx_table, ctx->id);
mutex_lock(&file->mut);
ctx->destroying = 1; ctx->destroying = 1;
mutex_unlock(&file->mut); mutex_unlock(&file->mut);
xa_erase(&ctx_table, ctx->id);
flush_workqueue(file->close_wq); flush_workqueue(file->close_wq);
/* At that step once ctx was marked as destroying and workqueue /* At that step once ctx was marked as destroying and workqueue
* was flushed we are safe from any inflights handlers that * was flushed we are safe from any inflights handlers that
...@@ -1849,9 +1854,7 @@ static int ucma_close(struct inode *inode, struct file *filp) ...@@ -1849,9 +1854,7 @@ static int ucma_close(struct inode *inode, struct file *filp)
} }
ucma_free_ctx(ctx); ucma_free_ctx(ctx);
mutex_lock(&file->mut);
} }
mutex_unlock(&file->mut);
destroy_workqueue(file->close_wq); destroy_workqueue(file->close_wq);
kfree(file); kfree(file);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment