* [PATCHES 2.5.74-mm2] misc. nbd cleanups/fixes
@ 2003-07-06 20:11 Paul Clements
2003-07-06 20:33 ` Jeff Garzik
0 siblings, 1 reply; 3+ messages in thread
From: Paul Clements @ 2003-07-06 20:11 UTC (permalink / raw)
To: akpm; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 552 bytes --]
Andrew,
here are two nbd patches to apply to 2.5.74-mm2 after two of the
previous patches (from Lou Langholtz) are reverted:
nbd-ioctl-compat.patch (patch 6)
nbd-locking-fixes.patch (patch 7)
I'm fine with leaving the first 5 patches of his in there.
The two attached patches are:
1) nbd-remove_open_release.diff - remove the unneeded nbd_open and
nbd_release functions
2) nbd-block_layer_compat.diff - ensure that nbd and the block layer
agree about device block sizes and total device sizes
and should be applied in this order.
Thanks,
Paul
[-- Attachment #2: nbd-remove_open_release.diff --]
[-- Type: text/x-diff, Size: 2073 bytes --]
--- linux-2.5.74-mm2/drivers/block/nbd.c.MINUS_LL 2003-07-06 11:31:51.000000000 -0400
+++ linux-2.5.74-mm2/drivers/block/nbd.c 2003-07-06 11:36:51.000000000 -0400
@@ -77,8 +77,6 @@
#define dprintk(flags, fmt...) do { \
if (debugflags & (flags)) printk(KERN_DEBUG fmt); \
} while (0)
-#define DBG_OPEN 0x0001
-#define DBG_RELEASE 0x0002
#define DBG_IOCTL 0x0004
#define DBG_INIT 0x0010
#define DBG_EXIT 0x0020
@@ -521,33 +519,6 @@ static void do_nbd_request(request_queue
return;
}
-static int nbd_open(struct inode *inode, struct file *file)
-{
- struct nbd_device *lo = inode->i_bdev->bd_disk->private_data;
-
- dprintk(DBG_OPEN, "%s: nbd_open refcnt=%d\n", lo->disk->disk_name,
- lo->refcnt);
- lo->refcnt++;
- return 0;
-}
-
-static int nbd_release(struct inode *inode, struct file *file)
-{
- struct nbd_device *lo = inode->i_bdev->bd_disk->private_data;
-
-#ifdef PARANOIA
- if (lo->refcnt <= 0) {
- printk(KERN_ALERT "%s: nbd_release: refcount(%d) <= 0\n",
- lo->disk->disk_name, lo->refcnt);
- BUG();
- }
-#endif
- lo->refcnt--;
- dprintk(DBG_RELEASE, "%s: nbd_release: refcnt=%d\n",
- lo->disk->disk_name, lo->refcnt);
- return 0;
-}
-
static int nbd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
@@ -555,6 +526,8 @@ static int nbd_ioctl(struct inode *inode
int error;
struct request sreq ;
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
#ifdef PARANOIA
BUG_ON(lo->magic != LO_MAGIC);
#endif
@@ -562,8 +535,6 @@ static int nbd_ioctl(struct inode *inode
dprintk(DBG_IOCTL, "%s: nbd_ioctl cmd=%s(0x%x) arg=%lu\n",
lo->disk->disk_name, ioctl_cmd_to_ascii(cmd), cmd, arg);
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
switch (cmd) {
case NBD_DISCONNECT:
printk(KERN_INFO "%s: NBD_DISCONNECT\n", lo->disk->disk_name);
@@ -678,8 +649,6 @@ static int nbd_ioctl(struct inode *inode
static struct block_device_operations nbd_fops =
{
.owner = THIS_MODULE,
- .open = nbd_open,
- .release = nbd_release,
.ioctl = nbd_ioctl,
};
[-- Attachment #3: nbd-block_layer_compat.diff --]
[-- Type: text/x-diff, Size: 1081 bytes --]
--- linux-2.5.74-mm2/drivers/block/nbd.c.MINUS_OPEN_RELEASE 2003-07-06 11:36:51.000000000 -0400
+++ linux-2.5.74-mm2/drivers/block/nbd.c 2003-07-06 11:43:54.000000000 -0400
@@ -591,15 +591,21 @@ static int nbd_ioctl(struct inode *inode
if ((arg & (arg-1)) || (arg < 512) || (arg > PAGE_SIZE))
return -EINVAL;
lo->blksize = arg;
- lo->bytesize &= ~(lo->blksize-1);
+ lo->bytesize &= ~(lo->blksize-1);
+ inode->i_bdev->bd_inode->i_size = lo->bytesize;
+ inode->i_bdev->bd_block_size = lo->blksize;
set_capacity(lo->disk, lo->bytesize >> 9);
return 0;
case NBD_SET_SIZE:
- lo->bytesize = arg & ~(lo->blksize-1);
+ lo->bytesize = arg & ~(lo->blksize-1);
+ inode->i_bdev->bd_inode->i_size = lo->bytesize;
+ inode->i_bdev->bd_block_size = lo->blksize;
set_capacity(lo->disk, lo->bytesize >> 9);
return 0;
case NBD_SET_SIZE_BLOCKS:
lo->bytesize = ((u64) arg) * lo->blksize;
+ inode->i_bdev->bd_inode->i_size = lo->bytesize;
+ inode->i_bdev->bd_block_size = lo->blksize;
set_capacity(lo->disk, lo->bytesize >> 9);
return 0;
case NBD_DO_IT:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCHES 2.5.74-mm2] misc. nbd cleanups/fixes
2003-07-06 20:11 [PATCHES 2.5.74-mm2] misc. nbd cleanups/fixes Paul Clements
@ 2003-07-06 20:33 ` Jeff Garzik
2003-07-06 21:10 ` Paul Clements
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Garzik @ 2003-07-06 20:33 UTC (permalink / raw)
To: Paul Clements; +Cc: akpm, linux-kernel
Paul Clements wrote:
> The two attached patches are:
>
> 1) nbd-remove_open_release.diff - remove the unneeded nbd_open and
> nbd_release functions
Please remove the unneeded ->refcnt member as well.
> 2) nbd-block_layer_compat.diff - ensure that nbd and the block layer
> agree about device block sizes and total device sizes
Use set_blocksize, please.
Also, please split up your patches further. The Linux (Linus?) standard
is one patch per email... Also, attachments are discouraged, though not
a "no no" because of various broken corporate email systems...
Jeff
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCHES 2.5.74-mm2] misc. nbd cleanups/fixes
2003-07-06 20:33 ` Jeff Garzik
@ 2003-07-06 21:10 ` Paul Clements
0 siblings, 0 replies; 3+ messages in thread
From: Paul Clements @ 2003-07-06 21:10 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Paul Clements, akpm, linux-kernel
On Sun, 6 Jul 2003, Jeff Garzik wrote:
> Paul Clements wrote:
> > The two attached patches are:
> >
> > 1) nbd-remove_open_release.diff - remove the unneeded nbd_open and
> > nbd_release functions
>
> Please remove the unneeded ->refcnt member as well.
Yep, I forgot to do that...new patch on the way...
> > 2) nbd-block_layer_compat.diff - ensure that nbd and the block layer
> > agree about device block sizes and total device sizes
>
> Use set_blocksize, please.
OK, I've done that in this next patch, also on the way...
> Also, please split up your patches further. The Linux (Linus?) standard
> is one patch per email... Also, attachments are discouraged, though not
> a "no no" because of various broken corporate email systems...
OK, thanks...
--
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-07-06 20:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-06 20:11 [PATCHES 2.5.74-mm2] misc. nbd cleanups/fixes Paul Clements
2003-07-06 20:33 ` Jeff Garzik
2003-07-06 21:10 ` Paul Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox