Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp879537lqh; Fri, 31 May 2024 23:32:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUJfDxEl7WohR+voMV7FNqUPo8DyZcrpipedVYj+Ne+WyQYeaJw2KvU83feLn2xSf8uJyuJl4tBE7z2XoTlFktOqyohjraT+sHZhaU72g== X-Google-Smtp-Source: AGHT+IFo5BFHQ10YUE2nabfz653zCcc6fglm5dgqymMsnuIGSA3ueA7qtmsBw424CQ0gBcrSUsjG X-Received: by 2002:a05:6359:4113:b0:192:829b:3684 with SMTP id e5c5f4694b2df-19b48fa4060mr572615255d.25.1717223552603; Fri, 31 May 2024 23:32:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717223552; cv=pass; d=google.com; s=arc-20160816; b=oLlZuuyiBtv+gLdxe7LR9i/bQOY6EG4MW5zCxneih69ew/F7QdM9+arWWHdqzlfYzo aQtRE1+++fRbA1Epav+yyPHviUYr9ERrANlKv9bK/BF2UG+2svHqZVqd+1Na12LW7xRs lO3Z1NRydmlUmaeEyZoH9HyNS2ffkf0G7jnV1olI5cNBsrin43aarkNTSCs4VxfaUHtC J8hXRfyZC+H4taK6V7btK/fJnvtVpNmsLAxCc+w6ks7utwYLtQK7rTpQCyo9l7Cmm/WT HZo5RITyQdgPrhMH+6kijjm7cE2JcF9jYxev8tN/ho6RdhtZEgpDB1pRbFEuqQIPWV0n m14g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=TmSzTwWZRUx258jDWbWurxca+nK6tRL1mNdPFJEdggQ=; fh=201914GUii0UiSqq1fzZB6ynyVerIjguDo4mRTlY4oI=; b=zBnBfLguoNAQuvVlFGQB8lcDIJq4PH7iqx/yiGXpxPazUWs7q7ySwJ6mhguLjDNria JsvkJQ40zlVq9ZjUvDNXgvwZp6Bb+nGbdwY/l9tBdzi7mEeeH+nBJZasdSSeWVMTdY36 FuBklyf0nh4v+BFLNWYC6YIg2p/tDq5JqP7CZiO5nI7R6GXBLAaCjagIwFDMbuUf5fq2 n2btaf+sJm2VFxtQV/Fx2XWd37m96zEK/XPbKByaIqXFIZw9gqCFr7fswTlS9Q+y4A8X wbdnwojGH6ED9TAII2zNrYm5qEjlRxCIXhd5D8mxl7uclfwKFE2WfjUqMV+iRIyRjKew U3ww==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@famille-lp.fr header.s=local header.b=GWCSfDk6; arc=pass (i=1 spf=pass spfdomain=famille-lp.fr dkim=pass dkdomain=famille-lp.fr dmarc=pass fromdomain=famille-lp.fr); spf=pass (google.com: domain of linux-kernel+bounces-197725-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=famille-lp.fr Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c7e9bc6e92si736081a12.728.2024.05.31.23.32.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 May 2024 23:32:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-197725-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@famille-lp.fr header.s=local header.b=GWCSfDk6; arc=pass (i=1 spf=pass spfdomain=famille-lp.fr dkim=pass dkdomain=famille-lp.fr dmarc=pass fromdomain=famille-lp.fr); spf=pass (google.com: domain of linux-kernel+bounces-197725-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-197725-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=famille-lp.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 2C08B2885E3 for ; Sat, 1 Jun 2024 06:32:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A60561400A; Sat, 1 Jun 2024 06:32:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=famille-lp.fr header.i=@famille-lp.fr header.b="GWCSfDk6" Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [212.27.42.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B5E628EA; Sat, 1 Jun 2024 06:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.27.42.2 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717223541; cv=none; b=qBKttBY35cdIaU5S/CA4J5pmWrGCnydHqrqji7NwC+xitSqBV+xhYeTOpWqL4l6oYXeKF35OLbIbdozbPSwIugaaPk1USFrVYOprQlAtMF43NFd7ioTqndyC3GRqicIU8hDJM6J+s7iyX6TZXjPyh8w8tLXdsR3tL6z51KdA9zU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717223541; c=relaxed/simple; bh=sPpUWYqfJp5cwAeUS4VoZjs3sQm3X8bcKnRiemeWoQU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ezgjW7tcCAGYpp6LXYWVdrkMrEnqwotVkhcZbH8Hk0vOX3Xp6DzZo+s5kzXVBc0KdtWOeboo9c1y+PRrTvezTyLJuDD1YHwnr1WzgPVUGeG40DmvW1e/vp9mG0RF+jhNOmIvQgiq7UR27S5KJUm9NkV4Ac6NQLfz/Z3X10n6uE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=famille-lp.fr; spf=pass smtp.mailfrom=famille-lp.fr; dkim=pass (1024-bit key) header.d=famille-lp.fr header.i=@famille-lp.fr header.b=GWCSfDk6; arc=none smtp.client-ip=212.27.42.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=famille-lp.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=famille-lp.fr Received: from mail.famille-lp.fr (unknown [82.64.142.12]) by smtp2-g21.free.fr (Postfix) with ESMTPS id ED2EA20039E; Sat, 1 Jun 2024 08:32:03 +0200 (CEST) Received: from [192.168.0.7] (unknown [10.0.0.1]) by mail.famille-lp.fr (Postfix) with ESMTPSA id 8DECFA0B8B; Sat, 1 Jun 2024 06:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=famille-lp.fr; s=local; t=1717223523; bh=sPpUWYqfJp5cwAeUS4VoZjs3sQm3X8bcKnRiemeWoQU=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=GWCSfDk6d+dxbFfi+RGWTxvUg8Xej3QIapl5PxBvDyYX+anLPYL85zA2IvDBRHs8L /KPMAbetG/7WGqTVaWb23FSys58wEJRel01xQjPBKhIZSiCroSLY1Q+yq9JoLTP5+R YKdmHwAHpxl40vmEq59JXoG1pt9cK1r65zE5qprs= Message-ID: Date: Sat, 1 Jun 2024 08:32:02 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [BUG REPORT][BLOCK/NBD] Error when accessing qcow2 image through NBD To: Josef Bacik Cc: Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org References: <6d33a50a-eea5-4a40-8976-fd6beff191ad@gmail.com> <5d188452-fe93-48b3-9eb7-e0fbcb5e3648@famille-lp.fr> Content-Language: fr From: Michel LAFON-PUYO In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 31/05/2024 à 17:17, Josef Bacik a écrit : > On Fri, May 31, 2024 at 1:48 AM Michel LAFON-PUYO wrote: >> Hi! >> >> >> When switching from version 6.8.x to version 6.9.x, I've noticed errors when mounting NBD device: >> >> mount: /tmp/test: can't read superblock on /dev/nbd0. >> dmesg(1) may have more information after failed mount system call. >> >> dmesg shows this kind of messages: >> >> [ 5.138056] mount: attempt to access beyond end of device >> nbd0: rw=4096, sector=2, nr_sectors = 2 limit=0 >> [ 5.138062] EXT4-fs (nbd0): unable to read superblock >> [ 5.140097] nbd0: detected capacity change from 0 to 1024000 >> >> or >> >> [ 144.431247] blk_print_req_error: 61 callbacks suppressed >> [ 144.431250] I/O error, dev nbd0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 4 prio class 0 >> [ 144.431254] buffer_io_error: 66 callbacks suppressed >> [ 144.431255] Buffer I/O error on dev nbd0, logical block 0, async page read >> [ 144.431258] Buffer I/O error on dev nbd0, logical block 1, async page read >> [ 144.431259] Buffer I/O error on dev nbd0, logical block 2, async page read >> [ 144.431260] Buffer I/O error on dev nbd0, logical block 3, async page read >> [ 144.431273] I/O error, dev nbd0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.431275] Buffer I/O error on dev nbd0, logical block 0, async page read >> [ 144.431278] I/O error, dev nbd0, sector 2 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.431279] Buffer I/O error on dev nbd0, logical block 1, async page read >> [ 144.431282] I/O error, dev nbd0, sector 4 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.431283] Buffer I/O error on dev nbd0, logical block 2, async page read >> [ 144.431286] I/O error, dev nbd0, sector 6 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.431287] Buffer I/O error on dev nbd0, logical block 3, async page read >> [ 144.431289] nbd0: unable to read partition table >> [ 144.435144] I/O error, dev nbd0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.435154] Buffer I/O error on dev nbd0, logical block 0, async page read >> [ 144.435161] I/O error, dev nbd0, sector 2 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.435166] Buffer I/O error on dev nbd0, logical block 1, async page read >> [ 144.435170] I/O error, dev nbd0, sector 4 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.436007] I/O error, dev nbd0, sector 6 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.436023] I/O error, dev nbd0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 0 >> [ 144.436034] nbd0: unable to read partition table >> [ 144.437036] nbd0: unable to read partition table >> [ 144.438712] nbd0: unable to read partition table >> >> It can be reproduced on v6.10-rc1. >> >> I've bisected the commits between v6.8 tag and v6.9 tag on vanilla master branch and found out that commit 242a49e5c8784e93a99e4dc4277b28a8ba85eac5 seems to introduce this regression. When reverting this commit, everything seems fine. >> >> There is only one change in this commit in drivers/block/nbd.c. >> >> -static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, >> +static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize, >> >> +static int nbd_set_size(struct nbd_device *nbd, loff_t bytesize, >> + loff_t blksize) >> +{ >> + int error; >> + >> + blk_mq_freeze_queue(nbd->disk->queue); >> + error = __nbd_set_size(nbd, bytesize, blksize); >> + blk_mq_unfreeze_queue(nbd->disk->queue); >> + >> + return error; >> +} >> + >> >> To reproduce the issue, you need qemu-img and qemu-nbd. Executing the following script (as root) triggers the issue. This is not systematic but running the script once or twice is generally sufficient to get an error. >> >> qemu-img create -f qcow2 test.img 500M >> qemu-nbd -c /dev/nbd0 test.img >> mkfs.ext4 /dev/nbd0 >> qemu-nbd -d /dev/nbd0 >> mkdir /tmp/test >> >> for i in {1..20} ; do >> qemu-nbd -c /dev/nbd0 test.img >> mount /dev/nbd0 /tmp/test >> umount /dev/nbd0 >> qemu-nbd -d /dev/nbd0 >> sleep 0.5 >> done >> >> Output of the script is similar to: >> >> /dev/nbd0 disconnected >> /dev/nbd0 disconnected >> /dev/nbd0 disconnected >> /dev/nbd0 disconnected >> /dev/nbd0 disconnected >> /dev/nbd0 disconnected >> /dev/nbd0 disconnected >> mount: /tmp/test: can't read superblock on /dev/nbd0. >> dmesg(1) may have more information after failed mount system call. >> >> Can you please have a look at this issue? >> I can help at testing patches. >> > This is just you racing with the connection being ready and the device > being ready and you trying to mount it. The timing has changed, if > you look at this patch that I added for blk-tests you'll see the sort > of thing that needs to be done > > https://github.com/osandov/blktests/commit/698f1a024cb4d69b4b6cd5500b72efa758340d05 > > A better option for you is to load the module with devices=0, and use > the netlink thing so that the device doesn't show up until it's > actually connected. This problem exists because historically we used > the device itself to get configured, instead of a control device that > would then add the device once it is ready. We can't change the old > way, but going forward to avoid this style of problem you'll want to > use nbds_max=0 and then use the netlink interface for configuration, > that'll give you a much more "normal" experience. Thanks, > > Josef Hi Josef, I worked around the issue as you did in blk-tests. Thanks a lot for your support. Michel