]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
3.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Jun 2014 00:36:36 +0000 (17:36 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 5 Jun 2014 00:36:36 +0000 (17:36 -0700)
added patches:
nbd-fsync-and-kill-block-device-on-shutdown.patch

queue-3.4/nbd-fsync-and-kill-block-device-on-shutdown.patch [new file with mode: 0644]
queue-3.4/series

diff --git a/queue-3.4/nbd-fsync-and-kill-block-device-on-shutdown.patch b/queue-3.4/nbd-fsync-and-kill-block-device-on-shutdown.patch
new file mode 100644 (file)
index 0000000..6effc97
--- /dev/null
@@ -0,0 +1,95 @@
+From 3a2d63f87989e01437ba994df5f297528c353d7d Mon Sep 17 00:00:00 2001
+From: Paolo Bonzini <pbonzini@redhat.com>
+Date: Wed, 27 Feb 2013 17:05:25 -0800
+Subject: nbd: fsync and kill block device on shutdown
+
+From: Paolo Bonzini <pbonzini@redhat.com>
+
+commit 3a2d63f87989e01437ba994df5f297528c353d7d upstream.
+
+There are two problems with shutdown in the NBD driver.
+
+1: Receiving the NBD_DISCONNECT ioctl does not sync the filesystem.
+
+   This patch adds the sync operation into __nbd_ioctl()'s
+   NBD_DISCONNECT handler.  This is useful because BLKFLSBUF is restricted
+   to processes that have CAP_SYS_ADMIN, and the NBD client may not
+   possess it (fsync of the block device does not sync the filesystem,
+   either).
+
+2: Once we clear the socket we have no guarantee that later reads will
+   come from the same backing storage.
+
+   The patch adds calls to kill_bdev() in __nbd_ioctl()'s socket
+   clearing code so the page cache is cleaned, lest reads that hit on the
+   page cache will return stale data from the previously-accessible disk.
+
+Example:
+
+    # qemu-nbd -r -c/dev/nbd0 /dev/sr0
+    # file -s /dev/nbd0
+    /dev/stdin: # UDF filesystem data (version 1.5) etc.
+    # qemu-nbd -d /dev/nbd0
+    # qemu-nbd -r -c/dev/nbd0 /dev/sda
+    # file -s /dev/nbd0
+    /dev/stdin: # UDF filesystem data (version 1.5) etc.
+
+While /dev/sda has:
+
+    # file -s /dev/sda
+    /dev/sda: x86 boot sector; etc.
+
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Acked-by: Paul Clements <Paul.Clements@steeleye.com>
+Cc: Alex Bligh <alex@alex.org.uk>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+[bwh: Backported to 3.2:
+ - Adjusted context
+ - s/\bnbd\b/lo/
+ - Incorporate export of kill_bdev() from commit ff01bb483265
+   ('fs: move code out of buffer.c')]
+Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
+[hq: Backported to 3.4: Adjusted context]
+Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/block/nbd.c |    9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/drivers/block/nbd.c
++++ b/drivers/block/nbd.c
+@@ -584,10 +584,17 @@ static int __nbd_ioctl(struct block_devi
+               struct request sreq;
+               dev_info(disk_to_dev(nbd->disk), "NBD_DISCONNECT\n");
++              if (!nbd->sock)
++                      return -EINVAL;
++              mutex_unlock(&nbd->tx_lock);
++              fsync_bdev(bdev);
++              mutex_lock(&nbd->tx_lock);
+               blk_rq_init(NULL, &sreq);
+               sreq.cmd_type = REQ_TYPE_SPECIAL;
+               nbd_cmd(&sreq) = NBD_CMD_DISC;
++
++              /* Check again after getting mutex back.  */
+               if (!nbd->sock)
+                       return -EINVAL;
+@@ -606,6 +613,7 @@ static int __nbd_ioctl(struct block_devi
+               nbd_clear_que(nbd);
+               BUG_ON(!list_empty(&nbd->queue_head));
+               BUG_ON(!list_empty(&nbd->waiting_queue));
++              kill_bdev(bdev);
+               if (file)
+                       fput(file);
+               return 0;
+@@ -688,6 +696,7 @@ static int __nbd_ioctl(struct block_devi
+               nbd->file = NULL;
+               nbd_clear_que(nbd);
+               dev_warn(disk_to_dev(nbd->disk), "queue cleared\n");
++              kill_bdev(bdev);
+               if (file)
+                       fput(file);
+               nbd->bytesize = 0;
index be3ce7f46170fbf3f69f425df78a6be4d28af8d2..35dda3a74d4df11ce25f4bb3f5ea7d4a35ed7085 100644 (file)
@@ -153,3 +153,4 @@ efi-export-efi_query_variable_store-for-efivars.ko.patch
 x86-efi-implement-efi_no_storage_paranoia-parameter.patch
 modify-uefi-anti-bricking-code.patch
 x86-efi-fix-dummy-variable-buffer-allocation.patch
+nbd-fsync-and-kill-block-device-on-shutdown.patch