aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2017-11-03 18:26:44 -0400
committerDavid Sterba <dsterba@suse.com>2017-11-15 11:27:44 -0500
commitf48bf66b662e7acd6a32dbc28c4fa38931f8f0a6 (patch)
tree33007feca7584c39c3ca719b3b229fb3de95d6e3
parent56a0e706fcf870270878d6d72b71092ae42d229c (diff)
Btrfs: move definition of the function btrfs_find_new_delalloc_bytes
Move the definition of the function btrfs_find_new_delalloc_bytes() closer to the function btrfs_dirty_pages(), because in a future commit it will be used exclusively by btrfs_dirty_pages(). This just moves the function's definition, with no functional changes at all. Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/file.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index f80254d82f40..47e6ebad78c3 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -477,6 +477,47 @@ static void btrfs_drop_pages(struct page **pages, size_t num_pages)
477 } 477 }
478} 478}
479 479
480static int btrfs_find_new_delalloc_bytes(struct btrfs_inode *inode,
481 const u64 start,
482 const u64 len,
483 struct extent_state **cached_state)
484{
485 u64 search_start = start;
486 const u64 end = start + len - 1;
487
488 while (search_start < end) {
489 const u64 search_len = end - search_start + 1;
490 struct extent_map *em;
491 u64 em_len;
492 int ret = 0;
493
494 em = btrfs_get_extent(inode, NULL, 0, search_start,
495 search_len, 0);
496 if (IS_ERR(em))
497 return PTR_ERR(em);
498
499 if (em->block_start != EXTENT_MAP_HOLE)
500 goto next;
501
502 em_len = em->len;
503 if (em->start < search_start)
504 em_len -= search_start - em->start;
505 if (em_len > search_len)
506 em_len = search_len;
507
508 ret = set_extent_bit(&inode->io_tree, search_start,
509 search_start + em_len - 1,
510 EXTENT_DELALLOC_NEW,
511 NULL, cached_state, GFP_NOFS);
512next:
513 search_start = extent_map_end(em);
514 free_extent_map(em);
515 if (ret)
516 return ret;
517 }
518 return 0;
519}
520
480/* 521/*
481 * after copy_from_user, pages need to be dirtied and we need to make 522 * after copy_from_user, pages need to be dirtied and we need to make
482 * sure holes are created between the current EOF and the start of 523 * sure holes are created between the current EOF and the start of
@@ -1404,47 +1445,6 @@ fail:
1404 1445
1405} 1446}
1406 1447
1407static int btrfs_find_new_delalloc_bytes(struct btrfs_inode *inode,
1408 const u64 start,
1409 const u64 len,
1410 struct extent_state **cached_state)
1411{
1412 u64 search_start = start;
1413 const u64 end = start + len - 1;
1414
1415 while (search_start < end) {
1416 const u64 search_len = end - search_start + 1;
1417 struct extent_map *em;
1418 u64 em_len;
1419 int ret = 0;
1420
1421 em = btrfs_get_extent(inode, NULL, 0, search_start,
1422 search_len, 0);
1423 if (IS_ERR(em))
1424 return PTR_ERR(em);
1425
1426 if (em->block_start != EXTENT_MAP_HOLE)
1427 goto next;
1428
1429 em_len = em->len;
1430 if (em->start < search_start)
1431 em_len -= search_start - em->start;
1432 if (em_len > search_len)
1433 em_len = search_len;
1434
1435 ret = set_extent_bit(&inode->io_tree, search_start,
1436 search_start + em_len - 1,
1437 EXTENT_DELALLOC_NEW,
1438 NULL, cached_state, GFP_NOFS);
1439next:
1440 search_start = extent_map_end(em);
1441 free_extent_map(em);
1442 if (ret)
1443 return ret;
1444 }
1445 return 0;
1446}
1447
1448/* 1448/*
1449 * This function locks the extent and properly waits for data=ordered extents 1449 * This function locks the extent and properly waits for data=ordered extents
1450 * to finish before allowing the pages to be modified if need. 1450 * to finish before allowing the pages to be modified if need.