Lines Matching refs:bdev
16 static int blkpg_do_ioctl(struct block_device *bdev, in blkpg_do_ioctl() argument
19 struct gendisk *disk = bdev->bd_disk; in blkpg_do_ioctl()
27 if (bdev_is_partition(bdev)) in blkpg_do_ioctl()
39 if (!IS_ALIGNED(p.start | p.length, bdev_logical_block_size(bdev))) in blkpg_do_ioctl()
55 static int blkpg_ioctl(struct block_device *bdev, in blkpg_ioctl() argument
64 return blkpg_do_ioctl(bdev, udata, op); in blkpg_ioctl()
75 static int compat_blkpg_ioctl(struct block_device *bdev, in compat_blkpg_ioctl() argument
84 return blkpg_do_ioctl(bdev, compat_ptr(udata), op); in compat_blkpg_ioctl()
88 static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode, in blk_ioctl_discard() argument
93 struct inode *inode = bdev->bd_inode; in blk_ioctl_discard()
99 if (!bdev_max_discard_sectors(bdev)) in blk_ioctl_discard()
113 if (start + len > bdev_nr_bytes(bdev)) in blk_ioctl_discard()
117 err = truncate_bdev_range(bdev, mode, start, start + len - 1); in blk_ioctl_discard()
120 err = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL); in blk_ioctl_discard()
126 static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode, in blk_ioctl_secure_erase() argument
135 if (!bdev_max_secure_erase_sectors(bdev)) in blk_ioctl_secure_erase()
144 if (start + len > bdev_nr_bytes(bdev)) in blk_ioctl_secure_erase()
147 filemap_invalidate_lock(bdev->bd_inode->i_mapping); in blk_ioctl_secure_erase()
148 err = truncate_bdev_range(bdev, mode, start, start + len - 1); in blk_ioctl_secure_erase()
150 err = blkdev_issue_secure_erase(bdev, start >> 9, len >> 9, in blk_ioctl_secure_erase()
152 filemap_invalidate_unlock(bdev->bd_inode->i_mapping); in blk_ioctl_secure_erase()
157 static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode, in blk_ioctl_zeroout() argument
162 struct inode *inode = bdev->bd_inode; in blk_ioctl_zeroout()
179 if (end >= (uint64_t)bdev_nr_bytes(bdev)) in blk_ioctl_zeroout()
186 err = truncate_bdev_range(bdev, mode, start, end); in blk_ioctl_zeroout()
190 err = blkdev_issue_zeroout(bdev, start >> 9, len >> 9, GFP_KERNEL, in blk_ioctl_zeroout()
246 int blkdev_compat_ptr_ioctl(struct block_device *bdev, blk_mode_t mode, in blkdev_compat_ptr_ioctl() argument
249 struct gendisk *disk = bdev->bd_disk; in blkdev_compat_ptr_ioctl()
252 return disk->fops->ioctl(bdev, mode, cmd, in blkdev_compat_ptr_ioctl()
260 static bool blkdev_pr_allowed(struct block_device *bdev, blk_mode_t mode) in blkdev_pr_allowed() argument
263 if (bdev_is_partition(bdev)) in blkdev_pr_allowed()
275 static int blkdev_pr_register(struct block_device *bdev, blk_mode_t mode, in blkdev_pr_register() argument
278 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_register()
281 if (!blkdev_pr_allowed(bdev, mode)) in blkdev_pr_register()
290 return ops->pr_register(bdev, reg.old_key, reg.new_key, reg.flags); in blkdev_pr_register()
293 static int blkdev_pr_reserve(struct block_device *bdev, blk_mode_t mode, in blkdev_pr_reserve() argument
296 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_reserve()
299 if (!blkdev_pr_allowed(bdev, mode)) in blkdev_pr_reserve()
308 return ops->pr_reserve(bdev, rsv.key, rsv.type, rsv.flags); in blkdev_pr_reserve()
311 static int blkdev_pr_release(struct block_device *bdev, blk_mode_t mode, in blkdev_pr_release() argument
314 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_release()
317 if (!blkdev_pr_allowed(bdev, mode)) in blkdev_pr_release()
326 return ops->pr_release(bdev, rsv.key, rsv.type); in blkdev_pr_release()
329 static int blkdev_pr_preempt(struct block_device *bdev, blk_mode_t mode, in blkdev_pr_preempt() argument
332 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_preempt()
335 if (!blkdev_pr_allowed(bdev, mode)) in blkdev_pr_preempt()
344 return ops->pr_preempt(bdev, p.old_key, p.new_key, p.type, abort); in blkdev_pr_preempt()
347 static int blkdev_pr_clear(struct block_device *bdev, blk_mode_t mode, in blkdev_pr_clear() argument
350 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_clear()
353 if (!blkdev_pr_allowed(bdev, mode)) in blkdev_pr_clear()
362 return ops->pr_clear(bdev, c.key); in blkdev_pr_clear()
365 static int blkdev_flushbuf(struct block_device *bdev, unsigned cmd, in blkdev_flushbuf() argument
371 mutex_lock(&bdev->bd_holder_lock); in blkdev_flushbuf()
372 if (bdev->bd_holder_ops && bdev->bd_holder_ops->sync) in blkdev_flushbuf()
373 bdev->bd_holder_ops->sync(bdev); in blkdev_flushbuf()
375 sync_blockdev(bdev); in blkdev_flushbuf()
376 mutex_unlock(&bdev->bd_holder_lock); in blkdev_flushbuf()
378 invalidate_bdev(bdev); in blkdev_flushbuf()
382 static int blkdev_roset(struct block_device *bdev, unsigned cmd, in blkdev_roset() argument
392 if (bdev->bd_disk->fops->set_read_only) { in blkdev_roset()
393 ret = bdev->bd_disk->fops->set_read_only(bdev, n); in blkdev_roset()
397 bdev->bd_read_only = n; in blkdev_roset()
401 static int blkdev_getgeo(struct block_device *bdev, in blkdev_getgeo() argument
404 struct gendisk *disk = bdev->bd_disk; in blkdev_getgeo()
418 geo.start = get_start_sect(bdev); in blkdev_getgeo()
419 ret = disk->fops->getgeo(bdev, &geo); in blkdev_getgeo()
435 static int compat_hdio_getgeo(struct block_device *bdev, in compat_hdio_getgeo() argument
438 struct gendisk *disk = bdev->bd_disk; in compat_hdio_getgeo()
452 geo.start = get_start_sect(bdev); in compat_hdio_getgeo()
453 ret = disk->fops->getgeo(bdev, &geo); in compat_hdio_getgeo()
467 static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode, in blkdev_bszset() argument
480 return set_blocksize(bdev, n); in blkdev_bszset()
482 if (IS_ERR(blkdev_get_by_dev(bdev->bd_dev, mode, &bdev, NULL))) in blkdev_bszset()
484 ret = set_blocksize(bdev, n); in blkdev_bszset()
485 blkdev_put(bdev, &bdev); in blkdev_bszset()
495 static int blkdev_common_ioctl(struct block_device *bdev, blk_mode_t mode, in blkdev_common_ioctl() argument
503 return blkdev_flushbuf(bdev, cmd, arg); in blkdev_common_ioctl()
505 return blkdev_roset(bdev, cmd, arg); in blkdev_common_ioctl()
507 return blk_ioctl_discard(bdev, mode, arg); in blkdev_common_ioctl()
509 return blk_ioctl_secure_erase(bdev, mode, argp); in blkdev_common_ioctl()
511 return blk_ioctl_zeroout(bdev, mode, arg); in blkdev_common_ioctl()
513 return put_u64(argp, bdev->bd_disk->diskseq); in blkdev_common_ioctl()
515 return blkdev_report_zones_ioctl(bdev, cmd, arg); in blkdev_common_ioctl()
520 return blkdev_zone_mgmt_ioctl(bdev, mode, cmd, arg); in blkdev_common_ioctl()
522 return put_uint(argp, bdev_zone_sectors(bdev)); in blkdev_common_ioctl()
524 return put_uint(argp, bdev_nr_zones(bdev)); in blkdev_common_ioctl()
526 return put_int(argp, bdev_read_only(bdev) != 0); in blkdev_common_ioctl()
528 return put_int(argp, bdev_logical_block_size(bdev)); in blkdev_common_ioctl()
530 return put_uint(argp, bdev_physical_block_size(bdev)); in blkdev_common_ioctl()
532 return put_uint(argp, bdev_io_min(bdev)); in blkdev_common_ioctl()
534 return put_uint(argp, bdev_io_opt(bdev)); in blkdev_common_ioctl()
536 return put_int(argp, bdev_alignment_offset(bdev)); in blkdev_common_ioctl()
541 queue_max_sectors(bdev_get_queue(bdev))); in blkdev_common_ioctl()
544 return put_ushort(argp, !bdev_nonrot(bdev)); in blkdev_common_ioctl()
549 bdev->bd_disk->bdi->ra_pages = (arg * 512) / PAGE_SIZE; in blkdev_common_ioctl()
554 if (bdev_is_partition(bdev)) in blkdev_common_ioctl()
556 return disk_scan_partitions(bdev->bd_disk, mode); in blkdev_common_ioctl()
560 return blk_trace_ioctl(bdev, cmd, argp); in blkdev_common_ioctl()
562 return blkdev_pr_register(bdev, mode, argp); in blkdev_common_ioctl()
564 return blkdev_pr_reserve(bdev, mode, argp); in blkdev_common_ioctl()
566 return blkdev_pr_release(bdev, mode, argp); in blkdev_common_ioctl()
568 return blkdev_pr_preempt(bdev, mode, argp, false); in blkdev_common_ioctl()
570 return blkdev_pr_preempt(bdev, mode, argp, true); in blkdev_common_ioctl()
572 return blkdev_pr_clear(bdev, mode, argp); in blkdev_common_ioctl()
586 struct block_device *bdev = I_BDEV(file->f_mapping->host); in blkdev_ioctl() local
594 return blkdev_getgeo(bdev, argp); in blkdev_ioctl()
596 return blkpg_ioctl(bdev, argp); in blkdev_ioctl()
604 (bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512); in blkdev_ioctl()
606 if (bdev_nr_sectors(bdev) > ~0UL) in blkdev_ioctl()
608 return put_ulong(argp, bdev_nr_sectors(bdev)); in blkdev_ioctl()
612 return put_int(argp, block_size(bdev)); in blkdev_ioctl()
614 return blkdev_bszset(bdev, mode, argp); in blkdev_ioctl()
616 return put_u64(argp, bdev_nr_bytes(bdev)); in blkdev_ioctl()
620 return blk_trace_ioctl(bdev, cmd, argp); in blkdev_ioctl()
625 ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); in blkdev_ioctl()
629 if (!bdev->bd_disk->fops->ioctl) in blkdev_ioctl()
631 return bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg); in blkdev_ioctl()
647 struct block_device *bdev = I_BDEV(file->f_mapping->host); in compat_blkdev_ioctl() local
648 struct gendisk *disk = bdev->bd_disk; in compat_blkdev_ioctl()
654 return compat_hdio_getgeo(bdev, argp); in compat_blkdev_ioctl()
656 return compat_blkpg_ioctl(bdev, argp); in compat_blkdev_ioctl()
664 (bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512); in compat_blkdev_ioctl()
666 if (bdev_nr_sectors(bdev) > ~(compat_ulong_t)0) in compat_blkdev_ioctl()
668 return compat_put_ulong(argp, bdev_nr_sectors(bdev)); in compat_blkdev_ioctl()
672 return put_int(argp, bdev_logical_block_size(bdev)); in compat_blkdev_ioctl()
674 return blkdev_bszset(bdev, mode, argp); in compat_blkdev_ioctl()
676 return put_u64(argp, bdev_nr_bytes(bdev)); in compat_blkdev_ioctl()
680 return blk_trace_ioctl(bdev, cmd, argp); in compat_blkdev_ioctl()
685 ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); in compat_blkdev_ioctl()
687 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg); in compat_blkdev_ioctl()