Bug#352926: A patch to call fsync before renaming files over original binaries

2006-02-22 Thread Antti Salmela
On Tue, Feb 21, 2006 at 07:38:52PM -0800, Steve Langasek wrote:
> On Tue, Feb 21, 2006 at 05:22:31PM -0800, Steve Langasek wrote:
> > On Tue, Feb 21, 2006 at 04:10:54PM +0200, Antti Salmela wrote:
> > > Tags: patch
> 
> > > diff -ur prelink-0.0.20050901/src/cache.c 
> > > prelink-0.0.20050901.new/src/cache.c
> > > --- prelink-0.0.20050901/src/cache.c2004-10-01 22:29:08.0 
> > > +0300
> > > +++ prelink-0.0.20050901.new/src/cache.c2006-02-21 
> > > 15:56:33.0 +0200
> > > @@ -608,6 +608,7 @@
> > >if (write (fd, &cache, sizeof (cache)) != sizeof (cache)
> > >|| write (fd, data, len) != len
> > >|| fchmod (fd, 0644)
> > > +  || fsync (fd)
> > >|| close (fd)
> > >|| rename (prelink_cache_tmp, prelink_cache))
> > >  {
> > > diff -ur prelink-0.0.20050901/src/dso.c prelink-0.0.20050901.new/src/dso.c
> > > --- prelink-0.0.20050901/src/dso.c  2005-07-18 14:15:39.0 
> > > +0300
> > > +++ prelink-0.0.20050901.new/src/dso.c  2006-02-21 15:57:17.0 
> > > +0200
> > > @@ -1601,6 +1601,8 @@
> > >  }
> > > 
> > >elf_end (dso->elf);
> > > +  if (dso_is_rdwr (dso))
> > > +fsync (dso->fd);
> > >close (dso->fd);
> > >if (dso->elfro)
> > >  {
> 
> > Um, if you have to call fsync to ensure the filesystem does the write before
> > the rename, isn't that a filesystem bug?  I.e., isn't it a violation of
> > POSIX filesystem semantics for these ops to *not* be processed in order?
> 
> Also, what filesystem and mount options are you using for / and /usr,
> please?

ext3 with default mount options, that means data=ordered. I dont know if
POSIX mandates that file data must be flushed to disk before rename(), but I
think ext3 does that only with data=journal. 

-- 
Antti Salmela


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Bug#352926: A patch to call fsync before renaming files over original binaries

2006-02-21 Thread Steve Langasek
On Tue, Feb 21, 2006 at 05:22:31PM -0800, Steve Langasek wrote:
> On Tue, Feb 21, 2006 at 04:10:54PM +0200, Antti Salmela wrote:
> > Tags: patch

> > diff -ur prelink-0.0.20050901/src/cache.c 
> > prelink-0.0.20050901.new/src/cache.c
> > --- prelink-0.0.20050901/src/cache.c2004-10-01 22:29:08.0 +0300
> > +++ prelink-0.0.20050901.new/src/cache.c2006-02-21 
> > 15:56:33.0 +0200
> > @@ -608,6 +608,7 @@
> >if (write (fd, &cache, sizeof (cache)) != sizeof (cache)
> >|| write (fd, data, len) != len
> >|| fchmod (fd, 0644)
> > +  || fsync (fd)
> >|| close (fd)
> >|| rename (prelink_cache_tmp, prelink_cache))
> >  {
> > diff -ur prelink-0.0.20050901/src/dso.c prelink-0.0.20050901.new/src/dso.c
> > --- prelink-0.0.20050901/src/dso.c  2005-07-18 14:15:39.0 +0300
> > +++ prelink-0.0.20050901.new/src/dso.c  2006-02-21 15:57:17.0 +0200
> > @@ -1601,6 +1601,8 @@
> >  }
> > 
> >elf_end (dso->elf);
> > +  if (dso_is_rdwr (dso))
> > +fsync (dso->fd);
> >close (dso->fd);
> >if (dso->elfro)
> >  {

> Um, if you have to call fsync to ensure the filesystem does the write before
> the rename, isn't that a filesystem bug?  I.e., isn't it a violation of
> POSIX filesystem semantics for these ops to *not* be processed in order?

Also, what filesystem and mount options are you using for / and /usr,
please?

-- 
Steve Langasek   Give me a lever long enough and a Free OS
Debian Developer   to set it on, and I can move the world.
[EMAIL PROTECTED]   http://www.debian.org/


signature.asc
Description: Digital signature


Bug#352926: A patch to call fsync before renaming files over original binaries

2006-02-21 Thread Steve Langasek
On Tue, Feb 21, 2006 at 04:10:54PM +0200, Antti Salmela wrote:
> Tags: patch

> diff -ur prelink-0.0.20050901/src/cache.c prelink-0.0.20050901.new/src/cache.c
> --- prelink-0.0.20050901/src/cache.c2004-10-01 22:29:08.0 +0300
> +++ prelink-0.0.20050901.new/src/cache.c2006-02-21 15:56:33.0 
> +0200
> @@ -608,6 +608,7 @@
>if (write (fd, &cache, sizeof (cache)) != sizeof (cache)
>|| write (fd, data, len) != len
>|| fchmod (fd, 0644)
> +  || fsync (fd)
>|| close (fd)
>|| rename (prelink_cache_tmp, prelink_cache))
>  {
> diff -ur prelink-0.0.20050901/src/dso.c prelink-0.0.20050901.new/src/dso.c
> --- prelink-0.0.20050901/src/dso.c  2005-07-18 14:15:39.0 +0300
> +++ prelink-0.0.20050901.new/src/dso.c  2006-02-21 15:57:17.0 +0200
> @@ -1601,6 +1601,8 @@
>  }
> 
>elf_end (dso->elf);
> +  if (dso_is_rdwr (dso))
> +fsync (dso->fd);
>close (dso->fd);
>if (dso->elfro)
>  {

Um, if you have to call fsync to ensure the filesystem does the write before
the rename, isn't that a filesystem bug?  I.e., isn't it a violation of
POSIX filesystem semantics for these ops to *not* be processed in order?

-- 
Steve Langasek   Give me a lever long enough and a Free OS
Debian Developer   to set it on, and I can move the world.
[EMAIL PROTECTED]   http://www.debian.org/


signature.asc
Description: Digital signature


Bug#352926: A patch to call fsync before renaming files over original binaries

2006-02-21 Thread Antti Salmela
Tags: patch

diff -ur prelink-0.0.20050901/src/cache.c prelink-0.0.20050901.new/src/cache.c
--- prelink-0.0.20050901/src/cache.c2004-10-01 22:29:08.0 +0300
+++ prelink-0.0.20050901.new/src/cache.c2006-02-21 15:56:33.0 
+0200
@@ -608,6 +608,7 @@
   if (write (fd, &cache, sizeof (cache)) != sizeof (cache)
   || write (fd, data, len) != len
   || fchmod (fd, 0644)
+  || fsync (fd)
   || close (fd)
   || rename (prelink_cache_tmp, prelink_cache))
 {
diff -ur prelink-0.0.20050901/src/dso.c prelink-0.0.20050901.new/src/dso.c
--- prelink-0.0.20050901/src/dso.c  2005-07-18 14:15:39.0 +0300
+++ prelink-0.0.20050901.new/src/dso.c  2006-02-21 15:57:17.0 +0200
@@ -1601,6 +1601,8 @@
 }

   elf_end (dso->elf);
+  if (dso_is_rdwr (dso))
+fsync (dso->fd);
   close (dso->fd);
   if (dso->elfro)
 {

-- 
Antti Salmela


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]