Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[PATCH] don't swapon mounted devices

1 view
Skip to first unread message

Bjorn Helgaas

unread,
Feb 5, 2003, 3:24:20 PM2/5/03
to
The attached patch against 2.4.21-pre3 fixes a problem in sys_swapon.
Previous behavior:

* boot kernel with "root=/dev/sda3 init=/bin/bash" (ext3 root)
* mount -t proc proc /proc
* /sbin/swapon /dev/sda3 <--- NOTE: same as root!
* mount -n -o remount,rw /
* oops in __make_request because superblock buffer_head is
no longer mapped (via sys_swapon -> set_blocksize ->
kill_bdev-> truncate_inode_pages -> do_flushpage ->
block_flushpage -> discard_bh_page -> discard_buffer)

I think 2.5 avoids this problem by attempting to get exclusive
use of the device with bd_claim (see
http://linux.bkbits.net:8080/linux-2.5/cs...@1.369.32.10?nav=index.html|src/.|src/mm|related/mm/swapfile.c)

bd_claim is not in 2.4, so this seems next-best.

Bjorn


--- 1.25/mm/swapfile.c Sat Dec 28 16:18:13 2002
+++ edited/mm/swapfile.c Wed Feb 5 10:32:27 2003
@@ -915,6 +915,11 @@
struct block_device_operations *bdops;
devfs_handle_t de;

+ if (is_mounted(dev)) {
+ error = -EBUSY;
+ goto bad_swap_2;
+ }
+
p->swap_device = dev;
set_blocksize(dev, PAGE_SIZE);

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majo...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

0 new messages