From nobody Sun May 5 23:49:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=virtuozzo.com ARC-Seal: i=1; a=rsa-sha256; t=1566498835; cv=none; d=zoho.com; s=zohoarc; b=ITy2+tw5UbsJ4UT61h/yBaTnrpx2I1KZUqWpRiUaFWTuzYkL0jo8OQaKHo3xB+Y/8ERRc+qVI5yXTRjpJfeslGYQuJrokIaIcgSwb72xwbJD63EuIAFauEWHxIs+6314HKBU+G7MeM+q29OTrVCeIMUxrSrVLc4SIWQpkz0HwjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566498835; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=cUH6PQYl+P/8y1cd0juuNCxHwpmrW+bwxm2XKg03yMc=; b=lCmCshoX907L31Dy5AhuobJ9uD04dOhkMxLKQ3x3JmRNfTtgPBj07NMvBmk5pWtW8ByiWXSj++zsIG1N8pWP0KPLji+MBDHIeB3zqsILvUHfntYjtGkMOlnM+g0oP3kl6K1BSti3ybpx2xqZUBIfGikhJyoLQz5/tmd5B0ixFgM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566498834942871.8720844268875; Thu, 22 Aug 2019 11:33:54 -0700 (PDT) Received: from localhost ([::1]:47036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0ruD-0005EG-LZ for importer@patchew.org; Thu, 22 Aug 2019 14:33:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56181) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0rre-0004Gs-3G for qemu-devel@nongnu.org; Thu, 22 Aug 2019 14:31:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0rrc-0003PZ-Ok for qemu-devel@nongnu.org; Thu, 22 Aug 2019 14:31:13 -0400 Received: from relay.sw.ru ([185.231.240.75]:47102) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i0rrY-0003ME-UO; Thu, 22 Aug 2019 14:31:09 -0400 Received: from [172.16.25.136] (helo=localhost.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i0rrS-00012d-Pn; Thu, 22 Aug 2019 21:31:02 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Thu, 22 Aug 2019 21:31:01 +0300 Message-Id: <1566498661-53008-1-git-send-email-andrey.shinkevich@virtuozzo.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH] block: workaround for unaligned byte range in fallocate() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, fam@euphon.net, vsementsov@virtuozzo.com, mreitz@redhat.com, stefanha@redhat.com, andrey.shinkevich@virtuozzo.com, den@openvz.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Revert the commit 118f99442d 'block/io.c: fix for the allocation failure' and make better error handling for the file systems that do not support fallocate() for the unaligned byte range. Allow falling back to pwrite in case fallocate() returns EINVAL. Suggested-by: Kevin Wolf Suggested-by: Eric Blake Signed-off-by: Andrey Shinkevich Reviewed-by: Denis V. Lunev Reviewed-by: Eric Blake --- Discussed in email thread with the message ID <1554474244-553661-1-git-send-email-andrey.shinkevich@virtuozzo.com> block/file-posix.c | 7 +++++++ block/io.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index fbeb006..2c254ff 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1588,6 +1588,13 @@ static int handle_aiocb_write_zeroes(void *opaque) if (s->has_write_zeroes) { int ret =3D do_fallocate(s->fd, FALLOC_FL_ZERO_RANGE, aiocb->aio_offset, aiocb->aio_nbytes); + if (ret =3D=3D -EINVAL) { + /* + * Allow falling back to pwrite for file systems that + * do not support fallocate() for unaligned byte range. + */ + return -ENOTSUP; + } if (ret =3D=3D 0 || ret !=3D -ENOTSUP) { return ret; } diff --git a/block/io.c b/block/io.c index 56bbf19..58f08cd 100644 --- a/block/io.c +++ b/block/io.c @@ -1558,7 +1558,7 @@ static int coroutine_fn bdrv_co_do_pwrite_zeroes(Bloc= kDriverState *bs, assert(!bs->supported_zero_flags); } =20 - if (ret < 0 && !(flags & BDRV_REQ_NO_FALLBACK)) { + if (ret =3D=3D -ENOTSUP && !(flags & BDRV_REQ_NO_FALLBACK)) { /* Fall back to bounce buffer if write zeroes is unsupported */ BdrvRequestFlags write_flags =3D flags & ~BDRV_REQ_ZERO_WRITE; =20 --=20 1.8.3.1