From nobody Mon Feb 9 06:50:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657182227; cv=none; d=zohomail.com; s=zohoarc; b=gyP8DqvUp+eqXkzwS6KlE7ipg5x+sM1EWiQNq2lpv7tCtAD9Jk9IY3OuzuEwDQ0zSUBerE2LMqODM3fmCqWqNEaVAkXuB8YjBwnsbgY++jH83PEumm4g57pQkhphP/mZcdsBIhbDqHcVW58av3Nyc3OVggWih3DPrMrVkMnbFv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657182227; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a93GsxKY0muqBL+LWACkxxKWKt6MOUdxYh8WkWccbl0=; b=HXq3oyVZlzorbczVFDZnMT3pQbwnQsKKNpHmQDOJiU2rba5lIf2m/BYmgx4IL+nSyvJcdV98jjW+HZ0zFSomux3hq7Qt/6cAzoQVD16VtTuJeq4CW7VioPVj62HIYm6QXxlhLaqhQVyzgTk1vG94MA5L3/7SdPzIdT/ljBfGR+I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657182227075506.15405397985876; Thu, 7 Jul 2022 01:23:47 -0700 (PDT) Received: from localhost ([::1]:36356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9MnZ-0001oE-RE for importer@patchew.org; Thu, 07 Jul 2022 04:23:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9Md8-00070r-5W for qemu-devel@nongnu.org; Thu, 07 Jul 2022 04:12:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9Md6-0007mW-G6 for qemu-devel@nongnu.org; Thu, 07 Jul 2022 04:12:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-t9TKhChxPEWPLJRC6KU_5A-1; Thu, 07 Jul 2022 04:12:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1ACCF8339A4; Thu, 7 Jul 2022 08:12:51 +0000 (UTC) Received: from localhost (unknown [10.39.194.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1453C27D9A; Thu, 7 Jul 2022 08:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657181574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a93GsxKY0muqBL+LWACkxxKWKt6MOUdxYh8WkWccbl0=; b=SSJusMyGe3fEyntP7IXAHs96Fb8m/pTXNJUjEP8h8AcsQsFhvps0eA10IFLfr/WL30PHbQ UXGwGHCJtmNoukVn6GeequV/DiTJY0HYtAVyme/WFWPVZJZxSzcpGzl7yuWlXOCMzUCMkt rb82+eYPYp7Py4WS9E7WdbQhNg0l9mQ= X-MC-Unique: t9TKhChxPEWPLJRC6KU_5A-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Julia Suvorova , qemu-block@nongnu.org, Stefano Garzarella , Hanna Reitz , Kevin Wolf , Aarushi Mehta , Stefan Hajnoczi , Richard Henderson , Dominique Martinet Subject: [PULL 1/2] io_uring: fix short read slow path Date: Thu, 7 Jul 2022 09:12:46 +0100 Message-Id: <20220707081247.1416955-2-stefanha@redhat.com> In-Reply-To: <20220707081247.1416955-1-stefanha@redhat.com> References: <20220707081247.1416955-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657182228945100001 Content-Type: text/plain; charset="utf-8" From: Dominique Martinet sqeq.off here is the offset to read within the disk image, so obviously not 'nread' (the amount we just read), but as the author meant to write its current value incremented by the amount we just read. Normally recent versions of linux will not issue short reads, but it can happen so we should fix this. This lead to weird image corruptions when short read happened Fixes: 6663a0a33764 ("block/io_uring: implements interfaces for io_uring") Link: https://lkml.kernel.org/r/YrrFGO4A1jS0GI0G@atmark-techno.com Signed-off-by: Dominique Martinet Message-Id: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com> Reviewed-by: Hanna Reitz Reviewed-by: Stefano Garzarella Signed-off-by: Stefan Hajnoczi --- block/io_uring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/io_uring.c b/block/io_uring.c index d48e472e74..b238661740 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -89,7 +89,7 @@ static void luring_resubmit_short_read(LuringState *s, Lu= ringAIOCB *luringcb, trace_luring_resubmit_short_read(s, luringcb, nread); =20 /* Update read position */ - luringcb->total_read =3D nread; + luringcb->total_read +=3D nread; remaining =3D luringcb->qiov->size - luringcb->total_read; =20 /* Shorten qiov */ @@ -103,7 +103,7 @@ static void luring_resubmit_short_read(LuringState *s, = LuringAIOCB *luringcb, remaining); =20 /* Update sqe */ - luringcb->sqeq.off =3D nread; + luringcb->sqeq.off +=3D nread; luringcb->sqeq.addr =3D (__u64)(uintptr_t)luringcb->resubmit_qiov.iov; luringcb->sqeq.len =3D luringcb->resubmit_qiov.niov; =20 --=20 2.36.1 From nobody Mon Feb 9 06:50:27 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657183720; cv=none; d=zohomail.com; s=zohoarc; b=LbypoNWiKyl29o+h9ps7swRrVdfJ83xMeCZfi30k5I5IYT2B1Tc0+8kXMCeG+A8soDj4ZC8jEVMQU/F23TffB/Gk8j4k2wCWr0S3RJ2ESePKQfOh2ulfOacyPXojBDki+ALPRVhfajF2mLcA/PYh/GQvEJieoVWpLg8PZkVv8+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657183720; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CeBTMnW6x9bRaOSbJPDaYLuExUX3ZycHGAAA/UaTC6g=; b=OpPbh8Eha9MWyxfVZzSJaJinYUR4X4NHmcYpUN0eQEtIi6CZ+TR+Y1H50+ID1YsjaUfzDdYLsu4VOQHTa8TfRJjPya0afxMpk/enXJfTq1/HC8aP72+jttIYDq6N1RD7A/W65i8vwfh06XP7n9a9TNqzyydNp74mB7DLZCOil/0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 165718372042719.492936221774926; Thu, 7 Jul 2022 01:48:40 -0700 (PDT) Received: from localhost ([::1]:42544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9NBZ-0001dB-RP for importer@patchew.org; Thu, 07 Jul 2022 04:48:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9Md9-00073x-Gu for qemu-devel@nongnu.org; Thu, 07 Jul 2022 04:12:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30139) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9Md7-0007mh-6Q for qemu-devel@nongnu.org; Thu, 07 Jul 2022 04:12:59 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-kq8dt6QqMUKZXNj_4JQgJQ-1; Thu, 07 Jul 2022 04:12:53 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D25D43826A41; Thu, 7 Jul 2022 08:12:52 +0000 (UTC) Received: from localhost (unknown [10.39.194.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7F755401E6B; Thu, 7 Jul 2022 08:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657181576; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CeBTMnW6x9bRaOSbJPDaYLuExUX3ZycHGAAA/UaTC6g=; b=YNnDxYQmcqGWdZenX6MA4V6r2FXPbrzMy2L7UcNGopoKiicepa9NKhXXxcKv6we2Gj+RLw tU0C5A/Wen5E7kFqSeBNDWq1qp4T+0hUSR4nQYQKwMxklSOpLPE6Y5EDjwa+QPqm3hLNhK eu2gSkxrnTBHlspLkDbfbVfSna9gv+Y= X-MC-Unique: kq8dt6QqMUKZXNj_4JQgJQ-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Julia Suvorova , qemu-block@nongnu.org, Stefano Garzarella , Hanna Reitz , Kevin Wolf , Aarushi Mehta , Stefan Hajnoczi , Richard Henderson , Dominique Martinet Subject: [PULL 2/2] block/io_uring: clarify that short reads can happen Date: Thu, 7 Jul 2022 09:12:47 +0100 Message-Id: <20220707081247.1416955-3-stefanha@redhat.com> In-Reply-To: <20220707081247.1416955-1-stefanha@redhat.com> References: <20220707081247.1416955-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657183721724100001 Content-Type: text/plain; charset="utf-8" Jens Axboe has confirmed that short reads are rare but can happen: https://lore.kernel.org/io-uring/YsU%2FCGkl9ZXUI+Tj@stefanha-x1.localdomain= /T/#m729963dc577d709b709c191922e98ec79d7eef54 The luring_resubmit_short_read() comment claimed they were only due to a specific io_uring bug that was fixed in Linux commit 9d93a3f5a0c ("io_uring: punt short reads to async context"), which is wrong. Dominique Martinet found that a btrfs bug also causes short reads. There may be more kernel code paths that result in short reads. Let's consider short reads fair game. Cc: Dominique Martinet Based-on: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com> Signed-off-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Message-id: 20220706080341.1206476-1-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- block/io_uring.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/block/io_uring.c b/block/io_uring.c index b238661740..f8a19fd97f 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -73,12 +73,8 @@ static void luring_resubmit(LuringState *s, LuringAIOCB = *luringcb) /** * luring_resubmit_short_read: * - * Before Linux commit 9d93a3f5a0c ("io_uring: punt short reads to async - * context") a buffered I/O request with the start of the file range in the - * page cache could result in a short read. Applications need to resubmit= the - * remaining read request. - * - * This is a slow path but recent kernels never take it. + * Short reads are rare but may occur. The remaining read request needs to= be + * resubmitted. */ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luring= cb, int nread) --=20 2.36.1