Lines Matching full:holder

577  * @holder: holder trying to claim @bdev
578 * @hops: holder ops
580 * Test whether @bdev can be claimed by @holder.
585 static bool bd_may_claim(struct block_device *bdev, void *holder, in bd_may_claim() argument
594 * The same holder can always re-claim. in bd_may_claim()
596 if (bdev->bd_holder == holder) { in bd_may_claim()
605 * If the whole devices holder is set to bd_may_claim, a partition on in bd_may_claim()
617 * @holder: holder trying to claim @bdev
618 * @hops: holder ops.
621 * holder and waits if another claiming is in progress. return, the caller
627 int bd_prepare_to_claim(struct block_device *bdev, void *holder, in bd_prepare_to_claim() argument
632 if (WARN_ON_ONCE(!holder)) in bd_prepare_to_claim()
637 if (!bd_may_claim(bdev, holder, hops)) { in bd_prepare_to_claim()
655 whole->bd_claiming = holder; in bd_prepare_to_claim()
661 static void bd_clear_claiming(struct block_device *whole, void *holder) in bd_clear_claiming() argument
665 BUG_ON(whole->bd_claiming != holder); in bd_clear_claiming()
673 * @holder: holder that has claimed @bdev
674 * @hops: block device holder operations
677 * open by the holder and wake up all waiters for exclusive open to finish.
679 static void bd_finish_claiming(struct block_device *bdev, void *holder, in bd_finish_claiming() argument
685 BUG_ON(!bd_may_claim(bdev, holder, hops)); in bd_finish_claiming()
688 * and bd_holder will be set to bd_may_claim before being set to holder in bd_finish_claiming()
694 bdev->bd_holder = holder; in bd_finish_claiming()
697 bd_clear_claiming(whole, holder); in bd_finish_claiming()
704 * @holder: holder that has claimed @bdev
710 void bd_abort_claiming(struct block_device *bdev, void *holder) in bd_abort_claiming() argument
713 bd_clear_claiming(bdev_whole(bdev), holder); in bd_abort_claiming()
718 static void bd_end_claim(struct block_device *bdev, void *holder) in bd_end_claim() argument
724 * Release a claim on the device. The holder fields are protected with in bd_end_claim()
728 WARN_ON_ONCE(bdev->bd_holder != holder); in bd_end_claim()
744 * If this was the last claim, remove holder link and unblock evpoll if in bd_end_claim()
745 * it was a write holder. in bd_end_claim()
827 int bdev_permission(dev_t dev, blk_mode_t mode, void *holder) in bdev_permission() argument
839 if (mode & BLK_OPEN_RESTRICT_WRITES && !holder) in bdev_permission()
846 if (WARN_ON_ONCE(IS_ERR(holder))) in bdev_permission()
958 * @holder: exclusive holder identifier
959 * @hops: holder operations
962 * Open the block device. If @holder is not %NULL, the block device is opened
963 * with exclusive access. Exclusive opens may nest for the same @holder.
971 int bdev_open(struct block_device *bdev, blk_mode_t mode, void *holder, in bdev_open() argument
978 if (holder) { in bdev_open()
980 ret = bd_prepare_to_claim(bdev, holder, hops); in bdev_open()
1006 if (holder) { in bdev_open()
1007 bd_finish_claiming(bdev, holder, hops); in bdev_open()
1011 * holder makes the write_holder state stick until all are in bdev_open()
1036 bdev_file->private_data = holder; in bdev_open()
1042 if (holder) in bdev_open()
1043 bd_abort_claiming(bdev, holder); in bdev_open()
1079 struct file *bdev_file_open_by_dev(dev_t dev, blk_mode_t mode, void *holder, in bdev_file_open_by_dev() argument
1087 ret = bdev_permission(dev, mode, holder); in bdev_file_open_by_dev()
1104 ret = bdev_open(bdev, mode, holder, hops, bdev_file); in bdev_file_open_by_dev()
1116 void *holder, in bdev_file_open_by_path() argument
1127 file = bdev_file_open_by_dev(dev, mode, holder, hops); in bdev_file_open_by_path()
1142 void *holder = bdev_file->private_data; in bd_yield_claim() local
1146 if (WARN_ON_ONCE(IS_ERR_OR_NULL(holder))) in bd_yield_claim()
1150 bd_end_claim(bdev, holder); in bd_yield_claim()
1156 void *holder = bdev_file->private_data; in bdev_release() local
1160 if (IS_ERR(holder)) in bdev_release()
1176 if (holder) in bdev_release()
1198 * bdev_yield_claim - give up the holder claim on an open block device
1201 * Yield the holder and any write access for @bdev_file without closing it, so