From: Justin Tobler <jltobler@gmail.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/4] object-file: only flush batched fsync writes when enabled
Date: Tue, 17 Nov 2026 17:42:59 -0600 [thread overview]
Message-ID: <avzlrYKsGIbyMz8r@denethor> (raw)
In-Reply-To: <CAOLa=ZRp=JeAGhN3m6-RCos3F82__6Wzt2UsKvUjqHSHUg6o_Q@mail.gmail.com>
On 26/11/11 06:48AM, Karthik Nayak wrote:
> Justin Tobler <jltobler@gmail.com> writes:
>
> > When committing an ODB transaction for the "files" backend, a full
> > hardware flush is issued against a temporary file before the staged
> > objects are migrated into the main object database. This flush acts as a
> > barrier for objects that have been written with batched fsync, where
> > `odb_transaction_files_fsync()` only issues a writeout request for each
> > object instead of fully syncing it.
> >
>
> Does `fsync(fd)` even guarantee syncing of previous writes?
I believe the answer here is platform specific. This feature oringally
comes from c0f4752ed2 (core.fsyncmethod: batched disk flushes for
loose-objects, 2022-04-04) which has a pretty good explaination. :)
> > The flush is issued whenever the transaction has a temporary object
> > directory though, regardless of whether batched fsync is actually
> > enabled. For transactions configured for git-receive-pack(1), the
> > temporary object directory is always created, so the flush is also
> > performed when objects are synced individually or not synced at all. In
> > those cases there are no pending writeout requests and the flush is
> > unnecessary. Only issue the flush when batched fsync is enabled
> > accordingly.
> >
> > Signed-off-by: Justin Tobler <jltobler@gmail.com>
> > ---
> > object-file.c | 43 +++++++++++++++++++++++++------------------
> > 1 file changed, 25 insertions(+), 18 deletions(-)
> >
> > diff --git a/object-file.c b/object-file.c
> > index 201d9d6490..da189111bd 100644
> > --- a/object-file.c
> > +++ b/object-file.c
> > @@ -1330,6 +1330,29 @@ static int write_pack_lockfiles(struct odb_transaction_files *transaction)
> > return ret;
> > }
> >
> > +static void flush_batched_fsync(struct repository *repo)
> > +{
> > + struct strbuf temp_path = STRBUF_INIT;
> > + struct tempfile *temp;
> > +
> > + /*
> > + * Issue a full hardware flush against a temporary file to ensure
> > + * that all objects are durable before any renames occur. The code in
> > + * odb_transaction_files_fsync has already issued a writeout
> > + * request, but it has not flushed any writeback cache in the storage
> > + * hardware or any filesystem logs. This fsync call acts as a barrier
> > + * to ensure that the data in each new object file is durable before
> > + * the final name is visible.
> > + */
>
> Nit: This could become a function comment, since it now describes the
> function well.
Will do in the next version.
-Justin
next prev parent reply other threads:[~2026-11-17 23:43 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 0:22 [PATCH 0/4] object-file: eagerly create ODB transaction temporary directory Justin Tobler
2026-11-10 0:22 ` [PATCH 1/4] object-file: rename default transaction prefix Justin Tobler
2026-11-11 13:15 ` Patrick Steinhardt
2026-11-11 14:36 ` Karthik Nayak
2026-11-10 0:22 ` [PATCH 2/4] object-file: only flush batched fsync writes when enabled Justin Tobler
2026-11-11 13:16 ` Patrick Steinhardt
2026-11-17 23:35 ` Justin Tobler
2026-11-11 14:48 ` Karthik Nayak
2026-11-17 23:42 ` Justin Tobler [this message]
2026-11-10 0:22 ` [PATCH 3/4] tmp-objdir: preserve errno when directory creation fails Justin Tobler
2026-11-11 13:16 ` Patrick Steinhardt
2026-11-11 16:44 ` Karthik Nayak
2026-11-17 23:46 ` Justin Tobler
2026-11-10 0:22 ` [PATCH 4/4] object-file: create ODB transaction temporary directory eagerly Justin Tobler
2026-11-11 13:15 ` Patrick Steinhardt
2026-11-17 23:48 ` Justin Tobler
2026-11-11 16:48 ` Karthik Nayak
2026-11-17 23:57 ` Justin Tobler
2026-11-11 14:33 ` [PATCH 0/4] object-file: eagerly create ODB transaction temporary directory Karthik Nayak
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=avzlrYKsGIbyMz8r@denethor \
--to=jltobler@gmail.com \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox