aboutsummaryrefslogtreecommitdiffstats
path: root/block/ioctl.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-10 20:04:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-10 20:04:23 -0400
commitce40be7a820bb393ac4ac69865f018d2f4038cf0 (patch)
treeb1fe5a93346eb06f22b1c303d63ec5456d7212ab /block/ioctl.c
parentba0a5a36f60e4c1152af3a2ae2813251974405bf (diff)
parent02f3939e1a9357b7c370a4a69717cf9c02452737 (diff)
Merge branch 'for-3.7/core' of git://git.kernel.dk/linux-block
Pull block IO update from Jens Axboe: "Core block IO bits for 3.7. Not a huge round this time, it contains: - First series from Kent cleaning up and generalizing bio allocation and freeing. - WRITE_SAME support from Martin. - Mikulas patches to prevent O_DIRECT crashes when someone changes the block size of a device. - Make bio_split() work on data-less bio's (like trim/discards). - A few other minor fixups." Fixed up silent semantic mis-merge as per Mikulas Patocka and Andrew Morton. It is due to the VM no longer using a prio-tree (see commit 6b2dbba8b6ac: "mm: replace vma prio_tree with an interval tree"). So make set_blocksize() use mapping_mapped() instead of open-coding the internal VM knowledge that has changed. * 'for-3.7/core' of git://git.kernel.dk/linux-block: (26 commits) block: makes bio_split support bio without data scatterlist: refactor the sg_nents scatterlist: add sg_nents fs: fix include/percpu-rwsem.h export error percpu-rw-semaphore: fix documentation typos fs/block_dev.c:1644:5: sparse: symbol 'blkdev_mmap' was not declared blockdev: turn a rw semaphore into a percpu rw semaphore Fix a crash when block device is read and block size is changed at the same time block: fix request_queue->flags initialization block: lift the initial queue bypass mode on blk_register_queue() instead of blk_init_allocated_queue() block: ioctl to zero block ranges block: Make blkdev_issue_zeroout use WRITE SAME block: Implement support for WRITE SAME block: Consolidate command flag and queue limit checks for merges block: Clean up special command handling logic block/blk-tag.c: Remove useless kfree block: remove the duplicated setting for congestion_threshold block: reject invalid queue attribute values block: Add bio_clone_bioset(), bio_clone_kmalloc() block: Consolidate bio_alloc_bioset(), bio_kmalloc() ...
Diffstat (limited to 'block/ioctl.c')
-rw-r--r--block/ioctl.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/block/ioctl.c b/block/ioctl.c
index 4a85096f5410..a31d91d9bc5a 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -185,6 +185,22 @@ static int blk_ioctl_discard(struct block_device *bdev, uint64_t start,
185 return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags); 185 return blkdev_issue_discard(bdev, start, len, GFP_KERNEL, flags);
186} 186}
187 187
188static int blk_ioctl_zeroout(struct block_device *bdev, uint64_t start,
189 uint64_t len)
190{
191 if (start & 511)
192 return -EINVAL;
193 if (len & 511)
194 return -EINVAL;
195 start >>= 9;
196 len >>= 9;
197
198 if (start + len > (i_size_read(bdev->bd_inode) >> 9))
199 return -EINVAL;
200
201 return blkdev_issue_zeroout(bdev, start, len, GFP_KERNEL);
202}
203
188static int put_ushort(unsigned long arg, unsigned short val) 204static int put_ushort(unsigned long arg, unsigned short val)
189{ 205{
190 return put_user(val, (unsigned short __user *)arg); 206 return put_user(val, (unsigned short __user *)arg);
@@ -300,6 +316,17 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
300 return blk_ioctl_discard(bdev, range[0], range[1], 316 return blk_ioctl_discard(bdev, range[0], range[1],
301 cmd == BLKSECDISCARD); 317 cmd == BLKSECDISCARD);
302 } 318 }
319 case BLKZEROOUT: {
320 uint64_t range[2];
321
322 if (!(mode & FMODE_WRITE))
323 return -EBADF;
324
325 if (copy_from_user(range, (void __user *)arg, sizeof(range)))
326 return -EFAULT;
327
328 return blk_ioctl_zeroout(bdev, range[0], range[1]);
329 }
303 330
304 case HDIO_GETGEO: { 331 case HDIO_GETGEO: {
305 struct hd_geometry geo; 332 struct hd_geometry geo;