Re: [PATCH] CDRW packet writing support for 2.6.7-bk13
From: Peter Osterlund
Date: Wed Jul 07 2004 - 05:09:59 EST
Christoph Hellwig <hch@xxxxxxxxxxxxx> writes:
> > +static void pkt_release_dev(struct pktcdvd_device *pd, int flush)
> > +{
> > + struct block_device *bdev;
> > +
> > + atomic_dec(&pd->refcnt);
> > + if (atomic_read(&pd->refcnt) > 0)
> > + return;
> > +
> > + bdev = bdget(pd->pkt_dev);
> > + if (bdev) {
>
> You reallu should keep a reference to the underlying bdev as long as you use
> it
Remove pkt_dev from struct pktcdvd_device in the pktcdvd driver and
remove unnecessary calls to bdget(). Suggested by Christoph Hellwig.
Signed-off-by: Peter Osterlund <petero2@xxxxxxxxx>
---
linux-petero/drivers/block/pktcdvd.c | 20 ++++----------------
linux-petero/include/linux/pktcdvd.h | 1 -
2 files changed, 4 insertions(+), 17 deletions(-)
diff -puN drivers/block/pktcdvd.c~packet-bdev drivers/block/pktcdvd.c
--- linux/drivers/block/pktcdvd.c~packet-bdev 2004-07-06 21:39:26.000000000 +0200
+++ linux-petero/drivers/block/pktcdvd.c 2004-07-06 23:47:54.243208280 +0200
@@ -1990,7 +1990,6 @@ static void pkt_release_dev(struct pktcd
static int pkt_open(struct inode *inode, struct file *file)
{
struct pktcdvd_device *pd = NULL;
- struct block_device *pkt_bdev;
int ret;
int special_open, exclusive;
@@ -2047,11 +2046,7 @@ static int pkt_open(struct inode *inode,
* needed here as well, since ext2 (among others) may change
* the blocksize at mount time
*/
- pkt_bdev = bdget(inode->i_rdev);
- if (pkt_bdev) {
- set_blocksize(pkt_bdev, CD_FRAMESIZE);
- bdput(pkt_bdev);
- }
+ set_blocksize(inode->i_bdev, CD_FRAMESIZE);
done:
up(&pd->ctl_mutex);
@@ -2432,21 +2427,15 @@ out:
return ret;
}
-static int pkt_remove_dev(struct pktcdvd_device *pd)
+static int pkt_remove_dev(struct pktcdvd_device *pd, struct block_device *bdev)
{
- struct block_device *bdev;
-
if (!IS_ERR(pd->cdrw.thread))
kthread_stop(pd->cdrw.thread);
/*
* will also invalidate buffers for CD-ROM
*/
- bdev = bdget(pd->pkt_dev);
- if (bdev) {
- invalidate_bdev(bdev, 1);
- bdput(bdev);
- }
+ invalidate_bdev(bdev, 1);
pkt_shrink_pktlist(pd);
@@ -2508,7 +2497,7 @@ static int pkt_ioctl(struct inode *inode
if (pd->refcnt != 1)
ret = -EBUSY;
else
- ret = pkt_remove_dev(pd);
+ ret = pkt_remove_dev(pd, inode->i_bdev);
up(&pd->ctl_mutex);
return ret;
@@ -2579,7 +2568,6 @@ int pkt_init(void)
spin_lock_init(&pd->lock);
spin_lock_init(&pd->iosched.lock);
- pd->pkt_dev = MKDEV(PACKET_MAJOR, i);
sprintf(pd->name, "pktcdvd%d", i);
init_waitqueue_head(&pd->wqueue);
init_MUTEX(&pd->ctl_mutex);
diff -puN include/linux/pktcdvd.h~packet-bdev include/linux/pktcdvd.h
--- linux/include/linux/pktcdvd.h~packet-bdev 2004-07-06 21:39:26.000000000 +0200
+++ linux-petero/include/linux/pktcdvd.h 2004-07-06 23:47:54.244208128 +0200
@@ -230,7 +230,6 @@ struct pktcdvd_device
{
struct block_device *bdev; /* dev attached */
dev_t dev; /* dev attached */
- dev_t pkt_dev; /* our dev */
char name[20];
struct packet_settings settings;
struct packet_stats stats;
_
--
Peter Osterlund - petero2@xxxxxxxxx
http://w1.894.telia.com/~u89404340
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/