From patchwork Tue Nov 1 12:51:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 689861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t7WTd4Q6bz9t0q for ; Tue, 1 Nov 2016 23:57:09 +1100 (AEDT) Received: from localhost ([::1]:47686 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1Yck-0000dQ-Qs for incoming@patchwork.ozlabs.org; Tue, 01 Nov 2016 08:57:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c1YXJ-0004Gl-4l for qemu-devel@nongnu.org; Tue, 01 Nov 2016 08:51:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c1YXI-0003jv-6r for qemu-devel@nongnu.org; Tue, 01 Nov 2016 08:51:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50296) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c1YXA-0003gY-C6; Tue, 01 Nov 2016 08:51:20 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 8D30F61B95; Tue, 1 Nov 2016 12:51:19 +0000 (UTC) Received: from localhost (ovpn-112-28.phx2.redhat.com [10.3.112.28]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uA1CpIbb011867 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 1 Nov 2016 08:51:19 -0400 From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 1 Nov 2016 08:51:00 -0400 Message-Id: <1478004671-19154-4-git-send-email-jcody@redhat.com> In-Reply-To: <1478004671-19154-1-git-send-email-jcody@redhat.com> References: <1478004671-19154-1-git-send-email-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 01 Nov 2016 12:51:19 +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] [PULL v2 03/14] 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: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 Message-id: 00370bce5c98140d6c56ad5145635ec6551265cc.1475876377.git.jcody@redhat.com Signed-off-by: Jeff Cody --- block/gluster.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index af76d7d..1735d12 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -668,7 +668,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) { @@ -678,6 +681,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); } @@ -1178,12 +1183,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 @@ -1247,6 +1254,10 @@ static int find_allocation(BlockDriverState *bs, off_t start, /* D1 and H1 */ return -EBUSY; +#endif + +exit: + return -ENOTSUP; } /*