[PATCH] fix: nvme_update_ns_info method should be called even if nvme_ms_ids_equal return false
金韬
me at kingtous.cn
Fri Apr 8 00:56:49 PDT 2022
This is output from dmesg. Seems that "eui" has changed.
[ 2.086226] loop0: detected capacity change from 0 to 8
[ 26.577001] eui changed from 0100000000000000 to 0000000000000001
[ 26.577003] nvme nvme0: identifiers changed for nsid 1
在 2022/4/8 14:22, Christoph Hellwig 写道:
> 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