[PATCH] Get blockdev size right in pktcdvd after switching discs

From: Peter Osterlund (petero2_at_telia.com)
Date: 08/15/04

  • Next message: Peter Zijlstra: "Re: [patch] voluntary-preempt-2.6.8.1-P0"
    To: Andrew Morton <akpm@osdl.org>
    Date:	15 Aug 2004 16:00:32 +0200
    
    

    If you do "pktsetup 0 /dev/hdd", insert a CD and write some data to
    it, remove the CD and insert a DVD, the /dev/hdd block device will not
    have the correct size. This leads to bogus "attempt to access beyond
    end of device" errors.

    This patch fixes it.

    Signed-off-by: Peter Osterlund <petero2@telia.com>

    ---
     linux-petero/drivers/block/pktcdvd.c |    2 ++
     1 files changed, 2 insertions(+)
    diff -puN drivers/block/pktcdvd.c~packet-capacity drivers/block/pktcdvd.c
    --- linux/drivers/block/pktcdvd.c~packet-capacity	2004-08-15 15:08:08.000000000 +0200
    +++ linux-petero/drivers/block/pktcdvd.c	2004-08-15 15:44:18.102726968 +0200
    @@ -1971,6 +1971,8 @@ static int pkt_open_dev(struct pktcdvd_d
     	}
     
     	set_capacity(pd->disk, lba << 2);
    +	set_capacity(pd->bdev->bd_disk, lba << 2);
    +	bd_set_size(pd->bdev, (loff_t)lba << 11);
     
     	/*
     	 * The underlying block device needs to have its merge logic
    _
    -- 
    Peter Osterlund - petero2@telia.com
    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@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Peter Zijlstra: "Re: [patch] voluntary-preempt-2.6.8.1-P0"