Skip to contentSkip to conversation

nvme: correct locking around completion

PATCH Applied Paolo Bonzini 3 participants 7 messages Aug 14, 2018 – Oct 11, 2018 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 nvme: correct locking around completion

nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event.

---
 block/nvme.c | 2 --
 1 file changed, 2 deletions(-)
block/nvme.c +0 -2
index 6f71122bf5..42116907ed 100644
@@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n)
     BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
 
     trace_nvme_handle_event(s);
-    aio_context_acquire(s->aio_context);
     event_notifier_test_and_clear(n);
     nvme_poll_queues(s);
-    aio_context_release(s->aio_context);
 }
 
 static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 27 lines · Paolo Bonzini

nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event.

---
 block/nvme.c | 2 --
 1 file changed, 2 deletions(-)
block/nvme.c +0 -2
index 6f71122bf5..42116907ed 100644
@@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n)
     BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
 
     trace_nvme_handle_event(s);
-    aio_context_acquire(s->aio_context);
     event_notifier_test_and_clear(n);
     nvme_poll_queues(s);
-    aio_context_release(s->aio_context);
 }
 
 static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
Signature · 1 line
2.17.1

This patch and the other

[PATCH v2] nvme: simplify code around completion

only differ in subject. Which one to ignore? :)

Fam

#2 lore raw
Quoted 31 lines · Fam Zheng
Quoted 27 lines · Paolo Bonzini

nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event.

---
 block/nvme.c | 2 --
 1 file changed, 2 deletions(-)
block/nvme.c +0 -2
index 6f71122bf5..42116907ed 100644
@@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n)
     BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
 
     trace_nvme_handle_event(s);
-    aio_context_acquire(s->aio_context);
     event_notifier_test_and_clear(n);
     nvme_poll_queues(s);
-    aio_context_release(s->aio_context);
 }
 
 static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)
Signature · 1 line
2.17.1

This patch and the other

Quoted 3 lines

[PATCH v2] nvme: simplify code around completion

only differ in subject. Which one to ignore? :)

"Correct locking" is better. I thought I had hit Ctrl-C in time. :)

Paolo

#3 lore raw
In reply to Paolo Bonzini
Quoted 15 lines · Paolo Bonzini

nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event.

---
 block/nvme.c | 2 --
 1 file changed, 2 deletions(-)
block/nvme.c +0 -0
index 6f71122bf5..42116907ed 100644

block/nvme.c static void nvme_handle_event(EventNotifier *n) · line 496

Quoted 10 lines
block/nvme.c +0 -2
@@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n)
     BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
 
     trace_nvme_handle_event(s);
-    aio_context_acquire(s->aio_context);
     event_notifier_test_and_clear(n);
     nvme_poll_queues(s);
-    aio_context_release(s->aio_context);
 }
 
 static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)

This is over a month old (and seemingly didn't land); do we still want it?

#4 lore raw
Quoted 26 lines · John Snow
Quoted 23 lines · Paolo Bonzini

nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event.

---
 block/nvme.c | 2 --
 1 file changed, 2 deletions(-)
block/nvme.c +0 -2
index 6f71122bf5..42116907ed 100644
@@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n)
     BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
 
     trace_nvme_handle_event(s);
-    aio_context_acquire(s->aio_context);
     event_notifier_test_and_clear(n);
     nvme_poll_queues(s);
-    aio_context_release(s->aio_context);
 }
 
Quoted 5 lines

block/nvme.c static void nvme_handle_event(EventNotifier *n) · line 496

Quoted 2 lines
block/nvme.c +0 -0
 static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)

This is over a month old (and seemingly didn't land); do we still want it?

Yes, we do.

Paolo

Applied
#5 lore raw
Quoted 27 lines · Paolo Bonzini
Quoted 26 lines · John Snow
Quoted 23 lines · Paolo Bonzini

nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event.

---
 block/nvme.c | 2 --
 1 file changed, 2 deletions(-)
block/nvme.c +0 -2
index 6f71122bf5..42116907ed 100644
@@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n)
     BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
 
     trace_nvme_handle_event(s);
-    aio_context_acquire(s->aio_context);
     event_notifier_test_and_clear(n);
     nvme_poll_queues(s);
-    aio_context_release(s->aio_context);
 }
 
Quoted 7 lines
Quoted 5 lines

block/nvme.c static void nvme_handle_event(EventNotifier *n) · line 496

Quoted 2 lines
block/nvme.c +0 -0
 static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)

This is over a month old (and seemingly didn't land); do we still want it?

Yes, we do.

Queued, thanks!

Fam

#6 lore raw
In reply to Paolo Bonzini
Quoted 27 lines · Paolo Bonzini
Quoted 26 lines · John Snow
Quoted 23 lines · Paolo Bonzini

nvme_poll_queues is already protected by q->lock, and AIO callbacks are invoked outside the AioContext lock. So remove the acquire/release pair in nvme_handle_event.

---
 block/nvme.c | 2 --
 1 file changed, 2 deletions(-)
block/nvme.c +0 -2
index 6f71122bf5..42116907ed 100644
@@ -489,10 +489,8 @@ static void nvme_handle_event(EventNotifier *n)
     BDRVNVMeState *s = container_of(n, BDRVNVMeState, irq_notifier);
 
     trace_nvme_handle_event(s);
-    aio_context_acquire(s->aio_context);
     event_notifier_test_and_clear(n);
     nvme_poll_queues(s);
-    aio_context_release(s->aio_context);
 }
 
Quoted 8 lines
Quoted 5 lines

block/nvme.c static void nvme_handle_event(EventNotifier *n) · line 496

Quoted 2 lines
block/nvme.c +0 -0
 static bool nvme_add_io_queue(BlockDriverState *bs, Error **errp)

This is over a month old (and seemingly didn't land); do we still want it?

Yes, we do.

I'll send a pull request today. Thanks!

Fam