diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2016-01-12 05:01:12 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-01-12 05:01:12 -0500 |
commit | 1f16f116b01c110db20ab808562c8b8bc3ee3d6e (patch) | |
tree | 44db563f64cf5f8d62af8f99a61e2b248c44ea3a /fs | |
parent | 03724ac3d48f8f0e3caf1d30fa134f8fd96c94e2 (diff) | |
parent | f9eccf24615672896dc13251410c3f2f33a14f95 (diff) |
Merge branches 'clockevents/4.4-fixes' and 'clockevents/4.5-fixes' of http://git.linaro.org/people/daniel.lezcano/linux into timers/urgent
Pull in fixes from Daniel Lezcano:
- Fix the vt8500 timer leading to a system lock up when dealing with too
small delta (Roman Volkov)
- Select the CLKSRC_MMIO when the fsl_ftm_timer is enabled with COMPILE_TEST
(Daniel Lezcano)
- Prevent to compile timers using the 'iomem' API when the architecture has
not HAS_IOMEM set (Richard Weinberger)
Diffstat (limited to 'fs')
45 files changed, 439 insertions, 227 deletions
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 699941e90667..511078586fa1 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -451,9 +451,9 @@ void v9fs_evict_inode(struct inode *inode) | |||
451 | { | 451 | { |
452 | struct v9fs_inode *v9inode = V9FS_I(inode); | 452 | struct v9fs_inode *v9inode = V9FS_I(inode); |
453 | 453 | ||
454 | truncate_inode_pages_final(inode->i_mapping); | 454 | truncate_inode_pages_final(&inode->i_data); |
455 | clear_inode(inode); | 455 | clear_inode(inode); |
456 | filemap_fdatawrite(inode->i_mapping); | 456 | filemap_fdatawrite(&inode->i_data); |
457 | 457 | ||
458 | v9fs_cache_inode_put_cookie(inode); | 458 | v9fs_cache_inode_put_cookie(inode); |
459 | /* clunk the fid stashed in writeback_fid */ | 459 | /* clunk the fid stashed in writeback_fid */ |
diff --git a/fs/block_dev.c b/fs/block_dev.c index c25639e907bd..44d4a1e9244e 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -1523,11 +1523,14 @@ static void __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part) | |||
1523 | WARN_ON_ONCE(bdev->bd_holders); | 1523 | WARN_ON_ONCE(bdev->bd_holders); |
1524 | sync_blockdev(bdev); | 1524 | sync_blockdev(bdev); |
1525 | kill_bdev(bdev); | 1525 | kill_bdev(bdev); |
1526 | |||
1527 | bdev_write_inode(bdev); | ||
1526 | /* | 1528 | /* |
1527 | * ->release can cause the queue to disappear, so flush all | 1529 | * Detaching bdev inode from its wb in __destroy_inode() |
1528 | * dirty data before. | 1530 | * is too late: the queue which embeds its bdi (along with |
1531 | * root wb) can be gone as soon as we put_disk() below. | ||
1529 | */ | 1532 | */ |
1530 | bdev_write_inode(bdev); | 1533 | inode_detach_wb(bdev->bd_inode); |
1531 | } | 1534 | } |
1532 | if (bdev->bd_contains == bdev) { | 1535 | if (bdev->bd_contains == bdev) { |
1533 | if (disk->fops->release) | 1536 | if (disk->fops->release) |
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 6dcdb2ec9211..d453d62ab0c6 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -355,7 +355,7 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, | |||
355 | 355 | ||
356 | index = srcu_read_lock(&fs_info->subvol_srcu); | 356 | index = srcu_read_lock(&fs_info->subvol_srcu); |
357 | 357 | ||
358 | root = btrfs_read_fs_root_no_name(fs_info, &root_key); | 358 | root = btrfs_get_fs_root(fs_info, &root_key, false); |
359 | if (IS_ERR(root)) { | 359 | if (IS_ERR(root)) { |
360 | srcu_read_unlock(&fs_info->subvol_srcu, index); | 360 | srcu_read_unlock(&fs_info->subvol_srcu, index); |
361 | ret = PTR_ERR(root); | 361 | ret = PTR_ERR(root); |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8c58191249cc..35489e7129a7 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -3416,6 +3416,7 @@ int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, | |||
3416 | struct btrfs_block_group_cache *btrfs_lookup_block_group( | 3416 | struct btrfs_block_group_cache *btrfs_lookup_block_group( |
3417 | struct btrfs_fs_info *info, | 3417 | struct btrfs_fs_info *info, |
3418 | u64 bytenr); | 3418 | u64 bytenr); |
3419 | void btrfs_get_block_group(struct btrfs_block_group_cache *cache); | ||
3419 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); | 3420 | void btrfs_put_block_group(struct btrfs_block_group_cache *cache); |
3420 | int get_block_group_index(struct btrfs_block_group_cache *cache); | 3421 | int get_block_group_index(struct btrfs_block_group_cache *cache); |
3421 | struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, | 3422 | struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, |
@@ -3479,6 +3480,9 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
3479 | struct btrfs_root *root, u64 bytes_used, | 3480 | struct btrfs_root *root, u64 bytes_used, |
3480 | u64 type, u64 chunk_objectid, u64 chunk_offset, | 3481 | u64 type, u64 chunk_objectid, u64 chunk_offset, |
3481 | u64 size); | 3482 | u64 size); |
3483 | struct btrfs_trans_handle *btrfs_start_trans_remove_block_group( | ||
3484 | struct btrfs_fs_info *fs_info, | ||
3485 | const u64 chunk_offset); | ||
3482 | int btrfs_remove_block_group(struct btrfs_trans_handle *trans, | 3486 | int btrfs_remove_block_group(struct btrfs_trans_handle *trans, |
3483 | struct btrfs_root *root, u64 group_start, | 3487 | struct btrfs_root *root, u64 group_start, |
3484 | struct extent_map *em); | 3488 | struct extent_map *em); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index acf3ed11cfb6..c4661db2b72a 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -124,7 +124,7 @@ static int block_group_bits(struct btrfs_block_group_cache *cache, u64 bits) | |||
124 | return (cache->flags & bits) == bits; | 124 | return (cache->flags & bits) == bits; |
125 | } | 125 | } |
126 | 126 | ||
127 | static void btrfs_get_block_group(struct btrfs_block_group_cache *cache) | 127 | void btrfs_get_block_group(struct btrfs_block_group_cache *cache) |
128 | { | 128 | { |
129 | atomic_inc(&cache->count); | 129 | atomic_inc(&cache->count); |
130 | } | 130 | } |
@@ -5915,19 +5915,6 @@ static int update_block_group(struct btrfs_trans_handle *trans, | |||
5915 | set_extent_dirty(info->pinned_extents, | 5915 | set_extent_dirty(info->pinned_extents, |
5916 | bytenr, bytenr + num_bytes - 1, | 5916 | bytenr, bytenr + num_bytes - 1, |
5917 | GFP_NOFS | __GFP_NOFAIL); | 5917 | GFP_NOFS | __GFP_NOFAIL); |
5918 | /* | ||
5919 | * No longer have used bytes in this block group, queue | ||
5920 | * it for deletion. | ||
5921 | */ | ||
5922 | if (old_val == 0) { | ||
5923 | spin_lock(&info->unused_bgs_lock); | ||
5924 | if (list_empty(&cache->bg_list)) { | ||
5925 | btrfs_get_block_group(cache); | ||
5926 | list_add_tail(&cache->bg_list, | ||
5927 | &info->unused_bgs); | ||
5928 | } | ||
5929 | spin_unlock(&info->unused_bgs_lock); | ||
5930 | } | ||
5931 | } | 5918 | } |
5932 | 5919 | ||
5933 | spin_lock(&trans->transaction->dirty_bgs_lock); | 5920 | spin_lock(&trans->transaction->dirty_bgs_lock); |
@@ -5939,6 +5926,22 @@ static int update_block_group(struct btrfs_trans_handle *trans, | |||
5939 | } | 5926 | } |
5940 | spin_unlock(&trans->transaction->dirty_bgs_lock); | 5927 | spin_unlock(&trans->transaction->dirty_bgs_lock); |
5941 | 5928 | ||
5929 | /* | ||
5930 | * No longer have used bytes in this block group, queue it for | ||
5931 | * deletion. We do this after adding the block group to the | ||
5932 | * dirty list to avoid races between cleaner kthread and space | ||
5933 | * cache writeout. | ||
5934 | */ | ||
5935 | if (!alloc && old_val == 0) { | ||
5936 | spin_lock(&info->unused_bgs_lock); | ||
5937 | if (list_empty(&cache->bg_list)) { | ||
5938 | btrfs_get_block_group(cache); | ||
5939 | list_add_tail(&cache->bg_list, | ||
5940 | &info->unused_bgs); | ||
5941 | } | ||
5942 | spin_unlock(&info->unused_bgs_lock); | ||
5943 | } | ||
5944 | |||
5942 | btrfs_put_block_group(cache); | 5945 | btrfs_put_block_group(cache); |
5943 | total -= num_bytes; | 5946 | total -= num_bytes; |
5944 | bytenr += num_bytes; | 5947 | bytenr += num_bytes; |
@@ -8105,21 +8108,47 @@ reada: | |||
8105 | } | 8108 | } |
8106 | 8109 | ||
8107 | /* | 8110 | /* |
8108 | * TODO: Modify related function to add related node/leaf to dirty_extent_root, | 8111 | * These may not be seen by the usual inc/dec ref code so we have to |
8109 | * for later qgroup accounting. | 8112 | * add them here. |
8110 | * | ||
8111 | * Current, this function does nothing. | ||
8112 | */ | 8113 | */ |
8114 | static int record_one_subtree_extent(struct btrfs_trans_handle *trans, | ||
8115 | struct btrfs_root *root, u64 bytenr, | ||
8116 | u64 num_bytes) | ||
8117 | { | ||
8118 | struct btrfs_qgroup_extent_record *qrecord; | ||
8119 | struct btrfs_delayed_ref_root *delayed_refs; | ||
8120 | |||
8121 | qrecord = kmalloc(sizeof(*qrecord), GFP_NOFS); | ||
8122 | if (!qrecord) | ||
8123 | return -ENOMEM; | ||
8124 | |||
8125 | qrecord->bytenr = bytenr; | ||
8126 | qrecord->num_bytes = num_bytes; | ||
8127 | qrecord->old_roots = NULL; | ||
8128 | |||
8129 | delayed_refs = &trans->transaction->delayed_refs; | ||
8130 | spin_lock(&delayed_refs->lock); | ||
8131 | if (btrfs_qgroup_insert_dirty_extent(delayed_refs, qrecord)) | ||
8132 | kfree(qrecord); | ||
8133 | spin_unlock(&delayed_refs->lock); | ||
8134 | |||
8135 | return 0; | ||
8136 | } | ||
8137 | |||
8113 | static int account_leaf_items(struct btrfs_trans_handle *trans, | 8138 | static int account_leaf_items(struct btrfs_trans_handle *trans, |
8114 | struct btrfs_root *root, | 8139 | struct btrfs_root *root, |
8115 | struct extent_buffer *eb) | 8140 | struct extent_buffer *eb) |
8116 | { | 8141 | { |
8117 | int nr = btrfs_header_nritems(eb); | 8142 | int nr = btrfs_header_nritems(eb); |
8118 | int i, extent_type; | 8143 | int i, extent_type, ret; |
8119 | struct btrfs_key key; | 8144 | struct btrfs_key key; |
8120 | struct btrfs_file_extent_item *fi; | 8145 | struct btrfs_file_extent_item *fi; |
8121 | u64 bytenr, num_bytes; | 8146 | u64 bytenr, num_bytes; |
8122 | 8147 | ||
8148 | /* We can be called directly from walk_up_proc() */ | ||
8149 | if (!root->fs_info->quota_enabled) | ||
8150 | return 0; | ||
8151 | |||
8123 | for (i = 0; i < nr; i++) { | 8152 | for (i = 0; i < nr; i++) { |
8124 | btrfs_item_key_to_cpu(eb, &key, i); | 8153 | btrfs_item_key_to_cpu(eb, &key, i); |
8125 | 8154 | ||
@@ -8138,6 +8167,10 @@ static int account_leaf_items(struct btrfs_trans_handle *trans, | |||
8138 | continue; | 8167 | continue; |
8139 | 8168 | ||
8140 | num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi); | 8169 | num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi); |
8170 | |||
8171 | ret = record_one_subtree_extent(trans, root, bytenr, num_bytes); | ||
8172 | if (ret) | ||
8173 | return ret; | ||
8141 | } | 8174 | } |
8142 | return 0; | 8175 | return 0; |
8143 | } | 8176 | } |
@@ -8206,8 +8239,6 @@ static int adjust_slots_upwards(struct btrfs_root *root, | |||
8206 | 8239 | ||
8207 | /* | 8240 | /* |
8208 | * root_eb is the subtree root and is locked before this function is called. | 8241 | * root_eb is the subtree root and is locked before this function is called. |
8209 | * TODO: Modify this function to mark all (including complete shared node) | ||
8210 | * to dirty_extent_root to allow it get accounted in qgroup. | ||
8211 | */ | 8242 | */ |
8212 | static int account_shared_subtree(struct btrfs_trans_handle *trans, | 8243 | static int account_shared_subtree(struct btrfs_trans_handle *trans, |
8213 | struct btrfs_root *root, | 8244 | struct btrfs_root *root, |
@@ -8285,6 +8316,11 @@ walk_down: | |||
8285 | btrfs_tree_read_lock(eb); | 8316 | btrfs_tree_read_lock(eb); |
8286 | btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK); | 8317 | btrfs_set_lock_blocking_rw(eb, BTRFS_READ_LOCK); |
8287 | path->locks[level] = BTRFS_READ_LOCK_BLOCKING; | 8318 | path->locks[level] = BTRFS_READ_LOCK_BLOCKING; |
8319 | |||
8320 | ret = record_one_subtree_extent(trans, root, child_bytenr, | ||
8321 | root->nodesize); | ||
8322 | if (ret) | ||
8323 | goto out; | ||
8288 | } | 8324 | } |
8289 | 8325 | ||
8290 | if (level == 0) { | 8326 | if (level == 0) { |
@@ -10256,6 +10292,47 @@ out: | |||
10256 | return ret; | 10292 | return ret; |
10257 | } | 10293 | } |
10258 | 10294 | ||
10295 | struct btrfs_trans_handle * | ||
10296 | btrfs_start_trans_remove_block_group(struct btrfs_fs_info *fs_info, | ||
10297 | const u64 chunk_offset) | ||
10298 | { | ||
10299 | struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree; | ||
10300 | struct extent_map *em; | ||
10301 | struct map_lookup *map; | ||
10302 | unsigned int num_items; | ||
10303 | |||
10304 | read_lock(&em_tree->lock); | ||
10305 | em = lookup_extent_mapping(em_tree, chunk_offset, 1); | ||
10306 | read_unlock(&em_tree->lock); | ||
10307 | ASSERT(em && em->start == chunk_offset); | ||
10308 | |||
10309 | /* | ||
10310 | * We need to reserve 3 + N units from the metadata space info in order | ||
10311 | * to remove a block group (done at btrfs_remove_chunk() and at | ||
10312 | * btrfs_remove_block_group()), which are used for: | ||
10313 | * | ||
10314 | * 1 unit for adding the free space inode's orphan (located in the tree | ||
10315 | * of tree roots). | ||
10316 | * 1 unit for deleting the block group item (located in the extent | ||
10317 | * tree). | ||
10318 | * 1 unit for deleting the free space item (located in tree of tree | ||
10319 | * roots). | ||
10320 | * N units for deleting N device extent items corresponding to each | ||
10321 | * stripe (located in the device tree). | ||
10322 | * | ||
10323 | * In order to remove a block group we also need to reserve units in the | ||
10324 | * system space info in order to update the chunk tree (update one or | ||
10325 | * more device items and remove one chunk item), but this is done at | ||
10326 | * btrfs_remove_chunk() through a call to check_system_chunk(). | ||
10327 | */ | ||
10328 | map = (struct map_lookup *)em->bdev; | ||
10329 | num_items = 3 + map->num_stripes; | ||
10330 | free_extent_map(em); | ||
10331 | |||
10332 | return btrfs_start_transaction_fallback_global_rsv(fs_info->extent_root, | ||
10333 | num_items, 1); | ||
10334 | } | ||
10335 | |||
10259 | /* | 10336 | /* |
10260 | * Process the unused_bgs list and remove any that don't have any allocated | 10337 | * Process the unused_bgs list and remove any that don't have any allocated |
10261 | * space inside of them. | 10338 | * space inside of them. |
@@ -10322,8 +10399,8 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) | |||
10322 | * Want to do this before we do anything else so we can recover | 10399 | * Want to do this before we do anything else so we can recover |
10323 | * properly if we fail to join the transaction. | 10400 | * properly if we fail to join the transaction. |
10324 | */ | 10401 | */ |
10325 | /* 1 for btrfs_orphan_reserve_metadata() */ | 10402 | trans = btrfs_start_trans_remove_block_group(fs_info, |
10326 | trans = btrfs_start_transaction(root, 1); | 10403 | block_group->key.objectid); |
10327 | if (IS_ERR(trans)) { | 10404 | if (IS_ERR(trans)) { |
10328 | btrfs_dec_block_group_ro(root, block_group); | 10405 | btrfs_dec_block_group_ro(root, block_group); |
10329 | ret = PTR_ERR(trans); | 10406 | ret = PTR_ERR(trans); |
@@ -10403,11 +10480,15 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) | |||
10403 | * until transaction commit to do the actual discard. | 10480 | * until transaction commit to do the actual discard. |
10404 | */ | 10481 | */ |
10405 | if (trimming) { | 10482 | if (trimming) { |
10406 | WARN_ON(!list_empty(&block_group->bg_list)); | 10483 | spin_lock(&fs_info->unused_bgs_lock); |
10407 | spin_lock(&trans->transaction->deleted_bgs_lock); | 10484 | /* |
10485 | * A concurrent scrub might have added us to the list | ||
10486 | * fs_info->unused_bgs, so use a list_move operation | ||
10487 | * to add the block group to the deleted_bgs list. | ||
10488 | */ | ||
10408 | list_move(&block_group->bg_list, | 10489 | list_move(&block_group->bg_list, |
10409 | &trans->transaction->deleted_bgs); | 10490 | &trans->transaction->deleted_bgs); |
10410 | spin_unlock(&trans->transaction->deleted_bgs_lock); | 10491 | spin_unlock(&fs_info->unused_bgs_lock); |
10411 | btrfs_get_block_group(block_group); | 10492 | btrfs_get_block_group(block_group); |
10412 | } | 10493 | } |
10413 | end_trans: | 10494 | end_trans: |
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 977e715f0bf2..0f09526aa7d9 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c | |||
@@ -1291,7 +1291,8 @@ out: | |||
1291 | * on error we return an unlocked page and the error value | 1291 | * on error we return an unlocked page and the error value |
1292 | * on success we return a locked page and 0 | 1292 | * on success we return a locked page and 0 |
1293 | */ | 1293 | */ |
1294 | static int prepare_uptodate_page(struct page *page, u64 pos, | 1294 | static int prepare_uptodate_page(struct inode *inode, |
1295 | struct page *page, u64 pos, | ||
1295 | bool force_uptodate) | 1296 | bool force_uptodate) |
1296 | { | 1297 | { |
1297 | int ret = 0; | 1298 | int ret = 0; |
@@ -1306,6 +1307,10 @@ static int prepare_uptodate_page(struct page *page, u64 pos, | |||
1306 | unlock_page(page); | 1307 | unlock_page(page); |
1307 | return -EIO; | 1308 | return -EIO; |
1308 | } | 1309 | } |
1310 | if (page->mapping != inode->i_mapping) { | ||
1311 | unlock_page(page); | ||
1312 | return -EAGAIN; | ||
1313 | } | ||
1309 | } | 1314 | } |
1310 | return 0; | 1315 | return 0; |
1311 | } | 1316 | } |
@@ -1324,6 +1329,7 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, | |||
1324 | int faili; | 1329 | int faili; |
1325 | 1330 | ||
1326 | for (i = 0; i < num_pages; i++) { | 1331 | for (i = 0; i < num_pages; i++) { |
1332 | again: | ||
1327 | pages[i] = find_or_create_page(inode->i_mapping, index + i, | 1333 | pages[i] = find_or_create_page(inode->i_mapping, index + i, |
1328 | mask | __GFP_WRITE); | 1334 | mask | __GFP_WRITE); |
1329 | if (!pages[i]) { | 1335 | if (!pages[i]) { |
@@ -1333,13 +1339,17 @@ static noinline int prepare_pages(struct inode *inode, struct page **pages, | |||
1333 | } | 1339 | } |
1334 | 1340 | ||
1335 | if (i == 0) | 1341 | if (i == 0) |
1336 | err = prepare_uptodate_page(pages[i], pos, | 1342 | err = prepare_uptodate_page(inode, pages[i], pos, |
1337 | force_uptodate); | 1343 | force_uptodate); |
1338 | if (i == num_pages - 1) | 1344 | if (!err && i == num_pages - 1) |
1339 | err = prepare_uptodate_page(pages[i], | 1345 | err = prepare_uptodate_page(inode, pages[i], |
1340 | pos + write_bytes, false); | 1346 | pos + write_bytes, false); |
1341 | if (err) { | 1347 | if (err) { |
1342 | page_cache_release(pages[i]); | 1348 | page_cache_release(pages[i]); |
1349 | if (err == -EAGAIN) { | ||
1350 | err = 0; | ||
1351 | goto again; | ||
1352 | } | ||
1343 | faili = i - 1; | 1353 | faili = i - 1; |
1344 | goto fail; | 1354 | goto fail; |
1345 | } | 1355 | } |
@@ -1882,8 +1892,13 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | |||
1882 | struct btrfs_log_ctx ctx; | 1892 | struct btrfs_log_ctx ctx; |
1883 | int ret = 0; | 1893 | int ret = 0; |
1884 | bool full_sync = 0; | 1894 | bool full_sync = 0; |
1885 | const u64 len = end - start + 1; | 1895 | u64 len; |
1886 | 1896 | ||
1897 | /* | ||
1898 | * The range length can be represented by u64, we have to do the typecasts | ||
1899 | * to avoid signed overflow if it's [0, LLONG_MAX] eg. from fsync() | ||
1900 | */ | ||
1901 | len = (u64)end - (u64)start + 1; | ||
1887 | trace_btrfs_sync_file(file, datasync); | 1902 | trace_btrfs_sync_file(file, datasync); |
1888 | 1903 | ||
1889 | /* | 1904 | /* |
@@ -2071,8 +2086,7 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync) | |||
2071 | } | 2086 | } |
2072 | } | 2087 | } |
2073 | if (!full_sync) { | 2088 | if (!full_sync) { |
2074 | ret = btrfs_wait_ordered_range(inode, start, | 2089 | ret = btrfs_wait_ordered_range(inode, start, len); |
2075 | end - start + 1); | ||
2076 | if (ret) { | 2090 | if (ret) { |
2077 | btrfs_end_transaction(trans, root); | 2091 | btrfs_end_transaction(trans, root); |
2078 | goto out; | 2092 | goto out; |
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 85a1f8621b51..cfe99bec49de 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -891,7 +891,7 @@ out: | |||
891 | spin_unlock(&block_group->lock); | 891 | spin_unlock(&block_group->lock); |
892 | ret = 0; | 892 | ret = 0; |
893 | 893 | ||
894 | btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuild it now", | 894 | btrfs_warn(fs_info, "failed to load free space cache for block group %llu, rebuilding it now", |
895 | block_group->key.objectid); | 895 | block_group->key.objectid); |
896 | } | 896 | } |
897 | 897 | ||
@@ -2972,7 +2972,7 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, | |||
2972 | u64 cont1_bytes, u64 min_bytes) | 2972 | u64 cont1_bytes, u64 min_bytes) |
2973 | { | 2973 | { |
2974 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; | 2974 | struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; |
2975 | struct btrfs_free_space *entry; | 2975 | struct btrfs_free_space *entry = NULL; |
2976 | int ret = -ENOSPC; | 2976 | int ret = -ENOSPC; |
2977 | u64 bitmap_offset = offset_to_bitmap(ctl, offset); | 2977 | u64 bitmap_offset = offset_to_bitmap(ctl, offset); |
2978 | 2978 | ||
@@ -2983,8 +2983,10 @@ setup_cluster_bitmap(struct btrfs_block_group_cache *block_group, | |||
2983 | * The bitmap that covers offset won't be in the list unless offset | 2983 | * The bitmap that covers offset won't be in the list unless offset |
2984 | * is just its start offset. | 2984 | * is just its start offset. |
2985 | */ | 2985 | */ |
2986 | entry = list_first_entry(bitmaps, struct btrfs_free_space, list); | 2986 | if (!list_empty(bitmaps)) |
2987 | if (entry->offset != bitmap_offset) { | 2987 | entry = list_first_entry(bitmaps, struct btrfs_free_space, list); |
2988 | |||
2989 | if (!entry || entry->offset != bitmap_offset) { | ||
2988 | entry = tree_search_offset(ctl, bitmap_offset, 1, 0); | 2990 | entry = tree_search_offset(ctl, bitmap_offset, 1, 0); |
2989 | if (entry && list_empty(&entry->list)) | 2991 | if (entry && list_empty(&entry->list)) |
2990 | list_add(&entry->list, bitmaps); | 2992 | list_add(&entry->list, bitmaps); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 994490d5fa64..a70c5790f8f5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -4046,9 +4046,7 @@ int btrfs_unlink_inode(struct btrfs_trans_handle *trans, | |||
4046 | */ | 4046 | */ |
4047 | static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir) | 4047 | static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir) |
4048 | { | 4048 | { |
4049 | struct btrfs_trans_handle *trans; | ||
4050 | struct btrfs_root *root = BTRFS_I(dir)->root; | 4049 | struct btrfs_root *root = BTRFS_I(dir)->root; |
4051 | int ret; | ||
4052 | 4050 | ||
4053 | /* | 4051 | /* |
4054 | * 1 for the possible orphan item | 4052 | * 1 for the possible orphan item |
@@ -4057,27 +4055,7 @@ static struct btrfs_trans_handle *__unlink_start_trans(struct inode *dir) | |||
4057 | * 1 for the inode ref | 4055 | * 1 for the inode ref |
4058 | * 1 for the inode | 4056 | * 1 for the inode |
4059 | */ | 4057 | */ |
4060 | trans = btrfs_start_transaction(root, 5); | 4058 | return btrfs_start_transaction_fallback_global_rsv(root, 5, 5); |
4061 | if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC) | ||
4062 | return trans; | ||
4063 | |||
4064 | if (PTR_ERR(trans) == -ENOSPC) { | ||
4065 | u64 num_bytes = btrfs_calc_trans_metadata_size(root, 5); | ||
4066 | |||
4067 | trans = btrfs_start_transaction(root, 0); | ||
4068 | if (IS_ERR(trans)) | ||
4069 | return trans; | ||
4070 | ret = btrfs_cond_migrate_bytes(root->fs_info, | ||
4071 | &root->fs_info->trans_block_rsv, | ||
4072 | num_bytes, 5); | ||
4073 | if (ret) { | ||
4074 | btrfs_end_transaction(trans, root); | ||
4075 | return ERR_PTR(ret); | ||
4076 | } | ||
4077 | trans->block_rsv = &root->fs_info->trans_block_rsv; | ||
4078 | trans->bytes_reserved = num_bytes; | ||
4079 | } | ||
4080 | return trans; | ||
4081 | } | 4059 | } |
4082 | 4060 | ||
4083 | static int btrfs_unlink(struct inode *dir, struct dentry *dentry) | 4061 | static int btrfs_unlink(struct inode *dir, struct dentry *dentry) |
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 93e12c18ffd7..5279fdae7142 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -993,9 +993,10 @@ int btrfs_quota_disable(struct btrfs_trans_handle *trans, | |||
993 | mutex_lock(&fs_info->qgroup_ioctl_lock); | 993 | mutex_lock(&fs_info->qgroup_ioctl_lock); |
994 | if (!fs_info->quota_root) | 994 | if (!fs_info->quota_root) |
995 | goto out; | 995 | goto out; |
996 | spin_lock(&fs_info->qgroup_lock); | ||
997 | fs_info->quota_enabled = 0; | 996 | fs_info->quota_enabled = 0; |
998 | fs_info->pending_quota_state = 0; | 997 | fs_info->pending_quota_state = 0; |
998 | btrfs_qgroup_wait_for_completion(fs_info); | ||
999 | spin_lock(&fs_info->qgroup_lock); | ||
999 | quota_root = fs_info->quota_root; | 1000 | quota_root = fs_info->quota_root; |
1000 | fs_info->quota_root = NULL; | 1001 | fs_info->quota_root = NULL; |
1001 | fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_ON; | 1002 | fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_ON; |
@@ -1461,6 +1462,8 @@ struct btrfs_qgroup_extent_record | |||
1461 | struct btrfs_qgroup_extent_record *entry; | 1462 | struct btrfs_qgroup_extent_record *entry; |
1462 | u64 bytenr = record->bytenr; | 1463 | u64 bytenr = record->bytenr; |
1463 | 1464 | ||
1465 | assert_spin_locked(&delayed_refs->lock); | ||
1466 | |||
1464 | while (*p) { | 1467 | while (*p) { |
1465 | parent_node = *p; | 1468 | parent_node = *p; |
1466 | entry = rb_entry(parent_node, struct btrfs_qgroup_extent_record, | 1469 | entry = rb_entry(parent_node, struct btrfs_qgroup_extent_record, |
diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c index 2907a77fb1f6..b091d94ceef6 100644 --- a/fs/btrfs/scrub.c +++ b/fs/btrfs/scrub.c | |||
@@ -3432,7 +3432,9 @@ out: | |||
3432 | static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, | 3432 | static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, |
3433 | struct btrfs_device *scrub_dev, | 3433 | struct btrfs_device *scrub_dev, |
3434 | u64 chunk_offset, u64 length, | 3434 | u64 chunk_offset, u64 length, |
3435 | u64 dev_offset, int is_dev_replace) | 3435 | u64 dev_offset, |
3436 | struct btrfs_block_group_cache *cache, | ||
3437 | int is_dev_replace) | ||
3436 | { | 3438 | { |
3437 | struct btrfs_mapping_tree *map_tree = | 3439 | struct btrfs_mapping_tree *map_tree = |
3438 | &sctx->dev_root->fs_info->mapping_tree; | 3440 | &sctx->dev_root->fs_info->mapping_tree; |
@@ -3445,8 +3447,18 @@ static noinline_for_stack int scrub_chunk(struct scrub_ctx *sctx, | |||
3445 | em = lookup_extent_mapping(&map_tree->map_tree, chunk_offset, 1); | 3447 | em = lookup_extent_mapping(&map_tree->map_tree, chunk_offset, 1); |
3446 | read_unlock(&map_tree->map_tree.lock); | 3448 | read_unlock(&map_tree->map_tree.lock); |
3447 | 3449 | ||
3448 | if (!em) | 3450 | if (!em) { |
3449 | return -EINVAL; | 3451 | /* |
3452 | * Might have been an unused block group deleted by the cleaner | ||
3453 | * kthread or relocation. | ||
3454 | */ | ||
3455 | spin_lock(&cache->lock); | ||
3456 | if (!cache->removed) | ||
3457 | ret = -EINVAL; | ||
3458 | spin_unlock(&cache->lock); | ||
3459 | |||
3460 | return ret; | ||
3461 | } | ||
3450 | 3462 | ||
3451 | map = (struct map_lookup *)em->bdev; | 3463 | map = (struct map_lookup *)em->bdev; |
3452 | if (em->start != chunk_offset) | 3464 | if (em->start != chunk_offset) |
@@ -3483,6 +3495,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, | |||
3483 | u64 length; | 3495 | u64 length; |
3484 | u64 chunk_offset; | 3496 | u64 chunk_offset; |
3485 | int ret = 0; | 3497 | int ret = 0; |
3498 | int ro_set; | ||
3486 | int slot; | 3499 | int slot; |
3487 | struct extent_buffer *l; | 3500 | struct extent_buffer *l; |
3488 | struct btrfs_key key; | 3501 | struct btrfs_key key; |
@@ -3568,7 +3581,21 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, | |||
3568 | scrub_pause_on(fs_info); | 3581 | scrub_pause_on(fs_info); |
3569 | ret = btrfs_inc_block_group_ro(root, cache); | 3582 | ret = btrfs_inc_block_group_ro(root, cache); |
3570 | scrub_pause_off(fs_info); | 3583 | scrub_pause_off(fs_info); |
3571 | if (ret) { | 3584 | |
3585 | if (ret == 0) { | ||
3586 | ro_set = 1; | ||
3587 | } else if (ret == -ENOSPC) { | ||
3588 | /* | ||
3589 | * btrfs_inc_block_group_ro return -ENOSPC when it | ||
3590 | * failed in creating new chunk for metadata. | ||
3591 | * It is not a problem for scrub/replace, because | ||
3592 | * metadata are always cowed, and our scrub paused | ||
3593 | * commit_transactions. | ||
3594 | */ | ||
3595 | ro_set = 0; | ||
3596 | } else { | ||
3597 | btrfs_warn(fs_info, "failed setting block group ro, ret=%d\n", | ||
3598 | ret); | ||
3572 | btrfs_put_block_group(cache); | 3599 | btrfs_put_block_group(cache); |
3573 | break; | 3600 | break; |
3574 | } | 3601 | } |
@@ -3577,7 +3604,7 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, | |||
3577 | dev_replace->cursor_left = found_key.offset; | 3604 | dev_replace->cursor_left = found_key.offset; |
3578 | dev_replace->item_needs_writeback = 1; | 3605 | dev_replace->item_needs_writeback = 1; |
3579 | ret = scrub_chunk(sctx, scrub_dev, chunk_offset, length, | 3606 | ret = scrub_chunk(sctx, scrub_dev, chunk_offset, length, |
3580 | found_key.offset, is_dev_replace); | 3607 | found_key.offset, cache, is_dev_replace); |
3581 | 3608 | ||
3582 | /* | 3609 | /* |
3583 | * flush, submit all pending read and write bios, afterwards | 3610 | * flush, submit all pending read and write bios, afterwards |
@@ -3611,7 +3638,30 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, | |||
3611 | 3638 | ||
3612 | scrub_pause_off(fs_info); | 3639 | scrub_pause_off(fs_info); |
3613 | 3640 | ||
3614 | btrfs_dec_block_group_ro(root, cache); | 3641 | if (ro_set) |
3642 | btrfs_dec_block_group_ro(root, cache); | ||
3643 | |||
3644 | /* | ||
3645 | * We might have prevented the cleaner kthread from deleting | ||
3646 | * this block group if it was already unused because we raced | ||
3647 | * and set it to RO mode first. So add it back to the unused | ||
3648 | * list, otherwise it might not ever be deleted unless a manual | ||
3649 | * balance is triggered or it becomes used and unused again. | ||
3650 | */ | ||
3651 | spin_lock(&cache->lock); | ||
3652 | if (!cache->removed && !cache->ro && cache->reserved == 0 && | ||
3653 | btrfs_block_group_used(&cache->item) == 0) { | ||
3654 | spin_unlock(&cache->lock); | ||
3655 | spin_lock(&fs_info->unused_bgs_lock); | ||
3656 | if (list_empty(&cache->bg_list)) { | ||
3657 | btrfs_get_block_group(cache); | ||
3658 | list_add_tail(&cache->bg_list, | ||
3659 | &fs_info->unused_bgs); | ||
3660 | } | ||
3661 | spin_unlock(&fs_info->unused_bgs_lock); | ||
3662 | } else { | ||
3663 | spin_unlock(&cache->lock); | ||
3664 | } | ||
3615 | 3665 | ||
3616 | btrfs_put_block_group(cache); | 3666 | btrfs_put_block_group(cache); |
3617 | if (ret) | 3667 | if (ret) |
diff --git a/fs/btrfs/tests/free-space-tests.c b/fs/btrfs/tests/free-space-tests.c index c8c3d70c31ff..8b72b005bfb9 100644 --- a/fs/btrfs/tests/free-space-tests.c +++ b/fs/btrfs/tests/free-space-tests.c | |||
@@ -898,8 +898,10 @@ int btrfs_test_free_space_cache(void) | |||
898 | } | 898 | } |
899 | 899 | ||
900 | root = btrfs_alloc_dummy_root(); | 900 | root = btrfs_alloc_dummy_root(); |
901 | if (!root) | 901 | if (IS_ERR(root)) { |
902 | ret = PTR_ERR(root); | ||
902 | goto out; | 903 | goto out; |
904 | } | ||
903 | 905 | ||
904 | root->fs_info = btrfs_alloc_dummy_fs_info(); | 906 | root->fs_info = btrfs_alloc_dummy_fs_info(); |
905 | if (!root->fs_info) | 907 | if (!root->fs_info) |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 418c6a2ad7d8..be8eae80ff65 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -274,7 +274,6 @@ loop: | |||
274 | cur_trans->num_dirty_bgs = 0; | 274 | cur_trans->num_dirty_bgs = 0; |
275 | spin_lock_init(&cur_trans->dirty_bgs_lock); | 275 | spin_lock_init(&cur_trans->dirty_bgs_lock); |
276 | INIT_LIST_HEAD(&cur_trans->deleted_bgs); | 276 | INIT_LIST_HEAD(&cur_trans->deleted_bgs); |
277 | spin_lock_init(&cur_trans->deleted_bgs_lock); | ||
278 | spin_lock_init(&cur_trans->dropped_roots_lock); | 277 | spin_lock_init(&cur_trans->dropped_roots_lock); |
279 | list_add_tail(&cur_trans->list, &fs_info->trans_list); | 278 | list_add_tail(&cur_trans->list, &fs_info->trans_list); |
280 | extent_io_tree_init(&cur_trans->dirty_pages, | 279 | extent_io_tree_init(&cur_trans->dirty_pages, |
@@ -592,6 +591,38 @@ struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, | |||
592 | return start_transaction(root, num_items, TRANS_START, | 591 | return start_transaction(root, num_items, TRANS_START, |
593 | BTRFS_RESERVE_FLUSH_ALL); | 592 | BTRFS_RESERVE_FLUSH_ALL); |
594 | } | 593 | } |
594 | struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv( | ||
595 | struct btrfs_root *root, | ||
596 | unsigned int num_items, | ||
597 | int min_factor) | ||
598 | { | ||
599 | struct btrfs_trans_handle *trans; | ||
600 | u64 num_bytes; | ||
601 | int ret; | ||
602 | |||
603 | trans = btrfs_start_transaction(root, num_items); | ||
604 | if (!IS_ERR(trans) || PTR_ERR(trans) != -ENOSPC) | ||
605 | return trans; | ||
606 | |||
607 | trans = btrfs_start_transaction(root, 0); | ||
608 | if (IS_ERR(trans)) | ||
609 | return trans; | ||
610 | |||
611 | num_bytes = btrfs_calc_trans_metadata_size(root, num_items); | ||
612 | ret = btrfs_cond_migrate_bytes(root->fs_info, | ||
613 | &root->fs_info->trans_block_rsv, | ||
614 | num_bytes, | ||
615 | min_factor); | ||
616 | if (ret) { | ||
617 | btrfs_end_transaction(trans, root); | ||
618 | return ERR_PTR(ret); | ||
619 | } | ||
620 | |||
621 | trans->block_rsv = &root->fs_info->trans_block_rsv; | ||
622 | trans->bytes_reserved = num_bytes; | ||
623 | |||
624 | return trans; | ||
625 | } | ||
595 | 626 | ||
596 | struct btrfs_trans_handle *btrfs_start_transaction_lflush( | 627 | struct btrfs_trans_handle *btrfs_start_transaction_lflush( |
597 | struct btrfs_root *root, | 628 | struct btrfs_root *root, |
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index b05b2f64d913..64c8221b6165 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
@@ -77,8 +77,8 @@ struct btrfs_transaction { | |||
77 | */ | 77 | */ |
78 | struct mutex cache_write_mutex; | 78 | struct mutex cache_write_mutex; |
79 | spinlock_t dirty_bgs_lock; | 79 | spinlock_t dirty_bgs_lock; |
80 | /* Protected by spin lock fs_info->unused_bgs_lock. */ | ||
80 | struct list_head deleted_bgs; | 81 | struct list_head deleted_bgs; |
81 | spinlock_t deleted_bgs_lock; | ||
82 | spinlock_t dropped_roots_lock; | 82 | spinlock_t dropped_roots_lock; |
83 | struct btrfs_delayed_ref_root delayed_refs; | 83 | struct btrfs_delayed_ref_root delayed_refs; |
84 | int aborted; | 84 | int aborted; |
@@ -185,6 +185,10 @@ int btrfs_end_transaction(struct btrfs_trans_handle *trans, | |||
185 | struct btrfs_root *root); | 185 | struct btrfs_root *root); |
186 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, | 186 | struct btrfs_trans_handle *btrfs_start_transaction(struct btrfs_root *root, |
187 | unsigned int num_items); | 187 | unsigned int num_items); |
188 | struct btrfs_trans_handle *btrfs_start_transaction_fallback_global_rsv( | ||
189 | struct btrfs_root *root, | ||
190 | unsigned int num_items, | ||
191 | int min_factor); | ||
188 | struct btrfs_trans_handle *btrfs_start_transaction_lflush( | 192 | struct btrfs_trans_handle *btrfs_start_transaction_lflush( |
189 | struct btrfs_root *root, | 193 | struct btrfs_root *root, |
190 | unsigned int num_items); | 194 | unsigned int num_items); |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index a6df8fdc1312..a23399e8e3ab 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -1973,8 +1973,7 @@ void btrfs_rm_dev_replace_remove_srcdev(struct btrfs_fs_info *fs_info, | |||
1973 | if (srcdev->writeable) { | 1973 | if (srcdev->writeable) { |
1974 | fs_devices->rw_devices--; | 1974 | fs_devices->rw_devices--; |
1975 | /* zero out the old super if it is writable */ | 1975 | /* zero out the old super if it is writable */ |
1976 | btrfs_scratch_superblocks(srcdev->bdev, | 1976 | btrfs_scratch_superblocks(srcdev->bdev, srcdev->name->str); |
1977 | rcu_str_deref(srcdev->name)); | ||
1978 | } | 1977 | } |
1979 | 1978 | ||
1980 | if (srcdev->bdev) | 1979 | if (srcdev->bdev) |
@@ -2024,8 +2023,7 @@ void btrfs_destroy_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, | |||
2024 | btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev); | 2023 | btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev); |
2025 | 2024 | ||
2026 | if (tgtdev->bdev) { | 2025 | if (tgtdev->bdev) { |
2027 | btrfs_scratch_superblocks(tgtdev->bdev, | 2026 | btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str); |
2028 | rcu_str_deref(tgtdev->name)); | ||
2029 | fs_info->fs_devices->open_devices--; | 2027 | fs_info->fs_devices->open_devices--; |
2030 | } | 2028 | } |
2031 | fs_info->fs_devices->num_devices--; | 2029 | fs_info->fs_devices->num_devices--; |
@@ -2853,7 +2851,8 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset) | |||
2853 | if (ret) | 2851 | if (ret) |
2854 | return ret; | 2852 | return ret; |
2855 | 2853 | ||
2856 | trans = btrfs_start_transaction(root, 0); | 2854 | trans = btrfs_start_trans_remove_block_group(root->fs_info, |
2855 | chunk_offset); | ||
2857 | if (IS_ERR(trans)) { | 2856 | if (IS_ERR(trans)) { |
2858 | ret = PTR_ERR(trans); | 2857 | ret = PTR_ERR(trans); |
2859 | btrfs_std_error(root->fs_info, ret, NULL); | 2858 | btrfs_std_error(root->fs_info, ret, NULL); |
@@ -3123,7 +3122,7 @@ static int chunk_profiles_filter(u64 chunk_type, | |||
3123 | return 1; | 3122 | return 1; |
3124 | } | 3123 | } |
3125 | 3124 | ||
3126 | static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, | 3125 | static int chunk_usage_range_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, |
3127 | struct btrfs_balance_args *bargs) | 3126 | struct btrfs_balance_args *bargs) |
3128 | { | 3127 | { |
3129 | struct btrfs_block_group_cache *cache; | 3128 | struct btrfs_block_group_cache *cache; |
@@ -3156,7 +3155,7 @@ static int chunk_usage_filter(struct btrfs_fs_info *fs_info, u64 chunk_offset, | |||
3156 | return ret; | 3155 | return ret; |
3157 | } | 3156 | } |
3158 | 3157 | ||
3159 | static int chunk_usage_range_filter(struct btrfs_fs_info *fs_info, | 3158 | static int chunk_usage_filter(struct btrfs_fs_info *fs_info, |
3160 | u64 chunk_offset, struct btrfs_balance_args *bargs) | 3159 | u64 chunk_offset, struct btrfs_balance_args *bargs) |
3161 | { | 3160 | { |
3162 | struct btrfs_block_group_cache *cache; | 3161 | struct btrfs_block_group_cache *cache; |
@@ -3549,12 +3548,11 @@ again: | |||
3549 | 3548 | ||
3550 | ret = btrfs_force_chunk_alloc(trans, chunk_root, | 3549 | ret = btrfs_force_chunk_alloc(trans, chunk_root, |
3551 | BTRFS_BLOCK_GROUP_DATA); | 3550 | BTRFS_BLOCK_GROUP_DATA); |
3551 | btrfs_end_transaction(trans, chunk_root); | ||
3552 | if (ret < 0) { | 3552 | if (ret < 0) { |
3553 | mutex_unlock(&fs_info->delete_unused_bgs_mutex); | 3553 | mutex_unlock(&fs_info->delete_unused_bgs_mutex); |
3554 | goto error; | 3554 | goto error; |
3555 | } | 3555 | } |
3556 | |||
3557 | btrfs_end_transaction(trans, chunk_root); | ||
3558 | chunk_reserved = 1; | 3556 | chunk_reserved = 1; |
3559 | } | 3557 | } |
3560 | 3558 | ||
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index ec5712372732..d5c84f6b1353 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -382,7 +382,7 @@ struct map_lookup { | |||
382 | #define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5) | 382 | #define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5) |
383 | #define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6) | 383 | #define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6) |
384 | #define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7) | 384 | #define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7) |
385 | #define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 8) | 385 | #define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10) |
386 | 386 | ||
387 | #define BTRFS_BALANCE_ARGS_MASK \ | 387 | #define BTRFS_BALANCE_ARGS_MASK \ |
388 | (BTRFS_BALANCE_ARGS_PROFILES | \ | 388 | (BTRFS_BALANCE_ARGS_PROFILES | \ |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 6b66dd5d1540..a329f5ba35aa 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
@@ -1831,11 +1831,11 @@ cifs_invalidate_mapping(struct inode *inode) | |||
1831 | * @word: long word containing the bit lock | 1831 | * @word: long word containing the bit lock |
1832 | */ | 1832 | */ |
1833 | static int | 1833 | static int |
1834 | cifs_wait_bit_killable(struct wait_bit_key *key) | 1834 | cifs_wait_bit_killable(struct wait_bit_key *key, int mode) |
1835 | { | 1835 | { |
1836 | if (fatal_signal_pending(current)) | ||
1837 | return -ERESTARTSYS; | ||
1838 | freezable_schedule_unsafe(); | 1836 | freezable_schedule_unsafe(); |
1837 | if (signal_pending_state(mode, current)) | ||
1838 | return -ERESTARTSYS; | ||
1839 | return 0; | 1839 | return 0; |
1840 | } | 1840 | } |
1841 | 1841 | ||
diff --git a/fs/direct-io.c b/fs/direct-io.c index cb5337d8c273..602e8441bc0f 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c | |||
@@ -1169,6 +1169,16 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, | |||
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | 1171 | ||
1172 | /* Once we sampled i_size check for reads beyond EOF */ | ||
1173 | dio->i_size = i_size_read(inode); | ||
1174 | if (iov_iter_rw(iter) == READ && offset >= dio->i_size) { | ||
1175 | if (dio->flags & DIO_LOCKING) | ||
1176 | mutex_unlock(&inode->i_mutex); | ||
1177 | kmem_cache_free(dio_cache, dio); | ||
1178 | retval = 0; | ||
1179 | goto out; | ||
1180 | } | ||
1181 | |||
1172 | /* | 1182 | /* |
1173 | * For file extending writes updating i_size before data writeouts | 1183 | * For file extending writes updating i_size before data writeouts |
1174 | * complete can expose uninitialized blocks in dumb filesystems. | 1184 | * complete can expose uninitialized blocks in dumb filesystems. |
@@ -1222,7 +1232,6 @@ do_blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, | |||
1222 | sdio.next_block_for_io = -1; | 1232 | sdio.next_block_for_io = -1; |
1223 | 1233 | ||
1224 | dio->iocb = iocb; | 1234 | dio->iocb = iocb; |
1225 | dio->i_size = i_size_read(inode); | ||
1226 | 1235 | ||
1227 | spin_lock_init(&dio->bio_lock); | 1236 | spin_lock_init(&dio->bio_lock); |
1228 | dio->refcount = 1; | 1237 | dio->refcount = 1; |
diff --git a/fs/dlm/lowcomms.c b/fs/dlm/lowcomms.c index 87e9d796cf7d..3a37bd3f9637 100644 --- a/fs/dlm/lowcomms.c +++ b/fs/dlm/lowcomms.c | |||
@@ -421,7 +421,7 @@ static void lowcomms_write_space(struct sock *sk) | |||
421 | 421 | ||
422 | if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) { | 422 | if (test_and_clear_bit(CF_APP_LIMITED, &con->flags)) { |
423 | con->sock->sk->sk_write_pending--; | 423 | con->sock->sk->sk_write_pending--; |
424 | clear_bit(SOCK_ASYNC_NOSPACE, &con->sock->flags); | 424 | clear_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags); |
425 | } | 425 | } |
426 | 426 | ||
427 | if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) | 427 | if (!test_and_set_bit(CF_WRITE_PENDING, &con->flags)) |
@@ -1448,7 +1448,7 @@ static void send_to_sock(struct connection *con) | |||
1448 | msg_flags); | 1448 | msg_flags); |
1449 | if (ret == -EAGAIN || ret == 0) { | 1449 | if (ret == -EAGAIN || ret == 0) { |
1450 | if (ret == -EAGAIN && | 1450 | if (ret == -EAGAIN && |
1451 | test_bit(SOCK_ASYNC_NOSPACE, &con->sock->flags) && | 1451 | test_bit(SOCKWQ_ASYNC_NOSPACE, &con->sock->flags) && |
1452 | !test_and_set_bit(CF_APP_LIMITED, &con->flags)) { | 1452 | !test_and_set_bit(CF_APP_LIMITED, &con->flags)) { |
1453 | /* Notify TCP that we're limited by the | 1453 | /* Notify TCP that we're limited by the |
1454 | * application window size. | 1454 | * application window size. |
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 73c64daa0f55..60f03b78914e 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c | |||
@@ -592,10 +592,7 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) | |||
592 | } | 592 | } |
593 | unlock_page(page); | 593 | unlock_page(page); |
594 | } | 594 | } |
595 | if (PageDirty(page) || PageWriteback(page)) | 595 | *uptodate = PageUptodate(page); |
596 | *uptodate = true; | ||
597 | else | ||
598 | *uptodate = PageUptodate(page); | ||
599 | EXOFS_DBGMSG2("index=0x%lx uptodate=%d\n", index, *uptodate); | 596 | EXOFS_DBGMSG2("index=0x%lx uptodate=%d\n", index, *uptodate); |
600 | return page; | 597 | return page; |
601 | } else { | 598 | } else { |
diff --git a/fs/ext4/crypto.c b/fs/ext4/crypto.c index af06830bfc00..1a0835073663 100644 --- a/fs/ext4/crypto.c +++ b/fs/ext4/crypto.c | |||
@@ -389,7 +389,7 @@ int ext4_encrypted_zeroout(struct inode *inode, struct ext4_extent *ex) | |||
389 | struct ext4_crypto_ctx *ctx; | 389 | struct ext4_crypto_ctx *ctx; |
390 | struct page *ciphertext_page = NULL; | 390 | struct page *ciphertext_page = NULL; |
391 | struct bio *bio; | 391 | struct bio *bio; |
392 | ext4_lblk_t lblk = ex->ee_block; | 392 | ext4_lblk_t lblk = le32_to_cpu(ex->ee_block); |
393 | ext4_fsblk_t pblk = ext4_ext_pblock(ex); | 393 | ext4_fsblk_t pblk = ext4_ext_pblock(ex); |
394 | unsigned int len = ext4_ext_get_actual_len(ex); | 394 | unsigned int len = ext4_ext_get_actual_len(ex); |
395 | int ret, err = 0; | 395 | int ret, err = 0; |
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 750063f7a50c..cc7ca4e87144 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/seqlock.h> | 26 | #include <linux/seqlock.h> |
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/timer.h> | 28 | #include <linux/timer.h> |
29 | #include <linux/version.h> | ||
29 | #include <linux/wait.h> | 30 | #include <linux/wait.h> |
30 | #include <linux/blockgroup_lock.h> | 31 | #include <linux/blockgroup_lock.h> |
31 | #include <linux/percpu_counter.h> | 32 | #include <linux/percpu_counter.h> |
@@ -727,19 +728,55 @@ struct move_extent { | |||
727 | <= (EXT4_GOOD_OLD_INODE_SIZE + \ | 728 | <= (EXT4_GOOD_OLD_INODE_SIZE + \ |
728 | (einode)->i_extra_isize)) \ | 729 | (einode)->i_extra_isize)) \ |
729 | 730 | ||
731 | /* | ||
732 | * We use an encoding that preserves the times for extra epoch "00": | ||
733 | * | ||
734 | * extra msb of adjust for signed | ||
735 | * epoch 32-bit 32-bit tv_sec to | ||
736 | * bits time decoded 64-bit tv_sec 64-bit tv_sec valid time range | ||
737 | * 0 0 1 -0x80000000..-0x00000001 0x000000000 1901-12-13..1969-12-31 | ||
738 | * 0 0 0 0x000000000..0x07fffffff 0x000000000 1970-01-01..2038-01-19 | ||
739 | * 0 1 1 0x080000000..0x0ffffffff 0x100000000 2038-01-19..2106-02-07 | ||
740 | * 0 1 0 0x100000000..0x17fffffff 0x100000000 2106-02-07..2174-02-25 | ||
741 | * 1 0 1 0x180000000..0x1ffffffff 0x200000000 2174-02-25..2242-03-16 | ||
742 | * 1 0 0 0x200000000..0x27fffffff 0x200000000 2242-03-16..2310-04-04 | ||
743 | * 1 1 1 0x280000000..0x2ffffffff 0x300000000 2310-04-04..2378-04-22 | ||
744 | * 1 1 0 0x300000000..0x37fffffff 0x300000000 2378-04-22..2446-05-10 | ||
745 | * | ||
746 | * Note that previous versions of the kernel on 64-bit systems would | ||
747 | * incorrectly use extra epoch bits 1,1 for dates between 1901 and | ||
748 | * 1970. e2fsck will correct this, assuming that it is run on the | ||
749 | * affected filesystem before 2242. | ||
750 | */ | ||
751 | |||
730 | static inline __le32 ext4_encode_extra_time(struct timespec *time) | 752 | static inline __le32 ext4_encode_extra_time(struct timespec *time) |
731 | { | 753 | { |
732 | return cpu_to_le32((sizeof(time->tv_sec) > 4 ? | 754 | u32 extra = sizeof(time->tv_sec) > 4 ? |
733 | (time->tv_sec >> 32) & EXT4_EPOCH_MASK : 0) | | 755 | ((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK : 0; |
734 | ((time->tv_nsec << EXT4_EPOCH_BITS) & EXT4_NSEC_MASK)); | 756 | return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS)); |
735 | } | 757 | } |
736 | 758 | ||
737 | static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) | 759 | static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) |
738 | { | 760 | { |
739 | if (sizeof(time->tv_sec) > 4) | 761 | if (unlikely(sizeof(time->tv_sec) > 4 && |
740 | time->tv_sec |= (__u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) | 762 | (extra & cpu_to_le32(EXT4_EPOCH_MASK)))) { |
741 | << 32; | 763 | #if LINUX_VERSION_CODE < KERNEL_VERSION(4,20,0) |
742 | time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; | 764 | /* Handle legacy encoding of pre-1970 dates with epoch |
765 | * bits 1,1. We assume that by kernel version 4.20, | ||
766 | * everyone will have run fsck over the affected | ||
767 | * filesystems to correct the problem. (This | ||
768 | * backwards compatibility may be removed before this | ||
769 | * time, at the discretion of the ext4 developers.) | ||
770 | */ | ||
771 | u64 extra_bits = le32_to_cpu(extra) & EXT4_EPOCH_MASK; | ||
772 | if (extra_bits == 3 && ((time->tv_sec) & 0x80000000) != 0) | ||
773 | extra_bits = 0; | ||
774 | time->tv_sec += extra_bits << 32; | ||
775 | #else | ||
776 | time->tv_sec += (u64)(le32_to_cpu(extra) & EXT4_EPOCH_MASK) << 32; | ||
777 | #endif | ||
778 | } | ||
779 | time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; | ||
743 | } | 780 | } |
744 | 781 | ||
745 | #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \ | 782 | #define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode) \ |
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c index abe2401ce405..e8e7af62ac95 100644 --- a/fs/ext4/symlink.c +++ b/fs/ext4/symlink.c | |||
@@ -52,7 +52,7 @@ static const char *ext4_encrypted_follow_link(struct dentry *dentry, void **cook | |||
52 | /* Symlink is encrypted */ | 52 | /* Symlink is encrypted */ |
53 | sd = (struct ext4_encrypted_symlink_data *)caddr; | 53 | sd = (struct ext4_encrypted_symlink_data *)caddr; |
54 | cstr.name = sd->encrypted_path; | 54 | cstr.name = sd->encrypted_path; |
55 | cstr.len = le32_to_cpu(sd->len); | 55 | cstr.len = le16_to_cpu(sd->len); |
56 | if ((cstr.len + | 56 | if ((cstr.len + |
57 | sizeof(struct ext4_encrypted_symlink_data) - 1) > | 57 | sizeof(struct ext4_encrypted_symlink_data) - 1) > |
58 | max_size) { | 58 | max_size) { |
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c index 1b57c72f4a00..1420a3c614af 100644 --- a/fs/ext4/sysfs.c +++ b/fs/ext4/sysfs.c | |||
@@ -358,7 +358,7 @@ static int name##_open(struct inode *inode, struct file *file) \ | |||
358 | return single_open(file, ext4_seq_##name##_show, PDE_DATA(inode)); \ | 358 | return single_open(file, ext4_seq_##name##_show, PDE_DATA(inode)); \ |
359 | } \ | 359 | } \ |
360 | \ | 360 | \ |
361 | const struct file_operations ext4_seq_##name##_fops = { \ | 361 | static const struct file_operations ext4_seq_##name##_fops = { \ |
362 | .owner = THIS_MODULE, \ | 362 | .owner = THIS_MODULE, \ |
363 | .open = name##_open, \ | 363 | .open = name##_open, \ |
364 | .read = seq_read, \ | 364 | .read = seq_read, \ |
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index eae2c11268bc..8e3ee1936c7e 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c | |||
@@ -549,6 +549,8 @@ static int cuse_channel_release(struct inode *inode, struct file *file) | |||
549 | unregister_chrdev_region(cc->cdev->dev, 1); | 549 | unregister_chrdev_region(cc->cdev->dev, 1); |
550 | cdev_del(cc->cdev); | 550 | cdev_del(cc->cdev); |
551 | } | 551 | } |
552 | /* Base reference is now owned by "fud" */ | ||
553 | fuse_conn_put(&cc->fc); | ||
552 | 554 | ||
553 | rc = fuse_dev_release(inode, file); /* puts the base reference */ | 555 | rc = fuse_dev_release(inode, file); /* puts the base reference */ |
554 | 556 | ||
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index e0faf8f2c868..570ca4053c80 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
@@ -1049,6 +1049,7 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req, | |||
1049 | tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes); | 1049 | tmp = iov_iter_copy_from_user_atomic(page, ii, offset, bytes); |
1050 | flush_dcache_page(page); | 1050 | flush_dcache_page(page); |
1051 | 1051 | ||
1052 | iov_iter_advance(ii, tmp); | ||
1052 | if (!tmp) { | 1053 | if (!tmp) { |
1053 | unlock_page(page); | 1054 | unlock_page(page); |
1054 | page_cache_release(page); | 1055 | page_cache_release(page); |
@@ -1061,7 +1062,6 @@ static ssize_t fuse_fill_write_pages(struct fuse_req *req, | |||
1061 | req->page_descs[req->num_pages].length = tmp; | 1062 | req->page_descs[req->num_pages].length = tmp; |
1062 | req->num_pages++; | 1063 | req->num_pages++; |
1063 | 1064 | ||
1064 | iov_iter_advance(ii, tmp); | ||
1065 | count += tmp; | 1065 | count += tmp; |
1066 | pos += tmp; | 1066 | pos += tmp; |
1067 | offset += tmp; | 1067 | offset += tmp; |
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 89463eee6791..ca181e81c765 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
@@ -1009,7 +1009,8 @@ out: | |||
1009 | } | 1009 | } |
1010 | 1010 | ||
1011 | /* Fast check whether buffer is already attached to the required transaction */ | 1011 | /* Fast check whether buffer is already attached to the required transaction */ |
1012 | static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh) | 1012 | static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh, |
1013 | bool undo) | ||
1013 | { | 1014 | { |
1014 | struct journal_head *jh; | 1015 | struct journal_head *jh; |
1015 | bool ret = false; | 1016 | bool ret = false; |
@@ -1036,6 +1037,9 @@ static bool jbd2_write_access_granted(handle_t *handle, struct buffer_head *bh) | |||
1036 | jh = READ_ONCE(bh->b_private); | 1037 | jh = READ_ONCE(bh->b_private); |
1037 | if (!jh) | 1038 | if (!jh) |
1038 | goto out; | 1039 | goto out; |
1040 | /* For undo access buffer must have data copied */ | ||
1041 | if (undo && !jh->b_committed_data) | ||
1042 | goto out; | ||
1039 | if (jh->b_transaction != handle->h_transaction && | 1043 | if (jh->b_transaction != handle->h_transaction && |
1040 | jh->b_next_transaction != handle->h_transaction) | 1044 | jh->b_next_transaction != handle->h_transaction) |
1041 | goto out; | 1045 | goto out; |
@@ -1073,7 +1077,7 @@ int jbd2_journal_get_write_access(handle_t *handle, struct buffer_head *bh) | |||
1073 | struct journal_head *jh; | 1077 | struct journal_head *jh; |
1074 | int rc; | 1078 | int rc; |
1075 | 1079 | ||
1076 | if (jbd2_write_access_granted(handle, bh)) | 1080 | if (jbd2_write_access_granted(handle, bh, false)) |
1077 | return 0; | 1081 | return 0; |
1078 | 1082 | ||
1079 | jh = jbd2_journal_add_journal_head(bh); | 1083 | jh = jbd2_journal_add_journal_head(bh); |
@@ -1210,7 +1214,7 @@ int jbd2_journal_get_undo_access(handle_t *handle, struct buffer_head *bh) | |||
1210 | char *committed_data = NULL; | 1214 | char *committed_data = NULL; |
1211 | 1215 | ||
1212 | JBUFFER_TRACE(jh, "entry"); | 1216 | JBUFFER_TRACE(jh, "entry"); |
1213 | if (jbd2_write_access_granted(handle, bh)) | 1217 | if (jbd2_write_access_granted(handle, bh, true)) |
1214 | return 0; | 1218 | return 0; |
1215 | 1219 | ||
1216 | jh = jbd2_journal_add_journal_head(bh); | 1220 | jh = jbd2_journal_add_journal_head(bh); |
@@ -2152,6 +2156,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, | |||
2152 | 2156 | ||
2153 | if (!buffer_dirty(bh)) { | 2157 | if (!buffer_dirty(bh)) { |
2154 | /* bdflush has written it. We can drop it now */ | 2158 | /* bdflush has written it. We can drop it now */ |
2159 | __jbd2_journal_remove_checkpoint(jh); | ||
2155 | goto zap_buffer; | 2160 | goto zap_buffer; |
2156 | } | 2161 | } |
2157 | 2162 | ||
@@ -2181,6 +2186,7 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh, | |||
2181 | /* The orphan record's transaction has | 2186 | /* The orphan record's transaction has |
2182 | * committed. We can cleanse this buffer */ | 2187 | * committed. We can cleanse this buffer */ |
2183 | clear_buffer_jbddirty(bh); | 2188 | clear_buffer_jbddirty(bh); |
2189 | __jbd2_journal_remove_checkpoint(jh); | ||
2184 | goto zap_buffer; | 2190 | goto zap_buffer; |
2185 | } | 2191 | } |
2186 | } | 2192 | } |
diff --git a/fs/namei.c b/fs/namei.c index d84d7c7515fc..0c3974cd3ecd 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
@@ -1996,7 +1996,6 @@ static const char *path_init(struct nameidata *nd, unsigned flags) | |||
1996 | nd->last_type = LAST_ROOT; /* if there are only slashes... */ | 1996 | nd->last_type = LAST_ROOT; /* if there are only slashes... */ |
1997 | nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT; | 1997 | nd->flags = flags | LOOKUP_JUMPED | LOOKUP_PARENT; |
1998 | nd->depth = 0; | 1998 | nd->depth = 0; |
1999 | nd->total_link_count = 0; | ||
2000 | if (flags & LOOKUP_ROOT) { | 1999 | if (flags & LOOKUP_ROOT) { |
2001 | struct dentry *root = nd->root.dentry; | 2000 | struct dentry *root = nd->root.dentry; |
2002 | struct inode *inode = root->d_inode; | 2001 | struct inode *inode = root->d_inode; |
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 326d9e10d833..c7e8b87da5b2 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -75,11 +75,11 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr) | |||
75 | * nfs_wait_bit_killable - helper for functions that are sleeping on bit locks | 75 | * nfs_wait_bit_killable - helper for functions that are sleeping on bit locks |
76 | * @word: long word containing the bit lock | 76 | * @word: long word containing the bit lock |
77 | */ | 77 | */ |
78 | int nfs_wait_bit_killable(struct wait_bit_key *key) | 78 | int nfs_wait_bit_killable(struct wait_bit_key *key, int mode) |
79 | { | 79 | { |
80 | if (fatal_signal_pending(current)) | ||
81 | return -ERESTARTSYS; | ||
82 | freezable_schedule_unsafe(); | 80 | freezable_schedule_unsafe(); |
81 | if (signal_pending_state(mode, current)) | ||
82 | return -ERESTARTSYS; | ||
83 | return 0; | 83 | return 0; |
84 | } | 84 | } |
85 | EXPORT_SYMBOL_GPL(nfs_wait_bit_killable); | 85 | EXPORT_SYMBOL_GPL(nfs_wait_bit_killable); |
@@ -618,7 +618,10 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, | |||
618 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); | 618 | nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC); |
619 | nfs_vmtruncate(inode, attr->ia_size); | 619 | nfs_vmtruncate(inode, attr->ia_size); |
620 | } | 620 | } |
621 | nfs_update_inode(inode, fattr); | 621 | if (fattr->valid) |
622 | nfs_update_inode(inode, fattr); | ||
623 | else | ||
624 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATTR; | ||
622 | spin_unlock(&inode->i_lock); | 625 | spin_unlock(&inode->i_lock); |
623 | } | 626 | } |
624 | EXPORT_SYMBOL_GPL(nfs_setattr_update_inode); | 627 | EXPORT_SYMBOL_GPL(nfs_setattr_update_inode); |
@@ -1824,7 +1827,11 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1824 | if ((long)fattr->gencount - (long)nfsi->attr_gencount > 0) | 1827 | if ((long)fattr->gencount - (long)nfsi->attr_gencount > 0) |
1825 | nfsi->attr_gencount = fattr->gencount; | 1828 | nfsi->attr_gencount = fattr->gencount; |
1826 | } | 1829 | } |
1827 | invalid &= ~NFS_INO_INVALID_ATTR; | 1830 | |
1831 | /* Don't declare attrcache up to date if there were no attrs! */ | ||
1832 | if (fattr->valid != 0) | ||
1833 | invalid &= ~NFS_INO_INVALID_ATTR; | ||
1834 | |||
1828 | /* Don't invalidate the data if we were to blame */ | 1835 | /* Don't invalidate the data if we were to blame */ |
1829 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) | 1836 | if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) |
1830 | || S_ISLNK(inode->i_mode))) | 1837 | || S_ISLNK(inode->i_mode))) |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 56cfde26fb9c..9dea85f7f918 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
@@ -379,7 +379,7 @@ extern int nfs_drop_inode(struct inode *); | |||
379 | extern void nfs_clear_inode(struct inode *); | 379 | extern void nfs_clear_inode(struct inode *); |
380 | extern void nfs_evict_inode(struct inode *); | 380 | extern void nfs_evict_inode(struct inode *); |
381 | void nfs_zap_acl_cache(struct inode *inode); | 381 | void nfs_zap_acl_cache(struct inode *inode); |
382 | extern int nfs_wait_bit_killable(struct wait_bit_key *key); | 382 | extern int nfs_wait_bit_killable(struct wait_bit_key *key, int mode); |
383 | 383 | ||
384 | /* super.c */ | 384 | /* super.c */ |
385 | extern const struct super_operations nfs_sops; | 385 | extern const struct super_operations nfs_sops; |
diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 3e92a3cde15d..6b1ce9825430 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include "pnfs.h" | 14 | #include "pnfs.h" |
15 | #include "internal.h" | 15 | #include "internal.h" |
16 | 16 | ||
17 | #define NFSDBG_FACILITY NFSDBG_PNFS | 17 | #define NFSDBG_FACILITY NFSDBG_PROC |
18 | 18 | ||
19 | static int nfs42_set_rw_stateid(nfs4_stateid *dst, struct file *file, | 19 | static int nfs42_set_rw_stateid(nfs4_stateid *dst, struct file *file, |
20 | fmode_t fmode) | 20 | fmode_t fmode) |
@@ -284,6 +284,7 @@ static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f, | |||
284 | .dst_fh = NFS_FH(dst_inode), | 284 | .dst_fh = NFS_FH(dst_inode), |
285 | .src_offset = src_offset, | 285 | .src_offset = src_offset, |
286 | .dst_offset = dst_offset, | 286 | .dst_offset = dst_offset, |
287 | .count = count, | ||
287 | .dst_bitmask = server->cache_consistency_bitmask, | 288 | .dst_bitmask = server->cache_consistency_bitmask, |
288 | }; | 289 | }; |
289 | struct nfs42_clone_res res = { | 290 | struct nfs42_clone_res res = { |
diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 223bedda64ae..10410e8b5853 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c | |||
@@ -33,7 +33,7 @@ static int nfs_get_cb_ident_idr(struct nfs_client *clp, int minorversion) | |||
33 | return ret; | 33 | return ret; |
34 | idr_preload(GFP_KERNEL); | 34 | idr_preload(GFP_KERNEL); |
35 | spin_lock(&nn->nfs_client_lock); | 35 | spin_lock(&nn->nfs_client_lock); |
36 | ret = idr_alloc(&nn->cb_ident_idr, clp, 0, 0, GFP_NOWAIT); | 36 | ret = idr_alloc(&nn->cb_ident_idr, clp, 1, 0, GFP_NOWAIT); |
37 | if (ret >= 0) | 37 | if (ret >= 0) |
38 | clp->cl_cb_ident = ret; | 38 | clp->cl_cb_ident = ret; |
39 | spin_unlock(&nn->nfs_client_lock); | 39 | spin_unlock(&nn->nfs_client_lock); |
diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4aa571956cd6..db9b5fea5b3e 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/file.h> | 7 | #include <linux/file.h> |
8 | #include <linux/falloc.h> | 8 | #include <linux/falloc.h> |
9 | #include <linux/nfs_fs.h> | 9 | #include <linux/nfs_fs.h> |
10 | #include <uapi/linux/btrfs.h> /* BTRFS_IOC_CLONE/BTRFS_IOC_CLONE_RANGE */ | ||
10 | #include "delegation.h" | 11 | #include "delegation.h" |
11 | #include "internal.h" | 12 | #include "internal.h" |
12 | #include "iostat.h" | 13 | #include "iostat.h" |
@@ -203,6 +204,7 @@ nfs42_ioctl_clone(struct file *dst_file, unsigned long srcfd, | |||
203 | struct fd src_file; | 204 | struct fd src_file; |
204 | struct inode *src_inode; | 205 | struct inode *src_inode; |
205 | unsigned int bs = server->clone_blksize; | 206 | unsigned int bs = server->clone_blksize; |
207 | bool same_inode = false; | ||
206 | int ret; | 208 | int ret; |
207 | 209 | ||
208 | /* dst file must be opened for writing */ | 210 | /* dst file must be opened for writing */ |
@@ -221,10 +223,8 @@ nfs42_ioctl_clone(struct file *dst_file, unsigned long srcfd, | |||
221 | 223 | ||
222 | src_inode = file_inode(src_file.file); | 224 | src_inode = file_inode(src_file.file); |
223 | 225 | ||
224 | /* src and dst must be different files */ | ||
225 | ret = -EINVAL; | ||
226 | if (src_inode == dst_inode) | 226 | if (src_inode == dst_inode) |
227 | goto out_fput; | 227 | same_inode = true; |
228 | 228 | ||
229 | /* src file must be opened for reading */ | 229 | /* src file must be opened for reading */ |
230 | if (!(src_file.file->f_mode & FMODE_READ)) | 230 | if (!(src_file.file->f_mode & FMODE_READ)) |
@@ -249,8 +249,16 @@ nfs42_ioctl_clone(struct file *dst_file, unsigned long srcfd, | |||
249 | goto out_fput; | 249 | goto out_fput; |
250 | } | 250 | } |
251 | 251 | ||
252 | /* verify if ranges are overlapped within the same file */ | ||
253 | if (same_inode) { | ||
254 | if (dst_off + count > src_off && dst_off < src_off + count) | ||
255 | goto out_fput; | ||
256 | } | ||
257 | |||
252 | /* XXX: do we lock at all? what if server needs CB_RECALL_LAYOUT? */ | 258 | /* XXX: do we lock at all? what if server needs CB_RECALL_LAYOUT? */ |
253 | if (dst_inode < src_inode) { | 259 | if (same_inode) { |
260 | mutex_lock(&src_inode->i_mutex); | ||
261 | } else if (dst_inode < src_inode) { | ||
254 | mutex_lock_nested(&dst_inode->i_mutex, I_MUTEX_PARENT); | 262 | mutex_lock_nested(&dst_inode->i_mutex, I_MUTEX_PARENT); |
255 | mutex_lock_nested(&src_inode->i_mutex, I_MUTEX_CHILD); | 263 | mutex_lock_nested(&src_inode->i_mutex, I_MUTEX_CHILD); |
256 | } else { | 264 | } else { |
@@ -275,7 +283,9 @@ nfs42_ioctl_clone(struct file *dst_file, unsigned long srcfd, | |||
275 | truncate_inode_pages_range(&dst_inode->i_data, dst_off, dst_off + count - 1); | 283 | truncate_inode_pages_range(&dst_inode->i_data, dst_off, dst_off + count - 1); |
276 | 284 | ||
277 | out_unlock: | 285 | out_unlock: |
278 | if (dst_inode < src_inode) { | 286 | if (same_inode) { |
287 | mutex_unlock(&src_inode->i_mutex); | ||
288 | } else if (dst_inode < src_inode) { | ||
279 | mutex_unlock(&src_inode->i_mutex); | 289 | mutex_unlock(&src_inode->i_mutex); |
280 | mutex_unlock(&dst_inode->i_mutex); | 290 | mutex_unlock(&dst_inode->i_mutex); |
281 | } else { | 291 | } else { |
@@ -291,46 +301,31 @@ out_drop_write: | |||
291 | 301 | ||
292 | static long nfs42_ioctl_clone_range(struct file *dst_file, void __user *argp) | 302 | static long nfs42_ioctl_clone_range(struct file *dst_file, void __user *argp) |
293 | { | 303 | { |
294 | struct nfs_ioctl_clone_range_args args; | 304 | struct btrfs_ioctl_clone_range_args args; |
295 | 305 | ||
296 | if (copy_from_user(&args, argp, sizeof(args))) | 306 | if (copy_from_user(&args, argp, sizeof(args))) |
297 | return -EFAULT; | 307 | return -EFAULT; |
298 | 308 | ||
299 | return nfs42_ioctl_clone(dst_file, args.src_fd, args.src_off, args.dst_off, args.count); | 309 | return nfs42_ioctl_clone(dst_file, args.src_fd, args.src_offset, |
300 | } | 310 | args.dest_offset, args.src_length); |
301 | #else | ||
302 | static long nfs42_ioctl_clone(struct file *dst_file, unsigned long srcfd, | ||
303 | u64 src_off, u64 dst_off, u64 count) | ||
304 | { | ||
305 | return -ENOTTY; | ||
306 | } | ||
307 | |||
308 | static long nfs42_ioctl_clone_range(struct file *dst_file, void __user *argp) | ||
309 | { | ||
310 | return -ENOTTY; | ||
311 | } | 311 | } |
312 | #endif /* CONFIG_NFS_V4_2 */ | ||
313 | 312 | ||
314 | long nfs4_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 313 | long nfs4_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
315 | { | 314 | { |
316 | void __user *argp = (void __user *)arg; | 315 | void __user *argp = (void __user *)arg; |
317 | 316 | ||
318 | switch (cmd) { | 317 | switch (cmd) { |
319 | case NFS_IOC_CLONE: | 318 | case BTRFS_IOC_CLONE: |
320 | return nfs42_ioctl_clone(file, arg, 0, 0, 0); | 319 | return nfs42_ioctl_clone(file, arg, 0, 0, 0); |
321 | case NFS_IOC_CLONE_RANGE: | 320 | case BTRFS_IOC_CLONE_RANGE: |
322 | return nfs42_ioctl_clone_range(file, argp); | 321 | return nfs42_ioctl_clone_range(file, argp); |
323 | } | 322 | } |
324 | 323 | ||
325 | return -ENOTTY; | 324 | return -ENOTTY; |
326 | } | 325 | } |
326 | #endif /* CONFIG_NFS_V4_2 */ | ||
327 | 327 | ||
328 | const struct file_operations nfs4_file_operations = { | 328 | const struct file_operations nfs4_file_operations = { |
329 | #ifdef CONFIG_NFS_V4_2 | ||
330 | .llseek = nfs4_file_llseek, | ||
331 | #else | ||
332 | .llseek = nfs_file_llseek, | ||
333 | #endif | ||
334 | .read_iter = nfs_file_read, | 329 | .read_iter = nfs_file_read, |
335 | .write_iter = nfs_file_write, | 330 | .write_iter = nfs_file_write, |
336 | .mmap = nfs_file_mmap, | 331 | .mmap = nfs_file_mmap, |
@@ -342,14 +337,14 @@ const struct file_operations nfs4_file_operations = { | |||
342 | .flock = nfs_flock, | 337 | .flock = nfs_flock, |
343 | .splice_read = nfs_file_splice_read, | 338 | .splice_read = nfs_file_splice_read, |
344 | .splice_write = iter_file_splice_write, | 339 | .splice_write = iter_file_splice_write, |
345 | #ifdef CONFIG_NFS_V4_2 | ||
346 | .fallocate = nfs42_fallocate, | ||
347 | #endif /* CONFIG_NFS_V4_2 */ | ||
348 | .check_flags = nfs_check_flags, | 340 | .check_flags = nfs_check_flags, |
349 | .setlease = simple_nosetlease, | 341 | .setlease = simple_nosetlease, |
350 | #ifdef CONFIG_COMPAT | 342 | #ifdef CONFIG_NFS_V4_2 |
343 | .llseek = nfs4_file_llseek, | ||
344 | .fallocate = nfs42_fallocate, | ||
351 | .unlocked_ioctl = nfs4_ioctl, | 345 | .unlocked_ioctl = nfs4_ioctl, |
352 | #else | ||
353 | .compat_ioctl = nfs4_ioctl, | 346 | .compat_ioctl = nfs4_ioctl, |
354 | #endif /* CONFIG_COMPAT */ | 347 | #else |
348 | .llseek = nfs_file_llseek, | ||
349 | #endif | ||
355 | }; | 350 | }; |
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 765a03559363..89818036f035 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -7866,7 +7866,7 @@ static void nfs4_layoutget_done(struct rpc_task *task, void *calldata) | |||
7866 | spin_unlock(&inode->i_lock); | 7866 | spin_unlock(&inode->i_lock); |
7867 | goto out_restart; | 7867 | goto out_restart; |
7868 | } | 7868 | } |
7869 | if (nfs4_async_handle_error(task, server, state, NULL) == -EAGAIN) | 7869 | if (nfs4_async_handle_error(task, server, state, &lgp->timeout) == -EAGAIN) |
7870 | goto out_restart; | 7870 | goto out_restart; |
7871 | out: | 7871 | out: |
7872 | dprintk("<-- %s\n", __func__); | 7872 | dprintk("<-- %s\n", __func__); |
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index dfed4f5c8fcc..4e4441216804 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c | |||
@@ -3615,6 +3615,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st | |||
3615 | status = 0; | 3615 | status = 0; |
3616 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) | 3616 | if (unlikely(!(bitmap[0] & FATTR4_WORD0_FS_LOCATIONS))) |
3617 | goto out; | 3617 | goto out; |
3618 | bitmap[0] &= ~FATTR4_WORD0_FS_LOCATIONS; | ||
3618 | status = -EIO; | 3619 | status = -EIO; |
3619 | /* Ignore borken servers that return unrequested attrs */ | 3620 | /* Ignore borken servers that return unrequested attrs */ |
3620 | if (unlikely(res == NULL)) | 3621 | if (unlikely(res == NULL)) |
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index 5c0c6b58157f..9aebffb40505 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c | |||
@@ -476,10 +476,7 @@ static struct page *__r4w_get_page(void *priv, u64 offset, bool *uptodate) | |||
476 | } | 476 | } |
477 | unlock_page(page); | 477 | unlock_page(page); |
478 | } | 478 | } |
479 | if (PageDirty(page) || PageWriteback(page)) | 479 | *uptodate = PageUptodate(page); |
480 | *uptodate = true; | ||
481 | else | ||
482 | *uptodate = PageUptodate(page); | ||
483 | dprintk("%s: index=0x%lx uptodate=%d\n", __func__, index, *uptodate); | 480 | dprintk("%s: index=0x%lx uptodate=%d\n", __func__, index, *uptodate); |
484 | return page; | 481 | return page; |
485 | } | 482 | } |
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index fe3ddd20ff89..452a011ba0d8 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
@@ -129,7 +129,7 @@ __nfs_iocounter_wait(struct nfs_io_counter *c) | |||
129 | set_bit(NFS_IO_INPROGRESS, &c->flags); | 129 | set_bit(NFS_IO_INPROGRESS, &c->flags); |
130 | if (atomic_read(&c->io_count) == 0) | 130 | if (atomic_read(&c->io_count) == 0) |
131 | break; | 131 | break; |
132 | ret = nfs_wait_bit_killable(&q.key); | 132 | ret = nfs_wait_bit_killable(&q.key, TASK_KILLABLE); |
133 | } while (atomic_read(&c->io_count) != 0 && !ret); | 133 | } while (atomic_read(&c->io_count) != 0 && !ret); |
134 | finish_wait(wq, &q.wait); | 134 | finish_wait(wq, &q.wait); |
135 | return ret; | 135 | return ret; |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 93496c059837..bec0384499f7 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -872,33 +872,38 @@ send_layoutget(struct pnfs_layout_hdr *lo, | |||
872 | 872 | ||
873 | dprintk("--> %s\n", __func__); | 873 | dprintk("--> %s\n", __func__); |
874 | 874 | ||
875 | lgp = kzalloc(sizeof(*lgp), gfp_flags); | 875 | /* |
876 | if (lgp == NULL) | 876 | * Synchronously retrieve layout information from server and |
877 | return NULL; | 877 | * store in lseg. If we race with a concurrent seqid morphing |
878 | * op, then re-send the LAYOUTGET. | ||
879 | */ | ||
880 | do { | ||
881 | lgp = kzalloc(sizeof(*lgp), gfp_flags); | ||
882 | if (lgp == NULL) | ||
883 | return NULL; | ||
884 | |||
885 | i_size = i_size_read(ino); | ||
886 | |||
887 | lgp->args.minlength = PAGE_CACHE_SIZE; | ||
888 | if (lgp->args.minlength > range->length) | ||
889 | lgp->args.minlength = range->length; | ||
890 | if (range->iomode == IOMODE_READ) { | ||
891 | if (range->offset >= i_size) | ||
892 | lgp->args.minlength = 0; | ||
893 | else if (i_size - range->offset < lgp->args.minlength) | ||
894 | lgp->args.minlength = i_size - range->offset; | ||
895 | } | ||
896 | lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE; | ||
897 | lgp->args.range = *range; | ||
898 | lgp->args.type = server->pnfs_curr_ld->id; | ||
899 | lgp->args.inode = ino; | ||
900 | lgp->args.ctx = get_nfs_open_context(ctx); | ||
901 | lgp->gfp_flags = gfp_flags; | ||
902 | lgp->cred = lo->plh_lc_cred; | ||
878 | 903 | ||
879 | i_size = i_size_read(ino); | 904 | lseg = nfs4_proc_layoutget(lgp, gfp_flags); |
905 | } while (lseg == ERR_PTR(-EAGAIN)); | ||
880 | 906 | ||
881 | lgp->args.minlength = PAGE_CACHE_SIZE; | ||
882 | if (lgp->args.minlength > range->length) | ||
883 | lgp->args.minlength = range->length; | ||
884 | if (range->iomode == IOMODE_READ) { | ||
885 | if (range->offset >= i_size) | ||
886 | lgp->args.minlength = 0; | ||
887 | else if (i_size - range->offset < lgp->args.minlength) | ||
888 | lgp->args.minlength = i_size - range->offset; | ||
889 | } | ||
890 | lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE; | ||
891 | lgp->args.range = *range; | ||
892 | lgp->args.type = server->pnfs_curr_ld->id; | ||
893 | lgp->args.inode = ino; | ||
894 | lgp->args.ctx = get_nfs_open_context(ctx); | ||
895 | lgp->gfp_flags = gfp_flags; | ||
896 | lgp->cred = lo->plh_lc_cred; | ||
897 | |||
898 | /* Synchronously retrieve layout information from server and | ||
899 | * store in lseg. | ||
900 | */ | ||
901 | lseg = nfs4_proc_layoutget(lgp, gfp_flags); | ||
902 | if (IS_ERR(lseg)) { | 907 | if (IS_ERR(lseg)) { |
903 | switch (PTR_ERR(lseg)) { | 908 | switch (PTR_ERR(lseg)) { |
904 | case -ENOMEM: | 909 | case -ENOMEM: |
@@ -1461,11 +1466,11 @@ static bool pnfs_within_mdsthreshold(struct nfs_open_context *ctx, | |||
1461 | } | 1466 | } |
1462 | 1467 | ||
1463 | /* stop waiting if someone clears NFS_LAYOUT_RETRY_LAYOUTGET bit. */ | 1468 | /* stop waiting if someone clears NFS_LAYOUT_RETRY_LAYOUTGET bit. */ |
1464 | static int pnfs_layoutget_retry_bit_wait(struct wait_bit_key *key) | 1469 | static int pnfs_layoutget_retry_bit_wait(struct wait_bit_key *key, int mode) |
1465 | { | 1470 | { |
1466 | if (!test_bit(NFS_LAYOUT_RETRY_LAYOUTGET, key->flags)) | 1471 | if (!test_bit(NFS_LAYOUT_RETRY_LAYOUTGET, key->flags)) |
1467 | return 1; | 1472 | return 1; |
1468 | return nfs_wait_bit_killable(key); | 1473 | return nfs_wait_bit_killable(key, mode); |
1469 | } | 1474 | } |
1470 | 1475 | ||
1471 | static bool pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo) | 1476 | static bool pnfs_prepare_to_retry_layoutget(struct pnfs_layout_hdr *lo) |
@@ -1687,6 +1692,7 @@ pnfs_layout_process(struct nfs4_layoutget *lgp) | |||
1687 | /* existing state ID, make sure the sequence number matches. */ | 1692 | /* existing state ID, make sure the sequence number matches. */ |
1688 | if (pnfs_layout_stateid_blocked(lo, &res->stateid)) { | 1693 | if (pnfs_layout_stateid_blocked(lo, &res->stateid)) { |
1689 | dprintk("%s forget reply due to sequence\n", __func__); | 1694 | dprintk("%s forget reply due to sequence\n", __func__); |
1695 | status = -EAGAIN; | ||
1690 | goto out_forget_reply; | 1696 | goto out_forget_reply; |
1691 | } | 1697 | } |
1692 | pnfs_set_layout_stateid(lo, &res->stateid, false); | 1698 | pnfs_set_layout_stateid(lo, &res->stateid, false); |
diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index 9ffef06b30d5..c9d6c715c0fb 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c | |||
@@ -616,6 +616,7 @@ nfsd4_cb_layout_prepare(struct nfsd4_callback *cb) | |||
616 | 616 | ||
617 | mutex_lock(&ls->ls_mutex); | 617 | mutex_lock(&ls->ls_mutex); |
618 | nfs4_inc_and_copy_stateid(&ls->ls_recall_sid, &ls->ls_stid); | 618 | nfs4_inc_and_copy_stateid(&ls->ls_recall_sid, &ls->ls_stid); |
619 | mutex_unlock(&ls->ls_mutex); | ||
619 | } | 620 | } |
620 | 621 | ||
621 | static int | 622 | static int |
@@ -659,7 +660,6 @@ nfsd4_cb_layout_release(struct nfsd4_callback *cb) | |||
659 | 660 | ||
660 | trace_layout_recall_release(&ls->ls_stid.sc_stateid); | 661 | trace_layout_recall_release(&ls->ls_stid.sc_stateid); |
661 | 662 | ||
662 | mutex_unlock(&ls->ls_mutex); | ||
663 | nfsd4_return_all_layouts(ls, &reaplist); | 663 | nfsd4_return_all_layouts(ls, &reaplist); |
664 | nfsd4_free_layouts(&reaplist); | 664 | nfsd4_free_layouts(&reaplist); |
665 | nfs4_put_stid(&ls->ls_stid); | 665 | nfs4_put_stid(&ls->ls_stid); |
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index a03f6f433075..3123408da935 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -367,13 +367,11 @@ static int ocfs2_mknod(struct inode *dir, | |||
367 | goto leave; | 367 | goto leave; |
368 | } | 368 | } |
369 | 369 | ||
370 | status = posix_acl_create(dir, &mode, &default_acl, &acl); | 370 | status = posix_acl_create(dir, &inode->i_mode, &default_acl, &acl); |
371 | if (status) { | 371 | if (status) { |
372 | mlog_errno(status); | 372 | mlog_errno(status); |
373 | goto leave; | 373 | goto leave; |
374 | } | 374 | } |
375 | /* update inode->i_mode after mask with "umask". */ | ||
376 | inode->i_mode = mode; | ||
377 | 375 | ||
378 | handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb, | 376 | handle = ocfs2_start_trans(osb, ocfs2_mknod_credits(osb->sb, |
379 | S_ISDIR(mode), | 377 | S_ISDIR(mode), |
diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 871fcb67be97..0a8983492d91 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c | |||
@@ -195,8 +195,7 @@ int ovl_set_attr(struct dentry *upperdentry, struct kstat *stat) | |||
195 | 195 | ||
196 | static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir, | 196 | static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir, |
197 | struct dentry *dentry, struct path *lowerpath, | 197 | struct dentry *dentry, struct path *lowerpath, |
198 | struct kstat *stat, struct iattr *attr, | 198 | struct kstat *stat, const char *link) |
199 | const char *link) | ||
200 | { | 199 | { |
201 | struct inode *wdir = workdir->d_inode; | 200 | struct inode *wdir = workdir->d_inode; |
202 | struct inode *udir = upperdir->d_inode; | 201 | struct inode *udir = upperdir->d_inode; |
@@ -240,8 +239,6 @@ static int ovl_copy_up_locked(struct dentry *workdir, struct dentry *upperdir, | |||
240 | 239 | ||
241 | mutex_lock(&newdentry->d_inode->i_mutex); | 240 | mutex_lock(&newdentry->d_inode->i_mutex); |
242 | err = ovl_set_attr(newdentry, stat); | 241 | err = ovl_set_attr(newdentry, stat); |
243 | if (!err && attr) | ||
244 | err = notify_change(newdentry, attr, NULL); | ||
245 | mutex_unlock(&newdentry->d_inode->i_mutex); | 242 | mutex_unlock(&newdentry->d_inode->i_mutex); |
246 | if (err) | 243 | if (err) |
247 | goto out_cleanup; | 244 | goto out_cleanup; |
@@ -286,8 +283,7 @@ out_cleanup: | |||
286 | * that point the file will have already been copied up anyway. | 283 | * that point the file will have already been copied up anyway. |
287 | */ | 284 | */ |
288 | int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, | 285 | int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, |
289 | struct path *lowerpath, struct kstat *stat, | 286 | struct path *lowerpath, struct kstat *stat) |
290 | struct iattr *attr) | ||
291 | { | 287 | { |
292 | struct dentry *workdir = ovl_workdir(dentry); | 288 | struct dentry *workdir = ovl_workdir(dentry); |
293 | int err; | 289 | int err; |
@@ -345,26 +341,19 @@ int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, | |||
345 | } | 341 | } |
346 | upperdentry = ovl_dentry_upper(dentry); | 342 | upperdentry = ovl_dentry_upper(dentry); |
347 | if (upperdentry) { | 343 | if (upperdentry) { |
348 | unlock_rename(workdir, upperdir); | 344 | /* Raced with another copy-up? Nothing to do, then... */ |
349 | err = 0; | 345 | err = 0; |
350 | /* Raced with another copy-up? Do the setattr here */ | 346 | goto out_unlock; |
351 | if (attr) { | ||
352 | mutex_lock(&upperdentry->d_inode->i_mutex); | ||
353 | err = notify_change(upperdentry, attr, NULL); | ||
354 | mutex_unlock(&upperdentry->d_inode->i_mutex); | ||
355 | } | ||
356 | goto out_put_cred; | ||
357 | } | 347 | } |
358 | 348 | ||
359 | err = ovl_copy_up_locked(workdir, upperdir, dentry, lowerpath, | 349 | err = ovl_copy_up_locked(workdir, upperdir, dentry, lowerpath, |
360 | stat, attr, link); | 350 | stat, link); |
361 | if (!err) { | 351 | if (!err) { |
362 | /* Restore timestamps on parent (best effort) */ | 352 | /* Restore timestamps on parent (best effort) */ |
363 | ovl_set_timestamps(upperdir, &pstat); | 353 | ovl_set_timestamps(upperdir, &pstat); |
364 | } | 354 | } |
365 | out_unlock: | 355 | out_unlock: |
366 | unlock_rename(workdir, upperdir); | 356 | unlock_rename(workdir, upperdir); |
367 | out_put_cred: | ||
368 | revert_creds(old_cred); | 357 | revert_creds(old_cred); |
369 | put_cred(override_cred); | 358 | put_cred(override_cred); |
370 | 359 | ||
@@ -406,7 +395,7 @@ int ovl_copy_up(struct dentry *dentry) | |||
406 | ovl_path_lower(next, &lowerpath); | 395 | ovl_path_lower(next, &lowerpath); |
407 | err = vfs_getattr(&lowerpath, &stat); | 396 | err = vfs_getattr(&lowerpath, &stat); |
408 | if (!err) | 397 | if (!err) |
409 | err = ovl_copy_up_one(parent, next, &lowerpath, &stat, NULL); | 398 | err = ovl_copy_up_one(parent, next, &lowerpath, &stat); |
410 | 399 | ||
411 | dput(parent); | 400 | dput(parent); |
412 | dput(next); | 401 | dput(next); |
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index ec0c2a050043..4060ffde8722 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c | |||
@@ -12,8 +12,7 @@ | |||
12 | #include <linux/xattr.h> | 12 | #include <linux/xattr.h> |
13 | #include "overlayfs.h" | 13 | #include "overlayfs.h" |
14 | 14 | ||
15 | static int ovl_copy_up_last(struct dentry *dentry, struct iattr *attr, | 15 | static int ovl_copy_up_truncate(struct dentry *dentry) |
16 | bool no_data) | ||
17 | { | 16 | { |
18 | int err; | 17 | int err; |
19 | struct dentry *parent; | 18 | struct dentry *parent; |
@@ -30,10 +29,8 @@ static int ovl_copy_up_last(struct dentry *dentry, struct iattr *attr, | |||
30 | if (err) | 29 | if (err) |
31 | goto out_dput_parent; | 30 | goto out_dput_parent; |
32 | 31 | ||
33 | if (no_data) | 32 | stat.size = 0; |
34 | stat.size = 0; | 33 | err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat); |
35 | |||
36 | err = ovl_copy_up_one(parent, dentry, &lowerpath, &stat, attr); | ||
37 | 34 | ||
38 | out_dput_parent: | 35 | out_dput_parent: |
39 | dput(parent); | 36 | dput(parent); |
@@ -49,13 +46,13 @@ int ovl_setattr(struct dentry *dentry, struct iattr *attr) | |||
49 | if (err) | 46 | if (err) |
50 | goto out; | 47 | goto out; |
51 | 48 | ||
52 | upperdentry = ovl_dentry_upper(dentry); | 49 | err = ovl_copy_up(dentry); |
53 | if (upperdentry) { | 50 | if (!err) { |
51 | upperdentry = ovl_dentry_upper(dentry); | ||
52 | |||
54 | mutex_lock(&upperdentry->d_inode->i_mutex); | 53 | mutex_lock(&upperdentry->d_inode->i_mutex); |
55 | err = notify_change(upperdentry, attr, NULL); | 54 | err = notify_change(upperdentry, attr, NULL); |
56 | mutex_unlock(&upperdentry->d_inode->i_mutex); | 55 | mutex_unlock(&upperdentry->d_inode->i_mutex); |
57 | } else { | ||
58 | err = ovl_copy_up_last(dentry, attr, false); | ||
59 | } | 56 | } |
60 | ovl_drop_write(dentry); | 57 | ovl_drop_write(dentry); |
61 | out: | 58 | out: |
@@ -353,7 +350,7 @@ struct inode *ovl_d_select_inode(struct dentry *dentry, unsigned file_flags) | |||
353 | return ERR_PTR(err); | 350 | return ERR_PTR(err); |
354 | 351 | ||
355 | if (file_flags & O_TRUNC) | 352 | if (file_flags & O_TRUNC) |
356 | err = ovl_copy_up_last(dentry, NULL, true); | 353 | err = ovl_copy_up_truncate(dentry); |
357 | else | 354 | else |
358 | err = ovl_copy_up(dentry); | 355 | err = ovl_copy_up(dentry); |
359 | ovl_drop_write(dentry); | 356 | ovl_drop_write(dentry); |
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h index ea5a40b06e3a..e17154aeaae4 100644 --- a/fs/overlayfs/overlayfs.h +++ b/fs/overlayfs/overlayfs.h | |||
@@ -194,7 +194,6 @@ void ovl_cleanup(struct inode *dir, struct dentry *dentry); | |||
194 | /* copy_up.c */ | 194 | /* copy_up.c */ |
195 | int ovl_copy_up(struct dentry *dentry); | 195 | int ovl_copy_up(struct dentry *dentry); |
196 | int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, | 196 | int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, |
197 | struct path *lowerpath, struct kstat *stat, | 197 | struct path *lowerpath, struct kstat *stat); |
198 | struct iattr *attr); | ||
199 | int ovl_copy_xattr(struct dentry *old, struct dentry *new); | 198 | int ovl_copy_xattr(struct dentry *old, struct dentry *new); |
200 | int ovl_set_attr(struct dentry *upper, struct kstat *stat); | 199 | int ovl_set_attr(struct dentry *upper, struct kstat *stat); |
diff --git a/fs/proc/base.c b/fs/proc/base.c index bd3e9e68125b..4bd5d3118acd 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
@@ -2494,6 +2494,7 @@ static ssize_t proc_coredump_filter_write(struct file *file, | |||
2494 | mm = get_task_mm(task); | 2494 | mm = get_task_mm(task); |
2495 | if (!mm) | 2495 | if (!mm) |
2496 | goto out_no_mm; | 2496 | goto out_no_mm; |
2497 | ret = 0; | ||
2497 | 2498 | ||
2498 | for (i = 0, mask = 1; i < MMF_DUMP_FILTER_BITS; i++, mask <<= 1) { | 2499 | for (i = 0, mask = 1; i < MMF_DUMP_FILTER_BITS; i++, mask <<= 1) { |
2499 | if (val & mask) | 2500 | if (val & mask) |
diff --git a/fs/splice.c b/fs/splice.c index 801c21cd77fe..4cf700d50b40 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
@@ -809,6 +809,13 @@ static int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_des | |||
809 | */ | 809 | */ |
810 | static int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd) | 810 | static int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd) |
811 | { | 811 | { |
812 | /* | ||
813 | * Check for signal early to make process killable when there are | ||
814 | * always buffers available | ||
815 | */ | ||
816 | if (signal_pending(current)) | ||
817 | return -ERESTARTSYS; | ||
818 | |||
812 | while (!pipe->nrbufs) { | 819 | while (!pipe->nrbufs) { |
813 | if (!pipe->writers) | 820 | if (!pipe->writers) |
814 | return 0; | 821 | return 0; |
@@ -884,6 +891,7 @@ ssize_t __splice_from_pipe(struct pipe_inode_info *pipe, struct splice_desc *sd, | |||
884 | 891 | ||
885 | splice_from_pipe_begin(sd); | 892 | splice_from_pipe_begin(sd); |
886 | do { | 893 | do { |
894 | cond_resched(); | ||
887 | ret = splice_from_pipe_next(pipe, sd); | 895 | ret = splice_from_pipe_next(pipe, sd); |
888 | if (ret > 0) | 896 | if (ret > 0) |
889 | ret = splice_from_pipe_feed(pipe, sd, actor); | 897 | ret = splice_from_pipe_feed(pipe, sd, actor); |
diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c index 590ad9206e3f..02fa1dcc5969 100644 --- a/fs/sysv/inode.c +++ b/fs/sysv/inode.c | |||
@@ -162,15 +162,8 @@ void sysv_set_inode(struct inode *inode, dev_t rdev) | |||
162 | inode->i_fop = &sysv_dir_operations; | 162 | inode->i_fop = &sysv_dir_operations; |
163 | inode->i_mapping->a_ops = &sysv_aops; | 163 | inode->i_mapping->a_ops = &sysv_aops; |
164 | } else if (S_ISLNK(inode->i_mode)) { | 164 | } else if (S_ISLNK(inode->i_mode)) { |
165 | if (inode->i_blocks) { | 165 | inode->i_op = &sysv_symlink_inode_operations; |
166 | inode->i_op = &sysv_symlink_inode_operations; | 166 | inode->i_mapping->a_ops = &sysv_aops; |
167 | inode->i_mapping->a_ops = &sysv_aops; | ||
168 | } else { | ||
169 | inode->i_op = &simple_symlink_inode_operations; | ||
170 | inode->i_link = (char *)SYSV_I(inode)->i_data; | ||
171 | nd_terminate_link(inode->i_link, inode->i_size, | ||
172 | sizeof(SYSV_I(inode)->i_data) - 1); | ||
173 | } | ||
174 | } else | 167 | } else |
175 | init_special_inode(inode, inode->i_mode, rdev); | 168 | init_special_inode(inode, inode->i_mode, rdev); |
176 | } | 169 | } |