[PATCH 41/44] block: switch disk_part_iter_* to use a struct block_device
Jan Kara
jack at suse.cz
Fri Nov 27 12:30:10 EST 2020
On Fri 27-11-20 16:24:07, Christoph Hellwig wrote:
> On Fri, Nov 27, 2020 at 01:53:41PM +0100, Jan Kara wrote:
> > On Thu 26-11-20 14:04:19, Christoph Hellwig wrote:
> >
> > There's:
> >
> > /* put the last partition */
> > disk_put_part(piter->part);
> > piter->part = NULL;
> >
> > at the beginning of disk_part_iter_next() which also needs switching to
> > bdput(), doesn't it?
>
> That is switched to call disk_part_iter_exit in patch 13.
I see, sorry for the noise.
> > > @@ -271,8 +271,7 @@ struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter)
> > > piter->idx == 0))
> > > continue;
> > >
> > > - get_device(part_to_dev(part->bd_part));
> > > - piter->part = part->bd_part;
> > > + piter->part = bdgrab(part);
> >
> > bdgrab() could return NULL if we are racing with delete_partition() so I
> > think we need to take care of that.
>
> bdgrab never retuns NULL..
Ah, that's what I misunderstood. I was confusing bdgrab() with igrab().
igrab() can return NULL but bdgrab() uses ihold() and thus cannot return
NULL. But for the lifetime rules to be safe, we should be indeed using
igrab() and check for NULL return...
Honza
--
Jan Kara <jack at suse.com>
SUSE Labs, CR
More information about the linux-mtd
mailing list