Hi,

On Mon, 15 Feb 2010, Jean-Baptiste Lallement wrote:
> Initially, I didn't synced the files extracted from the data area but
> they were all 0 bytes in case of crash. The situation would be the
> same as today.

I understand that but what matters is that they are not 0 bytes if the
package is marked as "unpacked", they could end up 0 bytes if the package
is marked "half-installed", it would not matter much since the unpack
would have to be redone.

That's why I why suggesting to call sync() when we switch from
half-installed to unpacked instead of calling fsync() individually.

> Using sync instead of fsync won't make a big difference I guess, sooner
> or later we need do pages need to be flushed to disk and it will have an
> effect on system's performance. On the other hand, calling fsync on each
> file makes operation atomic and prevent data loss if the crash occurs
> during the installation.

I understand that.

> The call to rename doesn't fsync files nor guarantees which file will be
> visible after a crash so we need to call fsync on the directory.

I was referring to http://lwn.net/Articles/322823/: "Finally, this patch
forces block allocation when one file is renamed on top of another."

So it's only true if the rename overwrites a file.

But we should not rely on the behaviour of a specific filesystem and we
should rather err on the side of caution, I agree and we should not assume
this.

> > This lead me to believe that it's not the proper place for this code.
> > Instead I think (but I would want Guillem's opinion) that it should
> > be in process_archive() just after the call to dpkg-deb --control.
> >
> The idea was to fsync the files as soon as they're extracted. That's why
> I've put it there instead of inside dpkg's code. In fact the problem is
> more with tar than dpkg.

Indeed.

> From what I've understood of the behavior of dpkg, when called from
> dpkg, the argument `directory' is not null only when we extract the
> control files.

The parameter is always given AFAIK.

> When dpkg-deb is run directly with the extract or vextract command we
> want to fsync files.

Those commands are not used internally by dpkg AFAIK. So it's not so
important as it looks like.

> I was unsure where to fsync the control file so I will clearly follow
> your advice here.

It's my suggestion, but I'm not an expert on the C part of dpkg, if
Guillem says something else, please follow his advice.

> Thanks for reviewing the code. I'll submit a corrected patch for debian
> within a week.

Great!

Cheers,
-- 
Raphaƫl Hertzog




--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: http://lists.debian.org/20100215084405.gb8...@rivendell

Reply via email to