More Data: v1.10.0 swapon: swapfile has holes - blocksize ?

Jonathan Moore Jonathan.Moore at ubidyne.com
Thu Mar 27 14:04:34 UTC 2008


More data follows ....

/mnt $ dd if=/dev/zero of=/mnt/swapfile bs=1024 count=65536
65536+0 records in
65536+0 records out
/mnt $ mkswap /mnt/swapfile
Setting up swapspace version 1, size = 67104768 bytes
/mnt $ swapon /mnt/swapfile
swapon: blocks 131200 size 67108864
swapon: swapfile has holes
swapon: /mnt/swapfile: Invalid argument

mkswap and the extra debug output don't state the same size. Swapon is larger. Although blocks * 512 is larger than st.st_size, so no error statement is generated. I wonder if swapon believes the file is larger than it actually is ? Or does mkswap initialise the file with a header, hence actuall space will be reduced, hence swapon reports a lower than maximum size ?

With a block size of 512, I see a similar error:

/mnt $ rm swapfile
/mnt $ dd if=/dev/zero of=/mnt/swapfile bs=512 count=65536
65536+0 records in
65536+0 records out
/mnt $ mkswap /mnt/swapfile
Setting up swapspace version 1, size = 33550336 bytes
/mnt $ swapon /mnt/swapfile
swapon: blocks 65600 size 33554432
swapon: swapfile has holes
swapon: /mnt/swapfile: Invalid argument
/mnt $

On a different note:
bb_error_msg("blocks %lld size %%lld", (unsigned long long)st.st_blocks, (unsigned long long)st.st_size);
Contains a typo
bb_error_msg("blocks %lld size %lld", (unsigned long long)st.st_blocks, (unsigned long long)st.st_size);


Ubidyne GmbH
Lise-Meitner-Straße 14
D-89081 Ulm

mail      jonathan.moore at ubidyne.com
web       www.ubidyne.com
 
Registered office: Ulm
District court of Ulm: HRB 5295
Managing Directors:
Dipl. Ing. Ken Hawk
Dipl. Ing. Beat Müller
Dr. Clemens Rheinfelder

-----Original Message-----
From: Denys Vlasenko [mailto:vda.linux at googlemail.com] 
Sent: 27 March 2008 13:23
To: Jonathan Moore
Cc: busybox at busybox.net
Subject: Re: v1.10.0 swapon: swapfile has holes - blocksize ?

On Thursday 27 March 2008 12:49, Jonathan Moore wrote:
> The difference in messages is due to the ENABLE_DESKTOP define in swaponoff.c.
> It's the actual status = swapon(device, 0) call just after this check, 
> that is causing the error repost.

Yes. Code tries to do the following.

1. Check for "holeness", if it seems that there are holes,
   warn user.
2. Execute swapon() nevertheless, report errors if any.

There are four possible outcomes:

1. No errors.
2. "there are holes" warning, but swapon() worked - our "holeness" check is wrong.
3. no warning, but swapon() fails - most likely some problem not related to holes.
4. "there are holes" warning, and swapon() fails - most likely there are indeed holes.

You have case 4. Since it is strange (dd should have created file w/o holes), I'd like to have more data.

> BusyBox's swaponoff.c doesn't report a problem.
> 
> I need to look deeper into swapon, and also possibly mkswap and dd too.

Why don't you help bbox list to help you by letting us know what debug code *actually prints*?

> You can obtain more data by adding this message:
> 
>         if (S_ISREG(st.st_mode))
> {
> bb_error_msg("blocks %lld size %%lld", (unsigned long long)st.st_blocks, (unsigned long long)st.st_size);
>                 if (st.st_blocks * (off_t)512 < st.st_size)
>                         bb_error_msg("warning: swap file has holes"); 
> }

--
vda



More information about the busybox mailing list