[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] swap problem



On Mon, Mar 06, 2000 at 11:10:24PM +0100, Jens Kristian Søgaard wrote:
: I suppose you've never really read the kernel source for the VM?

Actually, you didn't read my answer :)  I said that you can use swapfiles, but
the kernel didn't see them any different then partitions.  I never said how 
then handled them internally.  I really don't think the people on this list
are up to a complete discussion of the internals of Linux's virtual memory
setup.
 
: Internally swap files and swap partitions are in many ways handled
: equally, but at some (low level) point - they must be treated
: differently. There's no concept of "file descriptors" to be put in use
: here.

I didn't state how the kernel hanndled themm, I stated that the kernel 
seem them the say way.  There is a difference there.  Internally, there is
a difference between the two but if you setup /dev/hda2 and /swap as swap
(device, files, whatever) it treats them that same.  Internally,  you correct.

You're now talking....

	( check this is a block device and not currently swapping on it)
       if (S_ISBLK(swap_dentry->d_inode->i_mode)) {
                p->swap_device = swap_dentry->d_inode->i_rdev;
                set_blocksize(p->swap_device, PAGE_SIZE);
                
                filp.f_dentry = swap_dentry;
                filp.f_mode = 3; /* read write */
                error = blkdev_open(swap_dentry->d_inode, &filp);
                if (error)
                        goto bad_swap_2;
                set_blocksize(p->swap_device, PAGE_SIZE);
                error = -ENODEV;
                if (!p->swap_device ||
                    (blk_size[MAJOR(p->swap_device)] &&
                     !blk_size[MAJOR(p->swap_device)][MINOR(p->swap_device)]))
                        goto bad_swap;
                error = -EBUSY;
                for (i = 0 ; i < nr_swapfiles ; i++) {
                        if (i == type)
                                continue;
                        if (p->swap_device == swap_info[i].swap_device)
                                goto bad_swap;
                }
[ vs ]

	( or a regular file and not using it)
    } else if (S_ISREG(swap_dentry->d_inode->i_mode)) {
                error = -EBUSY;
                for (i = 0 ; i < nr_swapfiles ; i++) {
                        if (i == type)
                                continue;
                        if (swap_dentry->d_inode == swap_info[i].swap_file->d_in
ode)
                                goto bad_swap;
                }
.....(I belive this is what we are refering to?)

 
: There's a subtle difference between writing/reading to a partition and
: a file. Then you read/write to a file, it (the smap()) must go through
: the filesystem (you can have swapfiles on a vfat filesystem, fx). When
: you're dealing with a partition, you can "just" write as you like.
: 
: Imagine networked swapfiles... not quite the same thing as a direct
: write...
: 
: In the code you see a lot of branches, being "is swap file? or
: partition?" ... there's a reason for those!

Actually, it looks for block devices or regular files.

Point being, how the kernel sees it is the same, what it does with it is 
different.  By default, the racks use swap partitions and those are the 
most common way that people setup their Linux boxes.

-- 
Mat Kovach                                      mkovach@xxxxxxxxxxxxxxxxx
Cleveland Linux User Group                       http://cleveland.lug.net