Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> |
| 3 | * Horst Hummel <Horst.Hummel@de.ibm.com> |
| 4 | * Carsten Otte <Cotte@de.ibm.com> |
| 5 | * Martin Schwidefsky <schwidefsky@de.ibm.com> |
| 6 | * Bugreports.to..: <Linux390@de.ibm.com> |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 7 | * Copyright IBM Corp. 1999, 2001 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 8 | * |
| 9 | * i/o controls for the dasd driver. |
| 10 | */ |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 11 | |
| 12 | #define KMSG_COMPONENT "dasd" |
| 13 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <linux/interrupt.h> |
Heiko Carstens | 048cd4e | 2012-02-27 10:01:52 +0100 | [diff] [blame] | 15 | #include <linux/compat.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <linux/major.h> |
| 17 | #include <linux/fs.h> |
| 18 | #include <linux/blkpg.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 19 | #include <linux/slab.h> |
Heiko Carstens | 8803486 | 2010-01-13 20:44:29 +0100 | [diff] [blame] | 20 | #include <asm/compat.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <asm/ccwdev.h> |
Sebastian Ott | 287a093 | 2012-10-29 16:50:20 +0100 | [diff] [blame] | 22 | #include <asm/schid.h> |
Christoph Hellwig | 8b2eb66 | 2006-03-24 03:15:21 -0800 | [diff] [blame] | 23 | #include <asm/cmb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include <asm/uaccess.h> |
| 25 | |
| 26 | /* This is ugly... */ |
| 27 | #define PRINTK_HEADER "dasd_ioctl:" |
| 28 | |
| 29 | #include "dasd_int.h" |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | static int |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 33 | dasd_ioctl_api_version(void __user *argp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | { |
| 35 | int ver = DASD_API_VERSION; |
Bastian Blank | b502962 | 2006-03-24 03:15:32 -0800 | [diff] [blame] | 36 | return put_user(ver, (int __user *)argp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | /* |
| 40 | * Enable device. |
| 41 | * used by dasdfmt after BIODASDDISABLE to retrigger blocksize detection |
| 42 | */ |
| 43 | static int |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 44 | dasd_ioctl_enable(struct block_device *bdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | { |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 46 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
| 48 | if (!capable(CAP_SYS_ADMIN)) |
| 49 | return -EACCES; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 50 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 51 | base = dasd_device_from_gendisk(bdev->bd_disk); |
| 52 | if (!base) |
| 53 | return -ENODEV; |
| 54 | |
| 55 | dasd_enable_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | /* Formatting the dasd device can change the capacity. */ |
Arjan van de Ven | c039e31 | 2006-03-23 03:00:28 -0800 | [diff] [blame] | 57 | mutex_lock(&bdev->bd_mutex); |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 58 | i_size_write(bdev->bd_inode, |
| 59 | (loff_t)get_capacity(base->block->gdp) << 9); |
Arjan van de Ven | c039e31 | 2006-03-23 03:00:28 -0800 | [diff] [blame] | 60 | mutex_unlock(&bdev->bd_mutex); |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 61 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | return 0; |
| 63 | } |
| 64 | |
| 65 | /* |
| 66 | * Disable device. |
| 67 | * Used by dasdfmt. Disable I/O operations but allow ioctls. |
| 68 | */ |
| 69 | static int |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 70 | dasd_ioctl_disable(struct block_device *bdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 72 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | |
| 74 | if (!capable(CAP_SYS_ADMIN)) |
| 75 | return -EACCES; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 76 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 77 | base = dasd_device_from_gendisk(bdev->bd_disk); |
| 78 | if (!base) |
| 79 | return -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | /* |
| 81 | * Man this is sick. We don't do a real disable but only downgrade |
| 82 | * the device to DASD_STATE_BASIC. The reason is that dasdfmt uses |
| 83 | * BIODASDDISABLE to disable accesses to the device via the block |
| 84 | * device layer but it still wants to do i/o on the device by |
| 85 | * using the BIODASDFMT ioctl. Therefore the correct state for the |
| 86 | * device is DASD_STATE_BASIC that allows to do basic i/o. |
| 87 | */ |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 88 | dasd_set_target_state(base, DASD_STATE_BASIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | /* |
| 90 | * Set i_size to zero, since read, write, etc. check against this |
| 91 | * value. |
| 92 | */ |
Arjan van de Ven | c039e31 | 2006-03-23 03:00:28 -0800 | [diff] [blame] | 93 | mutex_lock(&bdev->bd_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | i_size_write(bdev->bd_inode, 0); |
Arjan van de Ven | c039e31 | 2006-03-23 03:00:28 -0800 | [diff] [blame] | 95 | mutex_unlock(&bdev->bd_mutex); |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 96 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | /* |
| 101 | * Quiesce device. |
| 102 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 103 | static int dasd_ioctl_quiesce(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | unsigned long flags; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 106 | struct dasd_device *base; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 107 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 108 | base = block->base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | if (!capable (CAP_SYS_ADMIN)) |
| 110 | return -EACCES; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 111 | |
Stefan Haberland | ca99dab | 2009-09-11 10:28:30 +0200 | [diff] [blame] | 112 | pr_info("%s: The DASD has been put in the quiesce " |
| 113 | "state\n", dev_name(&base->cdev->dev)); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 114 | spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 115 | dasd_device_set_stop_bits(base, DASD_STOPPED_QUIESCE); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 116 | spin_unlock_irqrestore(get_ccwdev_lock(base->cdev), flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | return 0; |
| 118 | } |
| 119 | |
| 120 | |
| 121 | /* |
Stefan Haberland | fc19f38 | 2009-03-26 15:23:49 +0100 | [diff] [blame] | 122 | * Resume device. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 124 | static int dasd_ioctl_resume(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | unsigned long flags; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 127 | struct dasd_device *base; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 128 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 129 | base = block->base; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 130 | if (!capable (CAP_SYS_ADMIN)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | return -EACCES; |
| 132 | |
Stefan Haberland | ca99dab | 2009-09-11 10:28:30 +0200 | [diff] [blame] | 133 | pr_info("%s: I/O operations have been resumed " |
| 134 | "on the DASD\n", dev_name(&base->cdev->dev)); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 135 | spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags); |
Stefan Weinhuber | eb6e199 | 2009-12-07 12:51:51 +0100 | [diff] [blame] | 136 | dasd_device_remove_stop_bits(base, DASD_STOPPED_QUIESCE); |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 137 | spin_unlock_irqrestore(get_ccwdev_lock(base->cdev), flags); |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 138 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 139 | dasd_schedule_block_bh(block); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | /* |
Hannes Reinecke | 5ea34a0 | 2013-01-30 09:26:19 +0000 | [diff] [blame] | 144 | * Abort all failfast I/O on a device. |
| 145 | */ |
| 146 | static int dasd_ioctl_abortio(struct dasd_block *block) |
| 147 | { |
| 148 | unsigned long flags; |
| 149 | struct dasd_device *base; |
| 150 | struct dasd_ccw_req *cqr, *n; |
| 151 | |
| 152 | base = block->base; |
| 153 | if (!capable(CAP_SYS_ADMIN)) |
| 154 | return -EACCES; |
| 155 | |
| 156 | if (test_and_set_bit(DASD_FLAG_ABORTALL, &base->flags)) |
| 157 | return 0; |
| 158 | DBF_DEV_EVENT(DBF_NOTICE, base, "%s", "abortall flag set"); |
| 159 | |
| 160 | spin_lock_irqsave(&block->request_queue_lock, flags); |
| 161 | spin_lock(&block->queue_lock); |
| 162 | list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) { |
| 163 | if (test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) && |
| 164 | cqr->callback_data && |
| 165 | cqr->callback_data != DASD_SLEEPON_START_TAG && |
| 166 | cqr->callback_data != DASD_SLEEPON_END_TAG) { |
| 167 | spin_unlock(&block->queue_lock); |
| 168 | blk_abort_request(cqr->callback_data); |
| 169 | spin_lock(&block->queue_lock); |
| 170 | } |
| 171 | } |
| 172 | spin_unlock(&block->queue_lock); |
| 173 | spin_unlock_irqrestore(&block->request_queue_lock, flags); |
| 174 | |
| 175 | dasd_schedule_block_bh(block); |
| 176 | return 0; |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | * Allow I/O on a device |
| 181 | */ |
| 182 | static int dasd_ioctl_allowio(struct dasd_block *block) |
| 183 | { |
| 184 | struct dasd_device *base; |
| 185 | |
| 186 | base = block->base; |
| 187 | if (!capable(CAP_SYS_ADMIN)) |
| 188 | return -EACCES; |
| 189 | |
| 190 | if (test_and_clear_bit(DASD_FLAG_ABORTALL, &base->flags)) |
| 191 | DBF_DEV_EVENT(DBF_NOTICE, base, "%s", "abortall flag unset"); |
| 192 | |
| 193 | return 0; |
| 194 | } |
| 195 | |
| 196 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | * performs formatting of _device_ according to _fdata_ |
| 198 | * Note: The discipline's format_function is assumed to deliver formatting |
Stefan Haberland | d42e171 | 2013-04-15 16:22:23 +0200 | [diff] [blame] | 199 | * commands to format multiple units of the device. In terms of the ECKD |
| 200 | * devices this means CCWs are generated to format multiple tracks. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | */ |
Stefan Haberland | d42e171 | 2013-04-15 16:22:23 +0200 | [diff] [blame] | 202 | static int |
| 203 | dasd_format(struct dasd_block *block, struct format_data_t *fdata) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 205 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | int rc; |
| 207 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 208 | base = block->base; |
| 209 | if (base->discipline->format_device == NULL) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | return -EPERM; |
| 211 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 212 | if (base->state != DASD_STATE_BASIC) { |
Stefan Haberland | d42e171 | 2013-04-15 16:22:23 +0200 | [diff] [blame] | 213 | pr_warn("%s: The DASD cannot be formatted while it is enabled\n", |
| 214 | dev_name(&base->cdev->dev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | return -EBUSY; |
| 216 | } |
| 217 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 218 | DBF_DEV_EVENT(DBF_NOTICE, base, |
Stefan Weinhuber | b44b0ab3 | 2009-03-26 15:23:47 +0100 | [diff] [blame] | 219 | "formatting units %u to %u (%u B blocks) flags %u", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | fdata->start_unit, |
| 221 | fdata->stop_unit, fdata->blksize, fdata->intensity); |
| 222 | |
| 223 | /* Since dasdfmt keeps the device open after it was disabled, |
| 224 | * there still exists an inode for this device. |
| 225 | * We must update i_blkbits, otherwise we might get errors when |
| 226 | * enabling the device later. |
| 227 | */ |
| 228 | if (fdata->start_unit == 0) { |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 229 | struct block_device *bdev = bdget_disk(block->gdp, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | bdev->bd_inode->i_blkbits = blksize_bits(fdata->blksize); |
| 231 | bdput(bdev); |
| 232 | } |
| 233 | |
Stefan Haberland | d42e171 | 2013-04-15 16:22:23 +0200 | [diff] [blame] | 234 | rc = base->discipline->format_device(base, fdata); |
| 235 | if (rc) |
| 236 | return rc; |
| 237 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | /* |
| 242 | * Format device. |
| 243 | */ |
| 244 | static int |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 245 | dasd_ioctl_format(struct block_device *bdev, void __user *argp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | { |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 247 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | struct format_data_t fdata; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 249 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
| 251 | if (!capable(CAP_SYS_ADMIN)) |
| 252 | return -EACCES; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 253 | if (!argp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | return -EINVAL; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 255 | base = dasd_device_from_gendisk(bdev->bd_disk); |
| 256 | if (!base) |
| 257 | return -ENODEV; |
| 258 | if (base->features & DASD_FEATURE_READONLY || |
| 259 | test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) { |
| 260 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | return -EROFS; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 262 | } |
| 263 | if (copy_from_user(&fdata, argp, sizeof(struct format_data_t))) { |
| 264 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | return -EFAULT; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 266 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | if (bdev != bdev->bd_contains) { |
Stefan Haberland | ca99dab | 2009-09-11 10:28:30 +0200 | [diff] [blame] | 268 | pr_warning("%s: The specified DASD is a partition and cannot " |
| 269 | "be formatted\n", |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 270 | dev_name(&base->cdev->dev)); |
| 271 | dasd_put_device(base); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | return -EINVAL; |
| 273 | } |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 274 | rc = dasd_format(base->block, &fdata); |
| 275 | dasd_put_device(base); |
| 276 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | #ifdef CONFIG_DASD_PROFILE |
| 280 | /* |
| 281 | * Reset device profile information |
| 282 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 283 | static int dasd_ioctl_reset_profile(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | { |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 285 | dasd_profile_reset(&block->profile); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | return 0; |
| 287 | } |
| 288 | |
| 289 | /* |
| 290 | * Return device profile information |
| 291 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 292 | static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | { |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 294 | struct dasd_profile_info_t *data; |
Julia Lawall | ba465d8 | 2011-08-24 17:15:10 +0200 | [diff] [blame] | 295 | int rc = 0; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 296 | |
| 297 | data = kmalloc(sizeof(*data), GFP_KERNEL); |
| 298 | if (!data) |
| 299 | return -ENOMEM; |
| 300 | |
| 301 | spin_lock_bh(&block->profile.lock); |
| 302 | if (block->profile.data) { |
| 303 | data->dasd_io_reqs = block->profile.data->dasd_io_reqs; |
| 304 | data->dasd_io_sects = block->profile.data->dasd_io_sects; |
| 305 | memcpy(data->dasd_io_secs, block->profile.data->dasd_io_secs, |
| 306 | sizeof(data->dasd_io_secs)); |
| 307 | memcpy(data->dasd_io_times, block->profile.data->dasd_io_times, |
| 308 | sizeof(data->dasd_io_times)); |
| 309 | memcpy(data->dasd_io_timps, block->profile.data->dasd_io_timps, |
| 310 | sizeof(data->dasd_io_timps)); |
| 311 | memcpy(data->dasd_io_time1, block->profile.data->dasd_io_time1, |
| 312 | sizeof(data->dasd_io_time1)); |
| 313 | memcpy(data->dasd_io_time2, block->profile.data->dasd_io_time2, |
| 314 | sizeof(data->dasd_io_time2)); |
| 315 | memcpy(data->dasd_io_time2ps, |
| 316 | block->profile.data->dasd_io_time2ps, |
| 317 | sizeof(data->dasd_io_time2ps)); |
| 318 | memcpy(data->dasd_io_time3, block->profile.data->dasd_io_time3, |
| 319 | sizeof(data->dasd_io_time3)); |
| 320 | memcpy(data->dasd_io_nr_req, |
| 321 | block->profile.data->dasd_io_nr_req, |
| 322 | sizeof(data->dasd_io_nr_req)); |
| 323 | spin_unlock_bh(&block->profile.lock); |
| 324 | } else { |
| 325 | spin_unlock_bh(&block->profile.lock); |
Julia Lawall | ba465d8 | 2011-08-24 17:15:10 +0200 | [diff] [blame] | 326 | rc = -EIO; |
| 327 | goto out; |
Stefan Weinhuber | 4fa52aa | 2011-07-24 10:48:32 +0200 | [diff] [blame] | 328 | } |
| 329 | if (copy_to_user(argp, data, sizeof(*data))) |
Julia Lawall | ba465d8 | 2011-08-24 17:15:10 +0200 | [diff] [blame] | 330 | rc = -EFAULT; |
| 331 | out: |
| 332 | kfree(data); |
| 333 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
| 335 | #else |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 336 | static int dasd_ioctl_reset_profile(struct dasd_block *block) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | { |
Heiko Carstens | 2267a0c | 2012-09-06 14:47:30 +0200 | [diff] [blame] | 338 | return -ENOTTY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | } |
| 340 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 341 | static int dasd_ioctl_read_profile(struct dasd_block *block, void __user *argp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | { |
Heiko Carstens | 2267a0c | 2012-09-06 14:47:30 +0200 | [diff] [blame] | 343 | return -ENOTTY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 344 | } |
| 345 | #endif |
| 346 | |
| 347 | /* |
| 348 | * Return dasd information. Used for BIODASDINFO and BIODASDINFO2. |
| 349 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 350 | static int dasd_ioctl_information(struct dasd_block *block, |
| 351 | unsigned int cmd, void __user *argp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | struct dasd_information2_t *dasd_info; |
Sebastian Ott | 287a093 | 2012-10-29 16:50:20 +0100 | [diff] [blame] | 354 | struct subchannel_id sch_id; |
| 355 | struct ccw_dev_id dev_id; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 356 | struct dasd_device *base; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | struct ccw_device *cdev; |
Sebastian Ott | 287a093 | 2012-10-29 16:50:20 +0100 | [diff] [blame] | 358 | unsigned long flags; |
| 359 | int rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 361 | base = block->base; |
Stefan Haberland | 294001a | 2010-01-27 10:12:35 +0100 | [diff] [blame] | 362 | if (!base->discipline || !base->discipline->fill_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | return -EINVAL; |
| 364 | |
Horst Hummel | 554a826 | 2006-03-24 03:15:24 -0800 | [diff] [blame] | 365 | dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | if (dasd_info == NULL) |
| 367 | return -ENOMEM; |
| 368 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 369 | rc = base->discipline->fill_info(base, dasd_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | if (rc) { |
| 371 | kfree(dasd_info); |
| 372 | return rc; |
| 373 | } |
| 374 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 375 | cdev = base->cdev; |
Cornelia Huck | 9a92fe4 | 2007-05-10 15:45:42 +0200 | [diff] [blame] | 376 | ccw_device_get_id(cdev, &dev_id); |
Sebastian Ott | 287a093 | 2012-10-29 16:50:20 +0100 | [diff] [blame] | 377 | ccw_device_get_schid(cdev, &sch_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
Cornelia Huck | 9a92fe4 | 2007-05-10 15:45:42 +0200 | [diff] [blame] | 379 | dasd_info->devno = dev_id.devno; |
Sebastian Ott | 287a093 | 2012-10-29 16:50:20 +0100 | [diff] [blame] | 380 | dasd_info->schid = sch_id.sch_no; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | dasd_info->cu_type = cdev->id.cu_type; |
| 382 | dasd_info->cu_model = cdev->id.cu_model; |
| 383 | dasd_info->dev_type = cdev->id.dev_type; |
| 384 | dasd_info->dev_model = cdev->id.dev_model; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 385 | dasd_info->status = base->state; |
Horst Hummel | 5746719 | 2006-02-01 03:06:36 -0800 | [diff] [blame] | 386 | /* |
| 387 | * The open_count is increased for every opener, that includes |
| 388 | * the blkdev_get in dasd_scan_partitions. |
| 389 | * This must be hidden from user-space. |
| 390 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 391 | dasd_info->open_count = atomic_read(&block->open_count); |
| 392 | if (!block->bdev) |
Horst Hummel | 5746719 | 2006-02-01 03:06:36 -0800 | [diff] [blame] | 393 | dasd_info->open_count++; |
Horst Hummel | 138c014 | 2006-06-29 14:58:12 +0200 | [diff] [blame] | 394 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | /* |
| 396 | * check if device is really formatted |
| 397 | * LDL / CDL was returned by 'fill_info' |
| 398 | */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 399 | if ((base->state < DASD_STATE_READY) || |
| 400 | (dasd_check_blocksize(block->bp_block))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 401 | dasd_info->format = DASD_FORMAT_NONE; |
Horst Hummel | f24acd4 | 2005-05-01 08:58:59 -0700 | [diff] [blame] | 402 | |
Horst Hummel | c6eb7b7 | 2005-09-03 15:57:58 -0700 | [diff] [blame] | 403 | dasd_info->features |= |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 404 | ((base->features & DASD_FEATURE_READONLY) != 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | |
Stefan Haberland | 294001a | 2010-01-27 10:12:35 +0100 | [diff] [blame] | 406 | memcpy(dasd_info->type, base->discipline->name, 4); |
Horst Hummel | 554a826 | 2006-03-24 03:15:24 -0800 | [diff] [blame] | 407 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 408 | if (block->request_queue->request_fn) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | struct list_head *l; |
| 410 | #ifdef DASD_EXTENDED_PROFILING |
| 411 | { |
| 412 | struct list_head *l; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 413 | spin_lock_irqsave(&block->lock, flags); |
| 414 | list_for_each(l, &block->request_queue->queue_head) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | dasd_info->req_queue_len++; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 416 | spin_unlock_irqrestore(&block->lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | } |
| 418 | #endif /* DASD_EXTENDED_PROFILING */ |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 419 | spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags); |
| 420 | list_for_each(l, &base->ccw_queue) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | dasd_info->chanq_len++; |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 422 | spin_unlock_irqrestore(get_ccwdev_lock(base->cdev), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | flags); |
| 424 | } |
| 425 | |
| 426 | rc = 0; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 427 | if (copy_to_user(argp, dasd_info, |
| 428 | ((cmd == (unsigned int) BIODASDINFO2) ? |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 429 | sizeof(struct dasd_information2_t) : |
| 430 | sizeof(struct dasd_information_t)))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | rc = -EFAULT; |
| 432 | kfree(dasd_info); |
| 433 | return rc; |
| 434 | } |
| 435 | |
| 436 | /* |
| 437 | * Set read only |
| 438 | */ |
| 439 | static int |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 440 | dasd_ioctl_set_ro(struct block_device *bdev, void __user *argp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | { |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 442 | struct dasd_device *base; |
| 443 | int intval, rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | |
| 445 | if (!capable(CAP_SYS_ADMIN)) |
| 446 | return -EACCES; |
| 447 | if (bdev != bdev->bd_contains) |
| 448 | // ro setting is not allowed for partitions |
| 449 | return -EINVAL; |
Heiko Carstens | d2c993d | 2006-07-12 16:41:55 +0200 | [diff] [blame] | 450 | if (get_user(intval, (int __user *)argp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 | return -EFAULT; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 452 | base = dasd_device_from_gendisk(bdev->bd_disk); |
| 453 | if (!base) |
| 454 | return -ENODEV; |
| 455 | if (!intval && test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) { |
| 456 | dasd_put_device(base); |
Stefan Weinhuber | 33b62a3 | 2010-03-08 12:26:24 +0100 | [diff] [blame] | 457 | return -EROFS; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 458 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | set_disk_ro(bdev->bd_disk, intval); |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 460 | rc = dasd_set_feature(base->cdev, DASD_FEATURE_READONLY, intval); |
| 461 | dasd_put_device(base); |
| 462 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | } |
| 464 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 465 | static int dasd_ioctl_readall_cmb(struct dasd_block *block, unsigned int cmd, |
Heiko Carstens | 8803486 | 2010-01-13 20:44:29 +0100 | [diff] [blame] | 466 | struct cmbdata __user *argp) |
Christoph Hellwig | 8b2eb66 | 2006-03-24 03:15:21 -0800 | [diff] [blame] | 467 | { |
Christoph Hellwig | 8b2eb66 | 2006-03-24 03:15:21 -0800 | [diff] [blame] | 468 | size_t size = _IOC_SIZE(cmd); |
| 469 | struct cmbdata data; |
| 470 | int ret; |
| 471 | |
Stefan Weinhuber | 8e09f21 | 2008-01-26 14:11:23 +0100 | [diff] [blame] | 472 | ret = cmf_readall(block->base->cdev, &data); |
Christoph Hellwig | 8b2eb66 | 2006-03-24 03:15:21 -0800 | [diff] [blame] | 473 | if (!ret && copy_to_user(argp, &data, min(size, sizeof(*argp)))) |
| 474 | return -EFAULT; |
| 475 | return ret; |
| 476 | } |
| 477 | |
Arnd Bergmann | cfdb00a | 2010-05-31 22:38:40 +0200 | [diff] [blame] | 478 | int dasd_ioctl(struct block_device *bdev, fmode_t mode, |
| 479 | unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 480 | { |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 481 | struct dasd_block *block; |
| 482 | struct dasd_device *base; |
Heiko Carstens | 8803486 | 2010-01-13 20:44:29 +0100 | [diff] [blame] | 483 | void __user *argp; |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 484 | int rc; |
Heiko Carstens | 8803486 | 2010-01-13 20:44:29 +0100 | [diff] [blame] | 485 | |
| 486 | if (is_compat_task()) |
| 487 | argp = compat_ptr(arg); |
| 488 | else |
| 489 | argp = (void __user *)arg; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 491 | if ((_IOC_DIR(cmd) != _IOC_NONE) && !arg) { |
| 492 | PRINT_DEBUG("empty data ptr"); |
| 493 | return -EINVAL; |
| 494 | } |
| 495 | |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 496 | base = dasd_device_from_gendisk(bdev->bd_disk); |
| 497 | if (!base) |
| 498 | return -ENODEV; |
| 499 | block = base->block; |
| 500 | rc = 0; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 501 | switch (cmd) { |
| 502 | case BIODASDDISABLE: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 503 | rc = dasd_ioctl_disable(bdev); |
| 504 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 505 | case BIODASDENABLE: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 506 | rc = dasd_ioctl_enable(bdev); |
| 507 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 508 | case BIODASDQUIESCE: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 509 | rc = dasd_ioctl_quiesce(block); |
| 510 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 511 | case BIODASDRESUME: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 512 | rc = dasd_ioctl_resume(block); |
| 513 | break; |
Hannes Reinecke | 5ea34a0 | 2013-01-30 09:26:19 +0000 | [diff] [blame] | 514 | case BIODASDABORTIO: |
| 515 | rc = dasd_ioctl_abortio(block); |
| 516 | break; |
| 517 | case BIODASDALLOWIO: |
| 518 | rc = dasd_ioctl_allowio(block); |
| 519 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 520 | case BIODASDFMT: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 521 | rc = dasd_ioctl_format(bdev, argp); |
| 522 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 523 | case BIODASDINFO: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 524 | rc = dasd_ioctl_information(block, cmd, argp); |
| 525 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 526 | case BIODASDINFO2: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 527 | rc = dasd_ioctl_information(block, cmd, argp); |
| 528 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 529 | case BIODASDPRRD: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 530 | rc = dasd_ioctl_read_profile(block, argp); |
| 531 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 532 | case BIODASDPRRST: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 533 | rc = dasd_ioctl_reset_profile(block); |
| 534 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 535 | case BLKROSET: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 536 | rc = dasd_ioctl_set_ro(bdev, argp); |
| 537 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 538 | case DASDAPIVER: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 539 | rc = dasd_ioctl_api_version(argp); |
| 540 | break; |
Christoph Hellwig | 8b2eb66 | 2006-03-24 03:15:21 -0800 | [diff] [blame] | 541 | case BIODASDCMFENABLE: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 542 | rc = enable_cmf(base->cdev); |
| 543 | break; |
Christoph Hellwig | 8b2eb66 | 2006-03-24 03:15:21 -0800 | [diff] [blame] | 544 | case BIODASDCMFDISABLE: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 545 | rc = disable_cmf(base->cdev); |
| 546 | break; |
Christoph Hellwig | 8b2eb66 | 2006-03-24 03:15:21 -0800 | [diff] [blame] | 547 | case BIODASDREADALLCMB: |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 548 | rc = dasd_ioctl_readall_cmb(block, cmd, argp); |
| 549 | break; |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 550 | default: |
Christoph Hellwig | 1107ccf | 2006-03-24 03:15:20 -0800 | [diff] [blame] | 551 | /* if the discipline has an ioctl method try it. */ |
Heiko Carstens | 6b79d14 | 2012-08-27 10:59:42 +0200 | [diff] [blame] | 552 | rc = -ENOTTY; |
| 553 | if (base->discipline->ioctl) |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 554 | rc = base->discipline->ioctl(block, cmd, argp); |
Christoph Hellwig | 13c6204 | 2006-03-24 03:15:19 -0800 | [diff] [blame] | 555 | } |
Stefan Weinhuber | 65f8da4 | 2011-04-20 10:15:30 +0200 | [diff] [blame] | 556 | dasd_put_device(base); |
| 557 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | } |