Messages in this thread | | | Date | Mon, 1 Apr 2013 17:28:00 +0100 | From | Al Viro <> | Subject | Re: [PATCH] loop: prevent bdev freeing while device in use |
| |
On Mon, Apr 01, 2013 at 04:58:05AM -0700, Anatol Pomozov wrote: > lo->lo_flags |= LO_FLAGS_PARTSCAN; > if (lo->lo_flags & LO_FLAGS_PARTSCAN) > ioctl_by_bdev(bdev, BLKRRPART, 0); > + > + /* bdev lifecycle is defined by its bd_inode (see > + * struct bdev_inode usage). In case of loop device we need to make > + * sure that bdev deallocation will not happen between loop_set_fd() > + * and loop_clr_fd() invocations. To do this we need to hold > + * bdev inode here and put it later in loop_clr_fd(). > + */ > + ihold(bdev->bd_inode);
That's open-coded bdgrab()
> + if (bdev) { > + BUG_ON(atomic_read(&bdev->bd_inode->i_count) < 2); > + iput(bdev->bd_inode);
... and that - bdput() (I'd drop that BUG_ON())
| |