[PATCH] fix: nvme_update_ns_info method should be called even if nvme_ms_ids_equal return false

Christoph Hellwig hch at lst.de
Thu Apr 7 23:22:10 PDT 2022


On Fri, Apr 08, 2022 at 02:12:13PM +0800, me at kingtous.cn wrote:
> Yes, I only have one controller with one namespace.
> I've done `nvme id-ns /dev/nvme0n1` times before and after suspend. The only difference between the two output is nuse address. The nuse address's output is dynamic, the outputs are different each time I execute the nvme id-ns command.
> When the laptop wakes up, tty will show "identifiers changed for nsid 1". I checked the "nvme_ns_ids_equal" function, it will check uuid, nguid, eui64 and csi. So maybe there is something changed in uuid or csi?

Let's try this:

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index efb85c6d8e2d5..0c38184a3ffa2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1631,10 +1631,28 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns)
 
 static bool nvme_ns_ids_equal(struct nvme_ns_ids *a, struct nvme_ns_ids *b)
 {
-	return uuid_equal(&a->uuid, &b->uuid) &&
-		memcmp(&a->nguid, &b->nguid, sizeof(a->nguid)) == 0 &&
-		memcmp(&a->eui64, &b->eui64, sizeof(a->eui64)) == 0 &&
-		a->csi == b->csi;
+	if (uuid_equal(&a->uuid, &b->uuid)) {
+		printk("uuid changed from %pU to %pU\n",
+			&a->uuid, &b->uuid);
+		return false;
+	}
+	if (memcmp(&a->nguid, &b->nguid, sizeof(a->nguid))) {
+		printk("nguid changed from %16phN to %16phN\n",
+			&a->nguid, &b->nguid);
+		return false;
+	}
+	if (memcmp(&a->eui64, &b->eui64, sizeof(a->eui64))) {
+		printk("eui changed from %8phN to %8phN\n",
+			&a->eui64, &b->eui64);
+		return false;
+	}
+	if (a->csi != b->csi) {
+		printk("csi changed from %u to %u\n",
+			a->csi, b->csi);
+		return false;
+	}
+
+	return true;
 }
 
 static int nvme_init_ms(struct nvme_ns *ns, struct nvme_id_ns *id)



More information about the Linux-nvme mailing list