From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH v2 1/4] Introduce a function to lock/unlock file descriptors when appending
Date: Fri, 10 Aug 2018 23:31:14 +0200 (DST) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.1808102327080.71@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <xmqqzhxu6l81.fsf@gitster-ct.c.googlers.com>
Hi Junio,
On Fri, 10 Aug 2018, Junio C Hamano wrote:
> "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > +
> > +#ifndef GIT_WINDOWS_NATIVE
> > +int lock_or_unlock_fd_for_appending(int fd, int lock_it)
> > +{
> > + struct flock flock;
> > +
> > + flock.l_type = lock_it ? F_WRLCK : F_UNLCK;
> > +
> > + /* (un-)lock the whole file */
> > + flock.l_whence = SEEK_SET;
> > + flock.l_start = 0;
> > + flock.l_len = 0;
> > +
> > + return fcntl(fd, F_SETLKW, &flock);
> > +}
> > +#endif
>
> I think people already told you that this is not needed on systems
> with properly working O_APPEND [*1*]
I also wanted to safeguard against other (well-behaved) programs writing
to the trace file.
Granted, this is a bit theoretical, but it is quite possible that other
Git implementations do things differently than our trace.c. But with the
file locking that even that POSIX man page I quoted recommends, all this
is not an issue.
And this patch series implements that locking.
> Side note #1: and with network filesystems where O_APPEND
> may not work reliably, fcntl based range locking would not
> work either, so having this would not help.
At least on Windows, it would help, though.
And if there *is* a way to lock via NFS (which is the only network
filesystem I am aware of that has these locking issues, at least *some*
others are just fine), we would at least already have that function where
to implement it.
> I saw other Johannes and other Jeff peeking into fixing O_APPEND;
> I do not know how well that effort goes, but it would be preferrable
> if we can successfully go that route.
As I pointed out previously, my mail provider is losing mails left and
right for me. Could I ask for a pointer?
> As I said in my review of the first patch in v1 series, I am not
> fundamentally opposed to a few "lock here to work around lack of
> O_APPEND" and "unlock here for the same reason" calls to limited
> codepaths as a workaround, as the damage is limited (that is why I
> earlier looked at our use of O_APPEND), but that would be the last
> resort if O_APPEND cannot be made to work reliably on Windows.
>
> But even if we end up doing so, on systems with POSIX O_APPEND
> working, I think that function should be
>
> #define lock_or_unlock_for_appending(fd, lock) 0 /* nothing to do */
I think that that would be only appropriate if there were no other Git
implementations.
Ciao,
Dscho
next prev parent reply other threads:[~2018-08-10 21:31 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-09 17:35 [PATCH 0/4] t5552: fix flakiness by introducing proper locking for GIT_TRACE Johannes Schindelin via GitGitGadget
2018-08-09 17:35 ` [PATCH 1/4] Introduce a function to lock/unlock file descriptors when appending Johannes Schindelin via GitGitGadget
2018-08-09 19:01 ` Junio C Hamano
2018-08-10 18:32 ` Johannes Schindelin
2018-08-09 17:35 ` [PATCH 2/4] mingw: implement lock_or_unlock_fd_for_appending() Johannes Schindelin via GitGitGadget
2018-08-09 17:35 ` [PATCH 3/4] trace: lock the trace file to avoid racy trace_write() calls Johannes Schindelin via GitGitGadget
2018-08-09 17:35 ` [PATCH 4/4] trace: verify that locking works Johannes Schindelin via GitGitGadget
2018-08-09 19:47 ` [PATCH 0/4] t5552: fix flakiness by introducing proper locking for GIT_TRACE Jeff King
2018-08-09 20:49 ` Junio C Hamano
2018-08-09 21:08 ` Junio C Hamano
2018-08-09 21:32 ` Jeff King
2018-08-10 14:09 ` Jeff King
2018-08-10 15:58 ` Junio C Hamano
2018-08-10 15:58 ` Junio C Hamano
2018-08-10 16:43 ` Johannes Schindelin
2018-08-10 17:15 ` Jeff King
2018-08-10 18:40 ` Junio C Hamano
2018-08-10 19:34 ` Johannes Schindelin
2018-08-10 16:15 ` Johannes Sixt
2018-08-10 16:51 ` Jeff Hostetler
2018-08-10 16:57 ` Jeff Hostetler
2018-08-10 17:08 ` Johannes Sixt
2018-08-10 18:34 ` Junio C Hamano
2018-08-10 18:56 ` Jeff King
2018-08-13 19:02 ` [PATCH] mingw: enable atomic O_APPEND Johannes Sixt
2018-08-13 20:20 ` Junio C Hamano
2018-08-13 21:05 ` Johannes Sixt
2018-08-13 21:22 ` Ævar Arnfjörð Bjarmason
2018-08-13 21:55 ` Junio C Hamano
2018-08-13 22:37 ` Jeff King
2018-08-14 13:47 ` Ævar Arnfjörð Bjarmason
2018-08-14 14:53 ` Jeff King
2018-08-14 18:29 ` Johannes Sixt
2018-08-14 19:17 ` Jeff King
2018-08-14 13:01 ` Jeff Hostetler
2018-08-14 14:38 ` Junio C Hamano
2018-08-10 19:47 ` [PATCH v2 0/4] t5552: fix flakiness by introducing proper locking for GIT_TRACE Johannes Schindelin via GitGitGadget
2018-08-10 19:47 ` [PATCH v2 1/4] Introduce a function to lock/unlock file descriptors when appending Johannes Schindelin via GitGitGadget
2018-08-10 20:05 ` Junio C Hamano
2018-08-10 21:31 ` Johannes Schindelin [this message]
2018-08-10 19:47 ` [PATCH v2 2/4] mingw: implement lock_or_unlock_fd_for_appending() Johannes Schindelin via GitGitGadget
2018-08-10 19:47 ` [PATCH v2 3/4] trace: lock the trace file to avoid racy trace_write() calls Johannes Schindelin via GitGitGadget
2018-08-10 19:47 ` [PATCH v2 4/4] trace: verify that locking works Johannes Schindelin via GitGitGadget
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=nycvar.QRO.7.76.6.1808102327080.71@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=gitster@pobox.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.
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).