From: Neeraj Singh <nksingh85@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Patrick Steinhardt" <ps@pks.im>,
git@vger.kernel.org, "Eric Wong" <e@80x24.org>,
"Neeraj K. Singh" <neerajsi@microsoft.com>
Subject: Re: [PATCH] refs: sync loose refs to disk before committing them
Date: Thu, 4 Nov 2021 15:36:00 -0700 [thread overview]
Message-ID: <20211104223600.GA4069@neerajsi-x1.localdomain> (raw)
In-Reply-To: <xmqqk0hn1unp.fsf@gitster.g>
On Thu, Nov 04, 2021 at 02:24:26PM -0700, Junio C Hamano wrote:
> Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
>
> > I think it would probably be best to create a git_fsync_fd() function
> > which is non-fatal and has that config/while loop, and have
> > fsync_or_die() be a "..or die()" wrapper around that, then you could
> > call that git_fsync_fd() here.
>
> Adding git_fsync_fd() smells like a poor taste, as git_fsync() takes
> an fd already. How about making the current one into a static helper
>
> -int git_fsync(int fd, enum fsync_action action)
> +static int git_fsync_once(int fd, enum fsync_action action)
> ...
>
> and then hide the looping behavior behind git_fsync() proper?
>
> int git_fsync(int fd, enum fsync_action action)
> {
> while (git_fsync_once(fd, action) < 0)
> if (errno != EINTR)
> return -1;
> return 0;
> }
>
> fsync_or_die() can be simplified by getting rid of its loop.
>
> None of that needs to block Patrick's work, I think. A version that
> uses raw fsync() and punts on EINTR can graduate first, which makes
> the situation better than the status quo, and all the ongoing work
> that deal with fsync can be extended with an eye to make it also
> usable to replace the fsync() call Patrick's fix adds.
Is there some reason we shouldn't die if writing the ref fails? We are
already accustomed to dying if fsyncing a packfile or the index fails.
I assume the number of refs updated is not that high on any given git
operation, so it's not worth having a batch mode for this eventually.
Thanks,
Neeraj
next prev parent reply other threads:[~2021-11-04 22:36 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-04 12:38 [PATCH] refs: sync loose refs to disk before committing them Patrick Steinhardt
2021-11-04 13:14 ` Ævar Arnfjörð Bjarmason
2021-11-04 14:51 ` Patrick Steinhardt
2021-11-04 21:24 ` Junio C Hamano
2021-11-04 22:36 ` Neeraj Singh [this message]
2021-11-05 1:40 ` Junio C Hamano
2021-11-05 6:36 ` Jeff King
2021-11-05 8:35 ` Ævar Arnfjörð Bjarmason
2021-11-05 9:04 ` Jeff King
2021-11-05 7:07 ` Jeff King
2021-11-05 7:17 ` Jeff King
2021-11-05 9:12 ` Johannes Schindelin
2021-11-05 9:22 ` Patrick Steinhardt
2021-11-05 9:34 ` Jeff King
2021-11-09 11:25 ` Patrick Steinhardt
2021-11-10 8:36 ` Jeff King
2021-11-10 9:16 ` Patrick Steinhardt
2021-11-10 11:40 ` [PATCH v2 0/3] " Patrick Steinhardt
2021-11-10 11:40 ` [PATCH v2 1/3] wrapper: handle EINTR in `git_fsync()` Patrick Steinhardt
2021-11-10 14:33 ` Johannes Schindelin
2021-11-10 14:39 ` Ævar Arnfjörð Bjarmason
2021-11-10 11:40 ` [PATCH v2 2/3] wrapper: provide function to sync directories Patrick Steinhardt
2021-11-10 14:40 ` Ævar Arnfjörð Bjarmason
2021-11-10 11:41 ` [PATCH v2 3/3] refs: add configuration to enable flushing of refs Patrick Steinhardt
2021-11-10 14:49 ` Ævar Arnfjörð Bjarmason
2021-11-10 19:15 ` Neeraj Singh
2021-11-10 20:23 ` Ævar Arnfjörð Bjarmason
2021-11-11 0:03 ` Neeraj Singh
2021-11-11 12:14 ` Patrick Steinhardt
2021-11-11 12:06 ` Patrick Steinhardt
2021-11-11 0:18 ` Neeraj Singh
2021-11-10 14:44 ` [PATCH v2 0/3] refs: sync loose refs to disk before committing them Johannes Schindelin
2021-11-10 20:45 ` Jeff King
2021-11-11 11:47 ` Patrick Steinhardt
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211104223600.GA4069@neerajsi-x1.localdomain \
--to=nksingh85@gmail.com \
--cc=avarab@gmail.com \
--cc=e@80x24.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=neerajsi@microsoft.com \
--cc=ps@pks.im \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).