[PATCH v2 0/5] nbd: fixes for nbd

From: Pranay Kr. Srivastava
Date: Thu Jun 02 2016 - 11:25:56 EST


This patch series fixes the following

1) fix might_sleep warning on socket shutdown:
Fix sock_shutdown to avoid calling kernel_sock_shutdown
while holding spin_lock.

2) cleanup nbd_set_socket
Cleanup nbd_set_socket to use spin_lock instead of
irq version and remove the goto statement in favour
of a simple if-else statement.

3) fix various coding standard warnings
Make shutdown get called in a process context instead, using
system_wq.

4) make nbd device wait for its users.
When a timeout or error occurs then nbd driver simply kills
the block device. Many filesystem(s) example ext2/ext3 don't
expect their buffer heads to disappear like that. Fix this
by making nbd device wait for its users.

Introduced a new field to check if the device is currently
in use or not. This helps to check if the kref_put should
be done on device release or not.

This field needs to be atomic as the release function may
be called from NBD_DO_IT as well as from device's release
function.

5) use device_attr macros for sysfs attribute
use DEVICE_ATTR_RO for sysfs pid attribute.

Changelog for v2:
1) fix might_sleep warning on socket shutdown
use bool timedout instead of atomic

2) cleanup nbd_set_socket
Added this new patch to this series.

3) fix various coding standard warnings
No Change.

4) make nbd device wait for its users
Earlier version used to do a final kref put when
the kref->counter == 2. This required a check of
the internal atomic counter of kref which was ugly.

v2 of this patch make this more readable and doesn't
do manual check of the internal counter used by kref.

5) use device_attr macros for sysfs attribute
No Change.

Pranay Kr. Srivastava (5):
fix might_sleep warning on socket shutdown.
cleanup nbd_set_socket
fix various coding standard warnings
make nbd device wait for its users.
use device_attr macros for sysfs attribute

drivers/block/nbd.c | 173 +++++++++++++++++++++++++++++++++++++---------------
1 file changed, 124 insertions(+), 49 deletions(-)

--
2.6.2