Commit 49e57bfc authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] nbd: remove unneeded blksize_bits field

From: Lou Langholtz <ldl@aros.net>

This fourth patch simply removes the blksize_bits field from the nbd_device
struct and driver implementation.  How this field made it into this driver
to begin with is a mystery (where was Al Viro when that patch was
submitted??).  :-)

This patch modifies both drivers/block/nbd.c and include/linux/nbd.h files.
 It's intended to be applied incrementally on top of my third patch (for
enhanced diagnostics support).
parent 9c976399
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
* from sending/receiving disk data. <ldl@aros.net> * from sending/receiving disk data. <ldl@aros.net>
* 03-06-23 Cosmetic changes. <ldl@aros.net> * 03-06-23 Cosmetic changes. <ldl@aros.net>
* 03-06-23 Enhance diagnostics support. <ldl@aros.net> * 03-06-23 Enhance diagnostics support. <ldl@aros.net>
* 03-06-24 Remove unneeded blksize_bits field from nbd_device struct.
* <ldl@aros.net>
* *
* possible FIXME: make set_sock / set_blksize / set_size / do_it one syscall * possible FIXME: make set_sock / set_blksize / set_size / do_it one syscall
* why not: would need verify_area and friends, would share yet another * why not: would need verify_area and friends, would share yet another
...@@ -535,7 +537,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, ...@@ -535,7 +537,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
struct nbd_device *lo = inode->i_bdev->bd_disk->private_data; struct nbd_device *lo = inode->i_bdev->bd_disk->private_data;
int error, temp; int error;
struct request sreq ; struct request sreq ;
/* Anyone capable of this syscall can do *real bad* things */ /* Anyone capable of this syscall can do *real bad* things */
...@@ -600,12 +602,6 @@ static int nbd_ioctl(struct inode *inode, struct file *file, ...@@ -600,12 +602,6 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
if ((arg & (arg-1)) || (arg < 512) || (arg > PAGE_SIZE)) if ((arg & (arg-1)) || (arg < 512) || (arg > PAGE_SIZE))
return -EINVAL; return -EINVAL;
lo->blksize = arg; lo->blksize = arg;
temp = arg >> 9;
lo->blksize_bits = 9;
while (temp > 1) {
lo->blksize_bits++;
temp >>= 1;
}
lo->bytesize &= ~(lo->blksize-1); lo->bytesize &= ~(lo->blksize-1);
set_capacity(lo->disk, lo->bytesize >> 9); set_capacity(lo->disk, lo->bytesize >> 9);
return 0; return 0;
...@@ -614,7 +610,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file, ...@@ -614,7 +610,7 @@ static int nbd_ioctl(struct inode *inode, struct file *file,
set_capacity(lo->disk, lo->bytesize >> 9); set_capacity(lo->disk, lo->bytesize >> 9);
return 0; return 0;
case NBD_SET_SIZE_BLOCKS: case NBD_SET_SIZE_BLOCKS:
lo->bytesize = ((u64) arg) << lo->blksize_bits; lo->bytesize = ((u64) arg) * lo->blksize;
set_capacity(lo->disk, lo->bytesize >> 9); set_capacity(lo->disk, lo->bytesize >> 9);
return 0; return 0;
case NBD_DO_IT: case NBD_DO_IT:
...@@ -717,7 +713,6 @@ static int __init nbd_init(void) ...@@ -717,7 +713,6 @@ static int __init nbd_init(void)
INIT_LIST_HEAD(&nbd_dev[i].queue_head); INIT_LIST_HEAD(&nbd_dev[i].queue_head);
init_MUTEX(&nbd_dev[i].tx_lock); init_MUTEX(&nbd_dev[i].tx_lock);
nbd_dev[i].blksize = 1024; nbd_dev[i].blksize = 1024;
nbd_dev[i].blksize_bits = 10;
nbd_dev[i].bytesize = ((u64)0x7ffffc00) << 10; /* 2TB */ nbd_dev[i].bytesize = ((u64)0x7ffffc00) << 10; /* 2TB */
disk->major = NBD_MAJOR; disk->major = NBD_MAJOR;
disk->first_minor = i; disk->first_minor = i;
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
* 2001 Copyright (C) Steven Whitehouse * 2001 Copyright (C) Steven Whitehouse
* New nbd_end_request() for compatibility with new linux block * New nbd_end_request() for compatibility with new linux block
* layer code. * layer code.
* 2003/06/24 Louis D. Langholtz <ldl@aros.net>
* Removed unneeded blksize_bits field from nbd_device struct.
*/ */
#ifndef LINUX_NBD_H #ifndef LINUX_NBD_H
...@@ -50,7 +52,6 @@ struct nbd_device { ...@@ -50,7 +52,6 @@ struct nbd_device {
struct semaphore tx_lock; struct semaphore tx_lock;
struct gendisk *disk; struct gendisk *disk;
int blksize; int blksize;
int blksize_bits;
u64 bytesize; u64 bytesize;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment