public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: axboe@kernel.dk, martin.petersen@oracle.com
Cc: Lihong Kou <koulihong@huawei.com>,
	kbusch@kernel.org, sagi@grimberg.me, linux-block@vger.kernel.org,
	linux-nvme@lists.infradead.org
Subject: [PATCH 1/3] block: check if a profile is actually registered in blk_integrity_unregister
Date: Tue, 14 Sep 2021 09:06:55 +0200	[thread overview]
Message-ID: <20210914070657.87677-2-hch@lst.de> (raw)
In-Reply-To: <20210914070657.87677-1-hch@lst.de>

While clearing the profile itself is harmless, we really should not clear
the stable writes flag if it wasn't set due to a registered integrity
profile.

Reported-by: Lihong Kou <koulihong@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/blk-integrity.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 69a12177dfb62..48bfb53aa8571 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -426,8 +426,12 @@ EXPORT_SYMBOL(blk_integrity_register);
  */
 void blk_integrity_unregister(struct gendisk *disk)
 {
+	struct blk_integrity *bi = &disk->queue->integrity;
+
+	if (!bi->profile)
+		return;
 	blk_queue_flag_clear(QUEUE_FLAG_STABLE_WRITES, disk->queue);
-	memset(&disk->queue->integrity, 0, sizeof(struct blk_integrity));
+	memset(bi, 0, sizeof(*bi));
 }
 EXPORT_SYMBOL(blk_integrity_unregister);
 
-- 
2.30.2


  reply	other threads:[~2021-09-14  7:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14  7:06 fix an integrity profile unregistration race Christoph Hellwig
2021-09-14  7:06 ` Christoph Hellwig [this message]
2021-09-14  7:10   ` [PATCH 1/3] block: check if a profile is actually registered in blk_integrity_unregister Sagi Grimberg
2021-09-14  7:06 ` [PATCH 2/3] block: flush the integrity workqueue " Christoph Hellwig
2021-09-14  7:19   ` Sagi Grimberg
2021-09-14  7:06 ` [PATCH 3/3] nvme: remove the call to nvme_update_disk_info in nvme_ns_remove Christoph Hellwig
2021-09-14  7:19   ` Sagi Grimberg
2021-09-15  2:03 ` fix an integrity profile unregistration race Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210914070657.87677-2-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=kbusch@kernel.org \
    --cc=koulihong@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=martin.petersen@oracle.com \
    --cc=sagi@grimberg.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox