From nobody Sun May 19 07:16:20 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=1566914072; cv=none; d=zoho.com; s=zohoarc; b=BSNP08fkt8wcRqpZWMzolNQi87Di1BTRwTHE/buKz+qEnPpXkGNnG1/HC5BkFp1Wd5JO5UxHC7b00iUHBLmdOYJw5oM0TYDPDHgn//Juvfub/MgmzmTTv/Ss9aerNvfGptACgmROj2WtALdjDvDF09siCMMOC7BsExWnNlTMbm0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566914072; 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=xyHR4veZlq9dieGbVJO4T9OR+a5qX04OhdFH2kTpUbY=; b=nLLWMuxVEfDWLBYxXi0qZcfGdjLiv48j/T9ZIQozNEc0wKsrAmmoPTytYmNLkUbFI1XCwb0ZiOufclYtfZYhvdNvVVZ2PbOmXjQEcBB4ksRWyeFt0aWbpaaBXRUI6duFUb7/wPuCDShfmvHRmzgpqHWxHjaoxsEB6iHVkyucTN4= 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 1566914072676136.13387294654217; Tue, 27 Aug 2019 06:54:32 -0700 (PDT) Received: from localhost ([::1]:51782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2bvY-0002EJ-Jc for importer@patchew.org; Tue, 27 Aug 2019 09:54:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35104) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2bu8-0001H9-Q1 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 09:53:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2bu5-0006it-RI for qemu-devel@nongnu.org; Tue, 27 Aug 2019 09:52:59 -0400 Received: from relay.sw.ru ([185.231.240.75]:56650) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2bu5-0006ge-KZ; Tue, 27 Aug 2019 09:52:57 -0400 Received: from [172.16.25.136] (helo=dhcp-172-16-25-136.sw.ru) by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1i2bu2-0001p9-I5; Tue, 27 Aug 2019 16:52:54 +0300 From: Andrey Shinkevich To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 27 Aug 2019 16:52:53 +0300 Message-Id: <1566913973-15490-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 v2] 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 use better error handling for file systems that do not support fallocate() for an 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: Eric Blake Reviewed-by: Denis V. Lunev --- 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..b00259f 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 an 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