Re: Raw-io & Swap partitions

Khimenko Victor (khim@sch57.msk.ru)
Tue, 22 Dec 1998 16:42:19 +0300 (MSK)


In <Pine.LNX.3.96.981222104314.7914D-100000@ps.cus.umist.ac.uk> Riley Williams (rhw@bigfoot.com) wrote:
RW> Hi there.

>>>> There seem to be fairly significant parallels between Linux's
>>>> support of special partitions for swap, and the arguments for
>>>> raw disk I/O.

>>>> If the arguments against raw-io are technically correct, why do
>>>> we still support partition level access to swap ?

>>> I'm no expert on this, but my understanding is that swap needs to
>>> have the entire swap area in contiguous sectors, which can't be
>>> guaranteed for files, but is a given with partitions.

>> Of course this is not a case :-) At least for last four years ...

RW> Like I said, I'm no expert...but your comments appear to indicate that
RW> my comments are correct...

Of course not :-) They are indicate just that you are STILL unaware about how
powerfull ext2fs is :-))

>>> Indeed, as I understand it, on the ext2 file system, ANY file
>>> that's over 16 Megs in size is of necessity split into several
>>> separate fragments...

>> Hm. Looks like not all you statements are lie. This is correct.

RW> I have to admit that comment surprises me, as I never expected you to
RW> admit that somebody other than yourself can tell the truth...

Oops. There are a lot of peoples who can tell the truth far more often then I
am: Alan Cox, Linus Torvalds, Rik van Riel, etc. Not you unfortunatelly :-((

>>>> Assuming there's little performance difference between swap
>>>> partitions and swap files, swap files are a big win. No hardwired
>>>> decision on how much swap is needed, just create a swap file in
>>>> one of the filesystems. If you find it's too big or too small it
>>>> can be resized easilly. (Unlike a partition).

>>>> On the flip side, if swap partitions do give some advantages,
>>>> surely the same justification can be made for supporting raw-io.

>>> I don't believe it can, since the specific advantage gained by
>>> swap partitions that I mentioned above is in general irrelevant in
>>> all other contexts...

>> This is not so relevant for swap partition as well :-))

RW> WHy do you claim later in your missive that it is then?

Since you are REALLY clueless here. See below. This is really not relevant for
swap files !

>>>> Note: I'm not saying the two cases are identical, just that there
>>>> are fairly major simillarities.

>>> Unfortunately, swap also has some unique requirements which make
>>> the difference...

>> Not, of course.

RW> So why do you claim that they do have later in the same missive?

I'm NEVER claim something so stupid. May be on drugs I'll do but I'm not use
drugs.... Of course swap file should not contain holes -- swap subsystem in
Linux is not clever enough to fill this holes on swapon command :-(( This is
not unique requirements and could be easily fullfilled on ext2fs with 10Tb
files (on Alpha or Sparc of course -- on x86 there are famous 2Gb limit :-)

>>>> I appreciate that it's far easier to keep something out of the
>>>> kernel in the first place than to remove it later. However in the
>>>> case of swap partitions I'm confident they could be removed
>>>> painlessly. Just turn the partition into an e2fs one and create one
>>>> large file. (Worst case).

>>> Unfortunately wouldn't work - you'd have to creat a whole bunch of
>>> separate files, each just below the fragmentation limit, and each
>>> residing in a separate "block group" (the kernel's name, not mine),
>>> as otherwise, they'd be unusable...

>> You are joking ??? Gosh. Why you are permanently wrote something to
>> show your incompetency ? Of course this absolutely not a case. Do
>> you ever read `man mkswap` ? This is from there:

>> -- cut --
>> To setup a swap file, it is necessary to create that file
>> before running mkswap . A sequence of commands similar to
>> the following is reasonable for this purpose:
>>
>> # dd if=/dev/zero of=swapfile bs=1024 count=8192
>> # mkswap swapfile 8192
>> # sync
>> # swapon swapfile
>>
>> Note that a swap file must not contain any holes (so,
>> using cp(1) to create the file is not acceptable).
>> -- cut --

RW> Yes, I read that - and, as it points out, an 8 Meg swapfile created
RW> with the dd command is not a problem, since that's only half the size
RW> of the "block groups" that ext2 uses.

And 100Mb file is also not a problem :-)

RW> Your claim that I could replace any of my seven 126 Meg swap
RW> partitions with an ext2 partition containing one dirty great swap file
RW> is NOT consistant with that though, or have you overlooked the last
RW> sentence in your quote?

No. I'm not overlooked this sentence. No way. This is why you could not use
cp and should use dd instead. cp will make file with holes. Latest kernels
could use swap files >128Mb BTW.

RW> It does say "no holes", and that isn't possible on ext2 for files larger
RW> than the block group, AS YOU ADMITTED ABOVE...

GOSH. FANTASTIC ! You are THAT clueless !!! This is really shame for more then
year old linux user ! Are you REALLY unaware about what "holes in files" means ?
Damn. Of course you could make 1Gb file on ext2fs without ANY HOLES in them.
File will not be contigous but this is not a problem for swap file... Ok. If
you are not aware about what are "holes in files" then what the hell you are
doing in linux-kernel list ??? Short example:
-- cut --
[root@localhost /root]# cat test.c
#include <sys/stat.h>
#include <unistd.h>

main() {
int fd=creat("/tmp/testfile",S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP);
lseek(fd,0x40000000-1,SEEK_SET);
write(fd,&fd,1);
close(fd);
}
[root@localhost /root]# gcc -O6 test.c -o test
[root@localhost /root]# ./test
[root@localhost /root]# ls -al /tmp/testfile
-rw-r----- 1 root root 1073741824 Dec 22 16:08 /tmp/testfile
[root@localhost /root]# du -s /tmp/testfile
4 /tmp/testfile
[root@localhost /root]#
-- cut --
See ? There are file /tmp/testfile with 1Gb size but this file use only 4K on
disk since there are VERY VERY big hole. Such file could not be used as swap
file... Non-contigous file is not a problem for swap, file with holes is.

>> I'm does not have swap partition here at all (this was BIG problem
>> while setting up RedHat 5.1 -- I was REALLY mad when found that I'm
>> could not setup RedHat 5.1 without swap partition like RedHat 4.x
>> or RedHat 5.0 @##%^$%$^#$@). Instead I'm have commands

>> -- cut --
>> mkswap /dos/d-w95/windows/win386.swp
>> sync
>> swapon /dos/d-w95/windows/win386.swp
>> -- cut --

RW> I note that you're using VFAT partitions, not EXT2 ones like you were
RW> referring to in your original post. This is presumably because (unlike
RW> your claims) swap files larger than the block group size don't work on
RW> EXT2 partitions...

When I'm need really big swap area for some reason I'm use temporarily created
100-120Mb file on ext2fs :-) Like this:
-- cut --
dd if=/dev/zero of=/dev/swapfile count=120000 bs=1024
mkswap /dev/swapfile
sync
swapon /dev/swapfile
-- cut --
And of course win386.swp CREATED BY Windows 9x is usually NOT contigous :-))

>> This way I'm could use the same swap file in Linux and Windows 98
>> :-) And of course for last four years Linux was able to use swap
>> file instead of swap partition -- no problems with "block groups"
>> or whatever. On FAT (including FAT32 via VFAT as in example above
>> :-), ext2fs, etc.

RW> On FAT or VFAT, sure - I've never said otherwise. It's your stupid
RW> claim that 126 Meg swapfiles will work happily on EXT2 partitions that
RW> I'm challenging, and so far, you've succeeded in proving me right to
RW> challenge it...

Please try four lines above before challenging someone (especially me :-),
PLEASE. You'll be surprized :-))

>> P.S. In fact there are problem with swap file: you should be able
>> to mount partition with swap file before use of this file ! This
>> could be problem for tiny computers with 2Mb RAM... But 2.1.1xx
>> could not use them anyway...

RW> In other words, swap files do indeed have special requirements that
RW> are not applicable to other uses of raw I/O. Thanks for confirming my
RW> claims...

Hm. You are not only clueless but you also do not want to think for minute :-((
Swap partition is improvement of the same level as raw I/O. The only excuse for
them is that they are already in kernel...

P.S. Your archive of old kernels is nice idea though...

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/