Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: replace fmode_t with a block-specific type for block open flags

The only overlap between the block open flags mapped into the fmode_t and
other uses of fmode_t are FMODE_READ and FMODE_WRITE. Define a new
blk_mode_t instead for use in blkdev_get_by_{dev,path}, ->open and
->ioctl and stop abusing fmode_t.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jack Wang <jinpu.wang@ionos.com> [rnbd]
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Link: https://lore.kernel.org/r/20230608110258.189493-28-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
05bdb996 5e4ea834

+334 -315
+4 -4
arch/um/drivers/ubd_kern.c
··· 108 108 static DEFINE_MUTEX(ubd_lock); 109 109 static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */ 110 110 111 - static int ubd_open(struct gendisk *disk, fmode_t mode); 111 + static int ubd_open(struct gendisk *disk, blk_mode_t mode); 112 112 static void ubd_release(struct gendisk *disk); 113 - static int ubd_ioctl(struct block_device *bdev, fmode_t mode, 113 + static int ubd_ioctl(struct block_device *bdev, blk_mode_t mode, 114 114 unsigned int cmd, unsigned long arg); 115 115 static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo); 116 116 ··· 1154 1154 1155 1155 device_initcall(ubd_driver_init); 1156 1156 1157 - static int ubd_open(struct gendisk *disk, fmode_t mode) 1157 + static int ubd_open(struct gendisk *disk, blk_mode_t mode) 1158 1158 { 1159 1159 struct ubd *ubd_dev = disk->private_data; 1160 1160 int err = 0; ··· 1389 1389 return 0; 1390 1390 } 1391 1391 1392 - static int ubd_ioctl(struct block_device *bdev, fmode_t mode, 1392 + static int ubd_ioctl(struct block_device *bdev, blk_mode_t mode, 1393 1393 unsigned int cmd, unsigned long arg) 1394 1394 { 1395 1395 struct ubd *ubd_dev = bdev->bd_disk->private_data;
+1 -1
arch/xtensa/platforms/iss/simdisk.c
··· 120 120 bio_endio(bio); 121 121 } 122 122 123 - static int simdisk_open(struct gendisk *disk, fmode_t mode) 123 + static int simdisk_open(struct gendisk *disk, blk_mode_t mode) 124 124 { 125 125 struct simdisk *dev = disk->private_data; 126 126
+16 -16
block/bdev.c
··· 93 93 * Drop all buffers & page cache for given bdev range. This function bails 94 94 * with error if bdev has other exclusive owner (such as filesystem). 95 95 */ 96 - int truncate_bdev_range(struct block_device *bdev, fmode_t mode, 96 + int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode, 97 97 loff_t lstart, loff_t lend) 98 98 { 99 99 /* ··· 101 101 * while we discard the buffer cache to avoid discarding buffers 102 102 * under live filesystem. 103 103 */ 104 - if (!(mode & FMODE_EXCL)) { 104 + if (!(mode & BLK_OPEN_EXCL)) { 105 105 int err = bd_prepare_to_claim(bdev, truncate_bdev_range, NULL); 106 106 if (err) 107 107 goto invalidate; 108 108 } 109 109 110 110 truncate_inode_pages_range(bdev->bd_inode->i_mapping, lstart, lend); 111 - if (!(mode & FMODE_EXCL)) 111 + if (!(mode & BLK_OPEN_EXCL)) 112 112 bd_abort_claiming(bdev, truncate_bdev_range); 113 113 return 0; 114 114 ··· 647 647 bdev_write_inode(bdev); 648 648 } 649 649 650 - static int blkdev_get_whole(struct block_device *bdev, fmode_t mode) 650 + static int blkdev_get_whole(struct block_device *bdev, blk_mode_t mode) 651 651 { 652 652 struct gendisk *disk = bdev->bd_disk; 653 653 int ret; ··· 679 679 bdev->bd_disk->fops->release(bdev->bd_disk); 680 680 } 681 681 682 - static int blkdev_get_part(struct block_device *part, fmode_t mode) 682 + static int blkdev_get_part(struct block_device *part, blk_mode_t mode) 683 683 { 684 684 struct gendisk *disk = part->bd_disk; 685 685 int ret; ··· 743 743 { 744 744 put_device(&bdev->bd_device); 745 745 } 746 - 746 + 747 747 /** 748 748 * blkdev_get_by_dev - open a block device by device number 749 749 * @dev: device number of block device to open 750 - * @mode: FMODE_* mask 750 + * @mode: open mode (BLK_OPEN_*) 751 751 * @holder: exclusive holder identifier 752 752 * @hops: holder operations 753 753 * ··· 765 765 * RETURNS: 766 766 * Reference to the block_device on success, ERR_PTR(-errno) on failure. 767 767 */ 768 - struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder, 768 + struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder, 769 769 const struct blk_holder_ops *hops) 770 770 { 771 771 bool unblock_events = true; ··· 775 775 776 776 ret = devcgroup_check_permission(DEVCG_DEV_BLOCK, 777 777 MAJOR(dev), MINOR(dev), 778 - ((mode & FMODE_READ) ? DEVCG_ACC_READ : 0) | 779 - ((mode & FMODE_WRITE) ? DEVCG_ACC_WRITE : 0)); 778 + ((mode & BLK_OPEN_READ) ? DEVCG_ACC_READ : 0) | 779 + ((mode & BLK_OPEN_WRITE) ? DEVCG_ACC_WRITE : 0)); 780 780 if (ret) 781 781 return ERR_PTR(ret); 782 782 ··· 786 786 disk = bdev->bd_disk; 787 787 788 788 if (holder) { 789 - mode |= FMODE_EXCL; 789 + mode |= BLK_OPEN_EXCL; 790 790 ret = bd_prepare_to_claim(bdev, holder, hops); 791 791 if (ret) 792 792 goto put_blkdev; 793 793 } else { 794 - if (WARN_ON_ONCE(mode & FMODE_EXCL)) { 794 + if (WARN_ON_ONCE(mode & BLK_OPEN_EXCL)) { 795 795 ret = -EIO; 796 796 goto put_blkdev; 797 797 } ··· 821 821 * writeable reference is too fragile given the way @mode is 822 822 * used in blkdev_get/put(). 823 823 */ 824 - if ((mode & FMODE_WRITE) && !bdev->bd_write_holder && 824 + if ((mode & BLK_OPEN_WRITE) && !bdev->bd_write_holder && 825 825 (disk->event_flags & DISK_EVENT_FLAG_BLOCK_ON_EXCL_WRITE)) { 826 826 bdev->bd_write_holder = true; 827 827 unblock_events = false; ··· 848 848 /** 849 849 * blkdev_get_by_path - open a block device by name 850 850 * @path: path to the block device to open 851 - * @mode: FMODE_* mask 851 + * @mode: open mode (BLK_OPEN_*) 852 852 * @holder: exclusive holder identifier 853 853 * 854 854 * Open the block device described by the device file at @path. If @holder is ··· 861 861 * RETURNS: 862 862 * Reference to the block_device on success, ERR_PTR(-errno) on failure. 863 863 */ 864 - struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, 864 + struct block_device *blkdev_get_by_path(const char *path, blk_mode_t mode, 865 865 void *holder, const struct blk_holder_ops *hops) 866 866 { 867 867 struct block_device *bdev; ··· 873 873 return ERR_PTR(error); 874 874 875 875 bdev = blkdev_get_by_dev(dev, mode, holder, hops); 876 - if (!IS_ERR(bdev) && (mode & FMODE_WRITE) && bdev_read_only(bdev)) { 876 + if (!IS_ERR(bdev) && (mode & BLK_OPEN_WRITE) && bdev_read_only(bdev)) { 877 877 blkdev_put(bdev, holder); 878 878 return ERR_PTR(-EACCES); 879 879 }
+4 -4
block/blk-zoned.c
··· 356 356 return 0; 357 357 } 358 358 359 - static int blkdev_truncate_zone_range(struct block_device *bdev, fmode_t mode, 360 - const struct blk_zone_range *zrange) 359 + static int blkdev_truncate_zone_range(struct block_device *bdev, 360 + blk_mode_t mode, const struct blk_zone_range *zrange) 361 361 { 362 362 loff_t start, end; 363 363 ··· 376 376 * BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing. 377 377 * Called from blkdev_ioctl. 378 378 */ 379 - int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode, 379 + int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, 380 380 unsigned int cmd, unsigned long arg) 381 381 { 382 382 void __user *argp = (void __user *)arg; ··· 390 390 if (!bdev_is_zoned(bdev)) 391 391 return -ENOTTY; 392 392 393 - if (!(mode & FMODE_WRITE)) 393 + if (!(mode & BLK_OPEN_WRITE)) 394 394 return -EBADF; 395 395 396 396 if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
+6 -5
block/blk.h
··· 396 396 void disk_clear_zone_settings(struct gendisk *disk); 397 397 int blkdev_report_zones_ioctl(struct block_device *bdev, unsigned int cmd, 398 398 unsigned long arg); 399 - int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode, 399 + int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, 400 400 unsigned int cmd, unsigned long arg); 401 401 #else /* CONFIG_BLK_DEV_ZONED */ 402 402 static inline void disk_free_zone_bitmaps(struct gendisk *disk) {} ··· 407 407 return -ENOTTY; 408 408 } 409 409 static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev, 410 - fmode_t mode, unsigned int cmd, unsigned long arg) 410 + blk_mode_t mode, unsigned int cmd, unsigned long arg) 411 411 { 412 412 return -ENOTTY; 413 413 } ··· 451 451 452 452 struct request_queue *blk_alloc_queue(int node_id); 453 453 454 - int disk_scan_partitions(struct gendisk *disk, fmode_t mode); 454 + int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode); 455 455 456 456 int disk_alloc_events(struct gendisk *disk); 457 457 void disk_add_events(struct gendisk *disk); ··· 466 466 467 467 extern struct attribute_group blk_trace_attr_group; 468 468 469 - int truncate_bdev_range(struct block_device *bdev, fmode_t mode, loff_t lstart, 470 - loff_t lend); 469 + blk_mode_t file_to_blk_mode(struct file *file); 470 + int truncate_bdev_range(struct block_device *bdev, blk_mode_t mode, 471 + loff_t lstart, loff_t lend); 471 472 long blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg); 472 473 long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg); 473 474
+26 -6
block/fops.c
··· 470 470 return error; 471 471 } 472 472 473 + blk_mode_t file_to_blk_mode(struct file *file) 474 + { 475 + blk_mode_t mode = 0; 476 + 477 + if (file->f_mode & FMODE_READ) 478 + mode |= BLK_OPEN_READ; 479 + if (file->f_mode & FMODE_WRITE) 480 + mode |= BLK_OPEN_WRITE; 481 + if (file->f_mode & FMODE_EXCL) 482 + mode |= BLK_OPEN_EXCL; 483 + if (file->f_flags & O_NDELAY) 484 + mode |= BLK_OPEN_NDELAY; 485 + 486 + /* 487 + * If all bits in O_ACCMODE set (aka O_RDWR | O_WRONLY), the floppy 488 + * driver has historically allowed ioctls as if the file was opened for 489 + * writing, but does not allow and actual reads or writes. 490 + */ 491 + if ((file->f_flags & O_ACCMODE) == (O_RDWR | O_WRONLY)) 492 + mode |= BLK_OPEN_WRITE_IOCTL; 493 + 494 + return mode; 495 + } 496 + 473 497 static int blkdev_open(struct inode *inode, struct file *filp) 474 498 { 475 499 struct block_device *bdev; ··· 507 483 filp->f_flags |= O_LARGEFILE; 508 484 filp->f_mode |= FMODE_NOWAIT | FMODE_BUF_RASYNC; 509 485 510 - if (filp->f_flags & O_NDELAY) 511 - filp->f_mode |= FMODE_NDELAY; 512 486 if (filp->f_flags & O_EXCL) 513 487 filp->f_mode |= FMODE_EXCL; 514 - if ((filp->f_flags & O_ACCMODE) == 3) 515 - filp->f_mode |= FMODE_WRITE_IOCTL; 516 488 517 - bdev = blkdev_get_by_dev(inode->i_rdev, filp->f_mode, 489 + bdev = blkdev_get_by_dev(inode->i_rdev, file_to_blk_mode(filp), 518 490 (filp->f_mode & FMODE_EXCL) ? filp : NULL, 519 491 NULL); 520 492 if (IS_ERR(bdev)) ··· 668 648 filemap_invalidate_lock(inode->i_mapping); 669 649 670 650 /* Invalidate the page cache, including dirty pages. */ 671 - error = truncate_bdev_range(bdev, file->f_mode, start, end); 651 + error = truncate_bdev_range(bdev, file_to_blk_mode(file), start, end); 672 652 if (error) 673 653 goto fail; 674 654
+4 -4
block/genhd.c
··· 339 339 } 340 340 EXPORT_SYMBOL_GPL(disk_uevent); 341 341 342 - int disk_scan_partitions(struct gendisk *disk, fmode_t mode) 342 + int disk_scan_partitions(struct gendisk *disk, blk_mode_t mode) 343 343 { 344 344 struct block_device *bdev; 345 345 int ret = 0; ··· 357 357 * synchronize with other exclusive openers and other partition 358 358 * scanners. 359 359 */ 360 - if (!(mode & FMODE_EXCL)) { 360 + if (!(mode & BLK_OPEN_EXCL)) { 361 361 ret = bd_prepare_to_claim(disk->part0, disk_scan_partitions, 362 362 NULL); 363 363 if (ret) ··· 377 377 * creat partition for underlying disk. 378 378 */ 379 379 clear_bit(GD_NEED_PART_SCAN, &disk->state); 380 - if (!(mode & FMODE_EXCL)) 380 + if (!(mode & BLK_OPEN_EXCL)) 381 381 bd_abort_claiming(disk->part0, disk_scan_partitions); 382 382 return ret; 383 383 } ··· 505 505 506 506 bdev_add(disk->part0, ddev->devt); 507 507 if (get_capacity(disk)) 508 - disk_scan_partitions(disk, FMODE_READ); 508 + disk_scan_partitions(disk, BLK_OPEN_READ); 509 509 510 510 /* 511 511 * Announce the disk and partitions after all partitions are
+12 -30
block/ioctl.c
··· 82 82 } 83 83 #endif 84 84 85 - static int blk_ioctl_discard(struct block_device *bdev, fmode_t mode, 85 + static int blk_ioctl_discard(struct block_device *bdev, blk_mode_t mode, 86 86 unsigned long arg) 87 87 { 88 88 uint64_t range[2]; ··· 90 90 struct inode *inode = bdev->bd_inode; 91 91 int err; 92 92 93 - if (!(mode & FMODE_WRITE)) 93 + if (!(mode & BLK_OPEN_WRITE)) 94 94 return -EBADF; 95 95 96 96 if (!bdev_max_discard_sectors(bdev)) ··· 120 120 return err; 121 121 } 122 122 123 - static int blk_ioctl_secure_erase(struct block_device *bdev, fmode_t mode, 123 + static int blk_ioctl_secure_erase(struct block_device *bdev, blk_mode_t mode, 124 124 void __user *argp) 125 125 { 126 126 uint64_t start, len; 127 127 uint64_t range[2]; 128 128 int err; 129 129 130 - if (!(mode & FMODE_WRITE)) 130 + if (!(mode & BLK_OPEN_WRITE)) 131 131 return -EBADF; 132 132 if (!bdev_max_secure_erase_sectors(bdev)) 133 133 return -EOPNOTSUPP; ··· 151 151 } 152 152 153 153 154 - static int blk_ioctl_zeroout(struct block_device *bdev, fmode_t mode, 154 + static int blk_ioctl_zeroout(struct block_device *bdev, blk_mode_t mode, 155 155 unsigned long arg) 156 156 { 157 157 uint64_t range[2]; ··· 159 159 struct inode *inode = bdev->bd_inode; 160 160 int err; 161 161 162 - if (!(mode & FMODE_WRITE)) 162 + if (!(mode & BLK_OPEN_WRITE)) 163 163 return -EBADF; 164 164 165 165 if (copy_from_user(range, (void __user *)arg, sizeof(range))) ··· 240 240 * drivers that implement only commands that are completely compatible 241 241 * between 32-bit and 64-bit user space 242 242 */ 243 - int blkdev_compat_ptr_ioctl(struct block_device *bdev, fmode_t mode, 243 + int blkdev_compat_ptr_ioctl(struct block_device *bdev, blk_mode_t mode, 244 244 unsigned cmd, unsigned long arg) 245 245 { 246 246 struct gendisk *disk = bdev->bd_disk; ··· 439 439 #endif 440 440 441 441 /* set the logical block size */ 442 - static int blkdev_bszset(struct block_device *bdev, fmode_t mode, 442 + static int blkdev_bszset(struct block_device *bdev, blk_mode_t mode, 443 443 int __user *argp) 444 444 { 445 445 int ret, n; ··· 451 451 if (get_user(n, argp)) 452 452 return -EFAULT; 453 453 454 - if (mode & FMODE_EXCL) 454 + if (mode & BLK_OPEN_EXCL) 455 455 return set_blocksize(bdev, n); 456 456 457 457 if (IS_ERR(blkdev_get_by_dev(bdev->bd_dev, mode, &bdev, NULL))) ··· 467 467 * user space. Note the separate arg/argp parameters that are needed 468 468 * to deal with the compat_ptr() conversion. 469 469 */ 470 - static int blkdev_common_ioctl(struct block_device *bdev, fmode_t mode, 470 + static int blkdev_common_ioctl(struct block_device *bdev, blk_mode_t mode, 471 471 unsigned int cmd, unsigned long arg, 472 472 void __user *argp) 473 473 { ··· 560 560 { 561 561 struct block_device *bdev = I_BDEV(file->f_mapping->host); 562 562 void __user *argp = (void __user *)arg; 563 - fmode_t mode = file->f_mode; 563 + blk_mode_t mode = file_to_blk_mode(file); 564 564 int ret; 565 - 566 - /* 567 - * O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have 568 - * to updated it before every ioctl. 569 - */ 570 - if (file->f_flags & O_NDELAY) 571 - mode |= FMODE_NDELAY; 572 - else 573 - mode &= ~FMODE_NDELAY; 574 565 575 566 switch (cmd) { 576 567 /* These need separate implementations for the data structure */ ··· 621 630 void __user *argp = compat_ptr(arg); 622 631 struct block_device *bdev = I_BDEV(file->f_mapping->host); 623 632 struct gendisk *disk = bdev->bd_disk; 624 - fmode_t mode = file->f_mode; 625 - 626 - /* 627 - * O_NDELAY can be altered using fcntl(.., F_SETFL, ..), so we have 628 - * to updated it before every ioctl. 629 - */ 630 - if (file->f_flags & O_NDELAY) 631 - mode |= FMODE_NDELAY; 632 - else 633 - mode &= ~FMODE_NDELAY; 633 + blk_mode_t mode = file_to_blk_mode(file); 634 634 635 635 switch (cmd) { 636 636 /* These need separate implementations for the data structure */
+5 -7
drivers/block/amiflop.c
··· 1532 1532 return 0; 1533 1533 } 1534 1534 1535 - static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, 1535 + static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode, 1536 1536 unsigned int cmd, unsigned long param) 1537 1537 { 1538 1538 struct amiga_floppy_struct *p = bdev->bd_disk->private_data; ··· 1607 1607 return 0; 1608 1608 } 1609 1609 1610 - static int fd_ioctl(struct block_device *bdev, fmode_t mode, 1610 + static int fd_ioctl(struct block_device *bdev, blk_mode_t mode, 1611 1611 unsigned int cmd, unsigned long param) 1612 1612 { 1613 1613 int ret; ··· 1654 1654 * /dev/PS0 etc), and disallows simultaneous access to the same 1655 1655 * drive with different device numbers. 1656 1656 */ 1657 - static int floppy_open(struct gendisk *disk, fmode_t mode) 1657 + static int floppy_open(struct gendisk *disk, blk_mode_t mode) 1658 1658 { 1659 1659 int drive = disk->first_minor & 3; 1660 1660 int system = (disk->first_minor & 4) >> 2; ··· 1673 1673 mutex_unlock(&amiflop_mutex); 1674 1674 return -ENXIO; 1675 1675 } 1676 - 1677 - if (mode & (FMODE_READ|FMODE_WRITE)) { 1676 + if (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE)) { 1678 1677 disk_check_media_change(disk); 1679 - if (mode & FMODE_WRITE) { 1678 + if (mode & BLK_OPEN_WRITE) { 1680 1679 int wrprot; 1681 1680 1682 1681 get_fdc(drive); ··· 1690 1691 } 1691 1692 } 1692 1693 } 1693 - 1694 1694 local_irq_save(flags); 1695 1695 fd_ref[drive]++; 1696 1696 fd_device[drive] = system;
+2 -2
drivers/block/aoe/aoeblk.c
··· 204 204 } 205 205 206 206 static int 207 - aoeblk_open(struct gendisk *disk, fmode_t mode) 207 + aoeblk_open(struct gendisk *disk, blk_mode_t mode) 208 208 { 209 209 struct aoedev *d = disk->private_data; 210 210 ulong flags; ··· 285 285 } 286 286 287 287 static int 288 - aoeblk_ioctl(struct block_device *bdev, fmode_t mode, uint cmd, ulong arg) 288 + aoeblk_ioctl(struct block_device *bdev, blk_mode_t mode, uint cmd, ulong arg) 289 289 { 290 290 struct aoedev *d; 291 291
+12 -13
drivers/block/ataflop.c
··· 442 442 static void finish_fdc( void ); 443 443 static void finish_fdc_done( int dummy ); 444 444 static void setup_req_params( int drive ); 445 - static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int 446 - cmd, unsigned long param); 445 + static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode, 446 + unsigned int cmd, unsigned long param); 447 447 static void fd_probe( int drive ); 448 448 static int fd_test_drive_present( int drive ); 449 449 static void config_types( void ); 450 - static int floppy_open(struct gendisk *disk, fmode_t mode); 450 + static int floppy_open(struct gendisk *disk, blk_mode_t mode); 451 451 static void floppy_release(struct gendisk *disk); 452 452 453 453 /************************* End of Prototypes **************************/ ··· 1581 1581 return BLK_STS_OK; 1582 1582 } 1583 1583 1584 - static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, 1584 + static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode, 1585 1585 unsigned int cmd, unsigned long param) 1586 1586 { 1587 1587 struct gendisk *disk = bdev->bd_disk; ··· 1768 1768 } 1769 1769 } 1770 1770 1771 - static int fd_ioctl(struct block_device *bdev, fmode_t mode, 1771 + static int fd_ioctl(struct block_device *bdev, blk_mode_t mode, 1772 1772 unsigned int cmd, unsigned long arg) 1773 1773 { 1774 1774 int ret; ··· 1915 1915 * drive with different device numbers. 1916 1916 */ 1917 1917 1918 - static int floppy_open(struct gendisk *disk, fmode_t mode) 1918 + static int floppy_open(struct gendisk *disk, blk_mode_t mode) 1919 1919 { 1920 1920 struct atari_floppy_struct *p = disk->private_data; 1921 1921 int type = disk->first_minor >> 2; ··· 1924 1924 if (p->ref && p->type != type) 1925 1925 return -EBUSY; 1926 1926 1927 - if (p->ref == -1 || (p->ref && mode & FMODE_EXCL)) 1927 + if (p->ref == -1 || (p->ref && mode & BLK_OPEN_EXCL)) 1928 1928 return -EBUSY; 1929 - 1930 - if (mode & FMODE_EXCL) 1929 + if (mode & BLK_OPEN_EXCL) 1931 1930 p->ref = -1; 1932 1931 else 1933 1932 p->ref++; 1934 1933 1935 1934 p->type = type; 1936 1935 1937 - if (mode & FMODE_NDELAY) 1936 + if (mode & BLK_OPEN_NDELAY) 1938 1937 return 0; 1939 1938 1940 - if (mode & (FMODE_READ|FMODE_WRITE)) { 1939 + if (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE)) { 1941 1940 if (disk_check_media_change(disk)) 1942 1941 floppy_revalidate(disk); 1943 - if (mode & FMODE_WRITE) { 1942 + if (mode & BLK_OPEN_WRITE) { 1944 1943 if (p->wpstat) { 1945 1944 if (p->ref < 0) 1946 1945 p->ref = 0; ··· 1952 1953 return 0; 1953 1954 } 1954 1955 1955 - static int floppy_unlocked_open(struct gendisk *disk, fmode_t mode) 1956 + static int floppy_unlocked_open(struct gendisk *disk, blk_mode_t mode) 1956 1957 { 1957 1958 int ret; 1958 1959
+4 -3
drivers/block/drbd/drbd_main.c
··· 49 49 #include "drbd_debugfs.h" 50 50 51 51 static DEFINE_MUTEX(drbd_main_mutex); 52 - static int drbd_open(struct gendisk *disk, fmode_t mode); 52 + static int drbd_open(struct gendisk *disk, blk_mode_t mode); 53 53 static void drbd_release(struct gendisk *gd); 54 54 static void md_sync_timer_fn(struct timer_list *t); 55 55 static int w_bitmap_io(struct drbd_work *w, int unused); ··· 1882 1882 return 0; 1883 1883 } 1884 1884 1885 - static int drbd_open(struct gendisk *disk, fmode_t mode) 1885 + static int drbd_open(struct gendisk *disk, blk_mode_t mode) 1886 1886 { 1887 1887 struct drbd_device *device = disk->private_data; 1888 1888 unsigned long flags; ··· 1894 1894 * and no race with updating open_cnt */ 1895 1895 1896 1896 if (device->state.role != R_PRIMARY) { 1897 - if (mode & FMODE_WRITE) 1897 + if (mode & BLK_OPEN_WRITE) 1898 1898 rv = -EROFS; 1899 1899 else if (!drbd_allow_oos) 1900 1900 rv = -EMEDIUMTYPE; ··· 1911 1911 static void drbd_release(struct gendisk *gd) 1912 1912 { 1913 1913 struct drbd_device *device = gd->private_data; 1914 + 1914 1915 mutex_lock(&drbd_main_mutex); 1915 1916 device->open_cnt--; 1916 1917 mutex_unlock(&drbd_main_mutex);
+1 -1
drivers/block/drbd/drbd_nl.c
··· 1640 1640 struct block_device *bdev; 1641 1641 int err = 0; 1642 1642 1643 - bdev = blkdev_get_by_path(bdev_path, FMODE_READ | FMODE_WRITE, 1643 + bdev = blkdev_get_by_path(bdev_path, BLK_OPEN_READ | BLK_OPEN_WRITE, 1644 1644 claim_ptr, NULL); 1645 1645 if (IS_ERR(bdev)) { 1646 1646 drbd_err(device, "open(\"%s\") failed with %ld\n",
+14 -14
drivers/block/floppy.c
··· 3394 3394 return true; 3395 3395 } 3396 3396 3397 - static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, 3398 - unsigned long param) 3397 + static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode, 3398 + unsigned int cmd, unsigned long param) 3399 3399 { 3400 3400 int drive = (long)bdev->bd_disk->private_data; 3401 3401 int type = ITYPE(drive_state[drive].fd_device); ··· 3428 3428 return ret; 3429 3429 3430 3430 /* permission checks */ 3431 - if (((cmd & 0x40) && !(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL))) || 3431 + if (((cmd & 0x40) && 3432 + !(mode & (BLK_OPEN_WRITE | BLK_OPEN_WRITE_IOCTL))) || 3432 3433 ((cmd & 0x80) && !capable(CAP_SYS_ADMIN))) 3433 3434 return -EPERM; 3434 3435 ··· 3567 3566 return 0; 3568 3567 } 3569 3568 3570 - static int fd_ioctl(struct block_device *bdev, fmode_t mode, 3569 + static int fd_ioctl(struct block_device *bdev, blk_mode_t mode, 3571 3570 unsigned int cmd, unsigned long param) 3572 3571 { 3573 3572 int ret; ··· 3655 3654 #define FDGETFDCSTAT32 _IOR(2, 0x15, struct compat_floppy_fdc_state) 3656 3655 #define FDWERRORGET32 _IOR(2, 0x17, struct compat_floppy_write_errors) 3657 3656 3658 - static int compat_set_geometry(struct block_device *bdev, fmode_t mode, unsigned int cmd, 3659 - struct compat_floppy_struct __user *arg) 3657 + static int compat_set_geometry(struct block_device *bdev, blk_mode_t mode, 3658 + unsigned int cmd, struct compat_floppy_struct __user *arg) 3660 3659 { 3661 3660 struct floppy_struct v; 3662 3661 int drive, type; ··· 3665 3664 BUILD_BUG_ON(offsetof(struct floppy_struct, name) != 3666 3665 offsetof(struct compat_floppy_struct, name)); 3667 3666 3668 - if (!(mode & (FMODE_WRITE | FMODE_WRITE_IOCTL))) 3667 + if (!(mode & (BLK_OPEN_WRITE | BLK_OPEN_WRITE_IOCTL))) 3669 3668 return -EPERM; 3670 3669 3671 3670 memset(&v, 0, sizeof(struct floppy_struct)); ··· 3862 3861 return 0; 3863 3862 } 3864 3863 3865 - static int fd_compat_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, 3866 - unsigned long param) 3864 + static int fd_compat_ioctl(struct block_device *bdev, blk_mode_t mode, 3865 + unsigned int cmd, unsigned long param) 3867 3866 { 3868 3867 int drive = (long)bdev->bd_disk->private_data; 3869 3868 switch (cmd) { ··· 3985 3984 * /dev/PS0 etc), and disallows simultaneous access to the same 3986 3985 * drive with different device numbers. 3987 3986 */ 3988 - static int floppy_open(struct gendisk *disk, fmode_t mode) 3987 + static int floppy_open(struct gendisk *disk, blk_mode_t mode) 3989 3988 { 3990 3989 int drive = (long)disk->private_data; 3991 3990 int old_dev, new_dev; ··· 4050 4049 4051 4050 if (fdc_state[FDC(drive)].rawcmd == 1) 4052 4051 fdc_state[FDC(drive)].rawcmd = 2; 4053 - 4054 - if (!(mode & FMODE_NDELAY)) { 4055 - if (mode & (FMODE_READ|FMODE_WRITE)) { 4052 + if (!(mode & BLK_OPEN_NDELAY)) { 4053 + if (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE)) { 4056 4054 drive_state[drive].last_checked = 0; 4057 4055 clear_bit(FD_OPEN_SHOULD_FAIL_BIT, 4058 4056 &drive_state[drive].flags); ··· 4063 4063 goto out; 4064 4064 } 4065 4065 res = -EROFS; 4066 - if ((mode & FMODE_WRITE) && 4066 + if ((mode & BLK_OPEN_WRITE) && 4067 4067 !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags)) 4068 4068 goto out; 4069 4069 }
+10 -12
drivers/block/loop.c
··· 990 990 return 0; 991 991 } 992 992 993 - static int loop_configure(struct loop_device *lo, fmode_t mode, 993 + static int loop_configure(struct loop_device *lo, blk_mode_t mode, 994 994 struct block_device *bdev, 995 995 const struct loop_config *config) 996 996 { ··· 1014 1014 * If we don't hold exclusive handle for the device, upgrade to it 1015 1015 * here to avoid changing device under exclusive owner. 1016 1016 */ 1017 - if (!(mode & FMODE_EXCL)) { 1017 + if (!(mode & BLK_OPEN_EXCL)) { 1018 1018 error = bd_prepare_to_claim(bdev, loop_configure, NULL); 1019 1019 if (error) 1020 1020 goto out_putf; ··· 1050 1050 if (error) 1051 1051 goto out_unlock; 1052 1052 1053 - if (!(file->f_mode & FMODE_WRITE) || !(mode & FMODE_WRITE) || 1053 + if (!(file->f_mode & FMODE_WRITE) || !(mode & BLK_OPEN_WRITE) || 1054 1054 !file->f_op->write_iter) 1055 1055 lo->lo_flags |= LO_FLAGS_READ_ONLY; 1056 1056 ··· 1116 1116 if (partscan) 1117 1117 loop_reread_partitions(lo); 1118 1118 1119 - if (!(mode & FMODE_EXCL)) 1119 + if (!(mode & BLK_OPEN_EXCL)) 1120 1120 bd_abort_claiming(bdev, loop_configure); 1121 1121 1122 1122 return 0; ··· 1124 1124 out_unlock: 1125 1125 loop_global_unlock(lo, is_loop); 1126 1126 out_bdev: 1127 - if (!(mode & FMODE_EXCL)) 1127 + if (!(mode & BLK_OPEN_EXCL)) 1128 1128 bd_abort_claiming(bdev, loop_configure); 1129 1129 out_putf: 1130 1130 fput(file); ··· 1528 1528 return err; 1529 1529 } 1530 1530 1531 - static int lo_ioctl(struct block_device *bdev, fmode_t mode, 1531 + static int lo_ioctl(struct block_device *bdev, blk_mode_t mode, 1532 1532 unsigned int cmd, unsigned long arg) 1533 1533 { 1534 1534 struct loop_device *lo = bdev->bd_disk->private_data; ··· 1563 1563 return loop_clr_fd(lo); 1564 1564 case LOOP_SET_STATUS: 1565 1565 err = -EPERM; 1566 - if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) { 1566 + if ((mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN)) 1567 1567 err = loop_set_status_old(lo, argp); 1568 - } 1569 1568 break; 1570 1569 case LOOP_GET_STATUS: 1571 1570 return loop_get_status_old(lo, argp); 1572 1571 case LOOP_SET_STATUS64: 1573 1572 err = -EPERM; 1574 - if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN)) { 1573 + if ((mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN)) 1575 1574 err = loop_set_status64(lo, argp); 1576 - } 1577 1575 break; 1578 1576 case LOOP_GET_STATUS64: 1579 1577 return loop_get_status64(lo, argp); 1580 1578 case LOOP_SET_CAPACITY: 1581 1579 case LOOP_SET_DIRECT_IO: 1582 1580 case LOOP_SET_BLOCK_SIZE: 1583 - if (!(mode & FMODE_WRITE) && !capable(CAP_SYS_ADMIN)) 1581 + if (!(mode & BLK_OPEN_WRITE) && !capable(CAP_SYS_ADMIN)) 1584 1582 return -EPERM; 1585 1583 fallthrough; 1586 1584 default: ··· 1689 1691 return err; 1690 1692 } 1691 1693 1692 - static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode, 1694 + static int lo_compat_ioctl(struct block_device *bdev, blk_mode_t mode, 1693 1695 unsigned int cmd, unsigned long arg) 1694 1696 { 1695 1697 struct loop_device *lo = bdev->bd_disk->private_data;
+2 -2
drivers/block/mtip32xx/mtip32xx.c
··· 3041 3041 * structure pointer. 3042 3042 */ 3043 3043 static int mtip_block_ioctl(struct block_device *dev, 3044 - fmode_t mode, 3044 + blk_mode_t mode, 3045 3045 unsigned cmd, 3046 3046 unsigned long arg) 3047 3047 { ··· 3079 3079 * structure pointer. 3080 3080 */ 3081 3081 static int mtip_block_compat_ioctl(struct block_device *dev, 3082 - fmode_t mode, 3082 + blk_mode_t mode, 3083 3083 unsigned cmd, 3084 3084 unsigned long arg) 3085 3085 {
+2 -2
drivers/block/nbd.c
··· 1502 1502 return -ENOTTY; 1503 1503 } 1504 1504 1505 - static int nbd_ioctl(struct block_device *bdev, fmode_t mode, 1505 + static int nbd_ioctl(struct block_device *bdev, blk_mode_t mode, 1506 1506 unsigned int cmd, unsigned long arg) 1507 1507 { 1508 1508 struct nbd_device *nbd = bdev->bd_disk->private_data; ··· 1553 1553 return config; 1554 1554 } 1555 1555 1556 - static int nbd_open(struct gendisk *disk, fmode_t mode) 1556 + static int nbd_open(struct gendisk *disk, blk_mode_t mode) 1557 1557 { 1558 1558 struct nbd_device *nbd; 1559 1559 int ret = 0;
+9 -8
drivers/block/pktcdvd.c
··· 2154 2154 /* 2155 2155 * called at open time. 2156 2156 */ 2157 - static int pkt_open_dev(struct pktcdvd_device *pd, fmode_t write) 2157 + static int pkt_open_dev(struct pktcdvd_device *pd, bool write) 2158 2158 { 2159 2159 struct device *ddev = disk_to_dev(pd->disk); 2160 2160 int ret; ··· 2167 2167 * to read/write from/to it. It is already opened in O_NONBLOCK mode 2168 2168 * so open should not fail. 2169 2169 */ 2170 - bdev = blkdev_get_by_dev(pd->bdev->bd_dev, FMODE_READ, pd, NULL); 2170 + bdev = blkdev_get_by_dev(pd->bdev->bd_dev, BLK_OPEN_READ, pd, NULL); 2171 2171 if (IS_ERR(bdev)) { 2172 2172 ret = PTR_ERR(bdev); 2173 2173 goto out; ··· 2247 2247 return pkt_devs[dev_minor]; 2248 2248 } 2249 2249 2250 - static int pkt_open(struct gendisk *disk, fmode_t mode) 2250 + static int pkt_open(struct gendisk *disk, blk_mode_t mode) 2251 2251 { 2252 2252 struct pktcdvd_device *pd = NULL; 2253 2253 int ret; ··· 2263 2263 2264 2264 pd->refcnt++; 2265 2265 if (pd->refcnt > 1) { 2266 - if ((mode & FMODE_WRITE) && 2266 + if ((mode & BLK_OPEN_WRITE) && 2267 2267 !test_bit(PACKET_WRITABLE, &pd->flags)) { 2268 2268 ret = -EBUSY; 2269 2269 goto out_dec; 2270 2270 } 2271 2271 } else { 2272 - ret = pkt_open_dev(pd, mode & FMODE_WRITE); 2272 + ret = pkt_open_dev(pd, mode & BLK_OPEN_WRITE); 2273 2273 if (ret) 2274 2274 goto out_dec; 2275 2275 /* ··· 2278 2278 */ 2279 2279 set_blocksize(disk->part0, CD_FRAMESIZE); 2280 2280 } 2281 - 2282 2281 mutex_unlock(&ctl_mutex); 2283 2282 mutex_unlock(&pktcdvd_mutex); 2284 2283 return 0; ··· 2513 2514 } 2514 2515 } 2515 2516 2516 - bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_NDELAY, NULL, NULL); 2517 + bdev = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_NDELAY, NULL, 2518 + NULL); 2517 2519 if (IS_ERR(bdev)) 2518 2520 return PTR_ERR(bdev); 2519 2521 sdev = scsi_device_from_queue(bdev->bd_disk->queue); ··· 2550 2550 return -ENOMEM; 2551 2551 } 2552 2552 2553 - static int pkt_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long arg) 2553 + static int pkt_ioctl(struct block_device *bdev, blk_mode_t mode, 2554 + unsigned int cmd, unsigned long arg) 2554 2555 { 2555 2556 struct pktcdvd_device *pd = bdev->bd_disk->private_data; 2556 2557 struct device *ddev = disk_to_dev(pd->disk);
+1 -1
drivers/block/rbd.c
··· 660 660 return true; 661 661 } 662 662 663 - static int rbd_open(struct gendisk *disk, fmode_t mode) 663 + static int rbd_open(struct gendisk *disk, blk_mode_t mode) 664 664 { 665 665 struct rbd_device *rbd_dev = disk->private_data; 666 666 bool removing = false;
+2 -2
drivers/block/rnbd/rnbd-clt.c
··· 921 921 return sess; 922 922 } 923 923 924 - static int rnbd_client_open(struct gendisk *disk, fmode_t mode) 924 + static int rnbd_client_open(struct gendisk *disk, blk_mode_t mode) 925 925 { 926 926 struct rnbd_clt_dev *dev = disk->private_data; 927 927 928 - if (get_disk_ro(dev->gd) && (mode & FMODE_WRITE)) 928 + if (get_disk_ro(dev->gd) && (mode & BLK_OPEN_WRITE)) 929 929 return -EPERM; 930 930 931 931 if (dev->dev_state == DEV_STATE_UNMAPPED ||
+2 -2
drivers/block/rnbd/rnbd-srv.c
··· 677 677 struct rnbd_srv_sess_dev *srv_sess_dev; 678 678 const struct rnbd_msg_open *open_msg = msg; 679 679 struct block_device *bdev; 680 - fmode_t open_flags = FMODE_READ; 680 + blk_mode_t open_flags = BLK_OPEN_READ; 681 681 char *full_path; 682 682 struct rnbd_msg_open_rsp *rsp = data; 683 683 684 684 trace_process_msg_open(srv_sess, open_msg); 685 685 686 686 if (open_msg->access_mode != RNBD_ACCESS_RO) 687 - open_flags |= FMODE_WRITE; 687 + open_flags |= BLK_OPEN_WRITE; 688 688 689 689 mutex_lock(&srv_sess->lock); 690 690
+1 -1
drivers/block/sunvdc.c
··· 139 139 * when vdisk_mtype is VD_MEDIA_TYPE_CD or VD_MEDIA_TYPE_DVD. 140 140 * Needed to be able to install inside an ldom from an iso image. 141 141 */ 142 - static int vdc_ioctl(struct block_device *bdev, fmode_t mode, 142 + static int vdc_ioctl(struct block_device *bdev, blk_mode_t mode, 143 143 unsigned command, unsigned long argument) 144 144 { 145 145 struct vdc_port *port = bdev->bd_disk->private_data;
+7 -9
drivers/block/swim.c
··· 608 608 } 609 609 } 610 610 611 - static int floppy_open(struct gendisk *disk, fmode_t mode) 611 + static int floppy_open(struct gendisk *disk, blk_mode_t mode) 612 612 { 613 613 struct floppy_state *fs = disk->private_data; 614 614 struct swim __iomem *base = fs->swd->base; 615 615 int err; 616 616 617 - if (fs->ref_count == -1 || (fs->ref_count && mode & FMODE_EXCL)) 617 + if (fs->ref_count == -1 || (fs->ref_count && mode & BLK_OPEN_EXCL)) 618 618 return -EBUSY; 619 - 620 - if (mode & FMODE_EXCL) 619 + if (mode & BLK_OPEN_EXCL) 621 620 fs->ref_count = -1; 622 621 else 623 622 fs->ref_count++; 624 - 625 623 swim_write(base, setup, S_IBM_DRIVE | S_FCLK_DIV2); 626 624 udelay(10); 627 625 swim_drive(base, fs->location); ··· 634 636 635 637 set_capacity(fs->disk, fs->total_secs); 636 638 637 - if (mode & FMODE_NDELAY) 639 + if (mode & BLK_OPEN_NDELAY) 638 640 return 0; 639 641 640 - if (mode & (FMODE_READ|FMODE_WRITE)) { 642 + if (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE)) { 641 643 if (disk_check_media_change(disk) && fs->disk_in) 642 644 fs->ejected = 0; 643 645 if ((mode & FMODE_WRITE) && fs->write_protected) { ··· 657 659 return err; 658 660 } 659 661 660 - static int floppy_unlocked_open(struct gendisk *disk, fmode_t mode) 662 + static int floppy_unlocked_open(struct gendisk *disk, blk_mode_t mode) 661 663 { 662 664 int ret; 663 665 ··· 684 686 mutex_unlock(&swim_mutex); 685 687 } 686 688 687 - static int floppy_ioctl(struct block_device *bdev, fmode_t mode, 689 + static int floppy_ioctl(struct block_device *bdev, blk_mode_t mode, 688 690 unsigned int cmd, unsigned long param) 689 691 { 690 692 struct floppy_state *fs = bdev->bd_disk->private_data;
+12 -12
drivers/block/swim3.c
··· 246 246 int interruptible); 247 247 static void release_drive(struct floppy_state *fs); 248 248 static int fd_eject(struct floppy_state *fs); 249 - static int floppy_ioctl(struct block_device *bdev, fmode_t mode, 249 + static int floppy_ioctl(struct block_device *bdev, blk_mode_t mode, 250 250 unsigned int cmd, unsigned long param); 251 - static int floppy_open(struct gendisk *disk, fmode_t mode); 251 + static int floppy_open(struct gendisk *disk, blk_mode_t mode); 252 252 static unsigned int floppy_check_events(struct gendisk *disk, 253 253 unsigned int clearing); 254 254 static int floppy_revalidate(struct gendisk *disk); ··· 882 882 static struct floppy_struct floppy_type = 883 883 { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL }; /* 7 1.44MB 3.5" */ 884 884 885 - static int floppy_locked_ioctl(struct block_device *bdev, fmode_t mode, 885 + static int floppy_locked_ioctl(struct block_device *bdev, 886 886 unsigned int cmd, unsigned long param) 887 887 { 888 888 struct floppy_state *fs = bdev->bd_disk->private_data; ··· 910 910 return -ENOTTY; 911 911 } 912 912 913 - static int floppy_ioctl(struct block_device *bdev, fmode_t mode, 913 + static int floppy_ioctl(struct block_device *bdev, blk_mode_t mode, 914 914 unsigned int cmd, unsigned long param) 915 915 { 916 916 int ret; ··· 922 922 return ret; 923 923 } 924 924 925 - static int floppy_open(struct gendisk *disk, fmode_t mode) 925 + static int floppy_open(struct gendisk *disk, blk_mode_t mode) 926 926 { 927 927 struct floppy_state *fs = disk->private_data; 928 928 struct swim3 __iomem *sw = fs->swim3; ··· 957 957 swim3_action(fs, SETMFM); 958 958 swim3_select(fs, RELAX); 959 959 960 - } else if (fs->ref_count == -1 || mode & FMODE_EXCL) 960 + } else if (fs->ref_count == -1 || mode & BLK_OPEN_EXCL) 961 961 return -EBUSY; 962 962 963 - if (err == 0 && (mode & FMODE_NDELAY) == 0 964 - && (mode & (FMODE_READ|FMODE_WRITE))) { 963 + if (err == 0 && !(mode & BLK_OPEN_NDELAY) && 964 + (mode & (BLK_OPEN_READ | BLK_OPEN_WRITE))) { 965 965 if (disk_check_media_change(disk)) 966 966 floppy_revalidate(disk); 967 967 if (fs->ejected) 968 968 err = -ENXIO; 969 969 } 970 970 971 - if (err == 0 && (mode & FMODE_WRITE)) { 971 + if (err == 0 && (mode & BLK_OPEN_WRITE)) { 972 972 if (fs->write_prot < 0) 973 973 fs->write_prot = swim3_readbit(fs, WRITE_PROT); 974 974 if (fs->write_prot) ··· 984 984 return err; 985 985 } 986 986 987 - if (mode & FMODE_EXCL) 987 + if (mode & BLK_OPEN_EXCL) 988 988 fs->ref_count = -1; 989 989 else 990 990 ++fs->ref_count; ··· 992 992 return 0; 993 993 } 994 994 995 - static int floppy_unlocked_open(struct block_device *bdev, fmode_t mode) 995 + static int floppy_unlocked_open(struct gendisk *disk, blk_mode_t mode) 996 996 { 997 997 int ret; 998 998 999 999 mutex_lock(&swim3_mutex); 1000 - ret = floppy_open(bdev, mode); 1000 + ret = floppy_open(disk, mode); 1001 1001 mutex_unlock(&swim3_mutex); 1002 1002 1003 1003 return ret;
+1 -1
drivers/block/ublk_drv.c
··· 447 447 *owner_gid = from_kgid(&init_user_ns, gid); 448 448 } 449 449 450 - static int ublk_open(struct gendisk *disk, fmode_t mode) 450 + static int ublk_open(struct gendisk *disk, blk_mode_t mode) 451 451 { 452 452 struct ublk_device *ub = disk->private_data; 453 453
+1 -1
drivers/block/xen-blkback/xenbus.c
··· 492 492 vbd->pdevice = MKDEV(major, minor); 493 493 494 494 bdev = blkdev_get_by_dev(vbd->pdevice, vbd->readonly ? 495 - FMODE_READ : FMODE_WRITE, NULL, NULL); 495 + BLK_OPEN_READ : BLK_OPEN_WRITE, NULL, NULL); 496 496 497 497 if (IS_ERR(bdev)) { 498 498 pr_warn("xen_vbd_create: device %08x could not be opened\n",
+1 -1
drivers/block/xen-blkfront.c
··· 509 509 return 0; 510 510 } 511 511 512 - static int blkif_ioctl(struct block_device *bdev, fmode_t mode, 512 + static int blkif_ioctl(struct block_device *bdev, blk_mode_t mode, 513 513 unsigned command, unsigned long argument) 514 514 { 515 515 struct blkfront_info *info = bdev->bd_disk->private_data;
+1 -1
drivers/block/z2ram.c
··· 140 140 return; 141 141 } 142 142 143 - static int z2_open(struct gendisk *disk, fmode_t mode) 143 + static int z2_open(struct gendisk *disk, blk_mode_t mode) 144 144 { 145 145 int device = disk->first_minor; 146 146 int max_z2_map = (Z2RAM_SIZE / Z2RAM_CHUNKSIZE) * sizeof(z2ram_map[0]);
+3 -3
drivers/block/zram/zram_drv.c
··· 507 507 goto out; 508 508 } 509 509 510 - bdev = blkdev_get_by_dev(inode->i_rdev, FMODE_READ | FMODE_WRITE, zram, 511 - NULL); 510 + bdev = blkdev_get_by_dev(inode->i_rdev, BLK_OPEN_READ | BLK_OPEN_WRITE, 511 + zram, NULL); 512 512 if (IS_ERR(bdev)) { 513 513 err = PTR_ERR(bdev); 514 514 bdev = NULL; ··· 2097 2097 return len; 2098 2098 } 2099 2099 2100 - static int zram_open(struct gendisk *disk, fmode_t mode) 2100 + static int zram_open(struct gendisk *disk, blk_mode_t mode) 2101 2101 { 2102 2102 struct zram *zram = disk->private_data; 2103 2103
+3 -3
drivers/cdrom/cdrom.c
··· 1146 1146 * is in their own interest: device control becomes a lot easier 1147 1147 * this way. 1148 1148 */ 1149 - int cdrom_open(struct cdrom_device_info *cdi, fmode_t mode) 1149 + int cdrom_open(struct cdrom_device_info *cdi, blk_mode_t mode) 1150 1150 { 1151 1151 int ret; 1152 1152 ··· 1155 1155 /* if this was a O_NONBLOCK open and we should honor the flags, 1156 1156 * do a quick open without drive/disc integrity checks. */ 1157 1157 cdi->use_count++; 1158 - if ((mode & FMODE_NDELAY) && (cdi->options & CDO_USE_FFLAGS)) { 1158 + if ((mode & BLK_OPEN_NDELAY) && (cdi->options & CDO_USE_FFLAGS)) { 1159 1159 ret = cdi->ops->open(cdi, 1); 1160 1160 } else { 1161 1161 ret = open_for_data(cdi); ··· 1163 1163 goto err; 1164 1164 if (CDROM_CAN(CDC_GENERIC_PACKET)) 1165 1165 cdrom_mmc3_profile(cdi); 1166 - if (mode & FMODE_WRITE) { 1166 + if (mode & BLK_OPEN_WRITE) { 1167 1167 ret = -EROFS; 1168 1168 if (cdrom_open_write(cdi)) 1169 1169 goto err_release;
+2 -2
drivers/cdrom/gdrom.c
··· 474 474 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R, 475 475 }; 476 476 477 - static int gdrom_bdops_open(struct gendisk *disk, fmode_t mode) 477 + static int gdrom_bdops_open(struct gendisk *disk, blk_mode_t mode) 478 478 { 479 479 int ret; 480 480 ··· 499 499 return cdrom_check_events(gd.cd_info, clearing); 500 500 } 501 501 502 - static int gdrom_bdops_ioctl(struct block_device *bdev, fmode_t mode, 502 + static int gdrom_bdops_ioctl(struct block_device *bdev, blk_mode_t mode, 503 503 unsigned cmd, unsigned long arg) 504 504 { 505 505 int ret;
+1 -1
drivers/md/bcache/bcache.h
··· 275 275 276 276 int (*cache_miss)(struct btree *b, struct search *s, 277 277 struct bio *bio, unsigned int sectors); 278 - int (*ioctl)(struct bcache_device *d, fmode_t mode, 278 + int (*ioctl)(struct bcache_device *d, blk_mode_t mode, 279 279 unsigned int cmd, unsigned long arg); 280 280 }; 281 281
+2 -2
drivers/md/bcache/request.c
··· 1228 1228 detached_dev_do_request(d, bio, orig_bdev, start_time); 1229 1229 } 1230 1230 1231 - static int cached_dev_ioctl(struct bcache_device *d, fmode_t mode, 1231 + static int cached_dev_ioctl(struct bcache_device *d, blk_mode_t mode, 1232 1232 unsigned int cmd, unsigned long arg) 1233 1233 { 1234 1234 struct cached_dev *dc = container_of(d, struct cached_dev, disk); ··· 1318 1318 continue_at(cl, search_free, NULL); 1319 1319 } 1320 1320 1321 - static int flash_dev_ioctl(struct bcache_device *d, fmode_t mode, 1321 + static int flash_dev_ioctl(struct bcache_device *d, blk_mode_t mode, 1322 1322 unsigned int cmd, unsigned long arg) 1323 1323 { 1324 1324 return -ENOTTY;
+3 -3
drivers/md/bcache/super.c
··· 732 732 733 733 /* Bcache device */ 734 734 735 - static int open_dev(struct gendisk *disk, fmode_t mode) 735 + static int open_dev(struct gendisk *disk, blk_mode_t mode) 736 736 { 737 737 struct bcache_device *d = disk->private_data; 738 738 ··· 750 750 closure_put(&d->cl); 751 751 } 752 752 753 - static int ioctl_dev(struct block_device *b, fmode_t mode, 753 + static int ioctl_dev(struct block_device *b, blk_mode_t mode, 754 754 unsigned int cmd, unsigned long arg) 755 755 { 756 756 struct bcache_device *d = b->bd_disk->private_data; ··· 2558 2558 2559 2559 ret = -EINVAL; 2560 2560 err = "failed to open device"; 2561 - bdev = blkdev_get_by_path(strim(path), FMODE_READ | FMODE_WRITE, 2561 + bdev = blkdev_get_by_path(strim(path), BLK_OPEN_READ | BLK_OPEN_WRITE, 2562 2562 bcache_kobj, NULL); 2563 2563 if (IS_ERR(bdev)) { 2564 2564 if (bdev == ERR_PTR(-EBUSY)) {
+6 -6
drivers/md/dm-cache-target.c
··· 2051 2051 if (!at_least_one_arg(as, error)) 2052 2052 return -EINVAL; 2053 2053 2054 - r = dm_get_device(ca->ti, dm_shift_arg(as), FMODE_READ | FMODE_WRITE, 2055 - &ca->metadata_dev); 2054 + r = dm_get_device(ca->ti, dm_shift_arg(as), 2055 + BLK_OPEN_READ | BLK_OPEN_WRITE, &ca->metadata_dev); 2056 2056 if (r) { 2057 2057 *error = "Error opening metadata device"; 2058 2058 return r; ··· 2074 2074 if (!at_least_one_arg(as, error)) 2075 2075 return -EINVAL; 2076 2076 2077 - r = dm_get_device(ca->ti, dm_shift_arg(as), FMODE_READ | FMODE_WRITE, 2078 - &ca->cache_dev); 2077 + r = dm_get_device(ca->ti, dm_shift_arg(as), 2078 + BLK_OPEN_READ | BLK_OPEN_WRITE, &ca->cache_dev); 2079 2079 if (r) { 2080 2080 *error = "Error opening cache device"; 2081 2081 return r; ··· 2093 2093 if (!at_least_one_arg(as, error)) 2094 2094 return -EINVAL; 2095 2095 2096 - r = dm_get_device(ca->ti, dm_shift_arg(as), FMODE_READ | FMODE_WRITE, 2097 - &ca->origin_dev); 2096 + r = dm_get_device(ca->ti, dm_shift_arg(as), 2097 + BLK_OPEN_READ | BLK_OPEN_WRITE, &ca->origin_dev); 2098 2098 if (r) { 2099 2099 *error = "Error opening origin device"; 2100 2100 return r;
+5 -5
drivers/md/dm-clone-target.c
··· 1683 1683 int r; 1684 1684 sector_t metadata_dev_size; 1685 1685 1686 - r = dm_get_device(clone->ti, dm_shift_arg(as), FMODE_READ | FMODE_WRITE, 1687 - &clone->metadata_dev); 1686 + r = dm_get_device(clone->ti, dm_shift_arg(as), 1687 + BLK_OPEN_READ | BLK_OPEN_WRITE, &clone->metadata_dev); 1688 1688 if (r) { 1689 1689 *error = "Error opening metadata device"; 1690 1690 return r; ··· 1703 1703 int r; 1704 1704 sector_t dest_dev_size; 1705 1705 1706 - r = dm_get_device(clone->ti, dm_shift_arg(as), FMODE_READ | FMODE_WRITE, 1707 - &clone->dest_dev); 1706 + r = dm_get_device(clone->ti, dm_shift_arg(as), 1707 + BLK_OPEN_READ | BLK_OPEN_WRITE, &clone->dest_dev); 1708 1708 if (r) { 1709 1709 *error = "Error opening destination device"; 1710 1710 return r; ··· 1725 1725 int r; 1726 1726 sector_t source_dev_size; 1727 1727 1728 - r = dm_get_device(clone->ti, dm_shift_arg(as), FMODE_READ, 1728 + r = dm_get_device(clone->ti, dm_shift_arg(as), BLK_OPEN_READ, 1729 1729 &clone->source_dev); 1730 1730 if (r) { 1731 1731 *error = "Error opening source device";
+3 -4
drivers/md/dm-core.h
··· 207 207 unsigned integrity_added:1; 208 208 209 209 /* 210 - * Indicates the rw permissions for the new logical 211 - * device. This should be a combination of FMODE_READ 212 - * and FMODE_WRITE. 210 + * Indicates the rw permissions for the new logical device. This 211 + * should be a combination of BLK_OPEN_READ and BLK_OPEN_WRITE. 213 212 */ 214 - fmode_t mode; 213 + blk_mode_t mode; 215 214 216 215 /* a list of devices used by this table */ 217 216 struct list_head devices;
+4 -2
drivers/md/dm-era-target.c
··· 1482 1482 1483 1483 era->ti = ti; 1484 1484 1485 - r = dm_get_device(ti, argv[0], FMODE_READ | FMODE_WRITE, &era->metadata_dev); 1485 + r = dm_get_device(ti, argv[0], BLK_OPEN_READ | BLK_OPEN_WRITE, 1486 + &era->metadata_dev); 1486 1487 if (r) { 1487 1488 ti->error = "Error opening metadata device"; 1488 1489 era_destroy(era); 1489 1490 return -EINVAL; 1490 1491 } 1491 1492 1492 - r = dm_get_device(ti, argv[1], FMODE_READ | FMODE_WRITE, &era->origin_dev); 1493 + r = dm_get_device(ti, argv[1], BLK_OPEN_READ | BLK_OPEN_WRITE, 1494 + &era->origin_dev); 1493 1495 if (r) { 1494 1496 ti->error = "Error opening data device"; 1495 1497 era_destroy(era);
+5 -5
drivers/md/dm-ioctl.c
··· 861 861 862 862 table = dm_get_inactive_table(md, &srcu_idx); 863 863 if (table) { 864 - if (!(dm_table_get_mode(table) & FMODE_WRITE)) 864 + if (!(dm_table_get_mode(table) & BLK_OPEN_WRITE)) 865 865 param->flags |= DM_READONLY_FLAG; 866 866 param->target_count = table->num_targets; 867 867 } ··· 1192 1192 if (old_size && new_size && old_size != new_size) 1193 1193 need_resize_uevent = true; 1194 1194 1195 - if (dm_table_get_mode(new_map) & FMODE_WRITE) 1195 + if (dm_table_get_mode(new_map) & BLK_OPEN_WRITE) 1196 1196 set_disk_ro(dm_disk(md), 0); 1197 1197 else 1198 1198 set_disk_ro(dm_disk(md), 1); ··· 1381 1381 return 0; 1382 1382 } 1383 1383 1384 - static inline fmode_t get_mode(struct dm_ioctl *param) 1384 + static inline blk_mode_t get_mode(struct dm_ioctl *param) 1385 1385 { 1386 - fmode_t mode = FMODE_READ | FMODE_WRITE; 1386 + blk_mode_t mode = BLK_OPEN_READ | BLK_OPEN_WRITE; 1387 1387 1388 1388 if (param->flags & DM_READONLY_FLAG) 1389 - mode = FMODE_READ; 1389 + mode = BLK_OPEN_READ; 1390 1390 1391 1391 return mode; 1392 1392 }
+2 -2
drivers/md/dm-snap.c
··· 1242 1242 int r = -EINVAL; 1243 1243 char *origin_path, *cow_path; 1244 1244 unsigned int args_used, num_flush_bios = 1; 1245 - fmode_t origin_mode = FMODE_READ; 1245 + blk_mode_t origin_mode = BLK_OPEN_READ; 1246 1246 1247 1247 if (argc < 4) { 1248 1248 ti->error = "requires 4 or more arguments"; ··· 1252 1252 1253 1253 if (dm_target_is_snapshot_merge(ti)) { 1254 1254 num_flush_bios = 2; 1255 - origin_mode = FMODE_WRITE; 1255 + origin_mode = BLK_OPEN_WRITE; 1256 1256 } 1257 1257 1258 1258 s = kzalloc(sizeof(*s), GFP_KERNEL);
+6 -5
drivers/md/dm-table.c
··· 126 126 return 0; 127 127 } 128 128 129 - int dm_table_create(struct dm_table **result, fmode_t mode, 129 + int dm_table_create(struct dm_table **result, blk_mode_t mode, 130 130 unsigned int num_targets, struct mapped_device *md) 131 131 { 132 132 struct dm_table *t = kzalloc(sizeof(*t), GFP_KERNEL); ··· 304 304 * device and not to touch the existing bdev field in case 305 305 * it is accessed concurrently. 306 306 */ 307 - static int upgrade_mode(struct dm_dev_internal *dd, fmode_t new_mode, 307 + static int upgrade_mode(struct dm_dev_internal *dd, blk_mode_t new_mode, 308 308 struct mapped_device *md) 309 309 { 310 310 int r; ··· 330 330 * Note: the __ref annotation is because this function can call the __init 331 331 * marked early_lookup_bdev when called during early boot code from dm-init.c. 332 332 */ 333 - int __ref dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, 333 + int __ref dm_get_device(struct dm_target *ti, const char *path, blk_mode_t mode, 334 334 struct dm_dev **result) 335 335 { 336 336 int r; ··· 662 662 t->singleton = true; 663 663 } 664 664 665 - if (dm_target_always_writeable(ti->type) && !(t->mode & FMODE_WRITE)) { 665 + if (dm_target_always_writeable(ti->type) && 666 + !(t->mode & BLK_OPEN_WRITE)) { 666 667 ti->error = "target type may not be included in a read-only table"; 667 668 goto bad; 668 669 } ··· 2034 2033 return &t->devices; 2035 2034 } 2036 2035 2037 - fmode_t dm_table_get_mode(struct dm_table *t) 2036 + blk_mode_t dm_table_get_mode(struct dm_table *t) 2038 2037 { 2039 2038 return t->mode; 2040 2039 }
+5 -4
drivers/md/dm-thin.c
··· 3301 3301 unsigned long block_size; 3302 3302 dm_block_t low_water_blocks; 3303 3303 struct dm_dev *metadata_dev; 3304 - fmode_t metadata_mode; 3304 + blk_mode_t metadata_mode; 3305 3305 3306 3306 /* 3307 3307 * FIXME Remove validation from scope of lock. ··· 3334 3334 if (r) 3335 3335 goto out_unlock; 3336 3336 3337 - metadata_mode = FMODE_READ | ((pf.mode == PM_READ_ONLY) ? 0 : FMODE_WRITE); 3337 + metadata_mode = BLK_OPEN_READ | 3338 + ((pf.mode == PM_READ_ONLY) ? 0 : BLK_OPEN_WRITE); 3338 3339 r = dm_get_device(ti, argv[0], metadata_mode, &metadata_dev); 3339 3340 if (r) { 3340 3341 ti->error = "Error opening metadata block device"; ··· 3343 3342 } 3344 3343 warn_if_metadata_device_too_big(metadata_dev->bdev); 3345 3344 3346 - r = dm_get_device(ti, argv[1], FMODE_READ | FMODE_WRITE, &data_dev); 3345 + r = dm_get_device(ti, argv[1], BLK_OPEN_READ | BLK_OPEN_WRITE, &data_dev); 3347 3346 if (r) { 3348 3347 ti->error = "Error getting data device"; 3349 3348 goto out_metadata; ··· 4224 4223 goto bad_origin_dev; 4225 4224 } 4226 4225 4227 - r = dm_get_device(ti, argv[2], FMODE_READ, &origin_dev); 4226 + r = dm_get_device(ti, argv[2], BLK_OPEN_READ, &origin_dev); 4228 4227 if (r) { 4229 4228 ti->error = "Error opening origin device"; 4230 4229 goto bad_origin_dev;
+1 -1
drivers/md/dm-verity-fec.c
··· 607 607 (*argc)--; 608 608 609 609 if (!strcasecmp(arg_name, DM_VERITY_OPT_FEC_DEV)) { 610 - r = dm_get_device(ti, arg_value, FMODE_READ, &v->fec->dev); 610 + r = dm_get_device(ti, arg_value, BLK_OPEN_READ, &v->fec->dev); 611 611 if (r) { 612 612 ti->error = "FEC device lookup failed"; 613 613 return r;
+3 -3
drivers/md/dm-verity-target.c
··· 1196 1196 if (r) 1197 1197 goto bad; 1198 1198 1199 - if ((dm_table_get_mode(ti->table) & ~FMODE_READ)) { 1199 + if ((dm_table_get_mode(ti->table) & ~BLK_OPEN_READ)) { 1200 1200 ti->error = "Device must be readonly"; 1201 1201 r = -EINVAL; 1202 1202 goto bad; ··· 1225 1225 } 1226 1226 v->version = num; 1227 1227 1228 - r = dm_get_device(ti, argv[1], FMODE_READ, &v->data_dev); 1228 + r = dm_get_device(ti, argv[1], BLK_OPEN_READ, &v->data_dev); 1229 1229 if (r) { 1230 1230 ti->error = "Data device lookup failed"; 1231 1231 goto bad; 1232 1232 } 1233 1233 1234 - r = dm_get_device(ti, argv[2], FMODE_READ, &v->hash_dev); 1234 + r = dm_get_device(ti, argv[2], BLK_OPEN_READ, &v->hash_dev); 1235 1235 if (r) { 1236 1236 ti->error = "Hash device lookup failed"; 1237 1237 goto bad;
+5 -5
drivers/md/dm.c
··· 310 310 return test_bit(DMF_DELETING, &md->flags); 311 311 } 312 312 313 - static int dm_blk_open(struct gendisk *disk, fmode_t mode) 313 + static int dm_blk_open(struct gendisk *disk, blk_mode_t mode) 314 314 { 315 315 struct mapped_device *md; 316 316 ··· 448 448 dm_put_live_table(md, srcu_idx); 449 449 } 450 450 451 - static int dm_blk_ioctl(struct block_device *bdev, fmode_t mode, 451 + static int dm_blk_ioctl(struct block_device *bdev, blk_mode_t mode, 452 452 unsigned int cmd, unsigned long arg) 453 453 { 454 454 struct mapped_device *md = bdev->bd_disk->private_data; ··· 734 734 * Open a table device so we can use it as a map destination. 735 735 */ 736 736 static struct table_device *open_table_device(struct mapped_device *md, 737 - dev_t dev, fmode_t mode) 737 + dev_t dev, blk_mode_t mode) 738 738 { 739 739 struct table_device *td; 740 740 struct block_device *bdev; ··· 791 791 } 792 792 793 793 static struct table_device *find_table_device(struct list_head *l, dev_t dev, 794 - fmode_t mode) 794 + blk_mode_t mode) 795 795 { 796 796 struct table_device *td; 797 797 ··· 802 802 return NULL; 803 803 } 804 804 805 - int dm_get_table_device(struct mapped_device *md, dev_t dev, fmode_t mode, 805 + int dm_get_table_device(struct mapped_device *md, dev_t dev, blk_mode_t mode, 806 806 struct dm_dev **result) 807 807 { 808 808 struct table_device *td;
+1 -1
drivers/md/dm.h
··· 203 203 int dm_lock_for_deletion(struct mapped_device *md, bool mark_deferred, bool only_deferred); 204 204 int dm_cancel_deferred_remove(struct mapped_device *md); 205 205 int dm_request_based(struct mapped_device *md); 206 - int dm_get_table_device(struct mapped_device *md, dev_t dev, fmode_t mode, 206 + int dm_get_table_device(struct mapped_device *md, dev_t dev, blk_mode_t mode, 207 207 struct dm_dev **result); 208 208 void dm_put_table_device(struct mapped_device *md, struct dm_dev *d); 209 209
+4 -4
drivers/md/md.c
··· 3643 3643 if (err) 3644 3644 goto out_clear_rdev; 3645 3645 3646 - rdev->bdev = blkdev_get_by_dev(newdev, FMODE_READ | FMODE_WRITE, 3646 + rdev->bdev = blkdev_get_by_dev(newdev, BLK_OPEN_READ | BLK_OPEN_WRITE, 3647 3647 super_format == -2 ? &claim_rdev : rdev, NULL); 3648 3648 if (IS_ERR(rdev->bdev)) { 3649 3649 pr_warn("md: could not open device unknown-block(%u,%u).\n", ··· 7488 7488 return err; 7489 7489 } 7490 7490 7491 - static int md_ioctl(struct block_device *bdev, fmode_t mode, 7491 + static int md_ioctl(struct block_device *bdev, blk_mode_t mode, 7492 7492 unsigned int cmd, unsigned long arg) 7493 7493 { 7494 7494 int err = 0; ··· 7720 7720 return err; 7721 7721 } 7722 7722 #ifdef CONFIG_COMPAT 7723 - static int md_compat_ioctl(struct block_device *bdev, fmode_t mode, 7723 + static int md_compat_ioctl(struct block_device *bdev, blk_mode_t mode, 7724 7724 unsigned int cmd, unsigned long arg) 7725 7725 { 7726 7726 switch (cmd) { ··· 7769 7769 return err; 7770 7770 } 7771 7771 7772 - static int md_open(struct gendisk *disk, fmode_t mode) 7772 + static int md_open(struct gendisk *disk, blk_mode_t mode) 7773 7773 { 7774 7774 struct mddev *mddev; 7775 7775 int err;
+4 -4
drivers/mmc/core/block.c
··· 357 357 NULL, 358 358 }; 359 359 360 - static int mmc_blk_open(struct gendisk *disk, fmode_t mode) 360 + static int mmc_blk_open(struct gendisk *disk, blk_mode_t mode) 361 361 { 362 362 struct mmc_blk_data *md = mmc_blk_get(disk); 363 363 int ret = -ENXIO; ··· 365 365 mutex_lock(&block_mutex); 366 366 if (md) { 367 367 ret = 0; 368 - if ((mode & FMODE_WRITE) && md->read_only) { 368 + if ((mode & BLK_OPEN_WRITE) && md->read_only) { 369 369 mmc_blk_put(md); 370 370 ret = -EROFS; 371 371 } ··· 754 754 return 0; 755 755 } 756 756 757 - static int mmc_blk_ioctl(struct block_device *bdev, fmode_t mode, 757 + static int mmc_blk_ioctl(struct block_device *bdev, blk_mode_t mode, 758 758 unsigned int cmd, unsigned long arg) 759 759 { 760 760 struct mmc_blk_data *md; ··· 791 791 } 792 792 793 793 #ifdef CONFIG_COMPAT 794 - static int mmc_blk_compat_ioctl(struct block_device *bdev, fmode_t mode, 794 + static int mmc_blk_compat_ioctl(struct block_device *bdev, blk_mode_t mode, 795 795 unsigned int cmd, unsigned long arg) 796 796 { 797 797 return mmc_blk_ioctl(bdev, mode, cmd, (unsigned long) compat_ptr(arg));
+2 -2
drivers/mtd/devices/block2mtd.c
··· 220 220 * early_lookup_bdev when called from the early boot code. 221 221 */ 222 222 static struct block_device __ref *mdtblock_early_get_bdev(const char *devname, 223 - fmode_t mode, int timeout, struct block2mtd_dev *dev) 223 + blk_mode_t mode, int timeout, struct block2mtd_dev *dev) 224 224 { 225 225 struct block_device *bdev = ERR_PTR(-ENODEV); 226 226 #ifndef MODULE ··· 261 261 static struct block2mtd_dev *add_device(char *devname, int erase_size, 262 262 char *label, int timeout) 263 263 { 264 - const fmode_t mode = FMODE_READ | FMODE_WRITE; 264 + const blk_mode_t mode = BLK_OPEN_READ | BLK_OPEN_WRITE; 265 265 struct block_device *bdev; 266 266 struct block2mtd_dev *dev; 267 267 char *name;
+2 -2
drivers/mtd/mtd_blkdevs.c
··· 182 182 return BLK_STS_OK; 183 183 } 184 184 185 - static int blktrans_open(struct gendisk *disk, fmode_t mode) 185 + static int blktrans_open(struct gendisk *disk, blk_mode_t mode) 186 186 { 187 187 struct mtd_blktrans_dev *dev = disk->private_data; 188 188 int ret = 0; ··· 208 208 ret = __get_mtd_device(dev->mtd); 209 209 if (ret) 210 210 goto error_release; 211 - dev->writable = mode & FMODE_WRITE; 211 + dev->writable = mode & BLK_OPEN_WRITE; 212 212 213 213 unlock: 214 214 dev->open++;
+2 -3
drivers/mtd/ubi/block.c
··· 227 227 return BLK_STS_OK; 228 228 } 229 229 230 - static int ubiblock_open(struct gendisk *disk, fmode_t mode) 230 + static int ubiblock_open(struct gendisk *disk, blk_mode_t mode) 231 231 { 232 232 struct ubiblock *dev = disk->private_data; 233 233 int ret; ··· 246 246 * It's just a paranoid check, as write requests will get rejected 247 247 * in any case. 248 248 */ 249 - if (mode & FMODE_WRITE) { 249 + if (mode & BLK_OPEN_WRITE) { 250 250 ret = -EROFS; 251 251 goto out_unlock; 252 252 } 253 - 254 253 dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY); 255 254 if (IS_ERR(dev->desc)) { 256 255 dev_err(disk_to_dev(dev->gd), "failed to open ubi volume %d_%d",
+1 -1
drivers/nvme/host/core.c
··· 1591 1591 nvme_put_ns(ns); 1592 1592 } 1593 1593 1594 - static int nvme_open(struct gendisk *disk, fmode_t mode) 1594 + static int nvme_open(struct gendisk *disk, blk_mode_t mode) 1595 1595 { 1596 1596 return nvme_ns_open(disk->private_data); 1597 1597 }
+4 -4
drivers/nvme/host/ioctl.c
··· 709 709 } 710 710 } 711 711 712 - int nvme_ioctl(struct block_device *bdev, fmode_t mode, 712 + int nvme_ioctl(struct block_device *bdev, blk_mode_t mode, 713 713 unsigned int cmd, unsigned long arg) 714 714 { 715 715 struct nvme_ns *ns = bdev->bd_disk->private_data; 716 - bool open_for_write = mode & FMODE_WRITE; 716 + bool open_for_write = mode & BLK_OPEN_WRITE; 717 717 void __user *argp = (void __user *)arg; 718 718 unsigned int flags = 0; 719 719 ··· 817 817 return ret; 818 818 } 819 819 820 - int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode, 820 + int nvme_ns_head_ioctl(struct block_device *bdev, blk_mode_t mode, 821 821 unsigned int cmd, unsigned long arg) 822 822 { 823 823 struct nvme_ns_head *head = bdev->bd_disk->private_data; 824 - bool open_for_write = mode & FMODE_WRITE; 824 + bool open_for_write = mode & BLK_OPEN_WRITE; 825 825 void __user *argp = (void __user *)arg; 826 826 struct nvme_ns *ns; 827 827 int srcu_idx, ret = -EWOULDBLOCK;
+1 -1
drivers/nvme/host/multipath.c
··· 402 402 srcu_read_unlock(&head->srcu, srcu_idx); 403 403 } 404 404 405 - static int nvme_ns_head_open(struct gendisk *disk, fmode_t mode) 405 + static int nvme_ns_head_open(struct gendisk *disk, blk_mode_t mode) 406 406 { 407 407 if (!nvme_tryget_ns_head(disk->private_data)) 408 408 return -ENXIO;
+2 -2
drivers/nvme/host/nvme.h
··· 836 836 int nvme_cdev_add(struct cdev *cdev, struct device *cdev_device, 837 837 const struct file_operations *fops, struct module *owner); 838 838 void nvme_cdev_del(struct cdev *cdev, struct device *cdev_device); 839 - int nvme_ioctl(struct block_device *bdev, fmode_t mode, 839 + int nvme_ioctl(struct block_device *bdev, blk_mode_t mode, 840 840 unsigned int cmd, unsigned long arg); 841 841 long nvme_ns_chr_ioctl(struct file *file, unsigned int cmd, unsigned long arg); 842 - int nvme_ns_head_ioctl(struct block_device *bdev, fmode_t mode, 842 + int nvme_ns_head_ioctl(struct block_device *bdev, blk_mode_t mode, 843 843 unsigned int cmd, unsigned long arg); 844 844 long nvme_ns_head_chr_ioctl(struct file *file, unsigned int cmd, 845 845 unsigned long arg);
+1 -1
drivers/nvme/target/io-cmd-bdev.c
··· 85 85 return -ENOTBLK; 86 86 87 87 ns->bdev = blkdev_get_by_path(ns->device_path, 88 - FMODE_READ | FMODE_WRITE, NULL, NULL); 88 + BLK_OPEN_READ | BLK_OPEN_WRITE, NULL, NULL); 89 89 if (IS_ERR(ns->bdev)) { 90 90 ret = PTR_ERR(ns->bdev); 91 91 if (ret != -ENOTBLK) {
+2 -4
drivers/s390/block/dasd.c
··· 3234 3234 .exit_hctx = dasd_exit_hctx, 3235 3235 }; 3236 3236 3237 - static int dasd_open(struct gendisk *disk, fmode_t mode) 3237 + static int dasd_open(struct gendisk *disk, blk_mode_t mode) 3238 3238 { 3239 3239 struct dasd_device *base; 3240 3240 int rc; ··· 3268 3268 rc = -ENODEV; 3269 3269 goto out; 3270 3270 } 3271 - 3272 - if ((mode & FMODE_WRITE) && 3271 + if ((mode & BLK_OPEN_WRITE) && 3273 3272 (test_bit(DASD_FLAG_DEVICE_RO, &base->flags) || 3274 3273 (base->features & DASD_FEATURE_READONLY))) { 3275 3274 rc = -EROFS; 3276 3275 goto out; 3277 3276 } 3278 - 3279 3277 dasd_put_device(base); 3280 3278 return 0; 3281 3279
+2 -1
drivers/s390/block/dasd_genhd.c
··· 130 130 struct block_device *bdev; 131 131 int rc; 132 132 133 - bdev = blkdev_get_by_dev(disk_devt(block->gdp), FMODE_READ, NULL, NULL); 133 + bdev = blkdev_get_by_dev(disk_devt(block->gdp), BLK_OPEN_READ, NULL, 134 + NULL); 134 135 if (IS_ERR(bdev)) { 135 136 DBF_DEV_EVENT(DBF_ERR, block->base, 136 137 "scan partitions error, blkdev_get returned %ld",
+2 -1
drivers/s390/block/dasd_int.h
··· 965 965 void dasd_destroy_partitions(struct dasd_block *); 966 966 967 967 /* externals in dasd_ioctl.c */ 968 - int dasd_ioctl(struct block_device *, fmode_t, unsigned int, unsigned long); 968 + int dasd_ioctl(struct block_device *bdev, blk_mode_t mode, unsigned int cmd, 969 + unsigned long arg); 969 970 int dasd_set_read_only(struct block_device *bdev, bool ro); 970 971 971 972 /* externals in dasd_proc.c */
+1 -1
drivers/s390/block/dasd_ioctl.c
··· 612 612 return ret; 613 613 } 614 614 615 - int dasd_ioctl(struct block_device *bdev, fmode_t mode, 615 + int dasd_ioctl(struct block_device *bdev, blk_mode_t mode, 616 616 unsigned int cmd, unsigned long arg) 617 617 { 618 618 struct dasd_block *block;
+2 -2
drivers/s390/block/dcssblk.c
··· 28 28 #define DCSSBLK_PARM_LEN 400 29 29 #define DCSS_BUS_ID_SIZE 20 30 30 31 - static int dcssblk_open(struct gendisk *disk, fmode_t mode); 31 + static int dcssblk_open(struct gendisk *disk, blk_mode_t mode); 32 32 static void dcssblk_release(struct gendisk *disk); 33 33 static void dcssblk_submit_bio(struct bio *bio); 34 34 static long dcssblk_dax_direct_access(struct dax_device *dax_dev, pgoff_t pgoff, ··· 809 809 } 810 810 811 811 static int 812 - dcssblk_open(struct gendisk *disk, fmode_t mode) 812 + dcssblk_open(struct gendisk *disk, blk_mode_t mode) 813 813 { 814 814 struct dcssblk_dev_info *dev_info = disk->private_data; 815 815 int rc;
+10 -9
drivers/scsi/sd.c
··· 1298 1298 /** 1299 1299 * sd_open - open a scsi disk device 1300 1300 * @disk: disk to open 1301 - * @mode: FMODE_* mask 1301 + * @mode: open mode 1302 1302 * 1303 1303 * Returns 0 if successful. Returns a negated errno value in case 1304 1304 * of error. ··· 1310 1310 * 1311 1311 * Locking: called with disk->open_mutex held. 1312 1312 **/ 1313 - static int sd_open(struct gendisk *disk, fmode_t mode) 1313 + static int sd_open(struct gendisk *disk, blk_mode_t mode) 1314 1314 { 1315 1315 struct scsi_disk *sdkp = scsi_disk(disk); 1316 1316 struct scsi_device *sdev = sdkp->device; ··· 1336 1336 * If the drive is empty, just let the open fail. 1337 1337 */ 1338 1338 retval = -ENOMEDIUM; 1339 - if (sdev->removable && !sdkp->media_present && !(mode & FMODE_NDELAY)) 1339 + if (sdev->removable && !sdkp->media_present && 1340 + !(mode & BLK_OPEN_NDELAY)) 1340 1341 goto error_out; 1341 1342 1342 1343 /* ··· 1345 1344 * if the user expects to be able to write to the thing. 1346 1345 */ 1347 1346 retval = -EROFS; 1348 - if (sdkp->write_prot && (mode & FMODE_WRITE)) 1347 + if (sdkp->write_prot && (mode & BLK_OPEN_WRITE)) 1349 1348 goto error_out; 1350 1349 1351 1350 /* ··· 1380 1379 * Note: may block (uninterruptible) if error recovery is underway 1381 1380 * on this disk. 1382 1381 * 1383 - * Locking: called with bdev->bd_disk->open_mutex held. 1382 + * Locking: called with disk->open_mutex held. 1384 1383 **/ 1385 1384 static void sd_release(struct gendisk *disk) 1386 1385 { ··· 1425 1424 /** 1426 1425 * sd_ioctl - process an ioctl 1427 1426 * @bdev: target block device 1428 - * @mode: FMODE_* mask 1427 + * @mode: open mode 1429 1428 * @cmd: ioctl command number 1430 1429 * @arg: this is third argument given to ioctl(2) system call. 1431 1430 * Often contains a pointer. ··· 1436 1435 * Note: most ioctls are forward onto the block subsystem or further 1437 1436 * down in the scsi subsystem. 1438 1437 **/ 1439 - static int sd_ioctl(struct block_device *bdev, fmode_t mode, 1438 + static int sd_ioctl(struct block_device *bdev, blk_mode_t mode, 1440 1439 unsigned int cmd, unsigned long arg) 1441 1440 { 1442 1441 struct gendisk *disk = bdev->bd_disk; ··· 1458 1457 * access to the device is prohibited. 1459 1458 */ 1460 1459 error = scsi_ioctl_block_when_processing_errors(sdp, cmd, 1461 - (mode & FMODE_NDELAY) != 0); 1460 + (mode & BLK_OPEN_NDELAY)); 1462 1461 if (error) 1463 1462 return error; 1464 1463 1465 1464 if (is_sed_ioctl(cmd)) 1466 1465 return sed_ioctl(sdkp->opal_dev, cmd, p); 1467 - return scsi_ioctl(sdp, mode & FMODE_WRITE, cmd, p); 1466 + return scsi_ioctl(sdp, mode & BLK_OPEN_WRITE, cmd, p); 1468 1467 } 1469 1468 1470 1469 static void set_media_not_present(struct scsi_disk *sdkp)
+5 -5
drivers/scsi/sr.c
··· 484 484 get_sectorsize(cd); 485 485 } 486 486 487 - static int sr_block_open(struct gendisk *disk, fmode_t mode) 487 + static int sr_block_open(struct gendisk *disk, blk_mode_t mode) 488 488 { 489 489 struct scsi_cd *cd = scsi_cd(disk); 490 490 struct scsi_device *sdev = cd->device; ··· 518 518 scsi_device_put(cd->device); 519 519 } 520 520 521 - static int sr_block_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, 522 - unsigned long arg) 521 + static int sr_block_ioctl(struct block_device *bdev, blk_mode_t mode, 522 + unsigned cmd, unsigned long arg) 523 523 { 524 524 struct scsi_cd *cd = scsi_cd(bdev->bd_disk); 525 525 struct scsi_device *sdev = cd->device; ··· 532 532 mutex_lock(&cd->lock); 533 533 534 534 ret = scsi_ioctl_block_when_processing_errors(sdev, cmd, 535 - (mode & FMODE_NDELAY) != 0); 535 + (mode & BLK_OPEN_NDELAY)); 536 536 if (ret) 537 537 goto out; 538 538 ··· 543 543 if (ret != -ENOSYS) 544 544 goto put; 545 545 } 546 - ret = scsi_ioctl(sdev, mode & FMODE_WRITE, cmd, argp); 546 + ret = scsi_ioctl(sdev, mode & BLK_OPEN_WRITE, cmd, argp); 547 547 548 548 put: 549 549 scsi_autopm_put_device(sdev);
+2 -3
drivers/target/target_core_iblock.c
··· 90 90 struct request_queue *q; 91 91 struct block_device *bd = NULL; 92 92 struct blk_integrity *bi; 93 - fmode_t mode; 93 + blk_mode_t mode = BLK_OPEN_READ; 94 94 unsigned int max_write_zeroes_sectors; 95 95 int ret; 96 96 ··· 108 108 pr_debug( "IBLOCK: Claiming struct block_device: %s\n", 109 109 ib_dev->ibd_udev_path); 110 110 111 - mode = FMODE_READ; 112 111 if (!ib_dev->ibd_readonly) 113 - mode |= FMODE_WRITE; 112 + mode |= BLK_OPEN_WRITE; 114 113 else 115 114 dev->dev_flags |= DF_READ_ONLY; 116 115
+2 -2
drivers/target/target_core_pscsi.c
··· 366 366 * Claim exclusive struct block_device access to struct scsi_device 367 367 * for TYPE_DISK and TYPE_ZBC using supplied udev_path 368 368 */ 369 - bd = blkdev_get_by_path(dev->udev_path, FMODE_WRITE | FMODE_READ, pdv, 370 - NULL); 369 + bd = blkdev_get_by_path(dev->udev_path, BLK_OPEN_WRITE | BLK_OPEN_READ, 370 + pdv, NULL); 371 371 if (IS_ERR(bd)) { 372 372 pr_err("pSCSI: blkdev_get_by_path() failed\n"); 373 373 scsi_device_put(sd);
+1 -1
fs/btrfs/dev-replace.c
··· 257 257 return -EINVAL; 258 258 } 259 259 260 - bdev = blkdev_get_by_path(device_path, FMODE_WRITE, 260 + bdev = blkdev_get_by_path(device_path, BLK_OPEN_WRITE, 261 261 fs_info->bdev_holder, NULL); 262 262 if (IS_ERR(bdev)) { 263 263 btrfs_err(fs_info, "target device %s is invalid!", device_path);
+4 -4
fs/btrfs/super.c
··· 849 849 * All other options will be parsed on much later in the mount process and 850 850 * only when we need to allocate a new super block. 851 851 */ 852 - static int btrfs_parse_device_options(const char *options, fmode_t flags) 852 + static int btrfs_parse_device_options(const char *options, blk_mode_t flags) 853 853 { 854 854 substring_t args[MAX_OPT_ARGS]; 855 855 char *device_name, *opts, *orig, *p; ··· 1440 1440 struct btrfs_fs_devices *fs_devices = NULL; 1441 1441 struct btrfs_fs_info *fs_info = NULL; 1442 1442 void *new_sec_opts = NULL; 1443 - fmode_t mode = sb_open_mode(flags); 1443 + blk_mode_t mode = sb_open_mode(flags); 1444 1444 int error = 0; 1445 1445 1446 1446 if (data) { ··· 2185 2185 switch (cmd) { 2186 2186 case BTRFS_IOC_SCAN_DEV: 2187 2187 mutex_lock(&uuid_mutex); 2188 - device = btrfs_scan_one_device(vol->name, FMODE_READ); 2188 + device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ); 2189 2189 ret = PTR_ERR_OR_ZERO(device); 2190 2190 mutex_unlock(&uuid_mutex); 2191 2191 break; ··· 2199 2199 break; 2200 2200 case BTRFS_IOC_DEVICES_READY: 2201 2201 mutex_lock(&uuid_mutex); 2202 - device = btrfs_scan_one_device(vol->name, FMODE_READ); 2202 + device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ); 2203 2203 if (IS_ERR(device)) { 2204 2204 mutex_unlock(&uuid_mutex); 2205 2205 ret = PTR_ERR(device);
+8 -8
fs/btrfs/volumes.c
··· 490 490 491 491 492 492 static int 493 - btrfs_get_bdev_and_sb(const char *device_path, fmode_t flags, void *holder, 493 + btrfs_get_bdev_and_sb(const char *device_path, blk_mode_t flags, void *holder, 494 494 int flush, struct block_device **bdev, 495 495 struct btrfs_super_block **disk_super) 496 496 { ··· 590 590 * fs_devices->device_list_mutex here. 591 591 */ 592 592 static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, 593 - struct btrfs_device *device, fmode_t flags, 593 + struct btrfs_device *device, blk_mode_t flags, 594 594 void *holder) 595 595 { 596 596 struct block_device *bdev; ··· 1207 1207 } 1208 1208 1209 1209 static int open_fs_devices(struct btrfs_fs_devices *fs_devices, 1210 - fmode_t flags, void *holder) 1210 + blk_mode_t flags, void *holder) 1211 1211 { 1212 1212 struct btrfs_device *device; 1213 1213 struct btrfs_device *latest_dev = NULL; ··· 1255 1255 } 1256 1256 1257 1257 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, 1258 - fmode_t flags, void *holder) 1258 + blk_mode_t flags, void *holder) 1259 1259 { 1260 1260 int ret; 1261 1261 ··· 1346 1346 * and we are not allowed to call set_blocksize during the scan. The superblock 1347 1347 * is read via pagecache 1348 1348 */ 1349 - struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags) 1349 + struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags) 1350 1350 { 1351 1351 struct btrfs_super_block *disk_super; 1352 1352 bool new_device_added = false; ··· 2378 2378 return -ENOMEM; 2379 2379 } 2380 2380 2381 - ret = btrfs_get_bdev_and_sb(path, FMODE_READ, NULL, 0, 2381 + ret = btrfs_get_bdev_and_sb(path, BLK_OPEN_READ, NULL, 0, 2382 2382 &bdev, &disk_super); 2383 2383 if (ret) { 2384 2384 btrfs_put_dev_args_from_path(args); ··· 2625 2625 if (sb_rdonly(sb) && !fs_devices->seeding) 2626 2626 return -EROFS; 2627 2627 2628 - bdev = blkdev_get_by_path(device_path, FMODE_WRITE, 2628 + bdev = blkdev_get_by_path(device_path, BLK_OPEN_WRITE, 2629 2629 fs_info->bdev_holder, NULL); 2630 2630 if (IS_ERR(bdev)) 2631 2631 return PTR_ERR(bdev); ··· 6907 6907 if (IS_ERR(fs_devices)) 6908 6908 return fs_devices; 6909 6909 6910 - ret = open_fs_devices(fs_devices, FMODE_READ, fs_info->bdev_holder); 6910 + ret = open_fs_devices(fs_devices, BLK_OPEN_READ, fs_info->bdev_holder); 6911 6911 if (ret) { 6912 6912 free_fs_devices(fs_devices); 6913 6913 return ERR_PTR(ret);
+2 -2
fs/btrfs/volumes.h
··· 599 599 u64 type); 600 600 void btrfs_mapping_tree_free(struct extent_map_tree *tree); 601 601 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, 602 - fmode_t flags, void *holder); 603 - struct btrfs_device *btrfs_scan_one_device(const char *path, fmode_t flags); 602 + blk_mode_t flags, void *holder); 603 + struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags); 604 604 int btrfs_forget_devices(dev_t devt); 605 605 void btrfs_close_devices(struct btrfs_fs_devices *fs_devices); 606 606 void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices);
+1 -1
fs/erofs/super.c
··· 254 254 return PTR_ERR(fscache); 255 255 dif->fscache = fscache; 256 256 } else if (!sbi->devs->flatdev) { 257 - bdev = blkdev_get_by_path(dif->path, FMODE_READ, sb->s_type, 257 + bdev = blkdev_get_by_path(dif->path, BLK_OPEN_READ, sb->s_type, 258 258 NULL); 259 259 if (IS_ERR(bdev)) 260 260 return PTR_ERR(bdev);
+1 -1
fs/ext4/super.c
··· 1112 1112 { 1113 1113 struct block_device *bdev; 1114 1114 1115 - bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_WRITE, sb, 1115 + bdev = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE, sb, 1116 1116 &ext4_holder_ops); 1117 1117 if (IS_ERR(bdev)) 1118 1118 goto fail;
+1 -1
fs/f2fs/super.c
··· 3993 3993 struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi); 3994 3994 unsigned int max_devices = MAX_DEVICES; 3995 3995 unsigned int logical_blksize; 3996 - fmode_t mode = sb_open_mode(sbi->sb->s_flags); 3996 + blk_mode_t mode = sb_open_mode(sbi->sb->s_flags); 3997 3997 int i; 3998 3998 3999 3999 /* Initialize single device information */
+1 -1
fs/jfs/jfs_logmgr.c
··· 1100 1100 * file systems to log may have n-to-1 relationship; 1101 1101 */ 1102 1102 1103 - bdev = blkdev_get_by_dev(sbi->logdev, FMODE_READ | FMODE_WRITE, 1103 + bdev = blkdev_get_by_dev(sbi->logdev, BLK_OPEN_READ | BLK_OPEN_WRITE, 1104 1104 log, NULL); 1105 1105 if (IS_ERR(bdev)) { 1106 1106 rc = PTR_ERR(bdev);
+3 -2
fs/nfs/blocklayout/dev.c
··· 243 243 if (!dev) 244 244 return -EIO; 245 245 246 - bdev = blkdev_get_by_dev(dev, FMODE_READ | FMODE_WRITE, NULL, NULL); 246 + bdev = blkdev_get_by_dev(dev, BLK_OPEN_READ | BLK_OPEN_WRITE, NULL, 247 + NULL); 247 248 if (IS_ERR(bdev)) { 248 249 printk(KERN_WARNING "pNFS: failed to open device %d:%d (%ld)\n", 249 250 MAJOR(dev), MINOR(dev), PTR_ERR(bdev)); ··· 313 312 if (!devname) 314 313 return ERR_PTR(-ENOMEM); 315 314 316 - bdev = blkdev_get_by_path(devname, FMODE_READ | FMODE_WRITE, NULL, 315 + bdev = blkdev_get_by_path(devname, BLK_OPEN_READ | BLK_OPEN_WRITE, NULL, 317 316 NULL); 318 317 if (IS_ERR(bdev)) { 319 318 pr_warn("pNFS: failed to open device %s (%ld)\n",
+2 -1
fs/ocfs2/cluster/heartbeat.c
··· 1786 1786 goto out2; 1787 1787 1788 1788 reg->hr_bdev = blkdev_get_by_dev(f.file->f_mapping->host->i_rdev, 1789 - FMODE_WRITE | FMODE_READ, NULL, NULL); 1789 + BLK_OPEN_WRITE | BLK_OPEN_READ, NULL, 1790 + NULL); 1790 1791 if (IS_ERR(reg->hr_bdev)) { 1791 1792 ret = PTR_ERR(reg->hr_bdev); 1792 1793 reg->hr_bdev = NULL;
+2 -2
fs/reiserfs/journal.c
··· 2598 2598 struct reiserfs_journal *journal, 2599 2599 const char *jdev_name) 2600 2600 { 2601 - fmode_t blkdev_mode = FMODE_READ; 2601 + blk_mode_t blkdev_mode = BLK_OPEN_READ; 2602 2602 void *holder = journal; 2603 2603 int result; 2604 2604 dev_t jdev; ··· 2610 2610 new_decode_dev(SB_ONDISK_JOURNAL_DEVICE(super)) : super->s_dev; 2611 2611 2612 2612 if (!bdev_read_only(super->s_bdev)) 2613 - blkdev_mode |= FMODE_WRITE; 2613 + blkdev_mode |= BLK_OPEN_WRITE; 2614 2614 2615 2615 /* there is no "jdev" option and journal is on separate device */ 2616 2616 if ((!jdev_name || !jdev_name[0])) {
+1 -1
fs/xfs/xfs_super.c
··· 396 396 { 397 397 int error = 0; 398 398 399 - *bdevp = blkdev_get_by_path(name, FMODE_READ | FMODE_WRITE, mp, 399 + *bdevp = blkdev_get_by_path(name, BLK_OPEN_READ | BLK_OPEN_WRITE, mp, 400 400 &xfs_holder_ops); 401 401 if (IS_ERR(*bdevp)) { 402 402 error = PTR_ERR(*bdevp);
+23 -7
include/linux/blkdev.h
··· 112 112 unsigned char tag_size; 113 113 }; 114 114 115 + typedef unsigned int __bitwise blk_mode_t; 116 + 117 + /* open for reading */ 118 + #define BLK_OPEN_READ ((__force blk_mode_t)(1 << 0)) 119 + /* open for writing */ 120 + #define BLK_OPEN_WRITE ((__force blk_mode_t)(1 << 1)) 121 + /* open exclusively (vs other exclusive openers */ 122 + #define BLK_OPEN_EXCL ((__force blk_mode_t)(1 << 2)) 123 + /* opened with O_NDELAY */ 124 + #define BLK_OPEN_NDELAY ((__force blk_mode_t)(1 << 3)) 125 + /* open for "writes" only for ioctls (specialy hack for floppy.c) */ 126 + #define BLK_OPEN_WRITE_IOCTL ((__force blk_mode_t)(1 << 4)) 127 + 115 128 struct gendisk { 116 129 /* 117 130 * major/first_minor/minors should not be set by any new driver, the ··· 200 187 struct badblocks *bb; 201 188 struct lockdep_map lockdep_map; 202 189 u64 diskseq; 190 + blk_mode_t open_mode; 203 191 204 192 /* 205 193 * Independent sector access ranges. This is always NULL for ··· 1377 1363 void (*submit_bio)(struct bio *bio); 1378 1364 int (*poll_bio)(struct bio *bio, struct io_comp_batch *iob, 1379 1365 unsigned int flags); 1380 - int (*open)(struct gendisk *disk, fmode_t mode); 1366 + int (*open)(struct gendisk *disk, blk_mode_t mode); 1381 1367 void (*release)(struct gendisk *disk); 1382 - int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); 1383 - int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long); 1368 + int (*ioctl)(struct block_device *bdev, blk_mode_t mode, 1369 + unsigned cmd, unsigned long arg); 1370 + int (*compat_ioctl)(struct block_device *bdev, blk_mode_t mode, 1371 + unsigned cmd, unsigned long arg); 1384 1372 unsigned int (*check_events) (struct gendisk *disk, 1385 1373 unsigned int clearing); 1386 1374 void (*unlock_native_capacity) (struct gendisk *); ··· 1409 1393 }; 1410 1394 1411 1395 #ifdef CONFIG_COMPAT 1412 - extern int blkdev_compat_ptr_ioctl(struct block_device *, fmode_t, 1396 + extern int blkdev_compat_ptr_ioctl(struct block_device *, blk_mode_t, 1413 1397 unsigned int, unsigned long); 1414 1398 #else 1415 1399 #define blkdev_compat_ptr_ioctl NULL ··· 1471 1455 * as stored in sb->s_flags. 1472 1456 */ 1473 1457 #define sb_open_mode(flags) \ 1474 - (FMODE_READ | (((flags) & SB_RDONLY) ? 0 : FMODE_WRITE)) 1458 + (BLK_OPEN_READ | (((flags) & SB_RDONLY) ? 0 : BLK_OPEN_WRITE)) 1475 1459 1476 - struct block_device *blkdev_get_by_dev(dev_t dev, fmode_t mode, void *holder, 1460 + struct block_device *blkdev_get_by_dev(dev_t dev, blk_mode_t mode, void *holder, 1477 1461 const struct blk_holder_ops *hops); 1478 - struct block_device *blkdev_get_by_path(const char *path, fmode_t mode, 1462 + struct block_device *blkdev_get_by_path(const char *path, blk_mode_t mode, 1479 1463 void *holder, const struct blk_holder_ops *hops); 1480 1464 int bd_prepare_to_claim(struct block_device *bdev, void *holder, 1481 1465 const struct blk_holder_ops *hops);
+2 -1
include/linux/cdrom.h
··· 13 13 14 14 #include <linux/fs.h> /* not really needed, later.. */ 15 15 #include <linux/list.h> 16 + #include <linux/blkdev.h> 16 17 #include <scsi/scsi_common.h> 17 18 #include <uapi/linux/cdrom.h> 18 19 ··· 102 101 struct cdrom_tocentry *entry); 103 102 104 103 /* the general block_device operations structure: */ 105 - int cdrom_open(struct cdrom_device_info *cdi, fmode_t mode); 104 + int cdrom_open(struct cdrom_device_info *cdi, blk_mode_t mode); 106 105 void cdrom_release(struct cdrom_device_info *cdi); 107 106 int cdrom_ioctl(struct cdrom_device_info *cdi, struct block_device *bdev, 108 107 unsigned int cmd, unsigned long arg);
+4 -4
include/linux/device-mapper.h
··· 166 166 struct dm_dev { 167 167 struct block_device *bdev; 168 168 struct dax_device *dax_dev; 169 - fmode_t mode; 169 + blk_mode_t mode; 170 170 char name[16]; 171 171 }; 172 172 ··· 174 174 * Constructors should call these functions to ensure destination devices 175 175 * are opened/closed correctly. 176 176 */ 177 - int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, 177 + int dm_get_device(struct dm_target *ti, const char *path, blk_mode_t mode, 178 178 struct dm_dev **result); 179 179 void dm_put_device(struct dm_target *ti, struct dm_dev *d); 180 180 ··· 543 543 /* 544 544 * First create an empty table. 545 545 */ 546 - int dm_table_create(struct dm_table **result, fmode_t mode, 546 + int dm_table_create(struct dm_table **result, blk_mode_t mode, 547 547 unsigned int num_targets, struct mapped_device *md); 548 548 549 549 /* ··· 586 586 * Queries 587 587 */ 588 588 sector_t dm_table_get_size(struct dm_table *t); 589 - fmode_t dm_table_get_mode(struct dm_table *t); 589 + blk_mode_t dm_table_get_mode(struct dm_table *t); 590 590 struct mapped_device *dm_table_get_md(struct dm_table *t); 591 591 const char *dm_table_device_name(struct dm_table *t); 592 592
+3 -3
kernel/power/swap.c
··· 356 356 return res; 357 357 root_swap = res; 358 358 359 - hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, FMODE_WRITE, 360 - NULL, NULL); 359 + hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, 360 + BLK_OPEN_WRITE, NULL, NULL); 361 361 if (IS_ERR(hib_resume_bdev)) 362 362 return PTR_ERR(hib_resume_bdev); 363 363 ··· 1521 1521 void *holder = snapshot_test ? &swsusp_holder : NULL; 1522 1522 int error; 1523 1523 1524 - hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, FMODE_READ, 1524 + hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ, 1525 1525 holder, NULL); 1526 1526 if (!IS_ERR(hib_resume_bdev)) { 1527 1527 set_blocksize(hib_resume_bdev, PAGE_SIZE);
+1 -1
mm/swapfile.c
··· 2770 2770 2771 2771 if (S_ISBLK(inode->i_mode)) { 2772 2772 p->bdev = blkdev_get_by_dev(inode->i_rdev, 2773 - FMODE_READ | FMODE_WRITE, p, NULL); 2773 + BLK_OPEN_READ | BLK_OPEN_WRITE, p, NULL); 2774 2774 if (IS_ERR(p->bdev)) { 2775 2775 error = PTR_ERR(p->bdev); 2776 2776 p->bdev = NULL;