From patchwork Fri Oct 8 21:46:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12546513 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDA94C433EF for ; Fri, 8 Oct 2021 21:46:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5BA261027 for ; Fri, 8 Oct 2021 21:46:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243471AbhJHVs2 (ORCPT ); Fri, 8 Oct 2021 17:48:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243459AbhJHVs0 (ORCPT ); Fri, 8 Oct 2021 17:48:26 -0400 Received: from mail-io1-xd35.google.com (mail-io1-xd35.google.com [IPv6:2607:f8b0:4864:20::d35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D291C061570 for ; Fri, 8 Oct 2021 14:46:31 -0700 (PDT) Received: by mail-io1-xd35.google.com with SMTP id r134so1075657iod.11 for ; Fri, 08 Oct 2021 14:46:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Lp1JX8ap6gt7iNehfUEuY6/IwkA5y8cES4y/SXJPefg=; b=AXmKbQoMXCc3teXOhJN6rxOfzFa9K6n2Yx8HQY4Gm62M4UZhtuXVDhPXofmCZhXDdn bzmqZjFn1yVrL8wiGazo42OB5CQvt1ivzgT7tgniuHdFoGgGiEzPaNJn5Y1LQR8YXAcL 2PuhghZWyaM6Yat3Pto5/RTvU5AbtH2Y7FVHAO1eMmNqga4jRxLcLgdh5gk9IFCEkq8M 6/c6mUUI79z4jDuecO3kHvePL3HRyNC9p60PbMFGx7E32HzJoWD933pKeq/SN3aYYHCa K7z7msk1kxufdrQ9Mn4Vtl8RBuR1IVCinlGwFvEFnuBwFXQiJ6k9Ra4xliCtMETgJKuy uYgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Lp1JX8ap6gt7iNehfUEuY6/IwkA5y8cES4y/SXJPefg=; b=2apgVYO04a8TK9bgMFWk1PThRKmAIoWlfnERN4cha4Pj7egce5Gd2vS09+zKHGQ0hi BHn9ShWAH0TseKF1RMiT/f9cyvukrmnUW8yFB39s60FWeVRHYzMsJ+QNOaED/Hopz1Ua dw051kdk84fp+gKhgltkwgkWiVdzQKYlLIBFUtOWDynJh3pQ1/Tj0NvpVaLQ7MXFr1lM A5xYJjobu/SzkEF+09f0zqeeetWvLZipfCbsIs3sriZTWI9zJfDSblSytAah9iULLNfO HPvu2bgl97f+yR195A2h25s8LFrZzZQvxtuDO7ekYD0XmmjF7c3n0yBCxm3PAiLRSTDU /41Q== X-Gm-Message-State: AOAM531gH2veXL9Wut7IJQVCKmoABuI34p/9P63KWpL00tWEJLbNibtI 7tbUEHFzIQATS+gfgpRjHQm/RrMEvgEFsg== X-Google-Smtp-Source: ABdhPJxZxzmwF7Fm4RUfRWDocowJadZOZY0iV9lGJb0t9Ta7f5ClFCSPDfRSf5Q/ZmWQ9FSCOLkTdw== X-Received: by 2002:a6b:8d8a:: with SMTP id p132mr4540396iod.96.1633729590443; Fri, 08 Oct 2021 14:46:30 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id a4sm221347ilj.35.2021.10.08.14.46.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 14:46:30 -0700 (PDT) Date: Fri, 8 Oct 2021 17:46:29 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, dstolee@microsoft.com, jeffhost@microsoft.com, peff@peff.net Subject: [PATCH 1/4] midx.c: extract MIDX lookup by object_dir Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The first thing that write_midx_internal() does is load the MIDX corresponding to the given object directory, if one is present. Prepare for other functions in midx.c to do the same thing by extracting that operation out to a small helper function. Signed-off-by: Taylor Blau --- midx.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/midx.c b/midx.c index 18a4f25aa3..b66b75a3cd 100644 --- a/midx.c +++ b/midx.c @@ -1118,6 +1118,22 @@ static int write_midx_bitmap(char *midx_name, unsigned char *midx_hash, return ret; } +static struct multi_pack_index *lookup_multi_pack_index(struct repository *r, + const char *object_dir) +{ + struct multi_pack_index *cur; + + /* Ensure the given object_dir is local, or a known alternate. */ + find_odb(r, object_dir); + + for (cur = get_multi_pack_index(r); cur; cur = cur->next) { + if (!strcmp(object_dir, cur->object_dir)) + return cur; + } + + return NULL; +} + static int write_midx_internal(const char *object_dir, struct string_list *packs_to_include, struct string_list *packs_to_drop, @@ -1131,15 +1147,11 @@ static int write_midx_internal(const char *object_dir, struct hashfile *f = NULL; struct lock_file lk; struct write_midx_context ctx = { 0 }; - struct multi_pack_index *cur; int pack_name_concat_len = 0; int dropped_packs = 0; int result = 0; struct chunkfile *cf; - /* Ensure the given object_dir is local, or a known alternate. */ - find_odb(the_repository, object_dir); - midx_name = get_midx_filename(object_dir); if (safe_create_leading_directories(midx_name)) die_errno(_("unable to create leading directories of %s"), @@ -1151,12 +1163,7 @@ static int write_midx_internal(const char *object_dir, * packs to include, since all packs and objects are copied * blindly from an existing MIDX if one is present. */ - for (cur = get_multi_pack_index(the_repository); cur; cur = cur->next) { - if (!strcmp(object_dir, cur->object_dir)) { - ctx.m = cur; - break; - } - } + ctx.m = lookup_multi_pack_index(the_repository, object_dir); } if (ctx.m && !midx_checksum_valid(ctx.m)) { From patchwork Fri Oct 8 21:46:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12546515 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C49E0C433EF for ; Fri, 8 Oct 2021 21:46:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4B5460F9C for ; Fri, 8 Oct 2021 21:46:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243485AbhJHVsb (ORCPT ); Fri, 8 Oct 2021 17:48:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243348AbhJHVsa (ORCPT ); Fri, 8 Oct 2021 17:48:30 -0400 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 19DCBC061762 for ; Fri, 8 Oct 2021 14:46:35 -0700 (PDT) Received: by mail-qt1-x832.google.com with SMTP id b12so2846189qtq.3 for ; Fri, 08 Oct 2021 14:46:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Uv+MYi9c4NDJHzdoFHgNmYx/Y2px+7lWAV8mGl5WV6U=; b=ChjoQFi3lA7QqGEX6s8vJrsXb9+DPX9cXHTS02l3m7JO8fNfsXit5BcPVoQWi3h0CB uPXpIKzXo/3eWPOn9PIQ7D7rp4eFPqgXVy66iZJy6BjzurOY38gIzDQrfe5cd5b6ST+K /dYxkFFGOkvHr+JA9JZHbhRTlpnIIinMbTekvje69zoQJ3ankf/vFe6REW/+jh074k7c /6nIgZCq2sZYVHXbukwiqkmH6koOKTIHcLlnsEmP1IfROH9gPg3BrPsGGj/sAlWD6Lyj vTl5goolRjlmkoPNjXoQtzlHvW/w8ZbGNl2btMtwYoTxqbgQcajWrBxKMYdhDrjU/Pwk Q1WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Uv+MYi9c4NDJHzdoFHgNmYx/Y2px+7lWAV8mGl5WV6U=; b=oEH1HrAt4HgarzZ4MsenXjOB9gvupNJSFRBw81I3n0aGYJyjAWua+n2h0sCAEP4xk3 9ArufhaMLy5V0kgg8lREj6trDfzJ5c2Dz7tmtiCHChi12pcsmhlinkmDNj16a2x7AKCX 1m1/PUvmdi6EVRoAMQP1I5YkE58hIqRMOUcFL3/RcquAvPG7IavDUvnYyOLq5o1mck4R 6BaiM1JmIdYfsBtp1u6dUwTGookxrP3jWCCasTfe1Md++mzw9mNfPA2lRkLxA3OTkMEh ur//WL3IQtxuGkLzYImBy3my65OideIW6CWbPhAOZ7rHjwanlooL4yfcn+hFnZYKPb6d rcBg== X-Gm-Message-State: AOAM531a99G/COH0kHKT2goWUlGVmcnqT/LRIGEZ2dDzowXpqyyxdkJs euyfIqClPW0Tvb2MgjazchwWlruFxvamJA== X-Google-Smtp-Source: ABdhPJx4UZFroAOJND+wznCmkiOLsc6LkIZ7+JZx1OkuXs1CT8w7jMACuTn4aPHRcDmYeeGAoJvo1w== X-Received: by 2002:ac8:7351:: with SMTP id q17mr855021qtp.336.1633729593273; Fri, 08 Oct 2021 14:46:33 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id y23sm361944qtv.58.2021.10.08.14.46.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 14:46:33 -0700 (PDT) Date: Fri, 8 Oct 2021 17:46:32 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, dstolee@microsoft.com, jeffhost@microsoft.com, peff@peff.net Subject: [PATCH 2/4] midx.c: lookup MIDX by object directory during expire Message-ID: <84e95aacbdfb092082d0ca467892552982134774.1633729502.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 Before a new MIDX can be written, expire_midx_packs() first loads the existing MIDX, figures out which packs can be expired, and then writes a new MIDX based on that information. In order to load the existing MIDX, it uses load_multi_pack_index(), which mmaps the multi-pack-index file, but does not store the resulting `struct multi_pack_index *` in the object store. write_midx_internal() also needs to open the existing MIDX, and it does so by iterating the results of get_multi_pack_index(), so that it reuses the same pointer held by the object store. But before it can move the new MIDX into place, it close_object_store() to munmap() the multi-pack-index file to accommodate platforms like Windows which don't allow overwriting files which are memory mapped. That's where things get weird. Since expire_midx_packs has its own *separate* memory mapped copy of the MIDX, the MIDX file is still memory mapped! Interestingly, this doesn't seem to cause a problem in our tests. (I believe that this has much more to do with my own lack of familiarity with Windows than it does a lack of coverage in our tests). In any case, we can side-step the whole issue by teaching expire_midx_packs() to use the `struct multi_pack_index` pointer it found via the object store instead of maintain its own copy. That way, when write_midx_internal() calls `close_object_store()`, we know that there are no memory mapped copies of the MIDX laying around. A couple of other small notes about this patch: - As far as I can tell, passing `local == 1` to the call to load_multi_pack_index() was an error, since object_dir could be an alternate. But it doesn't matter, since even though we write `m->local = 1`, we never read that field back later on. - Setting `m = NULL` after write_midx_internal() was likely to prevent a double-free back from when that function took a `struct multi_pack_index *` that it called close_midx() on itself. We can rely on write_midx_internal() to call that for us now. Finally, this enforces the same "the value of --object-dir must be the local object store, or an alternate" rule from f57a739691 (midx: avoid opening multiple MIDXs when writing, 2021-09-01) to the `expire` sub-command, too. Signed-off-by: Taylor Blau --- This does leak the MIDX write_midx_internal returns before calling close_object_store(). We can't just blindly call close_object_store() here, either, since it's susceptible to double-frees. I'll think about improving this in a separate series. midx.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) -- 2.33.0.96.g73915697e6 diff --git a/midx.c b/midx.c index b66b75a3cd..7f1addf4b6 100644 --- a/midx.c +++ b/midx.c @@ -1707,7 +1707,7 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla { uint32_t i, *count, result = 0; struct string_list packs_to_drop = STRING_LIST_INIT_DUP; - struct multi_pack_index *m = load_multi_pack_index(object_dir, 1); + struct multi_pack_index *m = lookup_multi_pack_index(r, object_dir); struct progress *progress = NULL; if (!m) @@ -1752,12 +1752,11 @@ int expire_midx_packs(struct repository *r, const char *object_dir, unsigned fla free(count); - if (packs_to_drop.nr) { + if (packs_to_drop.nr) result = write_midx_internal(object_dir, NULL, &packs_to_drop, NULL, NULL, flags); - m = NULL; - } string_list_clear(&packs_to_drop, 0); + return result; } From patchwork Fri Oct 8 21:46:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12546517 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDFFCC433F5 for ; Fri, 8 Oct 2021 21:46:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D13AE60F9C for ; Fri, 8 Oct 2021 21:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243496AbhJHVsh (ORCPT ); Fri, 8 Oct 2021 17:48:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243493AbhJHVse (ORCPT ); Fri, 8 Oct 2021 17:48:34 -0400 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 12279C061570 for ; Fri, 8 Oct 2021 14:46:38 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id w14so10924610qkf.5 for ; Fri, 08 Oct 2021 14:46:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=xVfZXQMqdImuWVGIm4CQDMC4jct+iN9Q30KHfcq4pxU=; b=wTKvPg/QSmQ8GBNnUtSz11hgdfXzIcTfyxdNRIUts4+X6VyLmq6cIBR7sslEc1fBuE aYoPKO04HQ2VlTHjbqGDobczopNxz6OU9sh5vlNgq4/Nq3s+3nNjbOMdkGf6ZxBtgW5z JOfNhkXn6pIIkE9ptbuPhwPAPawXCsH+Py+zN6qFVrZ/WjKREkF9NqtG6aqrSwU4iecs tQhFFG75R8c2mLww7TFJWAZsAgDymjmxqDQJcMbT+vQ7UbZpjbm4gn2TMCTN2wvxdHDX bTnhCL0CY/eHd7eE6MbJ1MTSKPORG0zm2WKv0kqUqN2/3duly9J2yx986XkYQkKJroak i7OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=xVfZXQMqdImuWVGIm4CQDMC4jct+iN9Q30KHfcq4pxU=; b=cFch4UO1/cTnbwaQJdh9jVDEyfGOHLWJyNslmLJ9vrIzDVPDnYX18NzRE1nVH8LsIV 5SOOlQxamvISjwtIvgv6XmnQlrPRSqx3U9zTcVUH1duSgoEtw/cXDftZWGurvI35EScN FwU/8Gp13ULmVMIlAhGmvpHUD1zdQseXKWyiuo3txMvNs1QA5bkN5Q2hKrSEBjq45PsL z1+zDLDhHL5G9Zm0TBCaTAEMBXwZ0BBhCuqVXH2/rw7xtjPPfwP0dggGuomYzh4O5cLB jw8auANKq25N2b6aBH+HWxr1Q9Y3qN5k8I5cXrMQ02onQ09ZXJtRAeLJ1VVXP/8huKNR 0D+A== X-Gm-Message-State: AOAM533l+iYVtrhIP5tB5WwM2BzvrRKBO4dYx7dG6yfsfEPwXlhgBIec 6neLWGRvhld1IL3lTBZJo7MjB/4PmNRnVw== X-Google-Smtp-Source: ABdhPJwNVI1UB2x1Fv1pOX0imNl2+wnaqCweYXgd0QintEozIYrAoOvSEeAWDhfOHYOh5iJj3Hhczw== X-Received: by 2002:a37:86c7:: with SMTP id i190mr5216559qkd.384.1633729597168; Fri, 08 Oct 2021 14:46:37 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id k19sm515736qko.115.2021.10.08.14.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 14:46:36 -0700 (PDT) Date: Fri, 8 Oct 2021 17:46:35 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, dstolee@microsoft.com, jeffhost@microsoft.com, peff@peff.net Subject: [PATCH 3/4] midx.c: lookup MIDX by object directory during repack Message-ID: <0accab9139e095c10bf6f299b77bab048e2b4c77.1633729502.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 Apply similar treatment as in the last commit to the MIDX `repack` operation. Signed-off-by: Taylor Blau --- midx.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/midx.c b/midx.c index 7f1addf4b6..137af3fc67 100644 --- a/midx.c +++ b/midx.c @@ -1872,7 +1872,7 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, struct child_process cmd = CHILD_PROCESS_INIT; FILE *cmd_in; struct strbuf base_name = STRBUF_INIT; - struct multi_pack_index *m = load_multi_pack_index(object_dir, 1); + struct multi_pack_index *m = lookup_multi_pack_index(r, object_dir); /* * When updating the default for these configuration @@ -1944,11 +1944,8 @@ int midx_repack(struct repository *r, const char *object_dir, size_t batch_size, } result = write_midx_internal(object_dir, NULL, NULL, NULL, NULL, flags); - m = NULL; cleanup: - if (m) - close_midx(m); free(include_pack); return result; } From patchwork Fri Oct 8 21:46:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 12546519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22BA0C433EF for ; Fri, 8 Oct 2021 21:46:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 028ED61027 for ; Fri, 8 Oct 2021 21:46:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243493AbhJHVsi (ORCPT ); Fri, 8 Oct 2021 17:48:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243510AbhJHVsh (ORCPT ); Fri, 8 Oct 2021 17:48:37 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C55BCC061570 for ; Fri, 8 Oct 2021 14:46:41 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id t2so10907163qtx.8 for ; Fri, 08 Oct 2021 14:46:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=zCctGPyQyu5tmeL7GcQhm1RAugrwDDNTLhgQBy8IzWg=; b=ryKzYQvff7UqpDeu1ZYuYCONAcr3U56U6b/5YiKyshvH3PWSMZgvlt1vH4A7OTyHFB MJq1Fhno1yu+tev/Zsgwvy+9WiJgGmlVgR4jhWcTOHnEGJDOpcpHpT608ViJM0eqGW3D A62TFsjeI86MPAgS2FhLc4/LDS9eQ8Ew1fjP+jx7XdCIogM/GUYY7J1vsrk1sP7M5E2V XNANar2mr8rmQEA5o78EDDdk/RZ5rtRCOfE/FD5+QiNJJ9wB45bvQk4sLBNOP9EXyfOC F1ttaFWVEM53Wu+iA2qvVer+MK8WYDT5WNg0XfgXp2oEB1qjmAEHaZRX5Yl5BLEPcuZ2 Gxdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zCctGPyQyu5tmeL7GcQhm1RAugrwDDNTLhgQBy8IzWg=; b=7OBMwdMemu57OMSEkaT/XiIbvLAWsAQsydGlsMZYZYELbtyRC1kQawz2rFr5HCHfJC 4TMJSTbIMUs3I8AZ+kwXx9JM3w+Qja1mz5Nd0wXIeV0uGs09c9429bTQMumLwJtNtXtO +vMCsOsMJYw4TM1TVGZTQwTUCtlkGF82NQ883YVqGALSgpZsqjU6OxW0FgHfH05yzIJB Le3S+pbd0UAvYQLGSWkzJqcWJ6f+TJ5Roi3wVZbdB0HZgG5GfNzMB4XMqt11VqeITQio 0t/kld1txxWc80BuTkjQeoZssuH6T/gm0Qhlsp3C8Ia09SrqtWCW5xtKDHu5Ss3kKRDn Nq3g== X-Gm-Message-State: AOAM530vYujhtITZT6g1b19wOIuhopW52iTZnGIur8rIHLi157JkniXu JJRxJ9HClGXFuoJtlaN144l38F7lgFSD4A== X-Google-Smtp-Source: ABdhPJwCHeyxb9gkeTc2Jmja9ZVvMxfCOlfjYevLPn5iRhU/OvVfrSMzFSEc9NW0S3dE3AoOrtdtuA== X-Received: by 2002:aed:27c1:: with SMTP id m1mr802118qtg.241.1633729600039; Fri, 08 Oct 2021 14:46:40 -0700 (PDT) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id h125sm478719qkc.29.2021.10.08.14.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 14:46:39 -0700 (PDT) Date: Fri, 8 Oct 2021 17:46:38 -0400 From: Taylor Blau To: git@vger.kernel.org Cc: Johannes.Schindelin@gmx.de, dstolee@microsoft.com, jeffhost@microsoft.com, peff@peff.net Subject: [PATCH 4/4] midx.c: guard against commit_lock_file() failures Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org When writing a MIDX, we atomically move the new MIDX into place via commit_lock_file(), but do not check to see if that call was successful. Make sure that we do check in order to prevent us from incorrectly reporting that we wrote a new MIDX if we actually encountered an error. Signed-off-by: Taylor Blau --- midx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/midx.c b/midx.c index 137af3fc67..e79fb4427d 100644 --- a/midx.c +++ b/midx.c @@ -1434,7 +1434,8 @@ static int write_midx_internal(const char *object_dir, if (ctx.m) close_object_store(the_repository->objects); - commit_lock_file(&lk); + if (commit_lock_file(&lk) < 0) + die_errno(_("could not write multi-pack-index")); clear_midx_files_ext(object_dir, ".bitmap", midx_hash); clear_midx_files_ext(object_dir, ".rev", midx_hash);