Lines Matching defs:holder
452 * @holder: holder trying to claim @bdev
453 * @hops: holder ops
455 * Test whether @bdev can be claimed by @holder.
460 static bool bd_may_claim(struct block_device *bdev, void *holder,
469 * The same holder can always re-claim.
471 if (bdev->bd_holder == holder) {
480 * If the whole devices holder is set to bd_may_claim, a partition on
492 * @holder: holder trying to claim @bdev
493 * @hops: holder ops.
496 * holder and waits if another claiming is in progress. return, the caller
502 int bd_prepare_to_claim(struct block_device *bdev, void *holder,
507 if (WARN_ON_ONCE(!holder))
512 if (!bd_may_claim(bdev, holder, hops)) {
530 whole->bd_claiming = holder;
536 static void bd_clear_claiming(struct block_device *whole, void *holder)
540 BUG_ON(whole->bd_claiming != holder);
548 * @holder: holder that has claimed @bdev
549 * @hops: block device holder operations
552 * open by the holder and wake up all waiters for exclusive open to finish.
554 static void bd_finish_claiming(struct block_device *bdev, void *holder,
560 BUG_ON(!bd_may_claim(bdev, holder, hops));
563 * and bd_holder will be set to bd_may_claim before being set to holder
569 bdev->bd_holder = holder;
572 bd_clear_claiming(whole, holder);
579 * @holder: holder that has claimed @bdev
585 void bd_abort_claiming(struct block_device *bdev, void *holder)
588 bd_clear_claiming(bdev_whole(bdev), holder);
593 static void bd_end_claim(struct block_device *bdev, void *holder)
599 * Release a claim on the device. The holder fields are protected with
603 WARN_ON_ONCE(bdev->bd_holder != holder);
619 * If this was the last claim, remove holder link and unblock evpoll if
620 * it was a write holder.
737 * @holder: exclusive holder identifier
738 * @hops: holder operations
740 * Open the block device described by device number @dev. If @holder is not
742 * nest for the same @holder.
754 struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder,
774 if (holder) {
776 ret = bd_prepare_to_claim(bdev, holder, hops);
800 if (holder) {
801 bd_finish_claiming(bdev, holder, hops);
805 * holder makes the write_holder state stick until all are
824 if (holder)
825 bd_abort_claiming(bdev, holder);
834 struct bdev_handle *bdev_open_by_dev(dev_t dev, blk_mode_t mode, void *holder,
842 bdev = blkdev_get_by_dev(dev, mode, holder, hops);
848 handle->holder = holder;
857 * @holder: exclusive holder identifier
858 * @hops: holder operations
860 * Open the block device described by the device file at @path. If @holder is
862 * may nest for the same @holder.
871 void *holder, const struct blk_holder_ops *hops)
881 bdev = blkdev_get_by_dev(dev, mode, holder, hops);
883 blkdev_put(bdev, holder);
892 void *holder, const struct blk_holder_ops *hops)
902 handle = bdev_open_by_dev(dev, mode, holder, hops);
913 void blkdev_put(struct block_device *bdev, void *holder)
928 if (holder)
929 bd_end_claim(bdev, holder);
951 blkdev_put(handle->bdev, handle->holder);