From nobody Sun Feb 8 18:29:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1591083817; cv=none; d=zohomail.com; s=zohoarc; b=XhnymDbYXlhqs1H7va21fdVRJTrUy0QhyhEf1UQX8oVSYXQqo8wA25w6dDsECzZb+qIM7pNOpUNhrtD7iTt7ZAaXfTM8zdadGeyGuwXRmwWHiXMGlBR7JR/jV9q1EYaDxdF+lSjpWHOprKqCHREFB1nQNrGVosz+AncrM3+G/Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1591083817; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bFt0WsKi9YCNdM7hkyu3tuuPZYw4VooHNM+xovmMUSU=; b=XzEcq5laCxUM9C2Us1O4+LLqjpCjnFs9VjXE5ULgjdyCNsWKrP94rRLwMdt2UVJat/OcSXd2kZ5tLAdM+2icHIzIJvBWIbiVTeTMdvpTTkOG2MJpdxOZAsvzmCNPdFnteHSYlUteiZNWznB/k0B+vOM1SPZ8Bq7oyNlLe0IpyfE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159108381781267.56916875145248; Tue, 2 Jun 2020 00:43:37 -0700 (PDT) Received: from localhost ([::1]:54492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jg1a8-0005Jn-9h for importer@patchew.org; Tue, 02 Jun 2020 03:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jg1ZB-0003lZ-9j for qemu-devel@nongnu.org; Tue, 02 Jun 2020 03:42:33 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43724) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jg1ZA-0000Ym-LY for qemu-devel@nongnu.org; Tue, 02 Jun 2020 03:42:33 -0400 Received: by mail-wr1-x442.google.com with SMTP id l10so2269927wrr.10 for ; Tue, 02 Jun 2020 00:42:32 -0700 (PDT) Received: from t440p.suse.asia (60-251-47-115.HINET-IP.hinet.net. [60.251.47.115]) by smtp.gmail.com with ESMTPSA id w3sm2294518wmg.44.2020.06.02.00.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2020 00:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bFt0WsKi9YCNdM7hkyu3tuuPZYw4VooHNM+xovmMUSU=; b=UjHXT5b+mAHucrJN+ZcFcwlt4a7/rA+EDtXusPHC+3wo7dFu0POHseQ/H2tSunibjN eg6As0H9nuVDoyV6r2L0lx69QjH/mC87krqnX4yMN2YU/688/F8hVL17UJdH8C8zO5NO DTvZTClUy1Lw+Af0bI++6Zpxelkm8Z+YXQQgAEkWV/Ij7lKU16ls6/Yh10ge+qU9IjhF g5x+3fbZq25ChZNqGN8C1JV456pfzIaDpFaQExtMFASuw7yUCrNJIB2h6d0OA9Nps+VZ 0ma2bmy9F55JEE78QnIQq2thqOGOnlBqUjNUDZJlWZ7/YyuTd12cAbwgWRvbM12P/mx0 /5iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=bFt0WsKi9YCNdM7hkyu3tuuPZYw4VooHNM+xovmMUSU=; b=Irjf4pJFYbrDcQKYigU5rHWo9gi3Rlv2Afg2F3pcRE7uIFFIujWN7hxo0+3+ppPKL2 eC1xbsSJfRpucJz21ouSC5x/tRAIV8RoVmt3PdKSq3oiCIuNM4/71rf2BNQzh0SntO41 VmhLphLHBqQ+A4T1IbYTHLwbdGWUun0uaebX7bXkSjX9H6YtIQJNQmSl5hOVHHG3j5GQ c6iCW4NA+Emd4+Qol+6hLmgKWBsPBDzYMIegOK+UUwV6UGCXHpc3N0ppRcO2dTWsArHJ 3TSryPCCe2HzDqg48Nu7kf795kBulAVNfXHrvZG7fGiDgC8bi69WB7be5cgSJzBSvo3S MbrQ== X-Gm-Message-State: AOAM5324mg2R1b6RTRRYrGZbpeb6+yFTTRWxYCcH++X7mBIfklaeM4U3 SPEjz5D+xSEypFzx2K8Pj5OOLz+jZwE= X-Google-Smtp-Source: ABdhPJxicM6rpPP9PklDqcsi02NSQb1Yq9AysFhDVJeVZg4YJVUxyEu056EqBOTCBgwNAIRJ/vZOdw== X-Received: by 2002:adf:f389:: with SMTP id m9mr23676786wro.195.1591083751265; Tue, 02 Jun 2020 00:42:31 -0700 (PDT) From: Lin Ma To: qemu-devel@nongnu.org Subject: [PATCH 1/4] block: Add bdrv_co_get_lba_status Date: Tue, 2 Jun 2020 15:41:58 +0800 Message-Id: <20200602074201.10879-2-lma@suse.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200602074201.10879-1-lma@suse.com> References: <20200602074201.10879-1-lma@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=morecache@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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: pbonzini@redhat.com, stefanha@redhat.com, Lin Ma Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The get lba status wrapper based on the bdrv_block_status. The following patches will add GET LBA STATUS 16 support for scsi emulation layer. Signed-off-by: Lin Ma --- block/io.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/block/io.c b/block/io.c index 121ce17a49..dacc3c2471 100644 --- a/block/io.c +++ b/block/io.c @@ -2186,6 +2186,49 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *ch= ild, int64_t offset, BDRV_REQ_ZERO_WRITE | flags); } =20 +int coroutine_fn +bdrv_co_get_lba_status(BdrvChild *child, int64_t offset, int64_t bytes, + uint32_t *num_blocks, uint32_t *is_deallocated) +{ + BlockDriverState *bs =3D child->bs; + int ret; + int64_t target_size, count =3D 0; + bool first =3D true; + uint8_t wanted_bit1 =3D 0; + + target_size =3D bdrv_getlength(bs); + if (target_size < 0) { + return -EIO; + } + + if (offset < 0 || bytes < 0) { + return -EIO; + } + + for ( ; offset <=3D target_size - bytes; offset +=3D count) { + ret =3D bdrv_block_status(bs, offset, bytes, &count, NULL, NULL); + if (ret < 0) { + goto out; + } + if (first) { + if (ret & BDRV_BLOCK_ZERO) { + wanted_bit1 =3D BDRV_BLOCK_ZERO >> 1;; + *is_deallocated =3D 1; + } else { + wanted_bit1 =3D 0; + } + first =3D false; + } + if ((ret & BDRV_BLOCK_ZERO) >> 1 =3D=3D wanted_bit1) { + (*num_blocks)++; + } else { + break; + } + } +out: + return ret; +} + /* * Flush ALL BDSes regardless of if they are reachable via a BlkBackend or= not. */ --=20 2.24.0