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()
42 if (p.start & (bdev_logical_block_size(bdev) - 1)) in blkpg_do_ioctl()
52 static int blkpg_ioctl(struct block_device *bdev, in blkpg_ioctl() argument
61 return blkpg_do_ioctl(bdev, udata, op); in blkpg_ioctl()
72 static int compat_blkpg_ioctl(struct block_device *bdev, in compat_blkpg_ioctl() argument
81 return blkpg_do_ioctl(bdev, compat_ptr(udata), op); in compat_blkpg_ioctl()
85 static int blkdev_reread_part(struct block_device *bdev, fmode_t mode) in blkdev_reread_part() argument
89 if (!disk_part_scan_enabled(bdev->bd_disk) || bdev_is_partition(bdev)) in blkdev_reread_part()
93 if (bdev->bd_disk->open_partitions) in blkdev_reread_part()
101 set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state); in blkdev_reread_part()
103 tmp = blkdev_get_by_dev(bdev->bd_dev, mode, NULL); in blkdev_reread_part()
110 static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode, in blk_ioctl_discard() argument
115 struct request_queue *q = bdev_get_queue(bdev); in blk_ioctl_discard()
116 struct inode *inode = bdev->bd_inode; in blk_ioctl_discard()
136 if (start + len > bdev_nr_bytes(bdev)) in blk_ioctl_discard()
140 err = truncate_bdev_range(bdev, mode, start, start + len - 1); in blk_ioctl_discard()
144 err = blkdev_issue_discard(bdev, start >> 9, len >> 9, in blk_ioctl_discard()
152 static int blk_ioctl_zeroout(struct block_device *bdev, fmode_t mode, in blk_ioctl_zeroout() argument
157 struct inode *inode = bdev->bd_inode; in blk_ioctl_zeroout()
174 if (end >= (uint64_t)bdev_nr_bytes(bdev)) in blk_ioctl_zeroout()
181 err = truncate_bdev_range(bdev, mode, start, end); in blk_ioctl_zeroout()
185 err = blkdev_issue_zeroout(bdev, start >> 9, len >> 9, GFP_KERNEL, in blk_ioctl_zeroout()
241 int blkdev_compat_ptr_ioctl(struct block_device *bdev, fmode_t mode, in blkdev_compat_ptr_ioctl() argument
244 struct gendisk *disk = bdev->bd_disk; in blkdev_compat_ptr_ioctl()
247 return disk->fops->ioctl(bdev, mode, cmd, in blkdev_compat_ptr_ioctl()
255 static int blkdev_pr_register(struct block_device *bdev, in blkdev_pr_register() argument
258 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_register()
270 return ops->pr_register(bdev, reg.old_key, reg.new_key, reg.flags); in blkdev_pr_register()
273 static int blkdev_pr_reserve(struct block_device *bdev, in blkdev_pr_reserve() argument
276 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_reserve()
288 return ops->pr_reserve(bdev, rsv.key, rsv.type, rsv.flags); in blkdev_pr_reserve()
291 static int blkdev_pr_release(struct block_device *bdev, in blkdev_pr_release() argument
294 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_release()
306 return ops->pr_release(bdev, rsv.key, rsv.type); in blkdev_pr_release()
309 static int blkdev_pr_preempt(struct block_device *bdev, in blkdev_pr_preempt() argument
312 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_preempt()
324 return ops->pr_preempt(bdev, p.old_key, p.new_key, p.type, abort); in blkdev_pr_preempt()
327 static int blkdev_pr_clear(struct block_device *bdev, in blkdev_pr_clear() argument
330 const struct pr_ops *ops = bdev->bd_disk->fops->pr_ops; in blkdev_pr_clear()
342 return ops->pr_clear(bdev, c.key); in blkdev_pr_clear()
345 static int blkdev_flushbuf(struct block_device *bdev, fmode_t mode, in blkdev_flushbuf() argument
350 fsync_bdev(bdev); in blkdev_flushbuf()
351 invalidate_bdev(bdev); in blkdev_flushbuf()
355 static int blkdev_roset(struct block_device *bdev, fmode_t mode, in blkdev_roset() argument
365 if (bdev->bd_disk->fops->set_read_only) { in blkdev_roset()
366 ret = bdev->bd_disk->fops->set_read_only(bdev, n); in blkdev_roset()
370 bdev->bd_read_only = n; in blkdev_roset()
374 static int blkdev_getgeo(struct block_device *bdev, in blkdev_getgeo() argument
377 struct gendisk *disk = bdev->bd_disk; in blkdev_getgeo()
391 geo.start = get_start_sect(bdev); in blkdev_getgeo()
392 ret = disk->fops->getgeo(bdev, &geo); in blkdev_getgeo()
408 static int compat_hdio_getgeo(struct block_device *bdev, in compat_hdio_getgeo() argument
411 struct gendisk *disk = bdev->bd_disk; in compat_hdio_getgeo()
425 geo.start = get_start_sect(bdev); in compat_hdio_getgeo()
426 ret = disk->fops->getgeo(bdev, &geo); in compat_hdio_getgeo()
440 static int blkdev_bszset(struct block_device *bdev, fmode_t mode, in blkdev_bszset() argument
453 return set_blocksize(bdev, n); in blkdev_bszset()
455 if (IS_ERR(blkdev_get_by_dev(bdev->bd_dev, mode | FMODE_EXCL, &bdev))) in blkdev_bszset()
457 ret = set_blocksize(bdev, n); in blkdev_bszset()
458 blkdev_put(bdev, mode | FMODE_EXCL); in blkdev_bszset()
468 static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, in blkdev_common_ioctl() argument
475 return blkdev_flushbuf(bdev, mode, cmd, arg); in blkdev_common_ioctl()
477 return blkdev_roset(bdev, mode, cmd, arg); in blkdev_common_ioctl()
479 return blk_ioctl_discard(bdev, mode, arg, 0); in blkdev_common_ioctl()
481 return blk_ioctl_discard(bdev, mode, arg, in blkdev_common_ioctl()
484 return blk_ioctl_zeroout(bdev, mode, arg); in blkdev_common_ioctl()
486 return put_u64(argp, bdev->bd_disk->diskseq); in blkdev_common_ioctl()
488 return blkdev_report_zones_ioctl(bdev, mode, cmd, arg); in blkdev_common_ioctl()
493 return blkdev_zone_mgmt_ioctl(bdev, mode, cmd, arg); in blkdev_common_ioctl()
495 return put_uint(argp, bdev_zone_sectors(bdev)); in blkdev_common_ioctl()
497 return put_uint(argp, blkdev_nr_zones(bdev->bd_disk)); in blkdev_common_ioctl()
499 return put_int(argp, bdev_read_only(bdev) != 0); in blkdev_common_ioctl()
501 return put_int(argp, bdev_logical_block_size(bdev)); in blkdev_common_ioctl()
503 return put_uint(argp, bdev_physical_block_size(bdev)); in blkdev_common_ioctl()
505 return put_uint(argp, bdev_io_min(bdev)); in blkdev_common_ioctl()
507 return put_uint(argp, bdev_io_opt(bdev)); in blkdev_common_ioctl()
509 return put_int(argp, bdev_alignment_offset(bdev)); in blkdev_common_ioctl()
514 queue_max_sectors(bdev_get_queue(bdev))); in blkdev_common_ioctl()
517 return put_ushort(argp, !blk_queue_nonrot(bdev_get_queue(bdev))); in blkdev_common_ioctl()
522 bdev->bd_disk->bdi->ra_pages = (arg * 512) / PAGE_SIZE; in blkdev_common_ioctl()
525 return blkdev_reread_part(bdev, mode); in blkdev_common_ioctl()
529 return blk_trace_ioctl(bdev, cmd, argp); in blkdev_common_ioctl()
531 return blkdev_pr_register(bdev, argp); in blkdev_common_ioctl()
533 return blkdev_pr_reserve(bdev, argp); in blkdev_common_ioctl()
535 return blkdev_pr_release(bdev, argp); in blkdev_common_ioctl()
537 return blkdev_pr_preempt(bdev, argp, false); in blkdev_common_ioctl()
539 return blkdev_pr_preempt(bdev, argp, true); in blkdev_common_ioctl()
541 return blkdev_pr_clear(bdev, argp); in blkdev_common_ioctl()
555 struct block_device *bdev = I_BDEV(file->f_mapping->host); in blkdev_ioctl() local
572 return blkdev_getgeo(bdev, argp); in blkdev_ioctl()
574 return blkpg_ioctl(bdev, argp); in blkdev_ioctl()
582 (bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512); in blkdev_ioctl()
584 if (bdev_nr_sectors(bdev) > ~0UL) in blkdev_ioctl()
586 return put_ulong(argp, bdev_nr_sectors(bdev)); in blkdev_ioctl()
590 return put_int(argp, block_size(bdev)); in blkdev_ioctl()
592 return blkdev_bszset(bdev, mode, argp); in blkdev_ioctl()
594 return put_u64(argp, bdev_nr_bytes(bdev)); in blkdev_ioctl()
598 return blk_trace_ioctl(bdev, cmd, argp); in blkdev_ioctl()
603 ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); in blkdev_ioctl()
607 if (!bdev->bd_disk->fops->ioctl) in blkdev_ioctl()
609 return bdev->bd_disk->fops->ioctl(bdev, mode, cmd, arg); in blkdev_ioctl()
625 struct block_device *bdev = I_BDEV(file->f_mapping->host); in compat_blkdev_ioctl() local
626 struct gendisk *disk = bdev->bd_disk; in compat_blkdev_ioctl()
641 return compat_hdio_getgeo(bdev, argp); in compat_blkdev_ioctl()
643 return compat_blkpg_ioctl(bdev, argp); in compat_blkdev_ioctl()
651 (bdev->bd_disk->bdi->ra_pages * PAGE_SIZE) / 512); in compat_blkdev_ioctl()
653 if (bdev_nr_sectors(bdev) > ~0UL) in compat_blkdev_ioctl()
655 return compat_put_ulong(argp, bdev_nr_sectors(bdev)); in compat_blkdev_ioctl()
659 return put_int(argp, bdev_logical_block_size(bdev)); in compat_blkdev_ioctl()
661 return blkdev_bszset(bdev, mode, argp); in compat_blkdev_ioctl()
663 return put_u64(argp, bdev_nr_bytes(bdev)); in compat_blkdev_ioctl()
667 return blk_trace_ioctl(bdev, cmd, argp); in compat_blkdev_ioctl()
672 ret = blkdev_common_ioctl(bdev, mode, cmd, arg, argp); in compat_blkdev_ioctl()
674 ret = disk->fops->compat_ioctl(bdev, mode, cmd, arg); in compat_blkdev_ioctl()