git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC v4 0/13] Introduce index file format version 5
@ 2012-08-16  9:58 Thomas Gummerer
  2012-08-16  9:58 ` [PATCH/RFC v4 01/13] Move index v2 specific functions to their own file Thomas Gummerer
                   ` (12 more replies)
  0 siblings, 13 replies; 17+ messages in thread
From: Thomas Gummerer @ 2012-08-16  9:58 UTC (permalink / raw)
  To: git; +Cc: trast, pclouds, mhagger, gitster, robin.rosenberg, t.gummerer

Previous rounds of the series are at $gmane/202752 and $gmane/202923
and $gmane/203088.

The modification to t3700 was removed as the smudge marker is replaced
with a CE_SMUDGED flag and therefore the code doesn't interfere with
the test.

Changes since the last round:

 [PATCH/RFC v4 01/13] Move index v2 specific functions to their own
 [PATCH/RFC v4 02/13] read-cache.c: Re-read index if index file
    Re-read the index file if the index file has changed since
    the first time we read it.  Checking if the index file changed
    is done by using it's stat data.

 [PATCH/RFC v4 03/13] t2104: Don't fail for index versions other than
 [PATCH/RFC v4 04/13] Add documentation of the index-v5 file format
    Documentation updates as suggested by Junio.

 [PATCH/RFC v4 05/13] Make in-memory format aware of stat_crc
 [PATCH/RFC v4 06/13] Read index-v5
    Replace the pointer casts with ptr_add makro as suggested by Junio.

    Use a CE_SMUDGED flag instaed of ce_mtime as smudge marker.

    Ignore the crc sum if we don't trust_cetime, since it may give
    us wrong results.

 [PATCH/RFC v4 07/13] Read resolve-undo data
    No longer do the conversion in resolve-undo.c but in
    read-cache-v5.c.  (The same is valid for 11/13)

 [PATCH/RFC v4 08/13] Read cache-tree in index-v5
    No longer do the conversion in cache-tree.c but in
    read-cache-v5.c.  (The same is valid for 10/13)

 [PATCH/RFC v4 09/13] Write index-v5
 [PATCH/RFC v4 10/13] Write index-v5 cache-tree data
 [PATCH/RFC v4 11/13] Write resolve-undo data for index-v5
 [PATCH/RFC v4 12/13] update-index.c: rewrite index when
    Don't introduce the force-rewrite option, but always rewrite the
    index if a index-version is given.

 [PATCH/RFC v4 13/13] p0002-index.sh: add perf test for the index

^ permalink raw reply	[flat|nested] 17+ messages in thread
* Re: [PATCH/RFC v4 02/13] read-cache.c: Re-read index if index file changed
@ 2012-08-25 16:02 Joachim Schmitz
  2012-08-27  9:39 ` Thomas Gummerer
  0 siblings, 1 reply; 17+ messages in thread
From: Joachim Schmitz @ 2012-08-25 16:02 UTC (permalink / raw)
  To: t.gummerer; +Cc: git

"Thomas Gummerer" <t.gummerer@gmail.com> schrieb im Newsbeitrag news:<1345111129-6925-3-git-send-email-t.gummerer@gmail.com>...
> Add the possibility of re-reading the index file, if it changed
> while reading.
> 
> The index file might change during the read, causing outdated
> information to be displayed. We check if the index file changed
> by using its stat data as heuristic.
> 
> Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
> ---
>  read-cache.c | 87 +++++++++++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 60 insertions(+), 27 deletions(-)
> 
> diff --git a/read-cache.c b/read-cache.c
> index 6a8b4b1..cdd8480 100644
> --- a/read-cache.c
> +++ b/read-cache.c
...
> @@ -1186,38 +1209,48 @@ int read_index_from(struct index_state *istate, const char *path)
>  	errno = ENOENT;
>  	istate->timestamp.sec = 0;
>  	istate->timestamp.nsec = 0;
> -	fd = open(path, O_RDONLY);
> -	if (fd < 0) {
> -		if (errno == ENOENT)
> -			return 0;
> -		die_errno("index file open failed");
> -	}
> +	do {
> +		err = 0;
> +		fd = open(path, O_RDONLY);
> +		if (fd < 0) {
> +			if (errno == ENOENT)
> +				return 0;
> +			die_errno("index file open failed");
> +		}
>  
> -	if (fstat(fd, &st))
> -		die_errno("cannot stat the open index");
> +		if (fstat(fd, &st_old))
> +			die_errno("cannot stat the open index");
>  
> -	errno = EINVAL;
> -	mmap_size = xsize_t(st.st_size);
> -	mmap = xmmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
> -	close(fd);
> -	if (mmap == MAP_FAILED)
> -		die_errno("unable to map index file");
> +		errno = EINVAL;
> +		mmap_size = xsize_t(st_old.st_size);
> +		mmap = xmmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
> +		close(fd);
> +		if (mmap == MAP_FAILED)
> +			die_errno("unable to map index file");
>  
> -	hdr = mmap;
> -	if (verify_hdr_version(istate, hdr, mmap_size) < 0)
> -		goto unmap;
> +		hdr = mmap;
> +		if (verify_hdr_version(istate, hdr, mmap_size) < 0)
> +			err = 1;
>  
> -	if (istate->ops->verify_hdr(mmap, mmap_size) < 0)
> -		goto unmap;
> +		if (istate->ops->verify_hdr(mmap, mmap_size) < 0)
> +			err = 1;
>  
> -	istate->ops->read_index(istate, mmap, mmap_size);
> -	istate->timestamp.sec = st.st_mtime;
> -	istate->timestamp.nsec = ST_MTIME_NSEC(st);
> +		if (istate->ops->read_index(istate, mmap, mmap_size) < 0)
> +			err = 1;
> +		istate->timestamp.sec = st_old.st_mtime;
> +		istate->timestamp.nsec = ST_MTIME_NSEC(st_old);
> +		if (lstat(path, &st_new))
> +			die_errno("cannot stat the open index");
>  
> -	munmap(mmap, mmap_size);
> -	return istate->cache_nr;
> +		munmap(mmap, mmap_size);
> +
> +		if (!index_changed(st_old, st_new) && !err)
> +			return istate->cache_nr;
> +
> +		usleep(10*1000);


usleep() is not available to anybody, e.g. it is not in HP NonStop (not in every case at least)

Bye, Jojo

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2012-09-07  7:22 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-16  9:58 [PATCH/RFC v4 0/13] Introduce index file format version 5 Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 01/13] Move index v2 specific functions to their own file Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 02/13] read-cache.c: Re-read index if index file changed Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 03/13] t2104: Don't fail for index versions other than [23] Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 04/13] Add documentation of the index-v5 file format Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 05/13] Make in-memory format aware of stat_crc Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 06/13] Read index-v5 Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 07/13] Read resolve-undo data Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 08/13] Read cache-tree in index-v5 Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 09/13] Write index-v5 Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 10/13] Write index-v5 cache-tree data Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 11/13] Write resolve-undo data for index-v5 Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 12/13] update-index.c: rewrite index when index-version is given Thomas Gummerer
2012-08-16  9:58 ` [PATCH/RFC v4 13/13] p0002-index.sh: add perf test for the index formats Thomas Gummerer
  -- strict thread matches above, loose matches on Subject: below --
2012-08-25 16:02 [PATCH/RFC v4 02/13] read-cache.c: Re-read index if index file changed Joachim Schmitz
2012-08-27  9:39 ` Thomas Gummerer
2012-09-07  7:22   ` Joachim Schmitz

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 NNTP newsgroup(s).