git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Eric Wong <e@80x24.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/2] packfile: replace lseek+read with pread
Date: Thu, 26 Dec 2019 10:32:35 -0800	[thread overview]
Message-ID: <xmqqv9q3kke4.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <xmqqzhffkku2.fsf@gitster-ct.c.googlers.com> (Junio C. Hamano's message of "Thu, 26 Dec 2019 10:23:01 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> Eric Wong <e@80x24.org> writes:
>
>> We already have pread emulation for portability, so there's
>> there's no reason to make two syscalls where one suffices.
>>
>> Furthermore, readers of the packfile will be using mmap
>> (or pread to emulate mmap), anyways, so the file description
>> offset does not matter in this case.
>
> s/description/descriptor/ probably.
>
> After seeking to the packfile trailer and reading the pack id hash
> using lseek+read, this helper function does not read from the file
> descriptor, and the sole caller of it closes the file descriptor
> immediately after it returns, which means the read file offset after
> reading the packfile trailer does not matter.

Oops, that was not right.  When we successfully open the packfile,
we leave the file descriptor open, so we do need the "we never read
using read(2) from the file descriptor" guarantee for this change to
be correct.

But we do have the guarantee, and existing code does depend on the
guarantee, so the patch is good.

Thanks.

  reply	other threads:[~2019-12-26 18:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26 10:42 [PATCH 0/2] packfile: small syscall reductions Eric Wong
2019-12-26 10:42 ` [PATCH 1/2] packfile: remove redundant fcntl F_GETFD/F_SETFD Eric Wong
2019-12-26 10:42 ` [PATCH 2/2] packfile: replace lseek+read with pread Eric Wong
2019-12-26 18:23   ` Junio C Hamano
2019-12-26 18:32     ` Junio C Hamano [this message]
2019-12-26 18:59     ` Eric Wong

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=xmqqv9q3kke4.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=e@80x24.org \
    --cc=git@vger.kernel.org \
    /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).