Il Thu, Nov 09, 2006 at 12:38:51AM +0100, Rafael J. Wysocki ha scritto: > On Thursday, 9 November 2006 00:32, Luca Tettamanti wrote: > > On 11/8/06, Rafael J. Wysocki <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > On Wednesday, 8 November 2006 18:58, Luca wrote: > > > > I've been working on a small program to find the first valid block of a > > > > swapfile. If I understand it correctly we need the first contiguos > > > > cluster > > > > of blocks (not counting the header) which is at least PAGE_SIZE big and > > > > the starting block must be page aligned. > > > > The block number must then be converted in an offset from the start of > > > > the device and the number must be expressed in multiple of PAGE_SIZE. > > > > > > > > This is what I've come up with ;) > > > > > > It doesn't look bad, but you shouldn't skip the header, actually. The > > > header > > > is what we need. ;-) > > > > Oh, right.. you print the offset of page_no == 0. Hum, I think I don't > > understand the layout of a swapfile then; reading swapfile.c I see > > that even the header should be a PAGE_SIZE continuous block, but I > > have test cases where the header is not contiguous on disk (ext2, > > 1024b per block, with artificial fragmentation) - which is why I > > thought that first-page-after-header was needed. > > Ouch, that's bad. The swsusp (and ours) swap-writing code will corrupt > the filesystem in such a case, because it assumes the header to be > continuous. > > I think we have to understand your test cases at this point. Can you please > post some numbers?
Ok, ext2 FS, created with 'mke2fs -I 1024', mounted with loop device. I've created a fragmented swapfile like this: dd if=/dev/zero of=swapfile bs=1k count=1 dd if=/dev/zero of=frag bs=1k count=2 dd if=/dev/zero of=swapfile oflag=append conv=notrunc bs=1M count=10 debugfs: stat /swapfile Inode: 12 Type: regular Mode: 0644 Flags: 0x0 Generation: 1271405748 User: 0 Group: 0 Size: 10485760 File ACL: 0 Directory ACL: 0 Links: 1 Blockcount: 20562 Fragment: Address: 0 Number: 0 Size: 0 ctime: 0x45535207 -- Thu Nov 9 17:06:31 2006 atime: 0x45535217 -- Thu Nov 9 17:06:47 2006 mtime: 0x45535207 -- Thu Nov 9 17:06:31 2006 BLOCKS: (0):1998, (1-11):2001-2011, (IND):2012, (12-267):2013-2268, (DIND):2269, (IND):2270, (268-523):2271-2526, (IND):2527...etc The signature should in the first page (at PAGE_SIZE - 10), but in my case I see the signature exactly at offset (4096 - 10) 0000ff0: 0000 0000 0000 5357 4150 5350 4143 4532 ......SWAPSPACE2 even if the first 4 blocks are not contiguous (block 1998 is not even aligned to PAGE_SIZE!). The loop device may be have a bad influence on the test case, I don't have a FS with blocksize < 4096. Luca -- "It is more complicated than you think" -- The Eighth Networking Truth from RFC 1925 ------------------------------------------------------------------------- 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