All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Osterlund <petero2@telia.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-kernel@vger.kernel.org, Jens Axboe <axboe@suse.de>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] CDRW packet writing support for 2.6.7-bk13
Date: 07 Jul 2004 12:06:44 +0200	[thread overview]
Message-ID: <m2r7rot9l7.fsf@telia.com> (raw)
In-Reply-To: <20040704130544.GA3825@infradead.org>

Christoph Hellwig <hch@infradead.org> 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@telia.com>

---

 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@telia.com
http://w1.894.telia.com/~u89404340

      parent reply	other threads:[~2004-07-07 10:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-01 13:34 [PATCH] CDRW packet writing support for 2.6.7-bk13 Peter Osterlund
2004-07-02 21:52 ` Peter Osterlund
2004-07-02 22:08   ` Andrew Morton
2004-07-02 22:47     ` Greg KH
2004-07-02 22:59       ` Andrew Morton
2004-07-02 23:24         ` Peter Osterlund
2004-07-02 23:51           ` Andrew Morton
2004-07-04 11:57             ` Peter Osterlund
2004-07-04 20:58               ` Andrew Morton
2004-07-04 21:06                 ` Christoph Hellwig
2004-07-04 12:30 ` [PATCH] Fix race in pktcdvd kernel thread handling Peter Osterlund
2004-07-04 12:37 ` [PATCH] Fix open/close races in pktcdvd Peter Osterlund
2004-07-04 13:05 ` [PATCH] CDRW packet writing support for 2.6.7-bk13 Christoph Hellwig
2004-07-04 23:49   ` Peter Osterlund
2004-07-05  0:01     ` Peter Osterlund
2004-07-10 23:20       ` Arnd Bergmann
2004-07-10 23:27         ` Christoph Hellwig
2004-07-11  1:06           ` Peter Osterlund
2004-07-12 16:25             ` Arnd Bergmann
2004-07-12 16:34               ` Christoph Hellwig
2004-07-13  6:04                 ` Jens Axboe
2004-07-14  0:06             ` [RFC][PATCH] Control pktcdvd with an auxiliary character device Peter Osterlund
2004-07-14  0:17               ` Peter Osterlund
2004-07-05  8:17     ` [PATCH] CDRW packet writing support for 2.6.7-bk13 Jens Axboe
2004-07-05 10:26     ` Christoph Hellwig
2004-07-06  8:45     ` Peter Osterlund
2004-07-07 10:06   ` Peter Osterlund [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2r7rot9l7.fsf@telia.com \
    --to=petero2@telia.com \
    --cc=akpm@osdl.org \
    --cc=axboe@suse.de \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.