Re: [PATCH 1/1] nbd: fsync and kill block device on shutdown

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 23, 2014 at 11:42:47AM +0800, Qiang Huang wrote:
> From: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> Acked-by: Paul Clements <Paul.Clements@xxxxxxxxxxxx>
> Cc: Alex Bligh <alex@xxxxxxxxxxx>
> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> [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@xxxxxxxxxxxxxxx>
> [hq: Backported to 3.4: Adjusted context]
> Signed-off-by: Qiang Huang <h.huangqiang@xxxxxxxxxx>

Applied, thanks.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]