From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: Max Kirillov <max@max630.net>, git@vger.kernel.org
Subject: Re: [PATCH v3 3/4] Add a function to release all packs
Date: Wed, 07 Oct 2015 10:49:49 -0700 [thread overview]
Message-ID: <xmqq4mi2va9u.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <9953f8ed40d0cf99f1be7cfe2fa0b699b7769645.1444131898.git.johannes.schindelin@gmx.de> (Johannes Schindelin's message of "Tue, 06 Oct 2015 15:18:34 +0200")
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> On Windows, files that are in use cannot be removed or renamed. That
> means that we have to release pack files when we are about to, say,
> repack them. Let's introduce a convenient function to close them
> pack files.
>
> While at it, we consolidate the close windows/close fd/close index
> stanza in `free_pack_by_name()` into the `close_pack()` function that
> is used by the new `close_all_packs()` function to avoid repeated code.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
> ---
This is the only one that was updated among the four and the change
looks sensible. I'd reword the end of the first paragraph of the
proposed log message, though, to replace "close them pack files"
with "close all the pack files and their idx files".
Thanks.
> cache.h | 1 +
> sha1_file.c | 23 ++++++++++++++++++++---
> 2 files changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index 752031e..57f6a74 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -1275,6 +1275,7 @@ extern void close_pack_index(struct packed_git *);
>
> extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
> extern void close_pack_windows(struct packed_git *);
> +extern void close_all_packs(void);
> extern void unuse_pack(struct pack_window **);
> extern void free_pack_by_name(const char *);
> extern void clear_delta_base_cache(void);
> diff --git a/sha1_file.c b/sha1_file.c
> index 8c3c913..ca699d7 100644
> --- a/sha1_file.c
> +++ b/sha1_file.c
> @@ -798,6 +798,25 @@ static int close_pack_fd(struct packed_git *p)
> return 1;
> }
>
> +static void close_pack(struct packed_git *p)
> +{
> + close_pack_windows(p);
> + close_pack_fd(p);
> + close_pack_index(p);
> +}
> +
> +void close_all_packs(void)
> +{
> + struct packed_git *p;
> +
> + for (p = packed_git; p; p = p->next)
> + if (p->do_not_close)
> + die("BUG! Want to close pack marked 'do-not-close'");
> + else
> + close_pack(p);
> +}
> +
> +
> /*
> * The LRU pack is the one with the oldest MRU window, preferring packs
> * with no used windows, or the oldest mtime if it has no windows allocated.
> @@ -906,9 +925,7 @@ void free_pack_by_name(const char *pack_name)
> p = *pp;
> if (strcmp(pack_name, p->pack_name) == 0) {
> clear_delta_base_cache();
> - close_pack_windows(p);
> - close_pack_fd(p);
> - close_pack_index(p);
> + close_pack(p);
> free(p->bad_object_sha1);
> *pp = p->next;
> if (last_found_pack == p)
next prev parent reply other threads:[~2015-10-07 17:50 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-28 19:44 [PATCH] clone --dissociate: avoid locking pack files Johannes Schindelin
2015-09-30 19:28 ` Max Kirillov
2015-09-30 19:42 ` Junio C Hamano
2015-10-01 3:29 ` [PATCH/RFC 0/2] close packs files when they are not needed Max Kirillov
2015-10-01 3:29 ` [PATCH/RFC 1/2] sha1_file: close all pack files after running Max Kirillov
2015-10-02 10:05 ` Johannes Schindelin
2015-10-02 10:13 ` Johannes Schindelin
2015-10-02 19:21 ` Max Kirillov
2015-10-04 14:53 ` Johannes Schindelin
2015-10-05 4:57 ` Max Kirillov
2015-10-05 9:03 ` Johannes Schindelin
2015-10-02 19:06 ` Max Kirillov
2015-10-02 20:06 ` Max Kirillov
2015-10-01 3:29 ` [PATCH/RFC 2/2] sha1_file: set packfile to O_CLOEXEC at open Max Kirillov
2015-10-02 10:08 ` Johannes Schindelin
2015-10-01 4:39 ` [PATCH] clone --dissociate: avoid locking pack files Max Kirillov
2015-10-05 18:32 ` Johannes Schindelin
2015-10-05 20:29 ` [PATCH v2 0/4] Fix locking issues on Windows with `git clone --dissociate` Johannes Schindelin
2015-10-05 20:29 ` [PATCH v2 1/4] Demonstrate a Windows file locking issue " Johannes Schindelin
2015-10-05 20:30 ` [PATCH v2 2/4] Consolidate code to close a pack's file descriptor Johannes Schindelin
2015-10-05 20:57 ` Junio C Hamano
2015-10-05 21:52 ` Johannes Schindelin
2015-10-05 22:15 ` Junio C Hamano
2015-10-06 13:42 ` Johannes Schindelin
2015-10-05 20:33 ` [PATCH v2 3/4] Add a function to release all packs Johannes Schindelin
2015-10-05 20:33 ` [PATCH v2 4/4] clone --dissociate: avoid locking pack files Johannes Schindelin
2015-10-05 21:00 ` Junio C Hamano
2015-10-06 13:17 ` [PATCH v3 0/4] Fix locking issues on Windows with `git clone --dissociate` Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 1/4] Demonstrate a Windows file locking issue " Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 2/4] Consolidate code to close a pack's file descriptor Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 3/4] Add a function to release all packs Johannes Schindelin
2015-10-07 17:49 ` Junio C Hamano [this message]
2015-10-08 19:10 ` Johannes Schindelin
2015-10-06 13:18 ` [PATCH v3 4/4] clone --dissociate: avoid locking pack files Johannes Schindelin
2015-10-11 10:45 ` [PATCH v3 0/4] Fix locking issues on Windows with `git clone --dissociate` Max Kirillov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq4mi2va9u.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=max@max630.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.