Paolo,
thanks for the patch...
On Wed, Sep 7, 2011 at 10:41 AM, Paolo Bonzini [off-list ref] wrote:
Add a IOCTL to negotiate features between the server and the
kernel module (mediated by the usermode client). Features are
stored in the pre-existing flags field.
I'm not crazy about another ioctl, but we need to get this flag
setting functionality in, and I just have not had the time...
quoted hunk
Also zero out the flags when NBD_DO_IT completes.
Cc: Paul Clements <redacted>
Signed-off-by: Paolo Bonzini <redacted>
---
drivers/block/nbd.c | 8 ++++++++
include/linux/nbd.h | 24 +++++++++++++++---------
2 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index be23aec..c4fe9c8 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -85,6 +85,7 @@ static const char *ioctl_cmd_to_ascii(int cmd)
case NBD_PRINT_DEBUG: return "print-debug";
case NBD_SET_SIZE_BLOCKS: return "set-size-blocks";
case NBD_DISCONNECT: return "disconnect";
+ case NBD_SET_FEATURES: return "set-features";
Could you name this as NBD_SET_FLAGS, as that's more consistent with
what it's really doing?
Otherwise these look good for inclusion.
Thanks,
Paul
quoted hunk
case BLKROSET: return "set-read-only";
case BLKFLSBUF: return "flush-buffer-cache";
}
@@ -634,6 +635,12 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *lo,
lo->xmit_timeout = arg * HZ;
return 0;
+ case NBD_SET_FEATURES:
+ if (((u64) arg) & NBD_FEATURE_RESERVED)
+ return -EINVAL;
+ lo->flags = (lo->flags & NBD_FEATURE_RESERVED) | (u64)arg;
+ return 0;
+
case NBD_SET_SIZE_BLOCKS:
lo->bytesize = ((u64) arg) * lo->blksize;
bdev->bd_inode->i_size = lo->bytesize;
@@ -672,6 +679,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *lo,
printk(KERN_WARNING "%s: queue cleared\n", lo->disk->disk_name);
if (file)
fput(file);
+ lo->flags = 0;
lo->bytesize = 0;
bdev->bd_inode->i_size = 0;
set_capacity(lo->disk, 0);
diff --git a/include/linux/nbd.h b/include/linux/nbd.h
index 0582054..926f19d 100644
--- a/include/linux/nbd.h
+++ b/include/linux/nbd.h
#include <linux/types.h>
-#define NBD_SET_SOCK _IO( 0xab, 0 )
-#define NBD_SET_BLKSIZE _IO( 0xab, 1 )
-#define NBD_SET_SIZE _IO( 0xab, 2 )
-#define NBD_DO_IT _IO( 0xab, 3 )
-#define NBD_CLEAR_SOCK _IO( 0xab, 4 )
-#define NBD_CLEAR_QUE _IO( 0xab, 5 )
-#define NBD_PRINT_DEBUG _IO( 0xab, 6 )
-#define NBD_SET_SIZE_BLOCKS _IO( 0xab, 7 )
26 more quoted lines
------------------------------------------------------------------------------
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/