From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: Johannes Sixt <j6t@kdbg.org>, Ben Knoble <ben.knoble@gmail.com>,
Jeff King <peff@peff.net>,
"brian m. carlson" <sandals@crustytoothpaste.net>,
"Randall S. Becker" <randall.becker@nexbridge.ca>,
Phillip Wood <phillip.wood@dunelm.org.uk>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>,
git@vger.kernel.org
Subject: Re: [PATCH 0/5] Reintroduce writev(3p)
Date: Fri, 7 Aug 2026 08:29:59 +0200 [thread overview]
Message-ID: <anV7Z1fmC-HhaNfy@pks.im> (raw)
In-Reply-To: <xmqqcxvvhu6q.fsf@gitster.g>
On Thu, Aug 06, 2026 at 01:26:21PM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
>
> > On Wed, Aug 05, 2026 at 01:29:44PM -0700, Junio C Hamano wrote:
> >> Johannes Sixt <j6t@kdbg.org> writes:
> >>
> >> > Am 05.08.26 um 20:40 schrieb Junio C Hamano:
> >> >> I think it is OK to explicitly document that any writev(2) emulation
> >> >> is allowed to be non-atomic, and it is also OK to declare that using
> >> >> writev(2) in this application to allow competing writes to the same
> >> >> destination is a bug.
> >> >
> >> > These are fine.
> >> >
> >> > But I'm not worried about current uses of writev, I'm worried about
> >> > future uses: "Look, we already use writev elsewhere. Let's use it here,
> >> > too, where we can take adavantage of the atomicity of the write." It's
> >> > too easy to miss a note about non-atomic emulations when the function
> >> > name advertises more than can be guaranteed. For this reason, I strongly
> >> > suggest to use a different name.
> >>
> >> That is why I added the "it is also OK to declare" in the above.
> >
> > We could of course trivially restore the non-interleaving property by
> > only ever writing the first iovec. POSIX doesn't guarantee that the full
> > iovec is being written, and write(3p) is already non-interleaving. It
> > wouldn't even be less efficient compared to the current implementation,
> > as we have to loop around write(3p) anyway in our compatibility wrapper.
>
> OK, by castrating the writev(2) emulation implementation to write
> out only the first iovec[], we are making the emulation "atomic", so
> there is no need to say "your emulation does not have to be atomic"
> and we can rely on being able to pretend that we have writev(2)
> available everywhere. Also, it is a bug on the programmers' side to
> assume that their writev() calls will not result in a short write,
> so it does not have to be spelled out, either, which automatically
> means you'd better be calling writev_in_full() and not writev()
> itself.
>
> I can buy that. Clever. It means we'd need an update for [PATCH
> 1/5] 1ed0bc4e3b (compat/posix: introduce writev(3p) wrapper,
> 2026-07-16), right? The update would be a simplification that loses
> a lot of code (and overflow check), which is even nicer ;-).
Yeah, exactly. The overflow check I think we should keep though to be
closer to the POSIX requirements.
Patrick
next prev parent reply other threads:[~2026-08-07 6:30 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 7:52 [PATCH 0/5] Reintroduce writev(3p) Patrick Steinhardt
2026-07-16 7:52 ` [PATCH 1/5] compat/posix: introduce writev(3p) wrapper Patrick Steinhardt
2026-07-16 8:47 ` Simon Richter
2026-07-16 20:09 ` Junio C Hamano
2026-07-16 20:44 ` Junio C Hamano
2026-08-05 8:30 ` Patrick Steinhardt
2026-07-16 7:52 ` [PATCH 2/5] wrapper: introduce writev(3p) wrappers Patrick Steinhardt
2026-07-16 7:52 ` [PATCH 3/5] wrapper: properly handle MAX_IO_SIZE in writev(3p) Patrick Steinhardt
2026-07-16 7:52 ` [PATCH 4/5] sideband: use writev(3p) to send pktlines Patrick Steinhardt
2026-07-16 7:52 ` [PATCH 5/5] fast-import: use writev(3p) to send cat-blob responses Patrick Steinhardt
2026-07-16 18:56 ` [PATCH 0/5] Reintroduce writev(3p) Johannes Sixt
2026-07-27 15:44 ` Junio C Hamano
2026-08-05 8:30 ` Patrick Steinhardt
2026-08-05 16:36 ` Junio C Hamano
2026-08-05 17:55 ` Johannes Sixt
2026-08-05 18:40 ` Junio C Hamano
2026-08-05 20:00 ` Johannes Sixt
2026-08-05 20:29 ` Junio C Hamano
2026-08-06 6:28 ` Patrick Steinhardt
2026-08-06 20:26 ` Junio C Hamano
2026-08-07 6:29 ` Patrick Steinhardt [this message]
2026-08-07 6:18 ` [PATCH v2 " Patrick Steinhardt
2026-08-07 6:18 ` [PATCH v2 1/5] compat/posix: introduce writev(3p) wrapper Patrick Steinhardt
2026-08-07 6:18 ` [PATCH v2 2/5] wrapper: introduce writev(3p) wrappers Patrick Steinhardt
2026-08-07 6:18 ` [PATCH v2 3/5] wrapper: properly handle MAX_IO_SIZE in writev(3p) Patrick Steinhardt
2026-08-07 6:18 ` [PATCH v2 4/5] sideband: use writev(3p) to send pktlines Patrick Steinhardt
2026-08-07 6:18 ` [PATCH v2 5/5] fast-import: use writev(3p) to send cat-blob responses 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=anV7Z1fmC-HhaNfy@pks.im \
--to=ps@pks.im \
--cc=Johannes.Schindelin@gmx.de \
--cc=ben.knoble@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=peff@peff.net \
--cc=phillip.wood@dunelm.org.uk \
--cc=randall.becker@nexbridge.ca \
--cc=sandals@crustytoothpaste.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox