diff options
Diffstat (limited to 'fs/block_dev.c')
| -rw-r--r-- | fs/block_dev.c | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c index 99d6af811747..50e8c8582faa 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
| @@ -172,9 +172,8 @@ blkdev_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, | |||
| 172 | struct file *file = iocb->ki_filp; | 172 | struct file *file = iocb->ki_filp; |
| 173 | struct inode *inode = file->f_mapping->host; | 173 | struct inode *inode = file->f_mapping->host; |
| 174 | 174 | ||
| 175 | return blockdev_direct_IO_no_locking_newtrunc(rw, iocb, inode, | 175 | return __blockdev_direct_IO(rw, iocb, inode, I_BDEV(inode), iov, offset, |
| 176 | I_BDEV(inode), iov, offset, nr_segs, | 176 | nr_segs, blkdev_get_blocks, NULL, NULL, 0); |
| 177 | blkdev_get_blocks, NULL); | ||
| 178 | } | 177 | } |
| 179 | 178 | ||
| 180 | int __sync_blockdev(struct block_device *bdev, int wait) | 179 | int __sync_blockdev(struct block_device *bdev, int wait) |
| @@ -309,9 +308,8 @@ static int blkdev_write_begin(struct file *file, struct address_space *mapping, | |||
| 309 | loff_t pos, unsigned len, unsigned flags, | 308 | loff_t pos, unsigned len, unsigned flags, |
| 310 | struct page **pagep, void **fsdata) | 309 | struct page **pagep, void **fsdata) |
| 311 | { | 310 | { |
| 312 | *pagep = NULL; | 311 | return block_write_begin(mapping, pos, len, flags, pagep, |
| 313 | return block_write_begin_newtrunc(file, mapping, pos, len, flags, | 312 | blkdev_get_block); |
| 314 | pagep, fsdata, blkdev_get_block); | ||
| 315 | } | 313 | } |
| 316 | 314 | ||
| 317 | static int blkdev_write_end(struct file *file, struct address_space *mapping, | 315 | static int blkdev_write_end(struct file *file, struct address_space *mapping, |
| @@ -428,10 +426,13 @@ static inline void __bd_forget(struct inode *inode) | |||
| 428 | inode->i_mapping = &inode->i_data; | 426 | inode->i_mapping = &inode->i_data; |
| 429 | } | 427 | } |
| 430 | 428 | ||
| 431 | static void bdev_clear_inode(struct inode *inode) | 429 | static void bdev_evict_inode(struct inode *inode) |
| 432 | { | 430 | { |
| 433 | struct block_device *bdev = &BDEV_I(inode)->bdev; | 431 | struct block_device *bdev = &BDEV_I(inode)->bdev; |
| 434 | struct list_head *p; | 432 | struct list_head *p; |
| 433 | truncate_inode_pages(&inode->i_data, 0); | ||
| 434 | invalidate_inode_buffers(inode); /* is it needed here? */ | ||
| 435 | end_writeback(inode); | ||
| 435 | spin_lock(&bdev_lock); | 436 | spin_lock(&bdev_lock); |
| 436 | while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) { | 437 | while ( (p = bdev->bd_inodes.next) != &bdev->bd_inodes ) { |
| 437 | __bd_forget(list_entry(p, struct inode, i_devices)); | 438 | __bd_forget(list_entry(p, struct inode, i_devices)); |
| @@ -445,7 +446,7 @@ static const struct super_operations bdev_sops = { | |||
| 445 | .alloc_inode = bdev_alloc_inode, | 446 | .alloc_inode = bdev_alloc_inode, |
| 446 | .destroy_inode = bdev_destroy_inode, | 447 | .destroy_inode = bdev_destroy_inode, |
| 447 | .drop_inode = generic_delete_inode, | 448 | .drop_inode = generic_delete_inode, |
| 448 | .clear_inode = bdev_clear_inode, | 449 | .evict_inode = bdev_evict_inode, |
| 449 | }; | 450 | }; |
| 450 | 451 | ||
| 451 | static int bd_get_sb(struct file_system_type *fs_type, | 452 | static int bd_get_sb(struct file_system_type *fs_type, |
| @@ -681,8 +682,8 @@ retry: | |||
| 681 | if (!bd_may_claim(bdev, whole, holder)) | 682 | if (!bd_may_claim(bdev, whole, holder)) |
| 682 | return -EBUSY; | 683 | return -EBUSY; |
| 683 | 684 | ||
| 684 | /* if someone else is claiming, wait for it to finish */ | 685 | /* if claiming is already in progress, wait for it to finish */ |
| 685 | if (whole->bd_claiming && whole->bd_claiming != holder) { | 686 | if (whole->bd_claiming) { |
| 686 | wait_queue_head_t *wq = bit_waitqueue(&whole->bd_claiming, 0); | 687 | wait_queue_head_t *wq = bit_waitqueue(&whole->bd_claiming, 0); |
| 687 | DEFINE_WAIT(wait); | 688 | DEFINE_WAIT(wait); |
| 688 | 689 | ||
| @@ -1339,19 +1340,20 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
| 1339 | /* | 1340 | /* |
| 1340 | * hooks: /n/, see "layering violations". | 1341 | * hooks: /n/, see "layering violations". |
| 1341 | */ | 1342 | */ |
| 1342 | ret = devcgroup_inode_permission(bdev->bd_inode, perm); | 1343 | if (!for_part) { |
| 1343 | if (ret != 0) { | 1344 | ret = devcgroup_inode_permission(bdev->bd_inode, perm); |
| 1344 | bdput(bdev); | 1345 | if (ret != 0) { |
| 1345 | return ret; | 1346 | bdput(bdev); |
| 1347 | return ret; | ||
| 1348 | } | ||
| 1346 | } | 1349 | } |
| 1347 | 1350 | ||
| 1348 | lock_kernel(); | ||
| 1349 | restart: | 1351 | restart: |
| 1350 | 1352 | ||
| 1351 | ret = -ENXIO; | 1353 | ret = -ENXIO; |
| 1352 | disk = get_gendisk(bdev->bd_dev, &partno); | 1354 | disk = get_gendisk(bdev->bd_dev, &partno); |
| 1353 | if (!disk) | 1355 | if (!disk) |
| 1354 | goto out_unlock_kernel; | 1356 | goto out; |
| 1355 | 1357 | ||
| 1356 | mutex_lock_nested(&bdev->bd_mutex, for_part); | 1358 | mutex_lock_nested(&bdev->bd_mutex, for_part); |
| 1357 | if (!bdev->bd_openers) { | 1359 | if (!bdev->bd_openers) { |
| @@ -1431,7 +1433,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
| 1431 | if (for_part) | 1433 | if (for_part) |
| 1432 | bdev->bd_part_count++; | 1434 | bdev->bd_part_count++; |
| 1433 | mutex_unlock(&bdev->bd_mutex); | 1435 | mutex_unlock(&bdev->bd_mutex); |
| 1434 | unlock_kernel(); | ||
| 1435 | return 0; | 1436 | return 0; |
| 1436 | 1437 | ||
| 1437 | out_clear: | 1438 | out_clear: |
| @@ -1444,9 +1445,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) | |||
| 1444 | bdev->bd_contains = NULL; | 1445 | bdev->bd_contains = NULL; |
| 1445 | out_unlock_bdev: | 1446 | out_unlock_bdev: |
| 1446 | mutex_unlock(&bdev->bd_mutex); | 1447 | mutex_unlock(&bdev->bd_mutex); |
| 1447 | out_unlock_kernel: | 1448 | out: |
| 1448 | unlock_kernel(); | ||
| 1449 | |||
| 1450 | if (disk) | 1449 | if (disk) |
| 1451 | module_put(disk->fops->owner); | 1450 | module_put(disk->fops->owner); |
| 1452 | put_disk(disk); | 1451 | put_disk(disk); |
| @@ -1515,7 +1514,6 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
| 1515 | struct block_device *victim = NULL; | 1514 | struct block_device *victim = NULL; |
| 1516 | 1515 | ||
| 1517 | mutex_lock_nested(&bdev->bd_mutex, for_part); | 1516 | mutex_lock_nested(&bdev->bd_mutex, for_part); |
| 1518 | lock_kernel(); | ||
| 1519 | if (for_part) | 1517 | if (for_part) |
| 1520 | bdev->bd_part_count--; | 1518 | bdev->bd_part_count--; |
| 1521 | 1519 | ||
| @@ -1540,7 +1538,6 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
| 1540 | victim = bdev->bd_contains; | 1538 | victim = bdev->bd_contains; |
| 1541 | bdev->bd_contains = NULL; | 1539 | bdev->bd_contains = NULL; |
| 1542 | } | 1540 | } |
| 1543 | unlock_kernel(); | ||
| 1544 | mutex_unlock(&bdev->bd_mutex); | 1541 | mutex_unlock(&bdev->bd_mutex); |
| 1545 | bdput(bdev); | 1542 | bdput(bdev); |
| 1546 | if (victim) | 1543 | if (victim) |
