From patchwork Fri Oct 7 21:48:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9367707 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 92C1660487 for ; Fri, 7 Oct 2016 21:48:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 884752983E for ; Fri, 7 Oct 2016 21:48:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B54A29845; Fri, 7 Oct 2016 21:48:41 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 0A1202983E for ; Fri, 7 Oct 2016 21:48:40 +0000 (UTC) Received: from localhost ([::1]:38509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsd0Q-0005iD-8V for patchwork-qemu-devel@patchwork.kernel.org; Fri, 07 Oct 2016 17:48:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsd0B-0005gq-KE for qemu-devel@nongnu.org; Fri, 07 Oct 2016 17:48:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsd09-00020P-M1 for qemu-devel@nongnu.org; Fri, 07 Oct 2016 17:48:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34732) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsd03-0001wR-Nd; Fri, 07 Oct 2016 17:48:15 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1EE9C04B958; Fri, 7 Oct 2016 21:48:14 +0000 (UTC) Received: from localhost (ovpn-112-5.phx2.redhat.com [10.3.112.5]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u97LmDgZ000545 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 7 Oct 2016 17:48:14 -0400 From: Jeff Cody To: qemu-devel@nongnu.org Date: Fri, 7 Oct 2016 17:48:12 -0400 Message-Id: <00370bce5c98140d6c56ad5145635ec6551265cc.1475876377.git.jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 07 Oct 2016 21:48:14 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/1] block: add gluster ifdef guard checks for SEEK_DATA/SEEK_HOLE support 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: pkalever@redhat.com, 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 Add checks to see if the system compiling QEMU has support for SEEK_HOLE/SEEK_DATA. If the system does not, we will flag that seek data is unsupported in gluster. Note: this is not a check on whether the gluster server itself supports SEEK_DATA (that is already done during runtime), but rather if the compilation environment supports SEEK_DATA. Reviewed-by: Eric Blake Signed-off-by: Jeff Cody Tested-by: Eric Blake --- Changes from v1: - Fixed undefined variable warnings by moving variable declarations - Add a bit more whitespace to improve readability block/gluster.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index e7bd13c..4796bcb 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -672,7 +672,10 @@ static void qemu_gluster_parse_flags(int bdrv_flags, int *open_flags) */ static bool qemu_gluster_test_seek(struct glfs_fd *fd) { - off_t ret, eof; + off_t ret = 0; + +#if defined SEEK_HOLE && defined SEEK_DATA + off_t eof; eof = glfs_lseek(fd, 0, SEEK_END); if (eof < 0) { @@ -682,6 +685,8 @@ static bool qemu_gluster_test_seek(struct glfs_fd *fd) /* this should always fail with ENXIO if SEEK_DATA is supported */ ret = glfs_lseek(fd, eof, SEEK_DATA); +#endif + return (ret < 0) && (errno == ENXIO); } @@ -1182,12 +1187,14 @@ static int find_allocation(BlockDriverState *bs, off_t start, off_t *data, off_t *hole) { BDRVGlusterState *s = bs->opaque; - off_t offs; if (!s->supports_seek_data) { - return -ENOTSUP; + goto exit; } +#if defined SEEK_HOLE && defined SEEK_DATA + off_t offs; + /* * SEEK_DATA cases: * D1. offs == start: start is in data @@ -1251,6 +1258,10 @@ static int find_allocation(BlockDriverState *bs, off_t start, /* D1 and H1 */ return -EBUSY; +#endif + +exit: + return -ENOTSUP; } /*