Re: [patch] scsi: revert "[SCSI] Get rid of scsi_cmnd->done"

James Bottomley
2008-01-06T18:55:19Z

On Sun, 2008-01-06 at 10:44 -0800, Linus Torvalds wrote:
>
> On Sun, 6 Jan 2008, Linus Torvalds wrote:
> >
> > That said:
> >
> > > pktcdvd shouldn't be mucking with the size of the underlying CD/DVD ...
> >
> > I'm not sure if it should be mucking with the size or not, but it
> > definitely shouldn't be mucking with the block-size, because that can
> > indeed cause huge problems.
>
> Hmm. Looking closer, it's probably ok in that case, because it does do a
> "bd_claim()" to make sure that it has exclusive access, so while there may
> be other openers around, at least those other openers won't be filesystem
> mounts or anything that opened with O_EXCL.
>
> So changing the blocksize is probably ok in this case.
>
> That still leaves the question whether pktcdvd *should* muck with the base
> device at all, and I'm not at all sure about that. But I'm no longer sure
> that the pktcdvd code is necessarily *clearly* broken, now it's more of a
> "should it really do that?" thing.
>
> So I still suspect that this:
>
> > - set_capacity(pd->disk, lba << 2);
> > - set_capacity(pd->bdev->bd_disk, lba << 2);
> > - bd_set_size(pd->bdev, (loff_t)lba << 11);
> > + set_capacity(pd->disk, get_capacity(pd->bdev->bd_disk));
>
> is likely a good thing to do (in conjunction with my patch that made
> i_size be "reliable" after an open), but there may be some reason why
> pktcdvd really wants to control the size rather than be on the receiving
> end of the size.
>
> Peter, this is your decision. Apparently my one-liner fixes the immediate
> bug (but it's not really a regression either - I think the i_size issue
> has been there since pretty much day #1), and what pktcdvd does is
> somewhat less critical an issue?

I think perhaps the true bug lies in the way we handle layered devices
like this. pktcdvd holds the underlying device open, so its refcount
never drops to zero. This is what causes the gendisk/block layer never
to update the sizes, and what lead to pktcdvd doing it instead.

However, what perhaps really needs to happen is that pktcdvd needs to
take over the media change events as well. That way it could see the
disk change and invalidate and reread its own setting of the block size
(and possibly re set the size of the underlying device).

I agree, though, this isn't a regression. It's probably obscure enough
in reproduction to warrant not holding up 2.6.24 --- especially as I
think the true fix will do small perturbations to a lot of subsystems.
If this were a product and I were the release manager, I'd be updating
the release notes with a note about having to break pktcdvd binding
across media changes to work around this bug and a promise to fix it in
the next release.

James