Use sk_set_vmio() on the nbd socket.
Signed-off-by: Peter Zijlstra <[email protected]>
Signed-off-by: Daniel Phillips <[email protected]>
CC: Pavel Machek <[email protected]>
---
drivers/block/nbd.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
Index: linux-2.6/drivers/block/nbd.c
===================================================================
--- linux-2.6.orig/drivers/block/nbd.c
+++ linux-2.6/drivers/block/nbd.c
@@ -135,7 +135,6 @@ static int sock_xmit(struct socket *sock
spin_unlock_irqrestore(¤t->sighand->siglock, flags);
do {
- sock->sk->sk_allocation = GFP_NOIO;
iov.iov_base = buf;
iov.iov_len = size;
msg.msg_name = NULL;
@@ -525,6 +524,7 @@ static int nbd_ioctl(struct inode *inode
if (S_ISSOCK(inode->i_mode)) {
lo->file = file;
lo->sock = SOCKET_I(inode);
+ lo->sock->sk->sk_allocation = GFP_NOIO;
error = 0;
} else {
fput(file);
@@ -594,10 +594,30 @@ static int nbd_ioctl(struct inode *inode
return -EINVAL;
}
+static int nbd_swapdev(struct gendisk *disk, int enable)
+{
+ struct nbd_device *lo = disk->private_data;
+
+ if (enable) {
+ sk_adjust_memalloc(0, TX_RESERVE_PAGES);
+ if (!sk_set_vmio(lo->sock->sk))
+ printk(KERN_WARNING
+ "failed to set SOCK_VMIO on NBD socket\n");
+ } else {
+ if (!sk_clear_vmio(lo->sock->sk))
+ printk(KERN_WARNING
+ "failed to clear SOCK_VMIO on NBD socket\n");
+ sk_adjust_memalloc(0, -TX_RESERVE_PAGES);
+ }
+
+ return 0;
+}
+
static struct block_device_operations nbd_fops =
{
.owner = THIS_MODULE,
.ioctl = nbd_ioctl,
+ .swapdev = nbd_swapdev,
};
/*
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]