From patchwork Fri Jan 8 18:16:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8806FC433E0 for ; Fri, 8 Jan 2021 18:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E85E23A6A for ; Fri, 8 Jan 2021 18:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728603AbhAHSR2 (ORCPT ); Fri, 8 Jan 2021 13:17:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbhAHSR1 (ORCPT ); Fri, 8 Jan 2021 13:17:27 -0500 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7235FC061381 for ; Fri, 8 Jan 2021 10:16:47 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id f26so9302361qka.0 for ; Fri, 08 Jan 2021 10:16:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=mL09HQd5W+44PwPcuaBUp7pjSzo50ABFARlQMrsKfh8=; b=FLFLhMQzBPPvKaT5GIlnNjOfyA63KhxIZAFEPPBelKbzocrsjFB/WNoCty3HBCbyYw kaEbnh79Jgrj4KtGN0tCXpV6R3GuiGzQ7cJO99bpAsfUYMDMGt7pa8Vo5joTyOuRxm0b NmJCiownA0miTkJ1k8t6fJ+xBiRWUa0hw4+UOFpNw4earbK2lOjY0CssstSTwUQM6ncC MfZSQzmBabtEHjaXGz9q0AE/g9nuL6SbgdD2OoN+3oYhpCTB2RSkcd9+rfF52Gx/99cT /7ac3hmT8Iu8NOHghR9PxhSeMkvl4GtPGPQ7liP4YDUfkN3VXDdz0yz/hI2uKsxrlA+D pTPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mL09HQd5W+44PwPcuaBUp7pjSzo50ABFARlQMrsKfh8=; b=uoTLxFD158DQuh08e0lKgu5XYVnUPvmgd3mmp7PHB7gXOoZ6z9PKx66yIdqri/lHCm PcCEwAbMkEb/M8Ur1eZCHoEBP4W5ro9Uk9ypYM9ehHZtH5rUQGfjVrL3rOyg0vdnp8OT X3PhcyCuJou2in3wDE30uvWetoNitSgnIEyIF3lU97MH3Kqwj23T8o4qb3C5BTiLzIK4 N+qhnVVWguJOMapUkj6kttyGmGTR2fS6au6KJbEa9WhZVzUxiQrJ9vxEklG+KCaKFsSt FNxb4SZO9goOOqvTy+vL2MHF9VQp2yPgwqZ1gCJJNhMTgoWJovfhkaXAPJDEd4UNuFSa qtpQ== X-Gm-Message-State: AOAM531Q1Y7qdw0LU68RvBrtYWNEWjNkw73ahm1gKyhG99jJl9jh26lH /XS7nG7b7KxNgYN33FRR3QOpk4st756pfA== X-Google-Smtp-Source: ABdhPJzXxS7c00uQGqN6UUpJmnJ2B4RPkJMksIUpN2C1jbO8KNYYChpVegsrbqe5SbO9plfB0F/M6A== X-Received: by 2002:a05:620a:13a6:: with SMTP id m6mr5027660qki.319.1610129806338; Fri, 08 Jan 2021 10:16:46 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id c139sm5231845qke.24.2021.01.08.10.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:16:45 -0800 (PST) Date: Fri, 8 Jan 2021 13:16:43 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 01/20] pack-revindex: introduce a new API Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the next several patches, we will prepare for loading a reverse index either in memory, or from a yet-to-be-introduced on-disk format. To do that, we'll introduce an API that avoids the caller explicitly indexing the revindex pointer in the packed_git structure. There are four ways to interact with the reverse index. Accordingly, four functions will be exported from 'pack-revindex.h' by the time that the existing API is removed. A caller may: 1. Load the pack's reverse index. This involves opening up the index, generating an array, and then sorting it. Since opening the index can fail, this function ('load_pack_revindex()') returns an int. Accordingly, it takes only a single argument: the 'struct packed_git' the caller wants to build a reverse index for. This function is well-suited for both the current and new API. Callers will have to continue to open the reverse index explicitly, but this function will eventually learn how to detect and load a reverse index from the on-disk format, if one exists. Otherwise, it will fallback to generating one in memory from scratch. 2. Convert a pack position into an offset. This operation is now called `pack_pos_to_offset()`. It takes a pack and a position, and returns the corresponding off_t. 3. Convert a pack position into an index position. Same as above; this takes a pack and a position, and returns a uint32_t. This operation is known as `pack_pos_to_index()`. 4. Find the pack position for a given offset. This operation is now known as `offset_to_pack_pos()`. It takes a pack, an offset, and a pointer to a uint32_t where the position is written, if an object exists at that offset. Otherwise, -1 is returned to indicate failure. Unlike some of the callers that used to access '->offset' and '->nr' directly, the error checking around this call is somewhat more robust. This is important since callers can pass an offset which does not contain an object. This will become important in a subsequent patch where a caller which does not but could check the return value treats the signed `-1` from `find_revindex_position()` as an index into the 'revindex' array. Signed-off-by: Taylor Blau --- pack-revindex.c | 32 ++++++++++++++++++++++++++++++++ pack-revindex.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/pack-revindex.c b/pack-revindex.c index ecdde39cf4..6d86a85208 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -203,3 +203,35 @@ struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs) return p->revindex + pos; } + +int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos) +{ + int ret; + + if (load_pack_revindex(p) < 0) + return -1; + + ret = find_revindex_position(p, ofs); + if (ret < 0) + return -1; + *pos = ret; + return 0; +} + +uint32_t pack_pos_to_index(struct packed_git *p, uint32_t pos) +{ + if (!p->revindex) + BUG("pack_pos_to_index: reverse index not yet loaded"); + if (pos >= p->num_objects) + BUG("pack_pos_to_index: out-of-bounds object at %"PRIu32, pos); + return p->revindex[pos].nr; +} + +off_t pack_pos_to_offset(struct packed_git *p, uint32_t pos) +{ + if (!p->revindex) + BUG("pack_pos_to_index: reverse index not yet loaded"); + if (pos > p->num_objects) + BUG("pack_pos_to_offset: out-of-bounds object at %"PRIu32, pos); + return p->revindex[pos].offset; +} diff --git a/pack-revindex.h b/pack-revindex.h index 848331d5d6..256c0a9106 100644 --- a/pack-revindex.h +++ b/pack-revindex.h @@ -13,4 +13,8 @@ int find_revindex_position(struct packed_git *p, off_t ofs); struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs); +int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos); +uint32_t pack_pos_to_index(struct packed_git *p, uint32_t pos); +off_t pack_pos_to_offset(struct packed_git *p, uint32_t pos); + #endif From patchwork Fri Jan 8 18:16:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A909DC433DB for ; Fri, 8 Jan 2021 18:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6939F23A75 for ; Fri, 8 Jan 2021 18:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728611AbhAHSRe (ORCPT ); Fri, 8 Jan 2021 13:17:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbhAHSRc (ORCPT ); Fri, 8 Jan 2021 13:17:32 -0500 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44707C0612EA for ; Fri, 8 Jan 2021 10:16:52 -0800 (PST) Received: by mail-qv1-xf31.google.com with SMTP id p5so4712751qvs.7 for ; Fri, 08 Jan 2021 10:16:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=hIcEAq97ikHbEAiV58Hl3iJqqlyUqS4d3wqSJUqHQHI=; b=JjKwI1BjkHOzwMAq+a1kkPHiWr7dCjeO8jLWm8FKidR3R0WePU+DtvruePoiYj8mDL KWuY6iuL8ZGnMHdQ4uLhDxQdVzJJVqyqdIVnXXvhJWUMQX5dAawdYNyM9bh1dyo6e0tq i97kBe358IeBMICIKH/0oq/to6oe0PKfuaEU7Y4XZ8zw3mfbkeLeN0pGIIgJ3kee41AG V9DWE07AwWGU07cqyaH+c/ZaBVNiBoOUsNbPK3S0EY+CYB7m/TE371ZZ+JpEhqHzlPI3 T+bNMtbMNum/ZSc/g5NMc3z75+I53e3tiTvjZ4t88OtXH8zvx74pmo9uMXiquslBVTLn 4MLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hIcEAq97ikHbEAiV58Hl3iJqqlyUqS4d3wqSJUqHQHI=; b=qLC/xA3NbcikYKiqr6YoD91URsv1o9jHX5tYx7qdT0aytkPS34F21G/xH2FmvJNfAF aWwYfWW01f26PtHiJ4HiEk4qGO6RS+1mIkxJlEvEC3nlmtlWuXcY/qG9En44z+ftroIb DRsftQsQd6uGiAs7qMSfKya3FgeA5ajxUjthRt9/s3bTyv2SadXAIiY1ltnmJNV75bF4 nZqEUxpMls3NePxm2RV5wWC/KQGk1ZKHdDusr/PpX6ysvDiIQ7ETEx/GFTgqEPT3tbRV CwnPFf3od0exzOQY4fs42GNN7fNDoagAgRcnG0VlBOHj+THiV+e0igwS4j85iPGwzuC/ wxkw== X-Gm-Message-State: AOAM531urKgASB8U8WjJUWS4EiXsNCb4EtxgtCk50c2srb2nbi+zt1vC l8eNpNiIuk9HKBOpkzY7ajxCPxEmgeQ/sQ== X-Google-Smtp-Source: ABdhPJxR6fiO1x542+CaB3feSaXicmINF/wYS2cIPMoDbGSpeai8esiuKdqIBBxWOIwymomEC0ui7Q== X-Received: by 2002:a0c:a789:: with SMTP id v9mr4561028qva.41.1610129811297; Fri, 08 Jan 2021 10:16:51 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id t5sm4894051qte.20.2021.01.08.10.16.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:16:50 -0800 (PST) Date: Fri, 8 Jan 2021 13:16:48 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 02/20] write_reuse_object(): convert to new revindex API Message-ID: <00668523e1cd860f6de08dd7c5a2a54edc08b7b6.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org First replace 'find_pack_revindex()' with its replacement 'offset_to_pack_pos()'. This prevents any bogus OFS_DELTA that may make its way through until 'write_reuse_object()' from causing a bad memory read (if 'revidx' is 'NULL') Next, replace a direct access of '->nr' with the wrapper function 'pack_pos_to_index()'. Signed-off-by: Taylor Blau --- builtin/pack-objects.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 2a00358f34..03d25db442 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -419,7 +419,7 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry, { struct packed_git *p = IN_PACK(entry); struct pack_window *w_curs = NULL; - struct revindex_entry *revidx; + uint32_t pos; off_t offset; enum object_type type = oe_type(entry); off_t datalen; @@ -436,10 +436,13 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry, type, entry_size); offset = entry->in_pack_offset; - revidx = find_pack_revindex(p, offset); - datalen = revidx[1].offset - offset; + if (offset_to_pack_pos(p, offset, &pos) < 0) + die(_("write_reuse_object: could not locate %s"), + oid_to_hex(&entry->idx.oid)); + datalen = pack_pos_to_offset(p, pos + 1) - offset; if (!pack_to_stdout && p->index_version > 1 && - check_pack_crc(p, &w_curs, offset, datalen, revidx->nr)) { + check_pack_crc(p, &w_curs, offset, datalen, + pack_pos_to_index(p, pos))) { error(_("bad packed object CRC for %s"), oid_to_hex(&entry->idx.oid)); unuse_pack(&w_curs); From patchwork Fri Jan 8 18:16:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAE9BC433E6 for ; Fri, 8 Jan 2021 18:17:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E2F723A77 for ; Fri, 8 Jan 2021 18:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728620AbhAHSRg (ORCPT ); Fri, 8 Jan 2021 13:17:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbhAHSRg (ORCPT ); Fri, 8 Jan 2021 13:17:36 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EDBCC0612FD for ; Fri, 8 Jan 2021 10:16:56 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id 2so7139638qtt.10 for ; Fri, 08 Jan 2021 10:16:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UP73oMI7bhb0Pt6RrRRL5A/CykLwrQAxYltzzm+s29k=; b=xqIo1rea/81RUIBivrX2i/Ie4DHaeBnKEUdHI1Ict7P5D8bBzuANFkc3c4YCq2ua99 Cr1r7l0PdLyVwLTKYQwIYWK074LGPg2o3134HzD8APvC6HmnOIPAjfBAwVDj7IO+y9Cz anZ03EczkGM5ukUS0hx7R3ElY3A+L0TNcnJZM+Vf8Lmcth+tpqY//bZ8UXActQQcihBG DHKaxnUuB+j/7Up7yTo7IN5AZCg6QjmTeiP7Vk9BcOO9pLjGc2fepy+X6EeVXwGELBTX oJoQ0Jpg7sm/pAf1a6V87EJ+WcMyOlZoEq87VIgTNRBqKyVunj8MH8lQpMl9abxPUVCu IYHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=UP73oMI7bhb0Pt6RrRRL5A/CykLwrQAxYltzzm+s29k=; b=tdPiiKkqRNNt2Nb8V7LBTiNrJpR2jerl4O6hKLmiOYY9QweGeZ1mhpQ+RkAxU/j21K it9XRXGXSX7q4wjmyx0sI15Yg8eVuHmF74qnKQ3LWIlkAb//k1ACMIZkwnzmvNTgNzwS AOejgLe2UZJivppA1XtGmAIPYHnmEwlvclkVlFpugHo87jlrH77dGx0cQ0CUyhF2P+IY eJ6dAnkb6ObBvoDHu4OwIUrDD3ZueQqaXCJcwTreGL0BFY9AS/MtS91AHioDl1r/h0Fb eWbPmuIUGJ+F1LkyPmvvKewG6Fz6+MFNnjiJl6InQcIHnXwKPHOK65I2LatQmrsqYrnv Wpsw== X-Gm-Message-State: AOAM530ks5rQh7RYrLd1OAG7Ly4P2FHLC9tPKOaMO0p82A+JSwPhkwfs INkbCmkH+d1XyMJoYFMZzhWMn6WwwI3ASw== X-Google-Smtp-Source: ABdhPJykd27brv1uH43UWQfLy/MHGvBCp7AgDl2QjSbc6KQwlQk0xQDcpceMVM+jRbzgr42sEK/+Tg== X-Received: by 2002:ac8:1c38:: with SMTP id a53mr4818855qtk.70.1610129814876; Fri, 08 Jan 2021 10:16:54 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id 127sm5235003qkj.51.2021.01.08.10.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:16:54 -0800 (PST) Date: Fri, 8 Jan 2021 13:16:53 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 03/20] write_reused_pack_one(): convert to new revindex API Message-ID: <81ab11e18c0b00030019f9f521216f3469fdd744.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace direct revindex accesses with calls to 'pack_pos_to_offset()' and 'pack_pos_to_index()'. Signed-off-by: Taylor Blau --- builtin/pack-objects.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 03d25db442..ea7df9270f 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -866,8 +866,8 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out, enum object_type type; unsigned long size; - offset = reuse_packfile->revindex[pos].offset; - next = reuse_packfile->revindex[pos + 1].offset; + offset = pack_pos_to_offset(reuse_packfile, pos); + next = pack_pos_to_offset(reuse_packfile, pos + 1); record_reused_object(offset, offset - hashfile_total(out)); @@ -887,11 +887,15 @@ static void write_reused_pack_one(size_t pos, struct hashfile *out, /* Convert to REF_DELTA if we must... */ if (!allow_ofs_delta) { - int base_pos = find_revindex_position(reuse_packfile, base_offset); + uint32_t base_pos; struct object_id base_oid; + if (offset_to_pack_pos(reuse_packfile, base_offset, &base_pos) < 0) + die(_("expected object at offset %"PRIuMAX), + (uintmax_t)base_offset); + nth_packed_object_id(&base_oid, reuse_packfile, - reuse_packfile->revindex[base_pos].nr); + pack_pos_to_index(reuse_packfile, base_pos)); len = encode_in_pack_object_header(header, sizeof(header), OBJ_REF_DELTA, size); From patchwork Fri Jan 8 18:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C476C433E9 for ; Fri, 8 Jan 2021 18:17:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B23AB23A6A for ; Fri, 8 Jan 2021 18:17:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728629AbhAHSRk (ORCPT ); Fri, 8 Jan 2021 13:17:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbhAHSRk (ORCPT ); Fri, 8 Jan 2021 13:17:40 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECAB9C0612FE for ; Fri, 8 Jan 2021 10:16:59 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id q1so11154199ilt.6 for ; Fri, 08 Jan 2021 10:16:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2xW1uGJUcALzTWC2RA9kvuibHnE8HFT+26c0A+Pv9EQ=; b=Q+dToZtzKK+KPLZy8e6ljxFlQvdcrwAkmlgtaE1+4+H/HpRd58rMv8aq85njluywvN OnqIDAASsKxDbGmKNAzGI1F2LJ+jq5SnkXOiUoZdXGpLCFIEyt1eKKRxP93am5U8mOzN J+pZOk1e2KGqaNivAz58dMWpvx7khYfLG6sfTZ6Xldr4+F4S3L+PBLZERrrg7hgeFDlR AfRPxGOdHCxeeAX3YGXIrZ56XgaOurWyYnu9cVk7Ic10/28O9VL42efJjlWksO4kx8+D o3Lt8OhvGZly6WaNuG4TlRKAVHX8SeWL42jV1iO8nvYClvzCG5ib+bBh2nT0hRhp9dkA Z0ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2xW1uGJUcALzTWC2RA9kvuibHnE8HFT+26c0A+Pv9EQ=; b=iVftVFLhNx9MwJL6uVdTjhcKhL5vrTjmlnrxo662RFidM2NZGGpYbeZOfLGe1FvDs2 RUYYfGboD1hHQRbPrgefW8sz2O6FEbaa4jbysJjp/8ldoqB5MRaMYJ3OfXd5UD0WQCTu HsKSdq7eHFfIILa7/bk4bMeDN41UFBds/s7iJnewLDTV1rylh3g2k8aRNeriv4//Mwvw DAe05Rac2M9fA+ieIzZ/QpADcXs5GRQQ3Di0ZhpQwd7jNwOH2XfaCqEGKGX946MwMEDt BseHi8f2peSr8BzqVbNi7nDTZ7yNoHcvtXtfMs1doI/fSRqKXFqVK55j83x8cUGGGoNF NhjQ== X-Gm-Message-State: AOAM531d2Q11Cm3OhEQWj+QXEYnF1JOdUgXCTyoFu06mHni1VuA+/Frh DnlDXRJkGIXS6YYQ+ns5x4/hLGAVmY0tvA== X-Google-Smtp-Source: ABdhPJxJmQs95qkOoN/67WhkVIuAHSi2JZpY+vH7uK12DtjQ6+r4CHviUD4JngvarAShsokOkDI/Eg== X-Received: by 2002:a92:d8cc:: with SMTP id l12mr4851141ilo.225.1610129819161; Fri, 08 Jan 2021 10:16:59 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id s12sm7592881ilp.66.2021.01.08.10.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:16:58 -0800 (PST) Date: Fri, 8 Jan 2021 13:16:56 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 04/20] write_reused_pack_verbatim(): convert to new revindex API Message-ID: <14b35d01a062f2dfdd710718b659064042dc21d6.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace a direct access to the revindex array with 'pack_pos_to_offset()'. Signed-off-by: Taylor Blau --- builtin/pack-objects.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index ea7df9270f..4341bc27b4 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -948,7 +948,7 @@ static size_t write_reused_pack_verbatim(struct hashfile *out, off_t to_write; written = (pos * BITS_IN_EWORD); - to_write = reuse_packfile->revindex[written].offset + to_write = pack_pos_to_offset(reuse_packfile, written) - sizeof(struct pack_header); /* We're recording one chunk, not one object. */ From patchwork Fri Jan 8 18:17:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2773DC433E6 for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E028223A7C for ; Fri, 8 Jan 2021 18:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728663AbhAHSSE (ORCPT ); Fri, 8 Jan 2021 13:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727378AbhAHSSD (ORCPT ); Fri, 8 Jan 2021 13:18:03 -0500 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82574C0612FF for ; Fri, 8 Jan 2021 10:17:04 -0800 (PST) Received: by mail-qk1-x734.google.com with SMTP id d14so9206719qkc.13 for ; Fri, 08 Jan 2021 10:17:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=hW41lKfGSKRpSEd8Eam9htWLIgeE/xQG0bzdJaPFRss=; b=vKkYatt+vzPLHZsZpQ8aKYIW6fbnqfpE8CVL2T26lciODHBJIi6FOLYoepjhjB/JIk qapMn5/SBYw5th27CgROldjsNj9bvUnVwkgA0lWyZsFA0JOUAYoTqFpFFvhJIfCHqwIO zdKrGuRZHQOTpaD1ysbrQmkLk3Wge01jSN9B9+a4aR8Ej5gPCbSKvJTLLX8ow8WJFvBH gQcitupXlFGG9/HDyARliIgS3S0wEhDYP4II5AhSaMwkExOiYRf7Ng8wI8h6zLvzyIqC GO5HZFHDxAh1sNgJ2H0UzammfEKiuIVxt6bio7Q4Jm7B7rU5H+uudBLYPyyXrgsrruY1 ASTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=hW41lKfGSKRpSEd8Eam9htWLIgeE/xQG0bzdJaPFRss=; b=tHa7QzPIpH34O0cRxjs0QQP4HeZbfdk1s8rd+UIo9aNFA5CKFRQEEir0zwPZmYNgID LKlC9bvtFgbb4PNC+Dqp5RJ7RR/GwqEQBI6AapFDcTH6WUMczleLIXmQd+Bklgu2Rub3 +FczzdLYRGYdrObkHsQKmTb0Ma3YZrnplnsJIKi7yi8V41tSODP4Rit3TS0UclA7c+ot 0Dlz087IRgLciAs+aUfS6/C+EPoNxUtQ/nsYLA4VubzzPcVFS0m/MPFhp3cR8a8SaoHT CKhFulF18AezVRoW3nk4FfLj8tiyi/vb2Fq2Ck4NcH5+mxbnDXFCQDlafGNGue9IEHw9 dhkA== X-Gm-Message-State: AOAM530vSBv7Ao3D1WeFvp7BF8lkLJfkSnrnC2AXaITVgmW2D0aUxkY1 olNJWVzDNkD2tow7Ou+gJ5pKfmZtP988xQ== X-Google-Smtp-Source: ABdhPJxQK3AiDQAhz+awoClWI08Anb8hYj0Ilamm27JI5JcKWdb5RQziaXlSNzMss9tyt1gcv3kFRg== X-Received: by 2002:a37:9b04:: with SMTP id d4mr5104249qke.408.1610129823474; Fri, 08 Jan 2021 10:17:03 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id k141sm5167348qke.38.2021.01.08.10.17.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:02 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:00 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 05/20] check_object(): convert to new revindex API Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace direct accesses to the revindex with calls to 'offset_to_pack_pos()' and 'pack_pos_to_index()'. Since this caller already had some error checking (it can jump to the 'give_up' label if it encounters an error), we can easily check whether or not the provided offset points to an object in the given pack. This error checking existed prior to this patch, too, since the caller checks whether the return value from 'find_pack_revindex()' was NULL or not. Signed-off-by: Taylor Blau --- builtin/pack-objects.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 4341bc27b4..a193cdaf2f 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1813,11 +1813,11 @@ static void check_object(struct object_entry *entry, uint32_t object_index) goto give_up; } if (reuse_delta && !entry->preferred_base) { - struct revindex_entry *revidx; - revidx = find_pack_revindex(p, ofs); - if (!revidx) + uint32_t pos; + if (offset_to_pack_pos(p, ofs, &pos) < 0) goto give_up; - if (!nth_packed_object_id(&base_ref, p, revidx->nr)) + if (!nth_packed_object_id(&base_ref, p, + pack_pos_to_index(p, pos))) have_base = 1; } entry->in_pack_header_size = used + used_0; From patchwork Fri Jan 8 18:17:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06C0EC433E0 for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF6DA23A7B for ; Fri, 8 Jan 2021 18:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728668AbhAHSSE (ORCPT ); Fri, 8 Jan 2021 13:18:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbhAHSSD (ORCPT ); Fri, 8 Jan 2021 13:18:03 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F46AC06129C for ; Fri, 8 Jan 2021 10:17:08 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id bd6so4693296qvb.9 for ; Fri, 08 Jan 2021 10:17:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=eOAfwdgszWE6+IKgpnVgHm09fwsqu7Q3acsEhFfnltQ=; b=DkbhD5koMxgdchCsTxweoeCcl9z/t+2mCqeID8eBCcK5cByQpmkADQU/taXOaKRgeb fUJxRngF79V1TvmJDlgPGjAvdB6oBUDHxOqhl+1+MIepFaN4onUnY9verE+6aGLQYj2n 4Q2gSGb9Vc8g9XQNPCm7Pvibwu34kSITVLdHgrK/hkhxiiD2NxMF2IraXl4oNnDf0LPS 3siS2ZJ2r5rF6CIoC8sCG2fJjW0VQbsgqdVSGZj5MyyOOFsdzzcuQwK/kXZD7GxGuSAz e7uoXvBlS0SSXNBG9+qsyDSSHcJx3DTpYjipz2KPRpUvnU5Ds/pVj0wP20TM4Vwd9wpc xb4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eOAfwdgszWE6+IKgpnVgHm09fwsqu7Q3acsEhFfnltQ=; b=FLu9xtjDI10QG7xpO6hwU8kw/BRcJAWtY+L5sfVCh/NWmw1H6HXQ6piRNjg+kAdFsY mpuQobPg6ka2HHA2eNVD/7Z1etlPimTVqnZ0Z8gndf9Gslm4TKCZVF5VRGPjxXiQPExo RvcSXZhn4utG2LJtECG0VAqZutqNxFbaciYvZ8H3ejVqZMjubhA0LNiI98COFjmOjI5X ybbuXJ2GQ12/zteXx9tnMb4QeYaatBhffSerX0/VHYuZtIJKmx6IPjYN4Q1Y6nsy0Pw6 X0vRhlfv2uV8BCtetMOIhITf8bAtwxclTllzSig/29VoiOadQp/Y4LSKmuOPHG5mmGS+ J8hQ== X-Gm-Message-State: AOAM531v1vu2uPL3PzLsxJK5vO5eWxKYsw/Vo5SyeawK6Vx51xKux0JU F2tNkS6iLWJtnf9PF8ficfA8Ha0XVdiyig== X-Google-Smtp-Source: ABdhPJyVmY06Oq64yCdfppGQ6zH//mXvkIqL7uBp93s1/uSwzkjuwKw1FCqtPVplxxMg18rh/lN3XA== X-Received: by 2002:ad4:4e4d:: with SMTP id eb13mr7936518qvb.6.1610129827597; Fri, 08 Jan 2021 10:17:07 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id c20sm4755655qtj.29.2021.01.08.10.17.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:07 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:05 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 06/20] bitmap_position_packfile(): convert to new revindex API Message-ID: <3b170663dd57f33678cd24270d65153772043670.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace find_revindex_position() with its counterpart in the new API, offset_to_pack_pos(). Signed-off-by: Taylor Blau --- pack-bitmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index d88745fb02..d6861ddd4d 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -407,11 +407,14 @@ static inline int bitmap_position_extended(struct bitmap_index *bitmap_git, static inline int bitmap_position_packfile(struct bitmap_index *bitmap_git, const struct object_id *oid) { + uint32_t pos; off_t offset = find_pack_entry_one(oid->hash, bitmap_git->pack); if (!offset) return -1; - return find_revindex_position(bitmap_git->pack, offset); + if (offset_to_pack_pos(bitmap_git->pack, offset, &pos) < 0) + return -1; + return pos; } static int bitmap_position(struct bitmap_index *bitmap_git, From patchwork Fri Jan 8 18:17:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39ADDC43381 for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0A92923A7A for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728675AbhAHSSI (ORCPT ); Fri, 8 Jan 2021 13:18:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727439AbhAHSSI (ORCPT ); Fri, 8 Jan 2021 13:18:08 -0500 Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6FCC06129D for ; Fri, 8 Jan 2021 10:17:12 -0800 (PST) Received: by mail-il1-x132.google.com with SMTP id t3so7045291ilh.9 for ; Fri, 08 Jan 2021 10:17:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FpJPKToZQKcilGpyUbSieoLEDXY0+Q/REGAmXy1kLFQ=; b=v+eG1g2+2Vyn20ANgkXhQVkyGUHu0kjet88IGPeL2+lUnfXYHaJ7nJ3DG4r4TuJHPr jhOTETwYyLKr3uhzFpL3vHaL3stemwg4JO2639CmGHqISBJG981ICS+8V3jSW4aDkuXf sBGqvbnTqAuNga0qEI4ubvri/J1OMnY5EBpGk4s0RLKT103Xsmr6AcajzhG51r3I5FGD TY8eaE+geitJFKhj0mbXN1TWZ32a4jiC+P6vGKl2pu6KS7olqieV7mqqhos57M9IU1Mf /Owsg6W7XF9xb3pn5HHOtra73dtbwJ2ndARkUSam8WqUBp4RCHVbMZ0jvw0+t6Z7Juk9 VebA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FpJPKToZQKcilGpyUbSieoLEDXY0+Q/REGAmXy1kLFQ=; b=TjVKsYO4ML8xpDqgHM02arb8lTKdFxoxhS+HlEkucsjte2Snc9edvmh7TWFFaQ5J/M j8u7aUYHCM2Z2VJb6rILxai/dbRB63F5pR55EpG7e2/A8WNlp3G7kk0n6X2cu7oUQEfy wntoPo5nPlY/t2Oqz3ohMHdYkOGt2UUl4FrY+ECebdQSudhJs9VP08rHdKcnDubrwTWr eyjNbh63LGeVqAsTF9se0e69a6ouEYDkWaXFiUB6v3dg/WMz1vhSLdtRLQL3dwW9wtth 1KNtK7O5cUtRSNrJ2aWBIPGnXXYMLK+7d0YyPk/F5HACaimHm6UPKSG5g4gP6T0rzy5E szxg== X-Gm-Message-State: AOAM531ycf3lxCarBTWuQ18nlymMN0zDAu5+R5b1mSCUYNXdL2R8wN73 o2kjbOiJhBl+F+E5b0/5Nqr3OxVGyhvbmA== X-Google-Smtp-Source: ABdhPJw7uk5+v0xS6DzW0pO5SUc7uKSvfocghiEAiCoyJVdXO7dLgMfBcLkioFinvzXKJFwKDbRu7g== X-Received: by 2002:a92:1f87:: with SMTP id f7mr4859340ilf.0.1610129831889; Fri, 08 Jan 2021 10:17:11 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id r11sm7504985ilg.39.2021.01.08.10.17.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:11 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:09 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 07/20] show_objects_for_type(): convert to new revindex API Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Avoid storing the revindex entry directly, since this structure will soon be removed from the public interface. Instead, store the offset and index position by calling 'pack_pos_to_offset()' and 'pack_pos_to_index()', respectively. Signed-off-by: Taylor Blau --- pack-bitmap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index d6861ddd4d..80c57bde73 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -711,21 +711,22 @@ static void show_objects_for_type( for (offset = 0; offset < BITS_IN_EWORD; ++offset) { struct object_id oid; - struct revindex_entry *entry; - uint32_t hash = 0; + uint32_t hash = 0, n; + off_t ofs; if ((word >> offset) == 0) break; offset += ewah_bit_ctz64(word >> offset); - entry = &bitmap_git->pack->revindex[pos + offset]; - nth_packed_object_id(&oid, bitmap_git->pack, entry->nr); + n = pack_pos_to_index(bitmap_git->pack, pos + offset); + ofs = pack_pos_to_offset(bitmap_git->pack, pos + offset); + nth_packed_object_id(&oid, bitmap_git->pack, n); if (bitmap_git->hashes) - hash = get_be32(bitmap_git->hashes + entry->nr); + hash = get_be32(bitmap_git->hashes + n); - show_reach(&oid, object_type, 0, hash, bitmap_git->pack, entry->offset); + show_reach(&oid, object_type, 0, hash, bitmap_git->pack, ofs); } } } From patchwork Fri Jan 8 18:17:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B262C433E9 for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 284E523A7B for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728680AbhAHSSJ (ORCPT ); Fri, 8 Jan 2021 13:18:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728670AbhAHSSI (ORCPT ); Fri, 8 Jan 2021 13:18:08 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14876C06129E for ; Fri, 8 Jan 2021 10:17:17 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id h4so9278519qkk.4 for ; Fri, 08 Jan 2021 10:17:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GM9loUCar09yegUPLrtLkMMhYCJSKE0JxszIhPtP/ME=; b=ckjespQwaH1GlK5qo1BDhN/mSsMgXeK3tufwMcIUNqq+8WmG6iD97L8bSA0A6VDC3L h5ZFkXGgaSfQNnRjAXC91eJ3AyyAe9bW28roZ71/Erx0kuLkZjhQ0ZfFS9oOFCiO2NxY dUYsCblMVyR8O+rP+iMRNsAAEMWCZpwdrwy8RLEf2HVb39ZcdKI/Hyz3gjuVtz6ztBWH F2P6QpZ9LRjYAUHpNSH70bUzEtOSjY5+kFaOJ/pAebT/5WMGxsy2keYrkjKYrangx6WG CWDELBKZcSVzOAY2cVx9O+Y4E/QTa5GUQ4y351bOoqHNCZc55U2KVRBGayR+mgH4u1Fj 6/2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GM9loUCar09yegUPLrtLkMMhYCJSKE0JxszIhPtP/ME=; b=HQpPCskeaRKuszdoKDlJz4vQNXjWvu9ZtseXl81gF+BprX0hfd5cYLd1SuePAE3XQh roCNrm/UbsKp0cDkJuetcrG1jvUw9HEwSMMiaf6HcDKglvEhWiWYASxDDu3vKUxTfKHS H6+buLGsfsuYAZGwjwqmbl+FGV60gRm16pbBZTjufTLB+rY1hfKdNc8kkZ7oijRK2Tc8 FKVbhW9Cu5attZkD2TzEHyVzOstPEIB4+sIEZpKy450x6KhsEudc9gglWH++ITPSf+FO wPnzTulrYqP/sikPmMKFhDyn5WvML7fT3tGcoHMOqUMR1aV8/Gy/NA93wSM6Dnc/BB6j pJ9g== X-Gm-Message-State: AOAM533ZEWoIl1BNCjWgvEZIDnsOc52KE38N2Y1hlv+91ljdegP28dIC 1VHHpk7Cnjr3h/XREMedTTcL1GZZiWCHyw== X-Google-Smtp-Source: ABdhPJxk7OqJxhBqi8tNSiXWPsJqEGnSZ3zSUE2wYlGajT8MvYDbt9pWuWV3FeJnZ2PKkJ942RI0cg== X-Received: by 2002:a37:a24a:: with SMTP id l71mr5217325qke.161.1610129835876; Fri, 08 Jan 2021 10:17:15 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id d3sm5240381qka.36.2021.01.08.10.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:15 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:13 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 08/20] get_size_by_pos(): convert to new revindex API Message-ID: <541fe679f3e8e02617c4c9461b85fd310f55ccb6.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove another caller that holds onto a 'struct revindex_entry' by replacing the direct indexing with calls to 'pack_pos_to_offset()' and 'pack_pos_to_index()'. Signed-off-by: Taylor Blau --- pack-bitmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 80c57bde73..422505d7af 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -835,11 +835,11 @@ static unsigned long get_size_by_pos(struct bitmap_index *bitmap_git, oi.sizep = &size; if (pos < pack->num_objects) { - struct revindex_entry *entry = &pack->revindex[pos]; - if (packed_object_info(the_repository, pack, - entry->offset, &oi) < 0) { + off_t ofs = pack_pos_to_offset(pack, pos); + if (packed_object_info(the_repository, pack, ofs, &oi) < 0) { struct object_id oid; - nth_packed_object_id(&oid, pack, entry->nr); + nth_packed_object_id(&oid, pack, + pack_pos_to_index(pack, pos)); die(_("unable to get size of %s"), oid_to_hex(&oid)); } } else { From patchwork Fri Jan 8 18:17:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48367C43333 for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16B9C23A7B for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728736AbhAHSSV (ORCPT ); Fri, 8 Jan 2021 13:18:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728719AbhAHSSU (ORCPT ); Fri, 8 Jan 2021 13:18:20 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2EC9C06129F for ; Fri, 8 Jan 2021 10:17:20 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id et9so4699114qvb.10 for ; Fri, 08 Jan 2021 10:17:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=oBPwtvmJDVwAFmKX8JceYJERtX7VHhW3pjdbq3SSgHQ=; b=jjiQuuTTa/ZSnR42pLtw8GCotnwd+vk3GueVyqZgi/0rV6IQBEjy9PraLhNhaDJqLx +EkX80DAMkEZpZctaAR0sfp5bodda3RDx771Hv332xJ2VTMX/w4OUlpuLqamv4uklFXU O/dAQK6IBJ7IDWkhKeNyQCkkzs6wcXNM4AS5u55KNOJsOuVVh6mCagbbaQMunFjfq37q h3udhRwlmOWYjr1Z2h7YpxL8sS72n4LoJOsAGmUK/KnFqbS35KPcF83jaavC39sc027R XR4dOrXKjW75FeYj9e8yl0UYUzG0p1D/hARiwIyAAygnEzr+4CjJsh087UlYGR4Nt6Hs U1WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oBPwtvmJDVwAFmKX8JceYJERtX7VHhW3pjdbq3SSgHQ=; b=RDNHM1AMEGwLPZzRi/o+oMtKX7LAviwk+yQpmxBXMJ2IwAlJMCTHxnVJp6Q5vVxNU7 rIyGMUXk2MkIODiMvo7OVxoMcdAZUGqzTJ68E9oEMeS5xaCVqWhA5t8iNAMLSFKQuYM9 mmiFwe5dc0i9mTMMLc7dwkc75P9r/KI6dJtGli2olPh3nP3Jy75zilcEeZARA2URcvzy QIdPNVHGTsk8tPjOKAy197Xeg9Ndp4qzxuArUITB54Oh9O0mHLvmggzPr5sPWmKbQQHc ItymOXe8twrw2xRqneG2mThD/2ukbA9pJjvnC7svOLM7kXxdHevb0B+W89paAda9EpAD Akxg== X-Gm-Message-State: AOAM533fXU65M55hb8SfpWo1M9Fe0xm9oQcsq2aLB/ZG+7gR97UN9EP/ LXA9PdTgXZlH352UNfx+8oRhkw8V8s5QBA== X-Google-Smtp-Source: ABdhPJzwM5Ax+YZvy57TBctMtbM83klOzLXnQHzmP8GYIUOYh3POoXdFP9UzDBprCMKYutCZrRjSbg== X-Received: by 2002:a0c:c583:: with SMTP id a3mr4716509qvj.15.1610129839965; Fri, 08 Jan 2021 10:17:19 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id o29sm4842457qtl.7.2021.01.08.10.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:19 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:17 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 09/20] try_partial_reuse(): convert to new revindex API Message-ID: <54f4ad329f56808432549aa885f2847d5c9a8ac6.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove another instance of direct revindex manipulation by calling 'pack_pos_to_offset()' instead (the caller here does not care about the index position of the object at position 'pos'). Somewhat confusingly, the subsequent call to unpack_object_header() takes a pointer to &offset and then updates it with a new value. But, try_partial_reuse() cares about the offset of both the base's header and contents. The existing code made a copy of the offset field, and only addresses and manipulates one of them. Instead, store the return of pack_pos_to_offset twice: once in header and another in offset. Header will be left untouched, but offset will be addressed and modified by unpack_object_header(). Signed-off-by: Taylor Blau --- pack-bitmap.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 422505d7af..3f5cd4e77d 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1069,23 +1069,21 @@ static void try_partial_reuse(struct bitmap_index *bitmap_git, struct bitmap *reuse, struct pack_window **w_curs) { - struct revindex_entry *revidx; - off_t offset; + off_t offset, header; enum object_type type; unsigned long size; if (pos >= bitmap_git->pack->num_objects) return; /* not actually in the pack */ - revidx = &bitmap_git->pack->revindex[pos]; - offset = revidx->offset; + offset = header = pack_pos_to_offset(bitmap_git->pack, pos); type = unpack_object_header(bitmap_git->pack, w_curs, &offset, &size); if (type < 0) return; /* broken packfile, punt */ if (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA) { off_t base_offset; - int base_pos; + uint32_t base_pos; /* * Find the position of the base object so we can look it up @@ -1096,11 +1094,10 @@ static void try_partial_reuse(struct bitmap_index *bitmap_git, * more detail. */ base_offset = get_delta_base(bitmap_git->pack, w_curs, - &offset, type, revidx->offset); + &offset, type, header); if (!base_offset) return; - base_pos = find_revindex_position(bitmap_git->pack, base_offset); - if (base_pos < 0) + if (offset_to_pack_pos(bitmap_git->pack, base_offset, &base_pos) < 0) return; /* From patchwork Fri Jan 8 18:17:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E16C43332 for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA19C23A7A for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728733AbhAHSSV (ORCPT ); Fri, 8 Jan 2021 13:18:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728727AbhAHSSU (ORCPT ); Fri, 8 Jan 2021 13:18:20 -0500 Received: from mail-qv1-xf2c.google.com (mail-qv1-xf2c.google.com [IPv6:2607:f8b0:4864:20::f2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27A40C061380 for ; Fri, 8 Jan 2021 10:17:25 -0800 (PST) Received: by mail-qv1-xf2c.google.com with SMTP id h16so4699499qvu.8 for ; Fri, 08 Jan 2021 10:17:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=RFUmAYihgEn8U2ycrvgYAS4mVFzyah6mujmtOpaH3X4=; b=TLn7nm6snlOzbdPggwIlrSD5o6u/6wRBwPgcfa2jjDbnL95b4xHIquUtpSaRK92W4S wuw4DxsUX4ewePJK1p8//isAi3agHWAZD1c1hCJpoIgYf76pvAqakScTNTIvs/5PEgm/ RSI+nyH/7Y9uUaA8w8d4eo+zhZ+QkJAczXkyyKotThJ56koJj1liNEPCz8u5gbccd6sw LAkmZbyBpLBrO9/Mtv44SSCULm35X5LQndJ1r2gnS4qLfV9x2z9V96nO3p2eSYd2TY1Q GFZ6/MBI63pxkJ9KsvYS0exjqlTPM9EzSDbnGZyKP8Ye0dkke0YbPlUdfIFSFRd8DZZZ E0bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=RFUmAYihgEn8U2ycrvgYAS4mVFzyah6mujmtOpaH3X4=; b=d9yTGyU0ODbC8RITZH4af5YXuP9s6C2QSSE+VOHKT7pPMBmCA4lRrS4F36k1l0wCib vvHHYcH09ipX56Ll4qG8lLr7arP5UNQ6QnuAt3V0k9eA20VaPsVJlWfjO1T19TCdaAmS okWnO0UzBQNf7ZSAU/bsP+rS+L7KTxPkHH4VsSVBtBHTAs2p5MT7gFliTAvqNADIcPRS /pn+O1pORblZrRPZezkPYUUVHiq6GucexrpATomdNoK81dkmxMpSxc6KcCQCwv1H2qlx prQAaFjdOcasdXCx5cuN8IKdPhiWkniOIEh/UwYqgmG2aw+C6v8KrOJsuxUw5Ts7ZH2y kYfw== X-Gm-Message-State: AOAM532XHnbMVwpdhZz5NekZpa6sUJ29A2by6t1+9lyr6Ip/48CAdFbC uE/xlvMZ4Rvk+LtkI/1ZbBOYSpVaibnY/Q== X-Google-Smtp-Source: ABdhPJwRheSdvexf7SS4KqRaV4fME7WPHWcwTq+sS8JmlASbh/LmWtAnS947utx5TNrsGMaOrkQw0Q== X-Received: by 2002:a0c:bd2b:: with SMTP id m43mr4937665qvg.32.1610129844177; Fri, 08 Jan 2021 10:17:24 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id q27sm5079620qkj.131.2021.01.08.10.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:23 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:21 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 10/20] rebuild_existing_bitmaps(): convert to new revindex API Message-ID: <97eaa7b2d6d923da0dca6e96b890d4b85bf9d7d8.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove another instance of looking at the revindex directly by instead calling 'pack_pos_to_index()'. Unlike other patches, this caller only cares about the index position of each object in the loop. Signed-off-by: Taylor Blau --- pack-bitmap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pack-bitmap.c b/pack-bitmap.c index 3f5cd4e77d..24b9628dca 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1392,11 +1392,10 @@ uint32_t *create_bitmap_mapping(struct bitmap_index *bitmap_git, for (i = 0; i < num_objects; ++i) { struct object_id oid; - struct revindex_entry *entry; struct object_entry *oe; - entry = &bitmap_git->pack->revindex[i]; - nth_packed_object_id(&oid, bitmap_git->pack, entry->nr); + nth_packed_object_id(&oid, bitmap_git->pack, + pack_pos_to_index(bitmap_git->pack, i)); oe = packlist_find(mapping, &oid); if (oe) From patchwork Fri Jan 8 18:17:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9FE47C4332B for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D01B23A7B for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728712AbhAHSSR (ORCPT ); Fri, 8 Jan 2021 13:18:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728706AbhAHSSQ (ORCPT ); Fri, 8 Jan 2021 13:18:16 -0500 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 322E6C061381 for ; Fri, 8 Jan 2021 10:17:29 -0800 (PST) Received: by mail-io1-xd2b.google.com with SMTP id z5so10615643iob.11 for ; Fri, 08 Jan 2021 10:17:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=CpNdxqZGfiO4jb4DgI/7fB5wIx6DjqDt1SGCXFIuBIk=; b=Vxw71O1YG3FUVr+bZTPuOXpvumNUh7SYV0eH1Dy3wo94QZqQApn5CceWAzIFPbS6qG b0avSnlJTIXETv118xept30KcsYq11ZDndhoSOMCKrS2I9ZnlV2Lv+uEY6cR23E1A9/X ioIOUW6649061X89w6SkDiy24gSUPscgkOlJbOk1O3WZT4h/cTjmmY9HQILdlnmJS/o0 CkNmKySWgG/hwrVhDoshcxio4wl5A10JbSG61OlACOgYol8oPVpNA/RWtIHk+gYjeFtb 2E2Z+SQq0/xSCNab9EEdxOzCQVFuVv+cy1w+IZFsf8jYnN3cZonAzkHggWz0cjpXOM2M bEjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=CpNdxqZGfiO4jb4DgI/7fB5wIx6DjqDt1SGCXFIuBIk=; b=LMjZ1AsvI79ojwszKN8T6xuNNUprWtsHJmKuITpPp4dcXNiQKaoKv3Pn6QszIgF9Nu 6IB3TBkxRkEFYKGiIYA1czTzzOC8WE4sT5J8cb2CagbBZfPOJZVjK+seI6deXJoOpSv7 pCmFTUigGFuyQheWA2Z+gvXgmIa63c9C8lQ60C2UfGlF3Y7+Ee7jxNOQIZLjEPoAS5Vu hC6AALWH9H0vnmllVGsZyGiEBIPTefFmUKvADWfVdRqKfGDKbzqZ/248bZ+aNCZxguVi 5/ymUL3un8kiYSjCyJFhEQECjYz8//wx6phjxAG8J6sJdFw0Mhs43ypBtjB/Au1HjJhw F0FQ== X-Gm-Message-State: AOAM532CMTi77vDoo9CqVbs1njo+MBxW2FM+5V5ikc4mCfrm4vwpAqFr YYR2DXSLqNfRqzUUpQxG9zdmytTDSjQpjw== X-Google-Smtp-Source: ABdhPJw/O/9SjdbNT08D/AA5na8CFy+JCqU/2RtuF8ucljbuK4oQrRV+eu1WZYfTXmMCEFCdFP0aeQ== X-Received: by 2002:a02:a304:: with SMTP id q4mr4443410jai.97.1610129848374; Fri, 08 Jan 2021 10:17:28 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id r11sm7505245ilg.39.2021.01.08.10.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:27 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:25 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 11/20] get_delta_base_oid(): convert to new revindex API Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Replace direct accesses to the 'struct revindex' type with a call to 'pack_pos_to_index()'. Likewise drop the old-style 'find_pack_revindex()' with its replacement 'offset_to_pack_pos()' (while continuing to perform the same error checking). Signed-off-by: Taylor Blau --- packfile.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packfile.c b/packfile.c index 86f5c8dbf6..3e3f391949 100644 --- a/packfile.c +++ b/packfile.c @@ -1235,18 +1235,18 @@ static int get_delta_base_oid(struct packed_git *p, oidread(oid, base); return 0; } else if (type == OBJ_OFS_DELTA) { - struct revindex_entry *revidx; + uint32_t base_pos; off_t base_offset = get_delta_base(p, w_curs, &curpos, type, delta_obj_offset); if (!base_offset) return -1; - revidx = find_pack_revindex(p, base_offset); - if (!revidx) + if (offset_to_pack_pos(p, base_offset, &base_pos) < 0) return -1; - return nth_packed_object_id(oid, p, revidx->nr); + return nth_packed_object_id(oid, p, + pack_pos_to_index(p, base_pos)); } else return -1; } From patchwork Fri Jan 8 18:17:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71EDBC4332D for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4881F23A7A for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728716AbhAHSSR (ORCPT ); Fri, 8 Jan 2021 13:18:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728707AbhAHSSQ (ORCPT ); Fri, 8 Jan 2021 13:18:16 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C8EFC0612EA for ; Fri, 8 Jan 2021 10:17:34 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id p5so4713843qvs.7 for ; Fri, 08 Jan 2021 10:17:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=5SiY02Oy0Xb62PPHOJxVqcbNUHkVa6NVif34C1mP8AM=; b=yf3OskJKq8q0SZdSsvuRlHmIwblqOHBZy5l9trBEx76ZP50Tx/Uf/7S8UAZBKrrkJY hNI3iVaMBcmO5vhY0hd8oUu05wD0ArRdw0r1Te//qfxn+NUKOjNgKpyYCQxXHni7kEnG U2Mr5haCIQYK68I2ATEiFkhferr88Qb1AOkMGDxdDf6dyOFQEoWe9QHAdYR1HUQPZ5uR htAAnt8ML3u7u/roZcvu60lC6zAxWdRpAghEc1M1aOEgJIEM+2S/dhkDls0oS3V2bOHZ 6LOvzhSKK7NhiOVITG0gmm7O0ljH5xnMwLZxIsMEoxmsAxD2wxSixrd8JsgMHTO6Z5jz ChHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=5SiY02Oy0Xb62PPHOJxVqcbNUHkVa6NVif34C1mP8AM=; b=IYi77ugFr1AFxvZBoSkrUzbIWN6dREvPzrNyxWbLZ8edq7i8NJ6y7KPrbkxcYzlGj4 iM9wOhGUGDfxdErJs0zST5vQAw9zIgwgPdRwjfU3FpfR1FYyG5t//KOGoaB4EY+dIiLh 7qN/b4yBMRXoiTIvmUJu2Q5S0ekhqyLbQgpcASuwJV5GDPkqd0oVImlhP2iE9Anrly6S rRoS6QJaxTgmmja3iWAaM9UO/WmDPcPM3hNffD0nyDju6v8Iucw8+La+e1JvO5HWAP/J Li3Jf2ffbX5GnUN66LfZ5jDGW/1asicewMeF0LGCVAMjNGWHdb3HnvNXU3tw5zgWrwRn SfWA== X-Gm-Message-State: AOAM533rlHNum60fHuqAxx9/x/Boi+tYkX3G2d+SZskk0DoXQOmiACPD 0jN0bINU2Ts2ClqxNEBHPiDnxF/bw5E0Dw== X-Google-Smtp-Source: ABdhPJwiQyrCBro/ODlhP3akqJ4+NpkQlZjaOcioidRhrFM10NQxFntFyj51t7AQiNyQDpzf0uHdfQ== X-Received: by 2002:a0c:e84c:: with SMTP id l12mr8029818qvo.0.1610129852727; Fri, 08 Jan 2021 10:17:32 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id j30sm4849540qtl.43.2021.01.08.10.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:32 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:30 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 12/20] retry_bad_packed_offset(): convert to new revindex API Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Perform exactly the same conversion as in the previous commit to another caller within 'packfile.c'. Signed-off-by: Taylor Blau --- packfile.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packfile.c b/packfile.c index 3e3f391949..7c37f9ec5c 100644 --- a/packfile.c +++ b/packfile.c @@ -1256,12 +1256,11 @@ static int retry_bad_packed_offset(struct repository *r, off_t obj_offset) { int type; - struct revindex_entry *revidx; + uint32_t pos; struct object_id oid; - revidx = find_pack_revindex(p, obj_offset); - if (!revidx) + if (offset_to_pack_pos(p, obj_offset, &pos) < 0) return OBJ_BAD; - nth_packed_object_id(&oid, p, revidx->nr); + nth_packed_object_id(&oid, p, pack_pos_to_index(p, pos)); mark_bad_packed_object(p, oid.hash); type = oid_object_info(r, &oid, NULL); if (type <= OBJ_NONE) From patchwork Fri Jan 8 18:17:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D476C432C3 for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFBBC23A7C for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728741AbhAHSSW (ORCPT ); Fri, 8 Jan 2021 13:18:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728728AbhAHSSU (ORCPT ); Fri, 8 Jan 2021 13:18:20 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE5B7C0612FD for ; Fri, 8 Jan 2021 10:17:38 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id h4so9279686qkk.4 for ; Fri, 08 Jan 2021 10:17:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=r4lkHcEzjDWu67TnmEgApqdMZar61EkpRl4C7kmXzrk=; b=wi1bPYDYQX7KNh4WaX2zrWHlgSgHXLRRdREDnLqp13zKPewqk6fPrLIgwiU7v1hVVw d+XvDQu9wHjMh/9pfRyzfxXrNpxlcy207MG8hFpH0eYydfmxP0GqryrVOpdcavPRQDtq rh+gZL0k/AIT3RwUfc/Qy9qbisdKi3flVWlc50+K22Ah7UyA/W+I5jWzAUHeB+arECMA 1cpO8js/fs7SzdPNI00TDbYBcgm8Tk1A3OwzKmAx2uw+3PQe41IGHzP1F9ZZLS/df2+g /pf3BFVageNoW19JQQ0YRS6TmtDNqiwkKAGhHiDtGnb2tLOabn5auxFil2+G+RQKNzeg I0Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=r4lkHcEzjDWu67TnmEgApqdMZar61EkpRl4C7kmXzrk=; b=CjzKXmzeijbbXdGc4ltdQC1hU8p29mKiUozpe3eO8mhAJWrkjd7t426ahQI90GDxon MSv4kc7GoDon6DnG8eBQYPkCSl62hjkpXmtodytH+Bf2E6+40mpxsUgHuq0vKccSqWVy vqLhOTCpomSCeGjOoL14YdKUaDijravQ0x5txBhT2cG+HIhnNDkk2Lw/oz61llUzT0UE cWhV31ILzgBvmqy9uHMB9tPf33otQAfpRCWR2ma3RW/D9kv8tIs5l6mZRfz7xbpJ/2JD imL7Zv35wf1gSfLqx+Bbn96cS9876FbWzezIrIEgWRyh/HofgHs1WA139XsQu8mOBgkm ySNw== X-Gm-Message-State: AOAM533RtWjhx42dFB5raNSwlyoaKdHepIivvNU1KJdV/K9IFuacpHUi ct5dIL4G37puL0EBXA57K5dE881pos0zsQ== X-Google-Smtp-Source: ABdhPJwMlKyR20hRInU49gGgQy3o7/ZKesUoAYzPEx6bD9silpN5n9FJUm+LNOVBUo51Gg/pvtkZvQ== X-Received: by 2002:a05:620a:1467:: with SMTP id j7mr5091684qkl.266.1610129857742; Fri, 08 Jan 2021 10:17:37 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id 70sm5151871qkk.10.2021.01.08.10.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:36 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:34 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 13/20] packed_object_info(): convert to new revindex API Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Convert another call of 'find_pack_revindex()' to its replacement 'pack_pos_to_offset()'. Likewise: - Avoid manipulating `struct packed_git`'s `revindex` pointer directly by removing the pointer-as-array indexing. - Add an additional guard to check that the offset 'obj_offset()' points to a real object. This should be the case with well-behaved callers to 'packed_object_info()', but isn't guarenteed. Other blocks that fill in various other values from the 'struct object_info' request handle bad inputs by setting the type to 'OBJ_BAD' and jumping to 'out'. Do the same when given a bad offset here. The previous code would have segfaulted when given a bad 'obj_offset' value, since 'find_pack_revindex()' would return 'NULL', and then the line that fills 'oi->disk_sizep' would try to access 'NULL[1]' with a stride of 16 bytes (the width of 'struct revindex_entry)'. Signed-off-by: Taylor Blau --- packfile.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packfile.c b/packfile.c index 7c37f9ec5c..469c8d4f57 100644 --- a/packfile.c +++ b/packfile.c @@ -1537,8 +1537,13 @@ int packed_object_info(struct repository *r, struct packed_git *p, } if (oi->disk_sizep) { - struct revindex_entry *revidx = find_pack_revindex(p, obj_offset); - *oi->disk_sizep = revidx[1].offset - obj_offset; + uint32_t pos; + if (offset_to_pack_pos(p, obj_offset, &pos) < 0) { + type = OBJ_BAD; + goto out; + } + + *oi->disk_sizep = pack_pos_to_offset(p, pos + 1) - obj_offset; } if (oi->typep || oi->type_name) { From patchwork Fri Jan 8 18:17:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 644F7C43219 for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3736F23A7A for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728747AbhAHSSY (ORCPT ); Fri, 8 Jan 2021 13:18:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728726AbhAHSSX (ORCPT ); Fri, 8 Jan 2021 13:18:23 -0500 Received: from mail-io1-xd2a.google.com (mail-io1-xd2a.google.com [IPv6:2607:f8b0:4864:20::d2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16EE3C0612FE for ; Fri, 8 Jan 2021 10:17:43 -0800 (PST) Received: by mail-io1-xd2a.google.com with SMTP id e22so10099399iom.5 for ; Fri, 08 Jan 2021 10:17:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=0YLqogTG7EGmbcQlGe+sLIobSiAU164UujVh+FiSqhY=; b=0RVvCiYTMGUmvcB6J4yP2MTV8iLrvOYM2yb1MqA/k8UNsPal9Y2yrV+dBAGI2eLE0V 4jq9EeL7uCGleQUoSglA5cwiLlGVC8V2YjmibfqN5af9qPzqBqTs1OIMsowF/oFofoBE XlDzO2EU0AdOMf2qTLIshRxmVR94E9nYzxZD9KtjohK0CCSpOdZf31/w/KmFQECPp8ZQ sG/UNL5YoMXOddMkHWy2be07QBXCkTiJf57doi4ly+XbC3aaa0XG70q/H4xGC7LES5f/ 8DX6R/rDBy6CWJWuJdrJ7nL4mW70UCkIks9lFS/z7DbkAIzNMPKA0GLV25Jruq+ZQMIE mHLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=0YLqogTG7EGmbcQlGe+sLIobSiAU164UujVh+FiSqhY=; b=b2VgivkJa/knLFbHAyu4CH0aj8zqNjYCxg1I7c3yqKMVk5G3YcjSPsFr4zYD4LZGkS M2Mr/JPUqV1NAoLnNYhVAKrvD0RHsLl+6nwWHVjWrwINdqLqR4f1nBNIepDfXKJHYn3J 2rE0KG0pt3yC3YxqHeVib3R2QUW2d4aZoMwL9IEl8CrSWcbhGyRTJROIKcemmToAi02C YRtWigQ6V0VHB1oIx98YE8rx+3VUnKvRMwlPsvUv5Fo5oZdS3g4bSlaDWm2/WkGyJvDV OVqdUzWqqVq+GQM+yMhVQU+sFoOVYmYzVtJKPcOf+9weh5baVzMYEWaS2NxO0gmUrJnc dI9Q== X-Gm-Message-State: AOAM531Xh3uUzn/bp74x1DfezXWh+jAGBEMBH4gDoct0IgSrKr+S1K0b R5MYBF1Xcy2oCVC1da0GkYQsfbSsB+IJNg== X-Google-Smtp-Source: ABdhPJzP5eyYht2QxzeDlGfzAHrOjZrYDLNU6JuEwGKsEPhyTvfdMgFriwZ7meiI94HjoBaxpM9acg== X-Received: by 2002:a5e:de08:: with SMTP id e8mr6207576iok.203.1610129862155; Fri, 08 Jan 2021 10:17:42 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id w3sm7824072ilk.17.2021.01.08.10.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:41 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:39 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 14/20] unpack_entry(): convert to new revindex API Message-ID: <13c49ed40ca72b7ab50939244616f0a90b5bf7f6.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Remove direct manipulation of the 'struct revindex_entry' type as well as calls to the deprecated API in 'packfile.c:unpack_entry()'. Usual clean-up is performed (replacing '->nr' with calls to 'pack_pos_to_index()' and so on). Add an additional check to make sure that 'obj_offset()' points at a valid object. Signed-off-by: Taylor Blau --- packfile.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packfile.c b/packfile.c index 469c8d4f57..34467ea4a3 100644 --- a/packfile.c +++ b/packfile.c @@ -1692,11 +1692,19 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset, } if (do_check_packed_object_crc && p->index_version > 1) { - struct revindex_entry *revidx = find_pack_revindex(p, obj_offset); - off_t len = revidx[1].offset - obj_offset; - if (check_pack_crc(p, &w_curs, obj_offset, len, revidx->nr)) { + uint32_t pos, nr; + off_t len; + + if (offset_to_pack_pos(p, obj_offset, &pos) < 0) { + data = NULL; + goto out; + } + + len = pack_pos_to_offset(p, pos + 1) - obj_offset; + nr = pack_pos_to_index(p, pos); + if (check_pack_crc(p, &w_curs, obj_offset, len, nr)) { struct object_id oid; - nth_packed_object_id(&oid, p, revidx->nr); + nth_packed_object_id(&oid, p, nr); error("bad packed object CRC for %s", oid_to_hex(&oid)); mark_bad_packed_object(p, oid.hash); @@ -1779,11 +1787,11 @@ void *unpack_entry(struct repository *r, struct packed_git *p, off_t obj_offset, * This is costly but should happen only in the presence * of a corrupted pack, and is better than failing outright. */ - struct revindex_entry *revidx; + uint32_t pos; struct object_id base_oid; - revidx = find_pack_revindex(p, obj_offset); - if (revidx) { - nth_packed_object_id(&base_oid, p, revidx->nr); + if (!(offset_to_pack_pos(p, obj_offset, &pos))) { + nth_packed_object_id(&base_oid, p, + pack_pos_to_index(p, pos)); error("failed to read delta base object %s" " at offset %"PRIuMAX" from %s", oid_to_hex(&base_oid), (uintmax_t)obj_offset, From patchwork Fri Jan 8 18:17:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2CE9C43331 for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA53523A7B for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728723AbhAHSST (ORCPT ); Fri, 8 Jan 2021 13:18:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728707AbhAHSSS (ORCPT ); Fri, 8 Jan 2021 13:18:18 -0500 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46FBFC0612A3 for ; Fri, 8 Jan 2021 10:17:47 -0800 (PST) Received: by mail-qv1-xf29.google.com with SMTP id s6so4714412qvn.6 for ; Fri, 08 Jan 2021 10:17:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=HoRaU13iduWPn49awvL3lquMnX6J2oADKyWbLdNdiyg=; b=tZAvqsVJixYLyjyFPYafjMbD+QDjzjtpr1ELOTXN+rFgKu0F3Uo7sg2iRfPJi1O1lW Co3rU2+SoFmWzCTCIHqDCA/qPzxrC51XYwmhaMnjjSM9L26C8wLCgv9vrtckYhOx9a2b qEJz+XWTeV6SFF8N/IO+FjxwYC3rTwfVMpro2tNk3ULCBr1okBql1s7yJccXuzd1OxvC Op8vvWgIgtCzspYE/46iJwKVNC5Sjnm2wxBfYtvCYje0o6/edOjzapSd3QwP8t1F5a27 NN4Fj2TDPDg5OFlkpbRvAwMsqxKI1GKDr9o191GtMKx5zvGcQwBbdiObg8LI7u+w0iYD fCXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=HoRaU13iduWPn49awvL3lquMnX6J2oADKyWbLdNdiyg=; b=aPsVlMy3ZENd2ptEFOs6OA/uSNHMN45ro5hzVPiD6zqNKLRF4NV2aECEN7cz1g+Apu hczFrbLvL4ddOvxm68nM1oE/VtugadaIYVwfdMzIsbqL19fx/pYmJ85jqKeO2DQKAEC5 +t5+yFILSCsxmi64a2Hs5LPxkSYV+q0+N1ExP3kVVdXnEJmKRnVVwWz/DpeW6BuNRoCQ pu5VFXNqAUWZqM8K7TjH06i/o3X1mDhysgSde5FrL4E1Rz/VaKMElQVGK/Zy1zUo84TC AuWhTTh+M80R6Tb0fJF9wJ2HYhB5QbxFN1ckZlBC4J5a4cHyT2CIOccG+7um7vx022DQ bcVQ== X-Gm-Message-State: AOAM530RywgByHo4aJU66ey0Rbt2c7fQJqftRu+mIWTejJ5l8VhraOB6 d6B7uvQxs47LI/JThwhI4ScG7+rDcZurpg== X-Google-Smtp-Source: ABdhPJz3AFYuQfVUcuBojQM6IuumVFIarupt6I1fC8le6B7Hocxy+bN9B5FmEy7/5KsXQRXQITLy5g== X-Received: by 2002:a0c:b4d1:: with SMTP id h17mr4757511qvf.53.1610129866305; Fri, 08 Jan 2021 10:17:46 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id w33sm4994459qth.34.2021.01.08.10.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:45 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:43 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 15/20] for_each_object_in_pack(): convert to new revindex API Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Avoid looking at the 'revindex' pointer directly and instead call 'pack_pos_to_index()'. Signed-off-by: Taylor Blau --- packfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packfile.c b/packfile.c index 34467ea4a3..46c9c7ea3c 100644 --- a/packfile.c +++ b/packfile.c @@ -2082,7 +2082,7 @@ int for_each_object_in_pack(struct packed_git *p, struct object_id oid; if (flags & FOR_EACH_OBJECT_PACK_ORDER) - pos = p->revindex[i].nr; + pos = pack_pos_to_index(p, i); else pos = i; From patchwork Fri Jan 8 18:17:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5D31C4332E for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BC3423A7A for ; Fri, 8 Jan 2021 18:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728725AbhAHSST (ORCPT ); Fri, 8 Jan 2021 13:18:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728719AbhAHSSS (ORCPT ); Fri, 8 Jan 2021 13:18:18 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 349EBC0612A4 for ; Fri, 8 Jan 2021 10:17:51 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id 75so11123755ilv.13 for ; Fri, 08 Jan 2021 10:17:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=zCb37iXSFsX9rFmR1LLC+H3EPGfQdLbpmMxbI4AJd3g=; b=XG5KQvesgB6lknDOW9L474XlfM+oGqa6oFussocfCaIxymWKhlq7NqiVbb50eTU5eS OPXaqlve707VO+31k7LByaySQvh4hVsNA/sxweDTFh0bO9nFPdMJf9k/WAcG7W+wAcbT aL8TWYkRKJHqsuk26sFiIu5SwUhSRekTy2a0XLL+Z++hgWo7NQZoGWqY0qkcuFLnNcvi b12Bt9dIHauMaN9j/EWvmgtGPJ3PAKHy2LwqxMRwkst0jk1d55lEOuhIjHcTbbBc7HfP xymvxubov3/vUWg/yznhXrG7XoQ1R9H73UWzamAgOT7wHGmiTZFJuDKxm4rU4joyg+DI avtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zCb37iXSFsX9rFmR1LLC+H3EPGfQdLbpmMxbI4AJd3g=; b=iuC8oiSKB71lHhTsCBf0ish+7HtEmhiUNRsxJKXuGo6dANlV3pdjrioqE6q8Vz0OFh I1fFuUvEUQG7NImDRKoD1cPgTH+ZfQBJS9hve4vHm6tcS4NhqdIiAI3E3pQUgDM0L5r4 6oUIypO/A458CJXOWTjSQkf5sqYGLeLaAat3awy9DhbC1b2Mqv1TX6owObKV87uRqw4l P8H3pc2J0wYAZM2mDTLWMJthOpZIwKsxH+aqNbohB+WCvNanC2q2V15cNvT3SpJ8sCNk O5rmG9NiDnd3FpVtVgmwFwrYt6lQSWNxBxiJ5pI3CSbwxr2DG71MZxRoOY0XBlB8bzZW 9SJw== X-Gm-Message-State: AOAM531Dgwze1YjqOef9b+TofpyH9Sumj9ugdfW5D+rhY/Y82HevkDyK CxBRPEcL7m27/ImRytKrn3NEmme0AJXw4Q== X-Google-Smtp-Source: ABdhPJyg08/wA1UZGxggeO85q+cvEFyzJxCFSlOefqvqO1DdJz+JTIOhKKxUvIZIJsa601W7gkdQag== X-Received: by 2002:a92:cec4:: with SMTP id z4mr4995627ilq.217.1610129870374; Fri, 08 Jan 2021 10:17:50 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id e9sm7266137ilc.73.2021.01.08.10.17.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:49 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:47 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 16/20] builtin/gc.c: guess the size of the revindex Message-ID: <7c17db7a7df8b524f13969efd1cb5e6e95de5a2d.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 'estimate_repack_memory()' takes into account the amount of memory required to load the reverse index in memory by multiplying the assumed number of objects by the size of the 'revindex_entry' struct. Prepare for hiding the definition of 'struct revindex_entry' by removing a 'sizeof()' of that type from outside of pack-revindex.c. Instead, guess that one off_t and one uint32_t are required per object. Strictly speaking, this is a worse guess than asking for 'sizeof(struct revindex_entry)' directly, since the true size of this struct is 16 bytes with padding on the end of the struct in order to align the offset field. But, this is an approximation anyway, and it does remove a use of the 'struct revindex_entry' from outside of pack-revindex internals. Signed-off-by: Taylor Blau --- builtin/gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/gc.c b/builtin/gc.c index 4c24f41852..c60811f212 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -301,7 +301,7 @@ static uint64_t estimate_repack_memory(struct packed_git *pack) /* and then obj_hash[], underestimated in fact */ heap += sizeof(struct object *) * nr_objects; /* revindex is used also */ - heap += sizeof(struct revindex_entry) * nr_objects; + heap += (sizeof(off_t) + sizeof(uint32_t)) * nr_objects; /* * read_sha1_file() (either at delta calculation phase, or * writing phase) also fills up the delta base cache From patchwork Fri Jan 8 18:17:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6571C433E0 for ; Fri, 8 Jan 2021 18:19:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 834DF23A7B for ; Fri, 8 Jan 2021 18:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728333AbhAHSSo (ORCPT ); Fri, 8 Jan 2021 13:18:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728317AbhAHSSn (ORCPT ); Fri, 8 Jan 2021 13:18:43 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB98FC0612A6 for ; Fri, 8 Jan 2021 10:17:55 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id c14so7190369qtn.0 for ; Fri, 08 Jan 2021 10:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vCuddtAjGaCy9Blc34YzMVmKVBD1Y4MOb555wFeIH2Q=; b=Eo0TTAXW9XDtd1S9Jjqp+zUL4lWS2JA34VlflkaccsmtzQZhg4Iq0sCEYQPEIyhkVJ 9JKi/hDA3vqeaqGULliB5dIzX1qVMdVycEg/iJ4Tfs0DsEOwFSzbqwHZlLLcUhnPQsMl OJDv4uueT3hKfQG8TAsjHJd7H9xodoBNpfCrp9hGfvL4hVQPf4aed0tLLXK5jkF32ZgP 2tWGsVeQq2X8wiuSaVP6EqyjwQ9U9mhTdNocv38ZNrg5NcWEdLgv2itJgkDN36LlYAaj 9Fa4658xCbaTHVLEi/n5sYTrZ37Qa9dJIe6jx9xu8QT0LaMsUON89X0TOzX6PoSYhpsZ fHsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vCuddtAjGaCy9Blc34YzMVmKVBD1Y4MOb555wFeIH2Q=; b=iyx3OHjYrjLgSAmlf4p+fQxJZV0A6lPW3/3WpGVzyhsz2kndbxv6TZfalZ/Ct6qCsE 3ELiP/71y1KNzYfftk/tuQ2gpXdnXwxYdCaomoaiMHSJWdeMDg6xz/HSDENmfIDF3xa8 uZxEG1WkoXFpAXohdiekGfdzqolnAlrXzQrbef5kwbvY94nnjuZtXtaQw9jGaTbh9Rm1 SkbrsgTg4iPEuyyyGUm+S6+NdYFT7KpHRGGMenNHoMkhAXTdT4TwCslKSllIrg6/SzCT AjqDiOAUd3RmRc4Gte0zd2VGqeUexdAjKWBSlxOjjDoQr/n+/TCHSxasFd5gj1p++JiG jlcA== X-Gm-Message-State: AOAM532IZQrp2mkoaXfI82cZ+fId+f9S8JWvtbXpNEAJPBMt0QWAGCCc onSAR0WGp1ljlZbAzI3xvbokFFaJ7Nx8Sw== X-Google-Smtp-Source: ABdhPJxrkbTkRAyXH3ZtkWUnqCabMqOEbnBgG325rwSikA38JGD9tGOOeOfVK5GTb3FV0I20OU3tdw== X-Received: by 2002:a05:622a:201:: with SMTP id b1mr4532527qtx.237.1610129874884; Fri, 08 Jan 2021 10:17:54 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id b6sm4900647qkc.128.2021.01.08.10.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:54 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:52 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 17/20] pack-revindex: remove unused 'find_pack_revindex()' Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that no callers of 'find_pack_revindex()' remain, remove the function's declaration and implementation entirely. Signed-off-by: Taylor Blau --- pack-revindex.c | 15 --------------- pack-revindex.h | 2 -- 2 files changed, 17 deletions(-) diff --git a/pack-revindex.c b/pack-revindex.c index 6d86a85208..4e42238906 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -189,21 +189,6 @@ int find_revindex_position(struct packed_git *p, off_t ofs) return -1; } -struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs) -{ - int pos; - - if (load_pack_revindex(p)) - return NULL; - - pos = find_revindex_position(p, ofs); - - if (pos < 0) - return NULL; - - return p->revindex + pos; -} - int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos) { int ret; diff --git a/pack-revindex.h b/pack-revindex.h index 256c0a9106..07c1a7a3c8 100644 --- a/pack-revindex.h +++ b/pack-revindex.h @@ -11,8 +11,6 @@ struct revindex_entry { int load_pack_revindex(struct packed_git *p); int find_revindex_position(struct packed_git *p, off_t ofs); -struct revindex_entry *find_pack_revindex(struct packed_git *p, off_t ofs); - int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos); uint32_t pack_pos_to_index(struct packed_git *p, uint32_t pos); off_t pack_pos_to_offset(struct packed_git *p, uint32_t pos); From patchwork Fri Jan 8 18:17:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 753A7C43217 for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 520B123A7B for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728754AbhAHSSZ (ORCPT ); Fri, 8 Jan 2021 13:18:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728728AbhAHSSX (ORCPT ); Fri, 8 Jan 2021 13:18:23 -0500 Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87DD6C0612A7 for ; Fri, 8 Jan 2021 10:18:00 -0800 (PST) Received: by mail-io1-xd32.google.com with SMTP id q137so10623844iod.9 for ; Fri, 08 Jan 2021 10:18:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lWyQSLMWGYK3VB2Z8idCthw32Pu7mSVUrKnWDgsJ440=; b=J0AX+GYpolhR5IosLZlsNZkGOt4nKiz/9YlGva+vQBBrx/Y9xSOQsaKc8oAx+OVNe/ 2DGOcGj7rbKxKPZffmCvoanIYXP+tfNtRwf/RXMGNggw4W+Ua20zAN8wQt7pj4zP+53I xBNhxUWiZOELcpfdpDYSuthYdQz7xrbKOo25Rg6T6rKPr6zsl+xuFX9/SWpqEObQfU6M y+nbAGChp0guKcKHrI6yehL++Va/9E1la71RzHWLgWi6ouqji3Fr9WMY9aKTAha+lxkN UgwvG0SkNeYDREicSQikzjYsjUv7oYyLZgNQM9ArR8ey2Ukk6U3F9rFeWr7qxat3wAsl 85EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lWyQSLMWGYK3VB2Z8idCthw32Pu7mSVUrKnWDgsJ440=; b=Eb1volvtNz8qXZ/xCui/Qm+Q3eE5JWewhjtQaevp52+hxGXm+McXUMUexOIMFwCAxB NC+RMDMBpBM1VhfvRKzEalhloqjiW61w/rqor8WhYWvjkASBZmgKq96s+3+vCOCbOQbo lNYDKg3PhvkC4E/yRYk7y6/q07AGG4vlIymttc1N5r7OEOJL6YqWzdAgLQ+Yr83ItIwt jJZmGzygLZa6Izv57jkxv0sqJFgdXzZbpYBaTZadhRGiIZxwMNXSjLDd/zGj8ZQBKqOF FuH1bb1s8AR0Chg1vllBY3Q1IeK19Y0e3hnZbf5YQ3duMiElfXVIf+ibT9ruZ/Is2tf9 f3og== X-Gm-Message-State: AOAM531FDbNNrNKdklXV71U/G9ran25nlKqMtkEfOwcPpy6ssVukRg2R sHfJRUNhg1B7PJ0UPCIKgFeXGEGCSUgsIQ== X-Google-Smtp-Source: ABdhPJxbCihFuA9YlNw/twlvKVPqwddytuuKEo1qTYGAcj24CmIFNsjJAOnttAi1kZVKXCb0bMVaXw== X-Received: by 2002:a5d:8483:: with SMTP id t3mr6409209iom.35.1610129879731; Fri, 08 Jan 2021 10:17:59 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id k15sm67456ilp.10.2021.01.08.10.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:17:59 -0800 (PST) Date: Fri, 8 Jan 2021 13:17:57 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 18/20] pack-revindex: remove unused 'find_revindex_position()' Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that all 'find_revindex_position()' callers have been removed (and converted to the more descriptive 'offset_to_pack_pos()'), it is almost safe to get rid of 'find_revindex_position()' entirely. Almost, except for the fact that 'offset_to_pack_pos()' calls 'find_revindex_position()'. Inline 'find_revindex_position()' into 'offset_to_pack_pos()', and then remove 'find_revindex_position()' entirely. This is a straightforward refactoring with one minor snag. 'offset_to_pack_pos()' used to load the index before calling 'find_revindex_position()'. That means that by the time 'find_revindex_position()' starts executing, 'p->num_objects' can be safely read. After inlining, be careful to not read 'p->num_objects' until _after_ 'load_pack_revindex()' (which loads the index as a side-effect) has been called. Signed-off-by: Taylor Blau --- pack-revindex.c | 29 +++++++++++------------------ pack-revindex.h | 1 - 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/pack-revindex.c b/pack-revindex.c index 4e42238906..9392c4be73 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -169,16 +169,23 @@ int load_pack_revindex(struct packed_git *p) return 0; } -int find_revindex_position(struct packed_git *p, off_t ofs) +int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos) { int lo = 0; - int hi = p->num_objects + 1; - const struct revindex_entry *revindex = p->revindex; + int hi; + const struct revindex_entry *revindex; + + if (load_pack_revindex(p) < 0) + return -1; + + hi = p->num_objects + 1; + revindex = p->revindex; do { const unsigned mi = lo + (hi - lo) / 2; if (revindex[mi].offset == ofs) { - return mi; + *pos = mi; + return 0; } else if (ofs < revindex[mi].offset) hi = mi; else @@ -189,20 +196,6 @@ int find_revindex_position(struct packed_git *p, off_t ofs) return -1; } -int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos) -{ - int ret; - - if (load_pack_revindex(p) < 0) - return -1; - - ret = find_revindex_position(p, ofs); - if (ret < 0) - return -1; - *pos = ret; - return 0; -} - uint32_t pack_pos_to_index(struct packed_git *p, uint32_t pos) { if (!p->revindex) diff --git a/pack-revindex.h b/pack-revindex.h index 07c1a7a3c8..b5dd114fd5 100644 --- a/pack-revindex.h +++ b/pack-revindex.h @@ -9,7 +9,6 @@ struct revindex_entry { }; int load_pack_revindex(struct packed_git *p); -int find_revindex_position(struct packed_git *p, off_t ofs); int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos); uint32_t pack_pos_to_index(struct packed_git *p, uint32_t pos); From patchwork Fri Jan 8 18:18:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89660C4321A for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C96823A7A for ; Fri, 8 Jan 2021 18:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728751AbhAHSSZ (ORCPT ); Fri, 8 Jan 2021 13:18:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728742AbhAHSSX (ORCPT ); Fri, 8 Jan 2021 13:18:23 -0500 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F558C0612FF for ; Fri, 8 Jan 2021 10:18:05 -0800 (PST) Received: by mail-il1-x12b.google.com with SMTP id 75so11124376ilv.13 for ; Fri, 08 Jan 2021 10:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=cqCXcF3s42aVhCLcgyqbKz+bbVfloj8Z9G3uiLc3txc=; b=Qoca/PEjIUHZBmqW5Vg/kRWuimb65fZcWBiCEYUchcQl0D0428XGbqi6v7jMx4lsSG LvVZFxyyjOZxH3CWJC6vQLkFqHC65eAVBFgncDU6XVeZoPrb45SOA+yqA+rFeEHecdpd uaizIwASykYhK758iXrRm39duDqLoJcZuX62YEMB7aqwGE+vh6/uVPl8UEG7/RcG4rz5 38sbjXvMWEdptSzZlNrhrztYKlMfr2H77Ioda1DXkJFvcPbVumIIqAfF+rPBjT3FMvd2 uptE1w1CL/fyOdLhZe7IpfYECQxPMXhK4rqPchWfOLJ9wqWeqh29t4O4oz8gi9cARvO1 ejJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=cqCXcF3s42aVhCLcgyqbKz+bbVfloj8Z9G3uiLc3txc=; b=rwTyPkj1fpDeWqSuvyPlTOVX1LorL9RsUdauQEyY21kWndOOdtdn324f/w0y+qHCt0 s1SWo20MprN2LeC3sA/KaRTeWBS5ASHIfAEDGuS+p4/wNr0tOaMUYvQx19xr4Crs3RSu tKnVmvpvVIPjl3WpYHaxzTeaq03wE0+DOX9m6ckyyO/Cslnugw8hysTIm8zuZUMc75lG LXl0jIYCCvSiMjjJ7PAiAHN9chQa6Wqy0yEQhAhHYhsIdCF9V6CqsGYWT92v+IQ0QhGC qbhpLObExU+gOUnyVH37h0UvonI8ikK7gKEReya+aCxQj2ZM8igmb9OMWF2OD8SnQM8o dH6Q== X-Gm-Message-State: AOAM532Yre8AEN2ZijrCl6bTqflNBNWjt/dm7rcV6klnJxQmpx1wxRLU CEXzHtcybHXWEU2NC5ZCPtElDj47+0JpMA== X-Google-Smtp-Source: ABdhPJxXye+6mr6ZXetxf9HjK1MpPQhjucBFC77D3pxMp7otH8G+yLtO9Uh8+6c5G/kk1Hq4TMsAjQ== X-Received: by 2002:a05:6e02:1a82:: with SMTP id k2mr5053226ilv.164.1610129884252; Fri, 08 Jan 2021 10:18:04 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id 15sm7487952ilx.84.2021.01.08.10.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:18:03 -0800 (PST) Date: Fri, 8 Jan 2021 13:18:01 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 19/20] pack-revindex: hide the definition of 'revindex_entry' Message-ID: <7c0e4acc845d1135e684188b2ccc61cf358994dc.1610129796.git.me@ttaylorr.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Now that all spots outside of pack-revindex.c that reference 'struct revindex_entry' directly have been removed, it is safe to hide the implementation by moving it from pack-revindex.h to pack-revindex.c. Signed-off-by: Taylor Blau --- pack-revindex.c | 5 +++++ pack-revindex.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pack-revindex.c b/pack-revindex.c index 9392c4be73..36ef276378 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -3,6 +3,11 @@ #include "object-store.h" #include "packfile.h" +struct revindex_entry { + off_t offset; + unsigned int nr; +}; + /* * Pack index for existing packs give us easy access to the offsets into * corresponding pack file where each object's data starts, but the entries diff --git a/pack-revindex.h b/pack-revindex.h index b5dd114fd5..b501a7cd62 100644 --- a/pack-revindex.h +++ b/pack-revindex.h @@ -3,11 +3,6 @@ struct packed_git; -struct revindex_entry { - off_t offset; - unsigned int nr; -}; - int load_pack_revindex(struct packed_git *p); int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos); From patchwork Fri Jan 8 18:18:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12007245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA780C433DB for ; Fri, 8 Jan 2021 18:19:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A348723A7C for ; Fri, 8 Jan 2021 18:19:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728728AbhAHSSu (ORCPT ); Fri, 8 Jan 2021 13:18:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728069AbhAHSSu (ORCPT ); Fri, 8 Jan 2021 13:18:50 -0500 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4A55C06129C for ; Fri, 8 Jan 2021 10:18:09 -0800 (PST) Received: by mail-io1-xd34.google.com with SMTP id m23so10685308ioy.2 for ; Fri, 08 Jan 2021 10:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=J+jW+1X1QIgtpR9XJFTsWi1rtNV9LEBigXUeAGkVWmI=; b=lumj/snH0t8dRbDA31AUasA88JiXZ/Y30+CUy3Fr9J3CPKJOd8Ay3BJ/bijkokQ+Nn NTGnadBnI9rlc33qNosKmxpylhg3nmX47GRQjbewooKNnaxoCMi41bpCpumH1vbAotIj 6SwNj9qxuiEhnCnZ/+fX+lvYY0itpRncnfYR2xqKuy2VN2jpl3qMwdKhnnvVWedOoHbu BzD+eJuGT+5xpEZYQ2v2vtUkofiGBVPHucyc7MGl+jcS468EvsR3FR5tCxVwMe5wZJe9 FNNwWZ4DIqnJKZHBPEQ9B5YnnxM75wvTOCEECMX+RyEhFanx23OJOmlWubh5uNGsWpqC 6lqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=J+jW+1X1QIgtpR9XJFTsWi1rtNV9LEBigXUeAGkVWmI=; b=I7KHkmXNDcAcitJYxhgGLLAwAYVaEomwyyuvCTGwD1jrAzOkeU5jSlGnapk10Mc5NZ TwC2MAMBakpsK5a0HGDPK/DI/iWWLz/5JKMUu12jmyikr4Gj/aK2jIWYiNI+SG/snFhI oILU3Ab49e/bqAaRFGs/xI/0g9EnfmNnpLT2Iqspywm/FPSTSFaI55OkGJpFPTtQzVOh MJLip1sVIx/VVGB+qjQFSUKlSiOJqutRzNx2oNEA2WxeYDJ8S9lQ9mJBeQOqZ+s8NJ4r SjHXWumM5YbWjMA6LW1GFEWqln0mK3enKNAm5tMbXDCOKWnpAcEUOXhb4NGlsU6/05VE NvyA== X-Gm-Message-State: AOAM530DvQCBJG8PTatk62XaiE5KA2G3FXXhsSADtBLeLWcLjZlm7IcS +BCHmD2WKTH8kd8DvynAWn+mv9jhYbhqMg== X-Google-Smtp-Source: ABdhPJxPts4jeZIOg2ZP8VAhmvfIKL9FRkjecNsgJriArisbgFH6ixc+TMmCt0jFhbLity8xfz00jQ== X-Received: by 2002:a02:a419:: with SMTP id c25mr4472512jal.91.1610129889085; Fri, 08 Jan 2021 10:18:09 -0800 (PST) Received: from localhost ([8.9.92.205]) by smtp.gmail.com with ESMTPSA id g2sm7313343ilh.41.2021.01.08.10.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Jan 2021 10:18:08 -0800 (PST) Date: Fri, 8 Jan 2021 13:18:06 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: peff@peff.net, jrnieder@gmail.com Subject: [PATCH 20/20] pack-revindex.c: avoid direct revindex access in 'offset_to_pack_pos()' Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org To prepare for on-disk reverse indexes, remove a spot in 'offset_to_pack_pos()' that looks at the 'revindex' array in 'struct packed_git'. Even though this use of the revindex pointer is within pack-revindex.c, this clean up is still worth doing. Since the 'revindex' pointer will be NULL when reading from an on-disk reverse index (instead the 'revindex_data' pointer will be mmaped to the 'pack-*.rev' file), this call-site would have to include a conditional to lookup the offset for position 'mi' each iteration through the search. So instead of open-coding 'pack_pos_to_offset()', call it directly from within 'offset_to_pack_pos()'. Signed-off-by: Taylor Blau --- pack-revindex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pack-revindex.c b/pack-revindex.c index 36ef276378..2cd9d632f1 100644 --- a/pack-revindex.c +++ b/pack-revindex.c @@ -178,20 +178,20 @@ int offset_to_pack_pos(struct packed_git *p, off_t ofs, uint32_t *pos) { int lo = 0; int hi; - const struct revindex_entry *revindex; if (load_pack_revindex(p) < 0) return -1; hi = p->num_objects + 1; - revindex = p->revindex; do { const unsigned mi = lo + (hi - lo) / 2; - if (revindex[mi].offset == ofs) { + off_t got = pack_pos_to_offset(p, mi); + + if (got == ofs) { *pos = mi; return 0; - } else if (ofs < revindex[mi].offset) + } else if (ofs < got) hi = mi; else lo = mi + 1;