On Sunday, 12 November 2006 01:00, Luca Tettamanti wrote:
> On 11/11/06, Rafael J. Wysocki <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > On Saturday, 11 November 2006 22:04, Pavel Machek wrote:
> > > Hi!
> > >
> > > > > Yeah :)
> > > >
> > > > Looks good, one small comment below.
> > > >
> > > > _However_,
> > > >
> > > > I think we can do one more thing.  Namely, if the header is not 
> > > > continuous,
> > > > the kernel will leave the first continuous PAGE_SIZE "block" of the 
> > > > swap file
> > > > untouched.  So, why don't we copy the swap signature into that "block",
> > > > to the place in which it would be if the the header was there, and 
> > > > return
> > > > its offset as the offset of the header?  Then, swsusp and s2disk should 
> > > > work
> > > > normally as well as the swap.
> > > >
> > > > I don't think the program should do this automatically, but there may 
> > > > be a
> > > > flag allowing the user to modify a swap file with non-continuous header 
> > > > so
> > > > that it can be used for suspending.
> > >
> > > I'm pretty sure we do not want *that* hack.
> > >
> > > ...don't we check header at offset ~4090, while writing some data to
> > > offset 0? If the file is not contiguous, this will kill data, no?
> >
> > Files may be non-continuous, but the swap-handling code finds continuous
> > PAGE_SIZE-sized blocks in them and maps these blocks using extents.  The 
> > first
> > PAGE_SIZE continuous block of a swap files is _never_ used for saving
> > any swap data, because it _may_ contain the swap header, but it _won't_
> > contain it if the header is not continuous (in such a case it may contain 
> > some
> > part of the header, though).
> >
> > Now if the swap header is not continuous (which _is_ possible, as the Luca's
> > example clearly shows), swsusp (and s2disk) won't be able to use that file
> > for suspending, because the swap signature is not where they expect it to be
> > (they expect the signature to be at the offset 4090 of the first 
> > _continuous_
> > PAGE_SIZE.block of the swap file).  However, in that case there are no swap
> > data at the offset 4090 of the first continuous PAGE_SIZE.block of the swap
> > file (this block is never used for saving data), so we can _safely_ copy the
> > swap signature into this place.
> 
> The header contains also other information (most notably bad and
> available pages).

If the header is not continuous, it won't matter to us, because we won't be
modifying the real header.

> > There only is danger that we could damage the real swap signature (ie. the
> > one that is used by the swap-handling code) if we modified the swap header
> > carelessly, but this is not the case.
> 
> It may impossible to copy it over (in case the real header overlaps
> the free page)

We don't need to copy the entire header.  We _only_ need to copy the signature
itself, and because it is the last 10 bytes of the blank page, it won't overlap 
with
anything (if it overlaps, the header is in a countinuous PAGE_SIZE block, but
we have assumed this is not the case, so it is impossible).

> and it may go out sync if the kernel updates the real 
> header (e.g. when it finds a bad block - unlikely but you never
> now...).

No, it won't, because the kernel will only modify the _real_ header, and not
the blank page area that doesn't overlap with the header.

> But AFAICS the offset is only needed for swap_type_of();

No.  In fact it's mostly needed for the resume, because the resume code
has no other means to find the swap header.

> instead using the extents it may be possible to use somehow the
> 'struct file' (f_path? sounds interesting :D) for swapfiles.

Yes, it is possible for the suspend, but not for the resume.

> > > Even if I'm wrong: If header is fragmented, it is likely that rest
> > > will also be fragmented and unusable, no?
> >
> > Not necessarily.
> >
> > Still, I'm not going to argue for using this hack, although I'm pretty sure
> > it would be 100% safe.
> >
> > In fact, I'd like to include the Luca's program in its current form into the
> > release, but it's missing a license notice ...
> 
> Released under GPLv2 (as per LICENSE file), feel free to add the usual
> boilerplate.

Okay, thanks.  I'll add a header like in the other files (eg. suspend.c).

Greetings,
Rafael


-- 
You never change things by fighting the existing reality.
                R. Buckminster Fuller


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Suspend-devel mailing list
Suspend-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/suspend-devel

Reply via email to