From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id F3F3380031 for ; Thu, 19 Nov 2026 14:31:20 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AJEU257012370; Thu, 19 Nov 2026 17:30:03 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJEU257012370 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=default; t=1795098606; bh=7SRfpnUm3ITYN7sgzd2Tk9ymHMhUL0VpJI/5CpzWSEM=; h=From:To:Date:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe; b=uBj2VwEy3rn4kOfYMAcGuvCItZNW18CEHIoRM33ch0gbak898DB4xtgwn93WRRYRX OBXC9WMnXQ/Y/Svy1OA4jy+WTP4OoO/G+MluEHEaVgWrBhUVVPrOM99Gi/B/5clO08 L8EM3Tc8nXBsVUpKDxjV1moUS6traai6jW+Oyx3+E7zAKVfeEGlfogo4DJUnb+I/2u kGyOQyO/V5EESSXqMbBEy8oEySaw3otrWG1uI0XbT5V/J92ovKRBSmyA/PE0k9LLOR n6AzZuKKBsRd9pdAc4ZyNcJczt/edTXmUbg3oIgUPzMW/nxWuyJqrhgAAyZEbJr+n/ tnzOmpm2/kOew== Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AJEU1lh012366 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 19 Nov 2026 17:30:01 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AJEU1lh012366 Authentication-Results: mail.openvz.org; dkim=pass (2048-bit key) header.d=openvz.org header.i=@openvz.org header.b="p0ts7MWW" Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-490d2ac331bso2216262f8f.0 for ; Thu, 19 Nov 2026 06:30:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErFwKvr7Pr1vAmF8Ujo8f+1gUrjavzi3MKlFHp3yo3FvEyFTGhLlLrHidZZSID3EBn9C4Us5CA==@openvz.org X-Gm-Message-State: APuU4Z++JBbs6ZaeZhTPrqJ7xTI38pSMiWCF1vZ+/WR7Y9sSbCXUPKHY lHNEJ9OEW0q0rZSwK4xxaN18CKqfZhMJWMBGf4EMAAHWGxDz8GxZFXWy5ylP8QaGaR7/OUnGLgW plIbjjrKUWxyKyhSzJ34iC6PJKS5uZxYRPbxcjKEFknmdGaBAXOChFw== X-Gm-Gg: AZFdTZczMjE6ATy51By8vMtVZXzXNnY/uWO/mETS8MGN+7+8ANoLmgV9PcZcOblCNfG CjL83syGHtdMPR8PHAc0nL1SNaFR5S29BQH2TWSfAEd4risC/dtL5n0BCZ+7tJardeGzqBKhBg2 wyYWJUvtDE588rmgYWCErmz0clkWO1k5XFDFNpjkrFrMWKc6HKBf81X5qlYq3r3xLB4MU3emIMz +irw4TeK4sQwJF9Kt2uNjCPebFIFVW8UlwCpye0eclwikO6whsFWs1CwnBy2swUf9l03/nCNlet fAol3YjwuQ== X-Received: by 2002:a05:6000:25f2:b0:4a5:8f40:a644 with SMTP id ffacd0b85a97d-4a639475320mr14515336f8f.9.1795098600709; Thu, 19 Nov 2026 06:30:00 -0800 (PST) X-Received: by 2002:a05:6000:25f2:b0:4a5:8f40:a644 with SMTP id ffacd0b85a97d-4a639475320mr14515294f8f.9.1795098600324; Thu, 19 Nov 2026 06:30:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1795098600; cv=none; d=google.com; s=arc-20260327; b=o6zXzzTCl6T08HxGcfIqh9f9+K9J7Y1zLgdS7ya2N8i8vJt7CB+PpAKKlz6nrvhdtu P1jMcFC0w6aLBrQJBULjJE/X8qVCTxjsHEBOgqhxjgOcIAkM94tqFztmw1FVU31qv4Hs pFuXFzyJ3iRuDTH4ioflpe6Hw58qpELdNb+4yOAv6JuCcW+blys2pAIv7xy0dVM/9O97 smURdn9OwQ1xLejJ8KlGW7fQchNQXv4oVwjDtWc7PfUyk+a4coq5mEIwXcwfHavR9jHe xiWE+pK0FthG/U5jjdb+LD/VP9CW+ipf43V8l/vL6J5cSKeMishvk9nbErLaZry7dSuJ 0UQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=ZSJPQCrXfFd7i5GMZebsHtq4EtaArvAaoVnhOd3+pvQ=; fh=KbNxWbzJfCXwwtOHalonY0hPnAssNGk4OzaBVEkjsxs=; b=W/qV3bP/rjJr5wSo3lHkLhFJorbsIWkRbFQT6V0BV51CCap6UN8MII1QEvzBG183H6 E42yygp3BsxkwsZeUtlbtMCYsll2w+NxnaNfQ7V/13TWZ1tDJm4+D+y8yuhy6Xx/dbUb rqOadFilJ1HWznm1crj4LpI95PJXtx2OP+uBn5gVhXybs5HrYFbwujVo9sISuTOB8zL9 QD1pc2JczlzLeVGT6A/6UVENycA4WoGjjsUl1eS/tHkOsgPOaBngZ5iBZR5ZC5KjWXhg IZa5x3/PPxA0NXGDW8vlQUlBprrgJlOlfbsQWFA2+b3NSvWNlvtZZ42HihRW8U6haIQk n0Iw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=p0ts7MWW; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id ffacd0b85a97d-4ab615cc79asor2709f8f.10.2026.11.19.06.30.00 for (Google Transport Security); Thu, 19 Nov 2026 06:30:00 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 as permitted sender) client-ip=2a06:5b06:b600:300:989f:a206:d03d:c3d5; Authentication-Results: mx.google.com; dkim=pass header.i=@openvz.org header.s=google header.b=p0ts7MWW; spf=softfail (google.com: domain of transitioning den@openvz.org does not designate 2a06:5b06:b600:300:989f:a206:d03d:c3d5 as permitted sender) smtp.mailfrom=den@openvz.org; dara=neutral header.i=@openvz.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1795098600; x=1795703400; darn=openvz.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ZSJPQCrXfFd7i5GMZebsHtq4EtaArvAaoVnhOd3+pvQ=; b=p0ts7MWWD8WFdz7GZRgAirfEXTtbeGGvX9kKFrK9uK2Gr+ux4j2aaxx1NJkv5syBbl 6XZ9tFtwit6vgaFGyx4NBn8xaYaew4ujQj5V92/t+nos/2dyjGCfjz9tSo9vPIk9pKgt QVlo8UJQ87u93LrxduhzKfEDlHDSqi3v74ezUTosAW81SVCDMgznyozObHb6L83HBjNQ dbCmUIPOKGt19VbkyjrRSrOu+pTIgj0bJ4REMJJNW6Lij88x7HZ/yfqNCjGLtZf9K/qC 8uSskz6EJDxucpPzBW+Quw/YUBJHpKj50Zrw84upZtnz1PfptBE8NLaZGYwAqZ4uTJ6L OkYQ== X-Forwarded-Encrypted: i=1; AL+hErEDU4ya9XUAuLy7DO497xPu0eV+xv2LqswAKRwJB9uSm/usmj/R1NsDsKPFe4NQ99mjLN+PcA==@openvz.org X-Received: by 2002:a05:6000:2907:b0:492:9630:6a7f with SMTP id ffacd0b85a97d-4a63d983a14mr14834925f8f.55.1795098599863; Thu, 19 Nov 2026 06:29:59 -0800 (PST) Received: from artemis.sw.ru ([2a06:5b06:b600:300:989f:a206:d03d:c3d5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab53e891b5sm144224f8f.19.2026.11.19.06.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Nov 2026 06:29:59 -0800 (PST) From: "Denis V. Lunev" To: alexander.ivanov@virtuozzo.com, vasileios.almpanis@virtuozzo.com Date: Thu, 19 Nov 2026 15:29:56 +0100 Message-ID: <20261119142956.998039-1-den@openvz.org> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.2] dm-qcow2: fix a short image read resubmitted at the wrong sector X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Denis V. Lunev data_rw_complete() resubmits the rest of a short image transfer through qio_advance(), which moves the buffer by ret bytes but bi_sector only by ret >> 9. When ret is not a multiple of 512, the resubmit rereads from below where the transfer stopped into the buffer past it. A read-only image whose file ends inside a sector and a page or more short of the read gets such a read. On ext4 or xfs the O_DIRECT resubmit fails with -EINVAL. On a file system that takes unaligned O_DIRECT reads, such as NFS or FUSE, the same tail bytes are read again and again into the buffer, and the read completes with wrong data and no error. A short read that ends at EOF of a read-only image cannot make progress, as the file does not grow: zero-fill it when less than a page is missing, as before, and fail it with -EIO otherwise. Fail any other short transfer that is not a multiple of 512 bytes, including a write, which would rewrite good bytes at the rounded-down offset, instead of resubmitting it. https://virtuozzo.atlassian.net/browse/VSTOR-156059 Fixes: 222b6f1291c1 ("dm-qcow2: Introduce driver to create block devices over QCOW2 files") Feature: dm-qcow2: block device over QCOW2 files driver Signed-off-by: Denis V. Lunev --- Applies on top of the series "dm-qcow2: fix a read livelock at EOF of a read-only image" v2. drivers/md/dm-qcow2-map.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/md/dm-qcow2-map.c b/drivers/md/dm-qcow2-map.c index cf66b9a98085..c0aaff8815ad 100644 --- a/drivers/md/dm-qcow2-map.c +++ b/drivers/md/dm-qcow2-map.c @@ -3013,11 +3013,14 @@ static void data_rw_complete(struct qio *qio) if (unlikely(qio->ret != qio->bi_iter.bi_size)) { if (!write && qio->ret > 0 && !qcow2_file_is_writable(qcow2) && - to_bytes(qio->bi_iter.bi_sector) + qio->ret == qcow2->file_size && - qio->bi_iter.bi_size - qio->ret < PAGE_SIZE) { + to_bytes(qio->bi_iter.bi_sector) + qio->ret == qcow2->file_size) { /* Read near EOF, same as md_page_read_complete() */ - zero_fill_qio(qio, qio->ret, qio->bi_iter.bi_size - qio->ret); - } else if (!write && qio->ret == 0) { + if (qio->bi_iter.bi_size - qio->ret < PAGE_SIZE) + zero_fill_qio(qio, qio->ret, qio->bi_iter.bi_size - qio->ret); + else + bi_status = BLK_STS_IOERR; + } else if ((!write && qio->ret == 0) || + (qio->ret > 0 && (qio->ret & (SECTOR_SIZE - 1)))) { bi_status = BLK_STS_IOERR; } else if (qio->ret >= 0) { WARN_ON_ONCE(qio->ret == 0); -- 2.55.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel