dasd_ioctl.c revision 138c014dcba74211dc4e835658f34a787c40cf17
11da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 21da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * File...........: linux/drivers/s390/block/dasd_ioctl.c 31da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> 41da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Horst Hummel <Horst.Hummel@de.ibm.com> 51da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Carsten Otte <Cotte@de.ibm.com> 61da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Martin Schwidefsky <schwidefsky@de.ibm.com> 71da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Bugreports.to..: <Linux390@de.ibm.com> 81da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001 91da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * 101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * i/o controls for the dasd driver. 111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/config.h> 131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/interrupt.h> 141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/major.h> 151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/fs.h> 161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <linux/blkpg.h> 171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/ccwdev.h> 198b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig#include <asm/cmb.h> 201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include <asm/uaccess.h> 211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* This is ugly... */ 231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#define PRINTK_HEADER "dasd_ioctl:" 241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#include "dasd_int.h" 261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 2913c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_api_version(void __user *argp) 301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int ver = DASD_API_VERSION; 32b5029622ac86bb441dc5e641226fb1152fca02d7Bastian Blank return put_user(ver, (int __user *)argp); 331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Enable device. 371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * used by dasdfmt after BIODASDDISABLE to retrigger blocksize detection 381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 4013c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_enable(struct block_device *bdev) 411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 4213c6204facb01d425320411c17febff666875518Christoph Hellwig struct dasd_device *device = bdev->bd_disk->private_data; 431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!capable(CAP_SYS_ADMIN)) 451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EACCES; 4613c6204facb01d425320411c17febff666875518Christoph Hellwig 471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_enable_device(device); 481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Formatting the dasd device can change the capacity. */ 49c039e3134ae62863bbc8e8429b29e3c43cf21b2aArjan van de Ven mutex_lock(&bdev->bd_mutex); 501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds i_size_write(bdev->bd_inode, (loff_t)get_capacity(device->gdp) << 9); 51c039e3134ae62863bbc8e8429b29e3c43cf21b2aArjan van de Ven mutex_unlock(&bdev->bd_mutex); 521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Disable device. 571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Used by dasdfmt. Disable I/O operations but allow ioctls. 581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 6013c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_disable(struct block_device *bdev) 611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 6213c6204facb01d425320411c17febff666875518Christoph Hellwig struct dasd_device *device = bdev->bd_disk->private_data; 631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!capable(CAP_SYS_ADMIN)) 651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EACCES; 6613c6204facb01d425320411c17febff666875518Christoph Hellwig 671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Man this is sick. We don't do a real disable but only downgrade 691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * the device to DASD_STATE_BASIC. The reason is that dasdfmt uses 701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * BIODASDDISABLE to disable accesses to the device via the block 711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * device layer but it still wants to do i/o on the device by 721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * using the BIODASDFMT ioctl. Therefore the correct state for the 731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * device is DASD_STATE_BASIC that allows to do basic i/o. 741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_set_target_state(device, DASD_STATE_BASIC); 761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Set i_size to zero, since read, write, etc. check against this 781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * value. 791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 80c039e3134ae62863bbc8e8429b29e3c43cf21b2aArjan van de Ven mutex_lock(&bdev->bd_mutex); 811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds i_size_write(bdev->bd_inode, 0); 82c039e3134ae62863bbc8e8429b29e3c43cf21b2aArjan van de Ven mutex_unlock(&bdev->bd_mutex); 831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Quiesce device. 881da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 9013c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_quiesce(struct dasd_device *device) 911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long flags; 93138c014dcba74211dc4e835658f34a787c40cf17Horst Hummel 941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!capable (CAP_SYS_ADMIN)) 951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EACCES; 96138c014dcba74211dc4e835658f34a787c40cf17Horst Hummel 971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds DEV_MESSAGE (KERN_DEBUG, device, "%s", 981da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "Quiesce IO on device"); 991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 1001da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds device->stopped |= DASD_STOPPED_QUIESCE; 1011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 1021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 1031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 1071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Quiesce device. 1081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 11013c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_resume(struct dasd_device *device) 1111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long flags; 113138c014dcba74211dc4e835658f34a787c40cf17Horst Hummel 114138c014dcba74211dc4e835658f34a787c40cf17Horst Hummel if (!capable (CAP_SYS_ADMIN)) 1151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EACCES; 1161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds DEV_MESSAGE (KERN_DEBUG, device, "%s", 1181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "resume IO on device"); 119138c014dcba74211dc4e835658f34a787c40cf17Horst Hummel 1201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 1211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds device->stopped &= ~DASD_STOPPED_QUIESCE; 1221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 1231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_schedule_bh (device); 1251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 1261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 1291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * performs formatting of _device_ according to _fdata_ 1301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Note: The discipline's format_function is assumed to deliver formatting 1311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * commands to format a single unit of the device. In terms of the ECKD 1321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * devices this means CCWs are generated to format a single track. 1331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 1351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsdasd_format(struct dasd_device * device, struct format_data_t * fdata) 1361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 1371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct dasd_ccw_req *cqr; 1381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds int rc; 1391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (device->discipline->format_device == NULL) 1411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EPERM; 1421da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (device->state != DASD_STATE_BASIC) { 1441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds DEV_MESSAGE(KERN_WARNING, device, "%s", 1451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "dasd_format: device is not disabled! "); 1461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EBUSY; 1471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds DBF_DEV_EVENT(DBF_NOTICE, device, 1501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "formatting units %d to %d (%d B blocks) flags %d", 1511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds fdata->start_unit, 1521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds fdata->stop_unit, fdata->blksize, fdata->intensity); 1531da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* Since dasdfmt keeps the device open after it was disabled, 1551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * there still exists an inode for this device. 1561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * We must update i_blkbits, otherwise we might get errors when 1571da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * enabling the device later. 1581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (fdata->start_unit == 0) { 1601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct block_device *bdev = bdget_disk(device->gdp, 0); 1611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds bdev->bd_inode->i_blkbits = blksize_bits(fdata->blksize); 1621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds bdput(bdev); 1631da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds while (fdata->start_unit <= fdata->stop_unit) { 1661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds cqr = device->discipline->format_device(device, fdata); 1671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (IS_ERR(cqr)) 1681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return PTR_ERR(cqr); 1691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds rc = dasd_sleep_on_interruptible(cqr); 1701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_sfree_request(cqr, cqr->device); 1711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (rc) { 1721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (rc != -ERESTARTSYS) 1731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds DEV_MESSAGE(KERN_ERR, device, 1741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds " Formatting of unit %d failed " 1751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "with rc = %d", 1761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds fdata->start_unit, rc); 1771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return rc; 1781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds fdata->start_unit++; 1801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 1811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 1821da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 1831da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1841da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 1851da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Format device. 1861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 1871da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 18813c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_format(struct block_device *bdev, void __user *argp) 1891da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 19013c6204facb01d425320411c17febff666875518Christoph Hellwig struct dasd_device *device = bdev->bd_disk->private_data; 1911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct format_data_t fdata; 1921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 1931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!capable(CAP_SYS_ADMIN)) 1941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EACCES; 19513c6204facb01d425320411c17febff666875518Christoph Hellwig if (!argp) 1961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EINVAL; 197f24acd4503270ed4c842c8fef0b71105285e0a06Horst Hummel 198c6eb7b7703ac4b3401b74f411c8c51ded214bf19Horst Hummel if (device->features & DASD_FEATURE_READONLY) 1991da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EROFS; 20013c6204facb01d425320411c17febff666875518Christoph Hellwig if (copy_from_user(&fdata, argp, sizeof(struct format_data_t))) 2011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EFAULT; 2021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (bdev != bdev->bd_contains) { 2031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds DEV_MESSAGE(KERN_WARNING, device, "%s", 2041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds "Cannot low-level format a partition"); 2051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EINVAL; 2061da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return dasd_format(device, &fdata); 2081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef CONFIG_DASD_PROFILE 2111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 2121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Reset device profile information 2131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 21513c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_reset_profile(struct dasd_device *device) 2161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds memset(&device->profile, 0, sizeof (struct dasd_profile_info_t)); 2181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 2191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 2221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Return device profile information 2231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 22513c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_read_profile(struct dasd_device *device, void __user *argp) 2261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2279a7af289660dc749d7c58234191601046a9bf488Horst Hummel if (dasd_profile_level == DASD_PROFILE_OFF) 2289a7af289660dc749d7c58234191601046a9bf488Horst Hummel return -EIO; 22913c6204facb01d425320411c17febff666875518Christoph Hellwig if (copy_to_user(argp, &device->profile, 2301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds sizeof (struct dasd_profile_info_t))) 2311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EFAULT; 2321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return 0; 2331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#else 2351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 23613c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_reset_profile(struct dasd_device *device) 2371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -ENOSYS; 2391da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2411da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 24213c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_read_profile(struct dasd_device *device, void __user *argp) 2431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -ENOSYS; 2451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 2461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif 2471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 2491da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Return dasd information. Used for BIODASDINFO and BIODASDINFO2. 2501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2511da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 25213c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_information(struct dasd_device *device, 25313c6204facb01d425320411c17febff666875518Christoph Hellwig unsigned int cmd, void __user *argp) 2541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 2551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct dasd_information2_t *dasd_info; 2561da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds unsigned long flags; 257c6eb7b7703ac4b3401b74f411c8c51ded214bf19Horst Hummel int rc; 2581da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct ccw_device *cdev; 2591da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2601da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!device->discipline->fill_info) 2611da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EINVAL; 2621da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 263554a826e0a29f1a88e5a5332f0718c059885ec17Horst Hummel dasd_info = kzalloc(sizeof(struct dasd_information2_t), GFP_KERNEL); 2641da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (dasd_info == NULL) 2651da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -ENOMEM; 2661da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2671da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds rc = device->discipline->fill_info(device, dasd_info); 2681da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (rc) { 2691da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds kfree(dasd_info); 2701da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return rc; 2711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 2721da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2731da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds cdev = device->cdev; 2741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 2751da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->devno = _ccw_device_get_device_number(device->cdev); 2761da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->schid = _ccw_device_get_subchannel_number(device->cdev); 2771da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->cu_type = cdev->id.cu_type; 2781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->cu_model = cdev->id.cu_model; 2791da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->dev_type = cdev->id.dev_type; 2801da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->dev_model = cdev->id.dev_model; 2811da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->status = device->state; 28257467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel /* 28357467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel * The open_count is increased for every opener, that includes 28457467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel * the blkdev_get in dasd_scan_partitions. 28557467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel * This must be hidden from user-space. 28657467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel */ 28757467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel dasd_info->open_count = atomic_read(&device->open_count); 28857467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel if (!device->bdev) 28957467195d1581e354998d5cc35dfd7a12d6e0a24Horst Hummel dasd_info->open_count++; 290138c014dcba74211dc4e835658f34a787c40cf17Horst Hummel 2911da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds /* 2921da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * check if device is really formatted 2931da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * LDL / CDL was returned by 'fill_info' 2941da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 2951da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if ((device->state < DASD_STATE_READY) || 2961da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds (dasd_check_blocksize(device->bp_block))) 2971da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->format = DASD_FORMAT_NONE; 298f24acd4503270ed4c842c8fef0b71105285e0a06Horst Hummel 299c6eb7b7703ac4b3401b74f411c8c51ded214bf19Horst Hummel dasd_info->features |= 300c6eb7b7703ac4b3401b74f411c8c51ded214bf19Horst Hummel ((device->features & DASD_FEATURE_READONLY) != 0); 3011da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3021da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (device->discipline) 3031da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds memcpy(dasd_info->type, device->discipline->name, 4); 3041da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds else 3051da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds memcpy(dasd_info->type, "none", 4); 306554a826e0a29f1a88e5a5332f0718c059885ec17Horst Hummel 3071da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (device->request_queue->request_fn) { 3081da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head *l; 3091da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#ifdef DASD_EXTENDED_PROFILING 3101da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds { 3111da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds struct list_head *l; 3121da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_lock_irqsave(&device->lock, flags); 3131da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds list_for_each(l, &device->request_queue->queue_head) 3141da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->req_queue_len++; 3151da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_unlock_irqrestore(&device->lock, flags); 3161da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3171da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds#endif /* DASD_EXTENDED_PROFILING */ 3181da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 3191da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds list_for_each(l, &device->ccw_queue) 3201da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds dasd_info->chanq_len++; 3211da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), 3221da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds flags); 3231da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds } 3241da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3251da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds rc = 0; 32613c6204facb01d425320411c17febff666875518Christoph Hellwig if (copy_to_user(argp, dasd_info, 32713c6204facb01d425320411c17febff666875518Christoph Hellwig ((cmd == (unsigned int) BIODASDINFO2) ? 3281da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds sizeof (struct dasd_information2_t) : 3291da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds sizeof (struct dasd_information_t)))) 3301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds rc = -EFAULT; 3311da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds kfree(dasd_info); 3321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return rc; 3331da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3341da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3351da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds/* 3361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds * Set read only 3371da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds */ 3381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsstatic int 33913c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl_set_ro(struct block_device *bdev, void __user *argp) 3401da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 34113c6204facb01d425320411c17febff666875518Christoph Hellwig struct dasd_device *device = bdev->bd_disk->private_data; 34213c6204facb01d425320411c17febff666875518Christoph Hellwig int intval; 3431da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3441da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (!capable(CAP_SYS_ADMIN)) 3451da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EACCES; 3461da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds if (bdev != bdev->bd_contains) 3471da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds // ro setting is not allowed for partitions 3481da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EINVAL; 34913c6204facb01d425320411c17febff666875518Christoph Hellwig if (get_user(intval, (int *)argp)) 3501da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds return -EFAULT; 351f24acd4503270ed4c842c8fef0b71105285e0a06Horst Hummel 3521da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds set_disk_ro(bdev->bd_disk, intval); 35313c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_set_feature(device->cdev, DASD_FEATURE_READONLY, intval); 3541da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 3551da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 3568b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwigstatic int 3578b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwigdasd_ioctl_readall_cmb(struct dasd_device *device, unsigned int cmd, 3588b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig unsigned long arg) 3598b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig{ 3608b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig struct cmbdata __user *argp = (void __user *) arg; 3618b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig size_t size = _IOC_SIZE(cmd); 3628b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig struct cmbdata data; 3638b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig int ret; 3648b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig 3658b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig ret = cmf_readall(device->cdev, &data); 3668b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig if (!ret && copy_to_user(argp, &data, min(size, sizeof(*argp)))) 3678b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig return -EFAULT; 3688b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig return ret; 3698b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig} 3708b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig 3711da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvaldsint 37213c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_ioctl(struct inode *inode, struct file *file, 37313c6204facb01d425320411c17febff666875518Christoph Hellwig unsigned int cmd, unsigned long arg) 3741da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 37513c6204facb01d425320411c17febff666875518Christoph Hellwig struct block_device *bdev = inode->i_bdev; 37613c6204facb01d425320411c17febff666875518Christoph Hellwig struct dasd_device *device = bdev->bd_disk->private_data; 37713c6204facb01d425320411c17febff666875518Christoph Hellwig void __user *argp = (void __user *)arg; 3781da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 37913c6204facb01d425320411c17febff666875518Christoph Hellwig if (!device) 38013c6204facb01d425320411c17febff666875518Christoph Hellwig return -ENODEV; 38113c6204facb01d425320411c17febff666875518Christoph Hellwig 38213c6204facb01d425320411c17febff666875518Christoph Hellwig if ((_IOC_DIR(cmd) != _IOC_NONE) && !arg) { 38313c6204facb01d425320411c17febff666875518Christoph Hellwig PRINT_DEBUG("empty data ptr"); 38413c6204facb01d425320411c17febff666875518Christoph Hellwig return -EINVAL; 38513c6204facb01d425320411c17febff666875518Christoph Hellwig } 3861da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 38713c6204facb01d425320411c17febff666875518Christoph Hellwig switch (cmd) { 38813c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDDISABLE: 38913c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_disable(bdev); 39013c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDENABLE: 39113c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_enable(bdev); 39213c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDQUIESCE: 39313c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_quiesce(device); 39413c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDRESUME: 39513c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_resume(device); 39613c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDFMT: 39713c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_format(bdev, argp); 39813c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDINFO: 39913c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_information(device, cmd, argp); 40013c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDINFO2: 40113c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_information(device, cmd, argp); 40213c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDPRRD: 40313c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_read_profile(device, argp); 40413c6204facb01d425320411c17febff666875518Christoph Hellwig case BIODASDPRRST: 40513c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_reset_profile(device); 40613c6204facb01d425320411c17febff666875518Christoph Hellwig case BLKROSET: 40713c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_set_ro(bdev, argp); 40813c6204facb01d425320411c17febff666875518Christoph Hellwig case DASDAPIVER: 40913c6204facb01d425320411c17febff666875518Christoph Hellwig return dasd_ioctl_api_version(argp); 4108b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig case BIODASDCMFENABLE: 4118b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig return enable_cmf(device->cdev); 4128b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig case BIODASDCMFDISABLE: 4138b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig return disable_cmf(device->cdev); 4148b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig case BIODASDREADALLCMB: 4158b2eb664ce9dcba8b54ececf5e057470c47e57f7Christoph Hellwig return dasd_ioctl_readall_cmb(device, cmd, arg); 41613c6204facb01d425320411c17febff666875518Christoph Hellwig default: 4171107ccfbdef280fedc677af3bdbc405611ba554aChristoph Hellwig /* if the discipline has an ioctl method try it. */ 4181107ccfbdef280fedc677af3bdbc405611ba554aChristoph Hellwig if (device->discipline->ioctl) { 4191107ccfbdef280fedc677af3bdbc405611ba554aChristoph Hellwig int rval = device->discipline->ioctl(device, cmd, argp); 4201107ccfbdef280fedc677af3bdbc405611ba554aChristoph Hellwig if (rval != -ENOIOCTLCMD) 4211107ccfbdef280fedc677af3bdbc405611ba554aChristoph Hellwig return rval; 4221107ccfbdef280fedc677af3bdbc405611ba554aChristoph Hellwig } 4231107ccfbdef280fedc677af3bdbc405611ba554aChristoph Hellwig 42413c6204facb01d425320411c17febff666875518Christoph Hellwig return -EINVAL; 42513c6204facb01d425320411c17febff666875518Christoph Hellwig } 4261da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 4271da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 42813c6204facb01d425320411c17febff666875518Christoph Hellwiglong 42913c6204facb01d425320411c17febff666875518Christoph Hellwigdasd_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 4301da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds{ 43113c6204facb01d425320411c17febff666875518Christoph Hellwig int rval; 4321da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 43313c6204facb01d425320411c17febff666875518Christoph Hellwig lock_kernel(); 43413c6204facb01d425320411c17febff666875518Christoph Hellwig rval = dasd_ioctl(filp->f_dentry->d_inode, filp, cmd, arg); 43513c6204facb01d425320411c17febff666875518Christoph Hellwig unlock_kernel(); 4361da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds 43713c6204facb01d425320411c17febff666875518Christoph Hellwig return (rval == -EINVAL) ? -ENOIOCTLCMD : rval; 4381da177e4c3f41524e886b7f1b8a0c1fc7321cacLinus Torvalds} 439