aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-11-21 10:38:32 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-21 10:38:32 -0500
commitadb072d3cd03dbdabdc3492488f67050b0fb4fd5 (patch)
treec7df6a809ea7b426489d6a8c58926fc470c2c02b /drivers
parent11ca75d2d6d18d5a7ee4d7ec1da6f864f5c8c8be (diff)
parent3cfa3b16dd2f1787f9d19d6da2fe9652d806b387 (diff)
Merge tag 'ceph-for-4.15-rc1' of git://github.com/ceph/ceph-client
Pull ceph updates from Ilya Dryomov: "We have a set of file locking improvements from Zheng, rbd rw/ro state handling code cleanup from myself and some assorted CephFS fixes from Jeff. rbd now defaults to single-major=Y, lifting the limit of ~240 rbd images per host for everyone" * tag 'ceph-for-4.15-rc1' of git://github.com/ceph/ceph-client: rbd: default to single-major device number scheme libceph: don't WARN() if user tries to add invalid key rbd: set discard_alignment to zero ceph: silence sparse endianness warning in encode_caps_cb ceph: remove the bump of i_version ceph: present consistent fsid, regardless of arch endianness ceph: clean up spinlocking and list handling around cleanup_cap_releases() rbd: get rid of rbd_mapping::read_only rbd: fix and simplify rbd_ioctl_set_ro() ceph: remove unused and redundant variable dropping ceph: mark expected switch fall-throughs ceph: -EINVAL on decoding failure in ceph_mdsc_handle_fsmap() ceph: disable cached readdir after dropping positive dentry ceph: fix bool initialization/comparison ceph: handle 'session get evicted while there are file locks' ceph: optimize flock encoding during reconnect ceph: make lock_to_ceph_filelock() static ceph: keep auth cap when inode has flocks or posix locks
Diffstat (limited to 'drivers')
-rw-r--r--drivers/block/rbd.c65
1 files changed, 13 insertions, 52 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index adc877dfef5c..38fc5f397fde 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -348,7 +348,6 @@ struct rbd_client_id {
348struct rbd_mapping { 348struct rbd_mapping {
349 u64 size; 349 u64 size;
350 u64 features; 350 u64 features;
351 bool read_only;
352}; 351};
353 352
354/* 353/*
@@ -450,12 +449,11 @@ static DEFINE_IDA(rbd_dev_id_ida);
450static struct workqueue_struct *rbd_wq; 449static struct workqueue_struct *rbd_wq;
451 450
452/* 451/*
453 * Default to false for now, as single-major requires >= 0.75 version of 452 * single-major requires >= 0.75 version of userspace rbd utility.
454 * userspace rbd utility.
455 */ 453 */
456static bool single_major = false; 454static bool single_major = true;
457module_param(single_major, bool, S_IRUGO); 455module_param(single_major, bool, S_IRUGO);
458MODULE_PARM_DESC(single_major, "Use a single major number for all rbd devices (default: false)"); 456MODULE_PARM_DESC(single_major, "Use a single major number for all rbd devices (default: true)");
459 457
460static int rbd_img_request_submit(struct rbd_img_request *img_request); 458static int rbd_img_request_submit(struct rbd_img_request *img_request);
461 459
@@ -608,9 +606,6 @@ static int rbd_open(struct block_device *bdev, fmode_t mode)
608 struct rbd_device *rbd_dev = bdev->bd_disk->private_data; 606 struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
609 bool removing = false; 607 bool removing = false;
610 608
611 if ((mode & FMODE_WRITE) && rbd_dev->mapping.read_only)
612 return -EROFS;
613
614 spin_lock_irq(&rbd_dev->lock); 609 spin_lock_irq(&rbd_dev->lock);
615 if (test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags)) 610 if (test_bit(RBD_DEV_FLAG_REMOVING, &rbd_dev->flags))
616 removing = true; 611 removing = true;
@@ -640,46 +635,24 @@ static void rbd_release(struct gendisk *disk, fmode_t mode)
640 635
641static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg) 636static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg)
642{ 637{
643 int ret = 0; 638 int ro;
644 int val;
645 bool ro;
646 bool ro_changed = false;
647 639
648 /* get_user() may sleep, so call it before taking rbd_dev->lock */ 640 if (get_user(ro, (int __user *)arg))
649 if (get_user(val, (int __user *)(arg)))
650 return -EFAULT; 641 return -EFAULT;
651 642
652 ro = val ? true : false; 643 /* Snapshots can't be marked read-write */
653 /* Snapshot doesn't allow to write*/
654 if (rbd_dev->spec->snap_id != CEPH_NOSNAP && !ro) 644 if (rbd_dev->spec->snap_id != CEPH_NOSNAP && !ro)
655 return -EROFS; 645 return -EROFS;
656 646
657 spin_lock_irq(&rbd_dev->lock); 647 /* Let blkdev_roset() handle it */
658 /* prevent others open this device */ 648 return -ENOTTY;
659 if (rbd_dev->open_count > 1) {
660 ret = -EBUSY;
661 goto out;
662 }
663
664 if (rbd_dev->mapping.read_only != ro) {
665 rbd_dev->mapping.read_only = ro;
666 ro_changed = true;
667 }
668
669out:
670 spin_unlock_irq(&rbd_dev->lock);
671 /* set_disk_ro() may sleep, so call it after releasing rbd_dev->lock */
672 if (ret == 0 && ro_changed)
673 set_disk_ro(rbd_dev->disk, ro ? 1 : 0);
674
675 return ret;
676} 649}
677 650
678static int rbd_ioctl(struct block_device *bdev, fmode_t mode, 651static int rbd_ioctl(struct block_device *bdev, fmode_t mode,
679 unsigned int cmd, unsigned long arg) 652 unsigned int cmd, unsigned long arg)
680{ 653{
681 struct rbd_device *rbd_dev = bdev->bd_disk->private_data; 654 struct rbd_device *rbd_dev = bdev->bd_disk->private_data;
682 int ret = 0; 655 int ret;
683 656
684 switch (cmd) { 657 switch (cmd) {
685 case BLKROSET: 658 case BLKROSET:
@@ -4050,15 +4023,8 @@ static void rbd_queue_workfn(struct work_struct *work)
4050 goto err_rq; 4023 goto err_rq;
4051 } 4024 }
4052 4025
4053 /* Only reads are allowed to a read-only device */ 4026 rbd_assert(op_type == OBJ_OP_READ ||
4054 4027 rbd_dev->spec->snap_id == CEPH_NOSNAP);
4055 if (op_type != OBJ_OP_READ) {
4056 if (rbd_dev->mapping.read_only) {
4057 result = -EROFS;
4058 goto err_rq;
4059 }
4060 rbd_assert(rbd_dev->spec->snap_id == CEPH_NOSNAP);
4061 }
4062 4028
4063 /* 4029 /*
4064 * Quit early if the mapped snapshot no longer exists. It's 4030 * Quit early if the mapped snapshot no longer exists. It's
@@ -4423,7 +4389,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
4423 /* enable the discard support */ 4389 /* enable the discard support */
4424 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 4390 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q);
4425 q->limits.discard_granularity = segment_size; 4391 q->limits.discard_granularity = segment_size;
4426 q->limits.discard_alignment = segment_size;
4427 blk_queue_max_discard_sectors(q, segment_size / SECTOR_SIZE); 4392 blk_queue_max_discard_sectors(q, segment_size / SECTOR_SIZE);
4428 blk_queue_max_write_zeroes_sectors(q, segment_size / SECTOR_SIZE); 4393 blk_queue_max_write_zeroes_sectors(q, segment_size / SECTOR_SIZE);
4429 4394
@@ -5994,7 +5959,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
5994 goto err_out_disk; 5959 goto err_out_disk;
5995 5960
5996 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE); 5961 set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
5997 set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only); 5962 set_disk_ro(rbd_dev->disk, rbd_dev->opts->read_only);
5998 5963
5999 ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id); 5964 ret = dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id);
6000 if (ret) 5965 if (ret)
@@ -6145,7 +6110,6 @@ static ssize_t do_rbd_add(struct bus_type *bus,
6145 struct rbd_options *rbd_opts = NULL; 6110 struct rbd_options *rbd_opts = NULL;
6146 struct rbd_spec *spec = NULL; 6111 struct rbd_spec *spec = NULL;
6147 struct rbd_client *rbdc; 6112 struct rbd_client *rbdc;
6148 bool read_only;
6149 int rc; 6113 int rc;
6150 6114
6151 if (!try_module_get(THIS_MODULE)) 6115 if (!try_module_get(THIS_MODULE))
@@ -6194,11 +6158,8 @@ static ssize_t do_rbd_add(struct bus_type *bus,
6194 } 6158 }
6195 6159
6196 /* If we are mapping a snapshot it must be marked read-only */ 6160 /* If we are mapping a snapshot it must be marked read-only */
6197
6198 read_only = rbd_dev->opts->read_only;
6199 if (rbd_dev->spec->snap_id != CEPH_NOSNAP) 6161 if (rbd_dev->spec->snap_id != CEPH_NOSNAP)
6200 read_only = true; 6162 rbd_dev->opts->read_only = true;
6201 rbd_dev->mapping.read_only = read_only;
6202 6163
6203 rc = rbd_dev_device_setup(rbd_dev); 6164 rc = rbd_dev_device_setup(rbd_dev);
6204 if (rc) 6165 if (rc)