From nobody Sat May 4 19:58:31 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1612092369; cv=none; d=zohomail.com; s=zohoarc; b=KxTd2mq0iSOwl6MU6pxGLLB6ptmZiAA6++ZOTdg+ECVlmcmjyQR7U39N4jRthMCgTh4SLb2IlbrmE46xeN+aWP00rHDAZzGE9S9Ci3wuvsUzYkZaUDlAwQaHf3CpVUoFqEVzGFHCUMwA/N8MlVGFa0NjxaS9y8dvZ0SGVwolx6I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612092369; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=SxIsYyVvA5aFWCZj2Gjuz98I0TIvo+7ncC+Z39QP3Ac=; b=lFLBXM4f1pciS58J53t/2dZTIwQ9DbjlcAW1i2EiNkH4QeEgJOaWw8JPTLPeCZ0kbuZKhykRQYHdYMJbSsIwbj5aKIRoUD6BKClRZ2uii6kpcuFQ4B9eatGkHb96IaoxuPIfkEdXogUNUNhkFXbiQ+UVRyhT3bG2qlL36OXflpU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1612092369010466.79605943168485; Sun, 31 Jan 2021 03:26:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-150-zNLA0kSINmevUB5oiarRKA-1; Sun, 31 Jan 2021 06:26:05 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D74EF107ACE8; Sun, 31 Jan 2021 11:25:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B394A6F99B; Sun, 31 Jan 2021 11:25:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 33D8450038; Sun, 31 Jan 2021 11:25:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10VBPmj7024445 for ; Sun, 31 Jan 2021 06:25:48 -0500 Received: by smtp.corp.redhat.com (Postfix) id 734902166B2A; Sun, 31 Jan 2021 11:25:48 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6E1902166B27 for ; Sun, 31 Jan 2021 11:25:45 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC1B4858281 for ; Sun, 31 Jan 2021 11:25:44 +0000 (UTC) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-vwpsd_oRMvmstIHvKFf5NA-1; Sun, 31 Jan 2021 06:25:42 -0500 Received: by mail-lf1-f51.google.com with SMTP id u25so18732157lfc.2 for ; Sun, 31 Jan 2021 03:25:42 -0800 (PST) Received: from kloomba.my.domain ([5.227.255.128]) by smtp.gmail.com with ESMTPSA id f23sm2630751lfc.63.2021.01.31.03.25.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Jan 2021 03:25:39 -0800 (PST) X-MC-Unique: zNLA0kSINmevUB5oiarRKA-1 X-MC-Unique: vwpsd_oRMvmstIHvKFf5NA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SxIsYyVvA5aFWCZj2Gjuz98I0TIvo+7ncC+Z39QP3Ac=; b=noTM5fNkB0uKqkncCRUUnJV0k9NLoXE9NcsJCJ9RC1o80UV22xZRHt4gZF6qbxsv3o uswUhlnjjYK868tKqC3EfnO46FrcENWlfkL7aOnKklIX0wGhXTKVmF5DOY6ippfN/2IH H3BmJucfamaLIunstVA3XrE9t9ZNXs0GVVkFuBOplCJxyA48cM5xqKpI7m4T1M0qDLsr 8V7aWIw/cWgaJfdfX+6HHmOHN4TVOZ0IpRa3YRBQe5RhghqzzB+hXpI+ZxWpnVBXA34A lXSubSCi+MVJwqhMue7H95HfVbRZWJMLnt6hvFVmhBzhA5iR+RY0tdGae/2yFiBDEU2y R4ww== X-Gm-Message-State: AOAM530ZirJ65/w1XZuRmzXVfjCw8EvZnXeBEaWhFn/Ild4vEAtpKhnr AL/4dyVUD59w96m951UbC1iS3SDszkx9ohYs X-Google-Smtp-Source: ABdhPJxVqMwtyaJJ9dBWbIkv33YZzURNOy6CCuhs5X2i2toH3VfavUZDbi9LCwrfGWERIEXZIq0OEw== X-Received: by 2002:a05:6512:398a:: with SMTP id j10mr6256022lfu.167.1612092340626; Sun, 31 Jan 2021 03:25:40 -0800 (PST) From: Roman Bogorodskiy To: libvir-list@redhat.com Subject: [PATCH] virfile: workaround for when posix_fallocate() is not supported by FS Date: Sun, 31 Jan 2021 15:25:21 +0400 Message-Id: <20210131112521.89512-1-bogorodskiy@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Roman Bogorodskiy X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" posix_fallocate() might be not supported by a filesystem, for example, it's not supported by ZFS. In that case it fails with return code 22 (EINVAL), and thus safezero_posix_fallocate() returns -1. As safezero_posix_fallocate() is the first function tried by safezero() and it tries other functions only when it returns -2, it fails immediately without falling back to other methods, such as safezero_slow(). Fix that by returning -2 if posix_fallocate() returns EINVAL, to give safezero() a chance to try other functions. Signed-off-by: Roman Bogorodskiy Reviewed-by: Michal Privoznik --- src/util/virfile.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/util/virfile.c b/src/util/virfile.c index 609cafdd34..67a350deb3 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1119,6 +1119,16 @@ safezero_posix_fallocate(int fd, off_t offset, off_t= len) int ret =3D posix_fallocate(fd, offset, len); if (ret =3D=3D 0) return 0; + else if (ret =3D=3D EINVAL) + /* EINVAL is returned when either: + - Operation is not supported by the underlying filesystem, + - offset or len argument values are invalid. + Assuming that offset and len are valid, this error means + the operation is not supported, and we need to fall back + to other methods. + */ + return -2; + errno =3D ret; return -1; } --=20 2.30.0