Use sk_set_vmio() on the nbd socket. Signed-off-by: Peter Zijlstra Signed-off-by: Daniel Phillips CC: Pavel Machek --- 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/