From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
David Miller <davem@davemloft.net>,
Rik van Riel <riel@redhat.com>,
Daniel Phillips <phillips@google.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Pavel Machek <pavel@ucw.cz>
Subject: [PATCH 13/20] nbd: use swapdev hook to make swap deadlock free
Date: Tue, 12 Sep 2006 17:25:49 +0200 [thread overview]
Message-ID: <20060912144904.417049000@chello.nl> (raw)
In-Reply-To: 20060912143049.278065000@chello.nl
[-- Attachment #1: nbd_vmio.patch --]
[-- Type: text/plain, Size: 3048 bytes --]
Set SOCK_VMIO on the NBD socket and make sure the request_fn always
runs with PF_MEMALLOC when used as a swapper, this ensures we can
always flush the requests.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Daniel Phillips <phillips@google.com>
CC: Pavel Machek <pavel@ucw.cz>
---
drivers/block/nbd.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
Index: linux-2.6/drivers/block/nbd.c
===================================================================
--- linux-2.6.orig/drivers/block/nbd.c 2006-09-07 18:44:12.000000000 +0200
+++ linux-2.6/drivers/block/nbd.c 2006-09-07 18:44:22.000000000 +0200
@@ -139,7 +139,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;
@@ -406,10 +405,13 @@ static void nbd_clear_que(struct nbd_dev
static void do_nbd_request(request_queue_t * q)
{
struct request *req;
+ unsigned long pflags = current->flags;
+ struct nbd_device *lo = q->queuedata;
+
+ if (lo->sock && sk_has_vmio(lo->sock->sk))
+ current->flags |= PF_MEMALLOC;
while ((req = elv_next_request(q)) != NULL) {
- struct nbd_device *lo;
-
blkdev_dequeue_request(req);
dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%lx)\n",
req->rq_disk->disk_name, req, req->flags);
@@ -417,8 +419,6 @@ static void do_nbd_request(request_queue
if (!(req->flags & REQ_CMD))
goto error_out;
- lo = req->rq_disk->private_data;
-
BUG_ON(lo->magic != LO_MAGIC);
nbd_cmd(req) = NBD_CMD_READ;
@@ -472,6 +472,7 @@ error_out:
* plug the device to close it.
*/
blk_plug_device(q);
+ current->flags = pflags;
return;
}
@@ -530,6 +531,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);
@@ -599,10 +601,33 @@ 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 (!lo->sock)
+ return -ENODEV;
+
+ 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,
};
/*
@@ -638,6 +663,7 @@ static int __init nbd_init(void)
put_disk(disk);
goto out;
}
+ disk->queue->queuedata = &nbd_dev[i];
blk_queue_max_segment_size(disk->queue, PAGE_SIZE);
blk_queue_max_hw_segments(disk->queue, 1);
blk_queue_max_phys_segments(disk->queue, 1);
--
WARNING: multiple messages have this Message-ID (diff)
From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Cc: Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
David Miller <davem@davemloft.net>,
Rik van Riel <riel@redhat.com>,
Daniel Phillips <phillips@google.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Pavel Machek <pavel@ucw.cz>
Subject: [PATCH 13/20] nbd: use swapdev hook to make swap deadlock free
Date: Tue, 12 Sep 2006 17:25:49 +0200 [thread overview]
Message-ID: <20060912144904.417049000@chello.nl> (raw)
In-Reply-To: 20060912143049.278065000@chello.nl
[-- Attachment #1: nbd_vmio.patch --]
[-- Type: text/plain, Size: 3273 bytes --]
Set SOCK_VMIO on the NBD socket and make sure the request_fn always
runs with PF_MEMALLOC when used as a swapper, this ensures we can
always flush the requests.
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Daniel Phillips <phillips@google.com>
CC: Pavel Machek <pavel@ucw.cz>
---
drivers/block/nbd.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
Index: linux-2.6/drivers/block/nbd.c
===================================================================
--- linux-2.6.orig/drivers/block/nbd.c 2006-09-07 18:44:12.000000000 +0200
+++ linux-2.6/drivers/block/nbd.c 2006-09-07 18:44:22.000000000 +0200
@@ -139,7 +139,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;
@@ -406,10 +405,13 @@ static void nbd_clear_que(struct nbd_dev
static void do_nbd_request(request_queue_t * q)
{
struct request *req;
+ unsigned long pflags = current->flags;
+ struct nbd_device *lo = q->queuedata;
+
+ if (lo->sock && sk_has_vmio(lo->sock->sk))
+ current->flags |= PF_MEMALLOC;
while ((req = elv_next_request(q)) != NULL) {
- struct nbd_device *lo;
-
blkdev_dequeue_request(req);
dprintk(DBG_BLKDEV, "%s: request %p: dequeued (flags=%lx)\n",
req->rq_disk->disk_name, req, req->flags);
@@ -417,8 +419,6 @@ static void do_nbd_request(request_queue
if (!(req->flags & REQ_CMD))
goto error_out;
- lo = req->rq_disk->private_data;
-
BUG_ON(lo->magic != LO_MAGIC);
nbd_cmd(req) = NBD_CMD_READ;
@@ -472,6 +472,7 @@ error_out:
* plug the device to close it.
*/
blk_plug_device(q);
+ current->flags = pflags;
return;
}
@@ -530,6 +531,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);
@@ -599,10 +601,33 @@ 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 (!lo->sock)
+ return -ENODEV;
+
+ 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,
};
/*
@@ -638,6 +663,7 @@ static int __init nbd_init(void)
put_disk(disk);
goto out;
}
+ disk->queue->queuedata = &nbd_dev[i];
blk_queue_max_segment_size(disk->queue, PAGE_SIZE);
blk_queue_max_hw_segments(disk->queue, 1);
blk_queue_max_phys_segments(disk->queue, 1);
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-09-12 15:56 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-12 15:25 [PATCH 00/20] vm deadlock avoidance for NFS, NBD and iSCSI (take 7) Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 18/20] netlink: add SOCK_VMIO support to AF_NETLINK Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 02/20] net: vm deadlock avoidance core Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 08/20] nfs: enable swap on NFS Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 01/20] mm: serialize access to min_free_kbytes Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 09/20] nfs: make swap on NFS robust Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 06/20] nfs: teach the NFS client how to treat PG_swapcache pages Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 15/20] iscsi: kernel side tcp connect Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 05/20] uml: rename arch/um remove_mapping() Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 04/20] mm: methods for teaching filesystems about PG_swapcache pages Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 11/20] nbd: request_fn fixup Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 22:47 ` Jens Axboe
2006-09-12 22:47 ` Jens Axboe
2006-09-13 0:21 ` Jeff Garzik
2006-09-13 0:21 ` Jeff Garzik
2006-09-13 6:14 ` Jens Axboe
2006-09-13 6:14 ` Jens Axboe
2006-09-12 15:25 ` [PATCH 19/20] mm: a process flags to avoid blocking allocations Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 16/20] iscsi: add session context to ep_connect Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra [this message]
2006-09-12 15:25 ` [PATCH 13/20] nbd: use swapdev hook to make swap deadlock free Peter Zijlstra
2006-09-12 15:25 ` [PATCH 14/20] uml: enable scsi and add iscsi config Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 12/20] nbd: limit blk_queue Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 22:47 ` Jens Axboe
2006-09-12 22:47 ` Jens Axboe
2006-09-12 15:25 ` [PATCH 03/20] mm: add support for non block device backed swap files Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 07/20] nfs: add a comment explaining the use of PG_private in the NFS client Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 17/20] scsi: propagate the swapdev hook into the scsi stack Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 10/20] mm: block device swap notification Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-12 15:25 ` [PATCH 20/20] iscsi: support for swapping over iSCSI Peter Zijlstra
2006-09-12 15:25 ` Peter Zijlstra
2006-09-13 20:50 ` Mike Christie
2006-09-13 20:50 ` Mike Christie
2006-09-14 6:17 ` Peter Zijlstra
2006-09-14 6:17 ` Peter Zijlstra
2006-09-14 19:22 ` Mike Christie
2006-09-14 19:22 ` Mike Christie
2006-09-14 20:35 ` Peter Zijlstra
2006-09-14 20:35 ` Peter Zijlstra
2006-09-14 20:46 ` Peter Zijlstra
2006-09-14 20:46 ` Peter Zijlstra
2006-09-14 21:09 ` Mike Christie
2006-09-14 21:09 ` Mike Christie
2006-09-14 21:28 ` Mike Christie
2006-09-14 21:28 ` Mike Christie
2006-09-14 21:00 ` Mike Christie
2006-09-14 21:00 ` Mike Christie
2006-09-14 21:03 ` Mike Christie
2006-09-14 21:03 ` Mike Christie
2006-09-14 21:18 ` Peter Zijlstra
2006-09-14 21:18 ` Peter Zijlstra
2006-09-12 16:37 ` [PATCH 00/20] vm deadlock avoidance for NFS, NBD and iSCSI (take 7) Linus Torvalds
2006-09-12 16:37 ` Linus Torvalds
2006-09-12 23:58 ` Nate Diller
2006-09-12 23:58 ` Nate Diller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060912144904.417049000@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=akpm@osdl.org \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=phillips@google.com \
--cc=riel@redhat.com \
--cc=torvalds@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.