[Devel] [PATCH RH9 2/3] dm-qcow2: Stop using err_status_lock
Kirill Tkhai
ktkhai at virtuozzo.com
Mon Feb 21 14:27:52 MSK 2022
Instead of using spinlock as mem barrier, use memory barrier instead.
Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
drivers/md/dm-qcow2-cmd.c | 11 ++++-------
drivers/md/dm-qcow2-target.c | 1 -
drivers/md/dm-qcow2.h | 1 -
3 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/md/dm-qcow2-cmd.c b/drivers/md/dm-qcow2-cmd.c
index 779c6618e598..7c91daa5af2d 100644
--- a/drivers/md/dm-qcow2-cmd.c
+++ b/drivers/md/dm-qcow2-cmd.c
@@ -41,12 +41,10 @@ static void service_qio_endio(struct qcow2_target *tgt, struct qio *qio,
void *data, blk_status_t status)
{
blk_status_t *status_ptr = data;
- unsigned long flags;
if (unlikely(status)) {
- spin_lock_irqsave(&tgt->err_status_lock, flags);
- *status_ptr = status;
- spin_unlock_irqrestore(&tgt->err_status_lock, flags);
+ WRITE_ONCE(*status_ptr, status);
+ smp_wmb(); /* Pairs with smp_rmb() in qcow2_service_iter() */
}
atomic_dec(&tgt->service_qios);
@@ -99,9 +97,8 @@ static int qcow2_service_iter(struct qcow2_target *tgt, struct qcow2 *qcow2,
wait_event(tgt->service_wq, !atomic_read(&tgt->service_qios));
if (!ret) {
- spin_lock_irq(&tgt->err_status_lock);
- ret = blk_status_to_errno(service_status);
- spin_unlock_irq(&tgt->err_status_lock);
+ smp_rmb(); /* Pairs with smp_wmb() in service_qio_endio() */
+ ret = blk_status_to_errno(READ_ONCE(service_status));
}
return ret;
diff --git a/drivers/md/dm-qcow2-target.c b/drivers/md/dm-qcow2-target.c
index 2a29bff42bfe..99a0359391ce 100644
--- a/drivers/md/dm-qcow2-target.c
+++ b/drivers/md/dm-qcow2-target.c
@@ -448,7 +448,6 @@ static struct qcow2_target *alloc_qcow2_target(struct dm_target *ti)
}
init_completion(&tgt->inflight_ref_comp);
- spin_lock_init(&tgt->err_status_lock);
mutex_init(&tgt->ctl_mutex);
init_waitqueue_head(&tgt->service_wq);
ti->private = tgt;
diff --git a/drivers/md/dm-qcow2.h b/drivers/md/dm-qcow2.h
index 962b767c84b1..14899608b30f 100644
--- a/drivers/md/dm-qcow2.h
+++ b/drivers/md/dm-qcow2.h
@@ -125,7 +125,6 @@ struct qcow2_target {
atomic_t service_qios;
struct wait_queue_head service_wq;
- spinlock_t err_status_lock;
struct mutex ctl_mutex;
};
More information about the Devel
mailing list