From patchwork Fri Feb 17 00:51:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nir Soffer X-Patchwork-Id: 9578567 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6C0256043A for ; Fri, 17 Feb 2017 00:55:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 588FA28691 for ; Fri, 17 Feb 2017 00:55:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A638286A0; Fri, 17 Feb 2017 00:55:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0979A28691 for ; Fri, 17 Feb 2017 00:55:43 +0000 (UTC) Received: from localhost ([::1]:51032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceWpr-0004L5-3Q for patchwork-qemu-devel@patchwork.kernel.org; Thu, 16 Feb 2017 19:55:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceWm9-0001HT-3D for qemu-devel@nongnu.org; Thu, 16 Feb 2017 19:51:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceWm8-0007sB-4p for qemu-devel@nongnu.org; Thu, 16 Feb 2017 19:51:53 -0500 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]:35436) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceWm7-0007rB-V6; Thu, 16 Feb 2017 19:51:52 -0500 Received: by mail-wr0-x243.google.com with SMTP id q39so3775063wrb.2; Thu, 16 Feb 2017 16:51:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=W5kSPSMkBLe3on5gFApAHXIVGAp4L6pHuUT946Qc+0g=; b=CV1FaJRiYp2wWFSouY/l9Cb2g7t/Y+8OVAJgf8aUEL0TwGxLypj6O4RxIuVS8SqRzx 3nYvRXbatjaf58qHa45kT87x4WVl2fVqS/+WPxv1pqzOHfJuigAOUlVMvY8eO1wqXh5v XVOGLz1vXuYbJsP9AmFjAwmPB5Mipu6ih/AT2cX5jB2pWq0jYMUgQK4qj9ionKJazlNa UpKG3grgvShqAEEQ1atvW13SIAfiXRH0Pw4HVfIhN4Vrh1tg9Cd7wuWhyJFlZzwc+YsM UtMtqtnn1XbwhfqO1tyAwbtk9EaHWkToLV5e0LYMPcFSbLKenn/xt0RBvG2pepkRBJg5 kVug== 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:in-reply-to :references; bh=W5kSPSMkBLe3on5gFApAHXIVGAp4L6pHuUT946Qc+0g=; b=g+Fc6r6C4F8NBU2I9iFkn5dfNXqdGfS1JXw2D5SlHrpnhs013AqAJ+6c48g/NRWES7 81GxpMDJU25NA30pmL8Q3viB5gCPfIX00Z9P85VqpSQ7sw9YyPlQEGTYBGJZErPmXsmb vCrf5s1yuRgHziBrXeRKyuAPHKPvrqrg87KJkq4E22f9rnVuOmQ1mJmjtSHZ+ZcI+XKW F6O1qy+JEmNLfTIZHLEZ3Di3SsqYXIRjNekpB6EpAkYLoThX1X1fy5UKShfIM2Uk1fW2 pAXnGQdSrfF9igFDyzWmw70shLfJ/0ImjXyRJIV/AysmUNXw3k3rOFt1TiZpiptITaR1 QylA== X-Gm-Message-State: AMke39lf1lsj7NUqnt7kbxyh+fBeEDuF8EMu1dzx5zrBUK4JPbkc0xUImornGwuRqB42Dg== X-Received: by 10.223.160.132 with SMTP id m4mr4885543wrm.116.1487292710866; Thu, 16 Feb 2017 16:51:50 -0800 (PST) Received: from lean.local (bzq-79-181-80-34.red.bezeqint.net. [79.181.80.34]) by smtp.gmail.com with ESMTPSA id u184sm123712wmb.29.2017.02.16.16.51.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Feb 2017 16:51:50 -0800 (PST) From: Nir Soffer To: qemu-devel@nongnu.org Date: Fri, 17 Feb 2017 02:51:27 +0200 Message-Id: <20170217005127.21010-4-nirsof@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170217005127.21010-1-nirsof@gmail.com> References: <20170217005127.21010-1-nirsof@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c0c::243 Subject: [Qemu-devel] [PATCH 3/3] qemu-img: Improve documentation for PREALLOC_MODE_FALLOC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Nir Soffer , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Now that we are truncating the file in both PREALLOC_MODE_FULL and PREALLOC_MODE_OFF, not truncating in PREALLOC_MODE_FALLOC looks odd. Add a comment explaining why we do not truncate in this case. Signed-off-by: Nir Soffer --- block/file-posix.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index d24e34b..20a261f 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1594,9 +1594,14 @@ static int raw_create(const char *filename, QemuOpts *opts, Error **errp) switch (prealloc) { #ifdef CONFIG_POSIX_FALLOCATE case PREALLOC_MODE_FALLOC: - /* posix_fallocate() doesn't set errno. */ + /* + * Truncating before posix_fallocate() makes it about twice slower on + * file systems that do not support fallocate(), trying to check if a + * block is allocated before allocating it. + */ result = -posix_fallocate(fd, 0, total_size); if (result != 0) { + /* posix_fallocate() doesn't set errno. */ error_setg_errno(errp, -result, "Could not preallocate data for the new file"); }