extents.c (10ce3cc919f50c2043b41ca968b43c26a3672600) extents.c (5f95d21fb6f2aaa52830e5b7fb405f6c71d3ab85)
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
4 *
5 * Architecture independence:
6 * Copyright (c) 2005, Bull S.A.
7 * Written by Pierre Peiffer <pierre.peiffer@bull.net>
8 *

--- 30 unchanged lines hidden (view full) ---

39#include <linux/slab.h>
40#include <linux/falloc.h>
41#include <asm/uaccess.h>
42#include <linux/fiemap.h>
43#include "ext4_jbd2.h"
44
45#include <trace/events/ext4.h>
46
1/*
2 * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
3 * Written by Alex Tomas <alex@clusterfs.com>
4 *
5 * Architecture independence:
6 * Copyright (c) 2005, Bull S.A.
7 * Written by Pierre Peiffer <pierre.peiffer@bull.net>
8 *

--- 30 unchanged lines hidden (view full) ---

39#include <linux/slab.h>
40#include <linux/falloc.h>
41#include <asm/uaccess.h>
42#include <linux/fiemap.h>
43#include "ext4_jbd2.h"
44
45#include <trace/events/ext4.h>
46
47/*
48 * used by extent splitting.
49 */
50#define EXT4_EXT_MAY_ZEROOUT 0x1 /* safe to zeroout if split fails \
51 due to ENOSPC */
52#define EXT4_EXT_MARK_UNINIT1 0x2 /* mark first half uninitialized */
53#define EXT4_EXT_MARK_UNINIT2 0x4 /* mark second half uninitialized */
54
47static int ext4_split_extent(handle_t *handle,
48 struct inode *inode,
49 struct ext4_ext_path *path,
50 struct ext4_map_blocks *map,
51 int split_flag,
52 int flags);
53
55static int ext4_split_extent(handle_t *handle,
56 struct inode *inode,
57 struct ext4_ext_path *path,
58 struct ext4_map_blocks *map,
59 int split_flag,
60 int flags);
61
62static int ext4_split_extent_at(handle_t *handle,
63 struct inode *inode,
64 struct ext4_ext_path *path,
65 ext4_lblk_t split,
66 int split_flag,
67 int flags);
68
54static int ext4_ext_truncate_extend_restart(handle_t *handle,
55 struct inode *inode,
56 int needed)
57{
58 int err;
59
60 if (!ext4_handle_valid(handle))
61 return 0;

--- 233 unchanged lines hidden (view full) ---

295 return max;
296}
297
298static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
299{
300 ext4_fsblk_t block = ext4_ext_pblock(ext);
301 int len = ext4_ext_get_actual_len(ext);
302
69static int ext4_ext_truncate_extend_restart(handle_t *handle,
70 struct inode *inode,
71 int needed)
72{
73 int err;
74
75 if (!ext4_handle_valid(handle))
76 return 0;

--- 233 unchanged lines hidden (view full) ---

310 return max;
311}
312
313static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext)
314{
315 ext4_fsblk_t block = ext4_ext_pblock(ext);
316 int len = ext4_ext_get_actual_len(ext);
317
318 if (len == 0)
319 return 0;
303 return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len);
304}
305
306static int ext4_valid_extent_idx(struct inode *inode,
307 struct ext4_extent_idx *ext_idx)
308{
309 ext4_fsblk_t block = ext4_idx_pblock(ext_idx);
310

--- 1992 unchanged lines hidden (view full) ---

2303 ext4_lblk_t a, b;
2304 unsigned num;
2305 ext4_lblk_t ex_ee_block;
2306 unsigned short ex_ee_len;
2307 unsigned uninitialized = 0;
2308 struct ext4_extent *ex;
2309
2310 /* the header must be checked already in ext4_ext_remove_space() */
320 return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len);
321}
322
323static int ext4_valid_extent_idx(struct inode *inode,
324 struct ext4_extent_idx *ext_idx)
325{
326 ext4_fsblk_t block = ext4_idx_pblock(ext_idx);
327

--- 1992 unchanged lines hidden (view full) ---

2320 ext4_lblk_t a, b;
2321 unsigned num;
2322 ext4_lblk_t ex_ee_block;
2323 unsigned short ex_ee_len;
2324 unsigned uninitialized = 0;
2325 struct ext4_extent *ex;
2326
2327 /* the header must be checked already in ext4_ext_remove_space() */
2311 ext_debug("truncate since %u in leaf\n", start);
2328 ext_debug("truncate since %u in leaf to %u\n", start, end);
2312 if (!path[depth].p_hdr)
2313 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh);
2314 eh = path[depth].p_hdr;
2315 if (unlikely(path[depth].p_hdr == NULL)) {
2316 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
2317 return -EIO;
2318 }
2319 /* find where to start removing */

--- 18 unchanged lines hidden (view full) ---

2338
2339 a = ex_ee_block > start ? ex_ee_block : start;
2340 b = ex_ee_block+ex_ee_len - 1 < end ?
2341 ex_ee_block+ex_ee_len - 1 : end;
2342
2343 ext_debug(" border %u:%u\n", a, b);
2344
2345 /* If this extent is beyond the end of the hole, skip it */
2329 if (!path[depth].p_hdr)
2330 path[depth].p_hdr = ext_block_hdr(path[depth].p_bh);
2331 eh = path[depth].p_hdr;
2332 if (unlikely(path[depth].p_hdr == NULL)) {
2333 EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
2334 return -EIO;
2335 }
2336 /* find where to start removing */

--- 18 unchanged lines hidden (view full) ---

2355
2356 a = ex_ee_block > start ? ex_ee_block : start;
2357 b = ex_ee_block+ex_ee_len - 1 < end ?
2358 ex_ee_block+ex_ee_len - 1 : end;
2359
2360 ext_debug(" border %u:%u\n", a, b);
2361
2362 /* If this extent is beyond the end of the hole, skip it */
2346 if (end <= ex_ee_block) {
2363 if (end < ex_ee_block) {
2347 ex--;
2348 ex_ee_block = le32_to_cpu(ex->ee_block);
2349 ex_ee_len = ext4_ext_get_actual_len(ex);
2350 continue;
2351 } else if (b != ex_ee_block + ex_ee_len - 1) {
2352 EXT4_ERROR_INODE(inode," bad truncate %u:%u\n",
2353 start, end);
2354 err = -EIO;

--- 122 unchanged lines hidden (view full) ---

2477 * if truncate on deeper level happened, it wasn't partial,
2478 * so we have to consider current index for truncation
2479 */
2480 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block)
2481 return 0;
2482 return 1;
2483}
2484
2364 ex--;
2365 ex_ee_block = le32_to_cpu(ex->ee_block);
2366 ex_ee_len = ext4_ext_get_actual_len(ex);
2367 continue;
2368 } else if (b != ex_ee_block + ex_ee_len - 1) {
2369 EXT4_ERROR_INODE(inode," bad truncate %u:%u\n",
2370 start, end);
2371 err = -EIO;

--- 122 unchanged lines hidden (view full) ---

2494 * if truncate on deeper level happened, it wasn't partial,
2495 * so we have to consider current index for truncation
2496 */
2497 if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block)
2498 return 0;
2499 return 1;
2500}
2501
2485static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start)
2502static int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
2503 ext4_lblk_t end)
2486{
2487 struct super_block *sb = inode->i_sb;
2488 int depth = ext_depth(inode);
2489 struct ext4_ext_path *path;
2490 ext4_fsblk_t partial_cluster = 0;
2491 handle_t *handle;
2492 int i, err;
2493
2504{
2505 struct super_block *sb = inode->i_sb;
2506 int depth = ext_depth(inode);
2507 struct ext4_ext_path *path;
2508 ext4_fsblk_t partial_cluster = 0;
2509 handle_t *handle;
2510 int i, err;
2511
2494 ext_debug("truncate since %u\n", start);
2512 ext_debug("truncate since %u to %u\n", start, end);
2495
2496 /* probably first extent we're gonna free will be last in block */
2497 handle = ext4_journal_start(inode, depth + 1);
2498 if (IS_ERR(handle))
2499 return PTR_ERR(handle);
2500
2501again:
2502 ext4_ext_invalidate_cache(inode);
2503
2504 trace_ext4_ext_remove_space(inode, start, depth);
2505
2506 /*
2513
2514 /* probably first extent we're gonna free will be last in block */
2515 handle = ext4_journal_start(inode, depth + 1);
2516 if (IS_ERR(handle))
2517 return PTR_ERR(handle);
2518
2519again:
2520 ext4_ext_invalidate_cache(inode);
2521
2522 trace_ext4_ext_remove_space(inode, start, depth);
2523
2524 /*
2525 * Check if we are removing extents inside the extent tree. If that
2526 * is the case, we are going to punch a hole inside the extent tree
2527 * so we have to check whether we need to split the extent covering
2528 * the last block to remove so we can easily remove the part of it
2529 * in ext4_ext_rm_leaf().
2530 */
2531 if (end < EXT_MAX_BLOCKS - 1) {
2532 struct ext4_extent *ex;
2533 ext4_lblk_t ee_block;
2534
2535 /* find extent for this block */
2536 path = ext4_ext_find_extent(inode, end, NULL);
2537 if (IS_ERR(path)) {
2538 ext4_journal_stop(handle);
2539 return PTR_ERR(path);
2540 }
2541 depth = ext_depth(inode);
2542 ex = path[depth].p_ext;
2543 if (!ex)
2544 goto cont;
2545
2546 ee_block = le32_to_cpu(ex->ee_block);
2547
2548 /*
2549 * See if the last block is inside the extent, if so split
2550 * the extent at 'end' block so we can easily remove the
2551 * tail of the first part of the split extent in
2552 * ext4_ext_rm_leaf().
2553 */
2554 if (end >= ee_block &&
2555 end < ee_block + ext4_ext_get_actual_len(ex) - 1) {
2556 int split_flag = 0;
2557
2558 if (ext4_ext_is_uninitialized(ex))
2559 split_flag = EXT4_EXT_MARK_UNINIT1 |
2560 EXT4_EXT_MARK_UNINIT2;
2561
2562 /*
2563 * Split the extent in two so that 'end' is the last
2564 * block in the first new extent
2565 */
2566 err = ext4_split_extent_at(handle, inode, path,
2567 end + 1, split_flag,
2568 EXT4_GET_BLOCKS_PRE_IO |
2569 EXT4_GET_BLOCKS_PUNCH_OUT_EXT);
2570
2571 if (err < 0)
2572 goto out;
2573 }
2574 ext4_ext_drop_refs(path);
2575 kfree(path);
2576 }
2577cont:
2578
2579 /*
2507 * We start scanning from right side, freeing all the blocks
2508 * after i_size and walking into the tree depth-wise.
2509 */
2510 depth = ext_depth(inode);
2511 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_NOFS);
2512 if (path == NULL) {
2513 ext4_journal_stop(handle);
2514 return -ENOMEM;
2515 }
2516 path[0].p_depth = depth;
2517 path[0].p_hdr = ext_inode_hdr(inode);
2580 * We start scanning from right side, freeing all the blocks
2581 * after i_size and walking into the tree depth-wise.
2582 */
2583 depth = ext_depth(inode);
2584 path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), GFP_NOFS);
2585 if (path == NULL) {
2586 ext4_journal_stop(handle);
2587 return -ENOMEM;
2588 }
2589 path[0].p_depth = depth;
2590 path[0].p_hdr = ext_inode_hdr(inode);
2591
2518 if (ext4_ext_check(inode, path[0].p_hdr, depth)) {
2519 err = -EIO;
2520 goto out;
2521 }
2522 i = err = 0;
2523
2524 while (i >= 0 && err == 0) {
2525 if (i == depth) {
2526 /* this is leaf block */
2527 err = ext4_ext_rm_leaf(handle, inode, path,
2528 &partial_cluster, start,
2592 if (ext4_ext_check(inode, path[0].p_hdr, depth)) {
2593 err = -EIO;
2594 goto out;
2595 }
2596 i = err = 0;
2597
2598 while (i >= 0 && err == 0) {
2599 if (i == depth) {
2600 /* this is leaf block */
2601 err = ext4_ext_rm_leaf(handle, inode, path,
2602 &partial_cluster, start,
2529 EXT_MAX_BLOCKS - 1);
2603 end);
2530 /* root level has p_bh == NULL, brelse() eats this */
2531 brelse(path[i].p_bh);
2532 path[i].p_bh = NULL;
2533 i--;
2534 continue;
2535 }
2536
2537 /* this is index block */

--- 166 unchanged lines hidden (view full) ---

2704 ret = sb_issue_zeroout(inode->i_sb, ee_pblock, ee_len, GFP_NOFS);
2705 if (ret > 0)
2706 ret = 0;
2707
2708 return ret;
2709}
2710
2711/*
2604 /* root level has p_bh == NULL, brelse() eats this */
2605 brelse(path[i].p_bh);
2606 path[i].p_bh = NULL;
2607 i--;
2608 continue;
2609 }
2610
2611 /* this is index block */

--- 166 unchanged lines hidden (view full) ---

2778 ret = sb_issue_zeroout(inode->i_sb, ee_pblock, ee_len, GFP_NOFS);
2779 if (ret > 0)
2780 ret = 0;
2781
2782 return ret;
2783}
2784
2785/*
2712 * used by extent splitting.
2713 */
2714#define EXT4_EXT_MAY_ZEROOUT 0x1 /* safe to zeroout if split fails \
2715 due to ENOSPC */
2716#define EXT4_EXT_MARK_UNINIT1 0x2 /* mark first half uninitialized */
2717#define EXT4_EXT_MARK_UNINIT2 0x4 /* mark second half uninitialized */
2718
2719/*
2720 * ext4_split_extent_at() splits an extent at given block.
2721 *
2722 * @handle: the journal handle
2723 * @inode: the file inode
2724 * @path: the path to the extent
2725 * @split: the logical block where the extent is splitted.
2726 * @split_flags: indicates if the extent could be zeroout if split fails, and
2727 * the states(init or uninit) of new extents.

--- 1495 unchanged lines hidden (view full) ---

4223 */
4224
4225 /* we have to know where to truncate from in crash case */
4226 EXT4_I(inode)->i_disksize = inode->i_size;
4227 ext4_mark_inode_dirty(handle, inode);
4228
4229 last_block = (inode->i_size + sb->s_blocksize - 1)
4230 >> EXT4_BLOCK_SIZE_BITS(sb);
2786 * ext4_split_extent_at() splits an extent at given block.
2787 *
2788 * @handle: the journal handle
2789 * @inode: the file inode
2790 * @path: the path to the extent
2791 * @split: the logical block where the extent is splitted.
2792 * @split_flags: indicates if the extent could be zeroout if split fails, and
2793 * the states(init or uninit) of new extents.

--- 1495 unchanged lines hidden (view full) ---

4289 */
4290
4291 /* we have to know where to truncate from in crash case */
4292 EXT4_I(inode)->i_disksize = inode->i_size;
4293 ext4_mark_inode_dirty(handle, inode);
4294
4295 last_block = (inode->i_size + sb->s_blocksize - 1)
4296 >> EXT4_BLOCK_SIZE_BITS(sb);
4231 err = ext4_ext_remove_space(inode, last_block);
4297 err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
4232
4233 /* In a multi-transaction truncate, we only make the final
4234 * transaction synchronous.
4235 */
4236 if (IS_SYNC(inode))
4237 ext4_handle_sync(handle);
4238
4239 up_write(&EXT4_I(inode)->i_data_sem);

--- 460 unchanged lines hidden (view full) ---

4700 * @length: The length of the hole
4701 *
4702 * Returns the number of blocks removed or negative on err
4703 */
4704int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
4705{
4706 struct inode *inode = file->f_path.dentry->d_inode;
4707 struct super_block *sb = inode->i_sb;
4298
4299 /* In a multi-transaction truncate, we only make the final
4300 * transaction synchronous.
4301 */
4302 if (IS_SYNC(inode))
4303 ext4_handle_sync(handle);
4304
4305 up_write(&EXT4_I(inode)->i_data_sem);

--- 460 unchanged lines hidden (view full) ---

4766 * @length: The length of the hole
4767 *
4768 * Returns the number of blocks removed or negative on err
4769 */
4770int ext4_ext_punch_hole(struct file *file, loff_t offset, loff_t length)
4771{
4772 struct inode *inode = file->f_path.dentry->d_inode;
4773 struct super_block *sb = inode->i_sb;
4708 struct ext4_ext_cache cache_ex;
4709 ext4_lblk_t first_block, last_block, num_blocks, iblock, max_blocks;
4774 ext4_lblk_t first_block, stop_block;
4710 struct address_space *mapping = inode->i_mapping;
4775 struct address_space *mapping = inode->i_mapping;
4711 struct ext4_map_blocks map;
4712 handle_t *handle;
4713 loff_t first_page, last_page, page_len;
4714 loff_t first_page_offset, last_page_offset;
4776 handle_t *handle;
4777 loff_t first_page, last_page, page_len;
4778 loff_t first_page_offset, last_page_offset;
4715 int ret, credits, blocks_released, err = 0;
4779 int credits, err = 0;
4716
4717 /* No need to punch hole beyond i_size */
4718 if (offset >= inode->i_size)
4719 return 0;
4720
4721 /*
4722 * If the hole extends beyond i_size, set the hole
4723 * to end after the page that contains i_size
4724 */
4725 if (offset + length > inode->i_size) {
4726 length = inode->i_size +
4727 PAGE_CACHE_SIZE - (inode->i_size & (PAGE_CACHE_SIZE - 1)) -
4728 offset;
4729 }
4730
4780
4781 /* No need to punch hole beyond i_size */
4782 if (offset >= inode->i_size)
4783 return 0;
4784
4785 /*
4786 * If the hole extends beyond i_size, set the hole
4787 * to end after the page that contains i_size
4788 */
4789 if (offset + length > inode->i_size) {
4790 length = inode->i_size +
4791 PAGE_CACHE_SIZE - (inode->i_size & (PAGE_CACHE_SIZE - 1)) -
4792 offset;
4793 }
4794
4731 first_block = (offset + sb->s_blocksize - 1) >>
4732 EXT4_BLOCK_SIZE_BITS(sb);
4733 last_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
4734
4735 first_page = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
4736 last_page = (offset + length) >> PAGE_CACHE_SHIFT;
4737
4738 first_page_offset = first_page << PAGE_CACHE_SHIFT;
4739 last_page_offset = last_page << PAGE_CACHE_SHIFT;
4740
4741 /*
4742 * Write out all dirty pages to avoid race conditions

--- 62 unchanged lines hidden (view full) ---

4805 if (page_len > 0) {
4806 err = ext4_discard_partial_page_buffers(handle, mapping,
4807 last_page_offset, page_len, 0);
4808 if (err)
4809 goto out;
4810 }
4811 }
4812
4795 first_page = (offset + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
4796 last_page = (offset + length) >> PAGE_CACHE_SHIFT;
4797
4798 first_page_offset = first_page << PAGE_CACHE_SHIFT;
4799 last_page_offset = last_page << PAGE_CACHE_SHIFT;
4800
4801 /*
4802 * Write out all dirty pages to avoid race conditions

--- 62 unchanged lines hidden (view full) ---

4865 if (page_len > 0) {
4866 err = ext4_discard_partial_page_buffers(handle, mapping,
4867 last_page_offset, page_len, 0);
4868 if (err)
4869 goto out;
4870 }
4871 }
4872
4813
4814 /*
4815 * If i_size is contained in the last page, we need to
4816 * unmap and zero the partial page after i_size
4817 */
4818 if (inode->i_size >> PAGE_CACHE_SHIFT == last_page &&
4819 inode->i_size % PAGE_CACHE_SIZE != 0) {
4820
4821 page_len = PAGE_CACHE_SIZE -
4822 (inode->i_size & (PAGE_CACHE_SIZE - 1));
4823
4824 if (page_len > 0) {
4825 err = ext4_discard_partial_page_buffers(handle,
4826 mapping, inode->i_size, page_len, 0);
4827
4828 if (err)
4829 goto out;
4830 }
4831 }
4832
4873 /*
4874 * If i_size is contained in the last page, we need to
4875 * unmap and zero the partial page after i_size
4876 */
4877 if (inode->i_size >> PAGE_CACHE_SHIFT == last_page &&
4878 inode->i_size % PAGE_CACHE_SIZE != 0) {
4879
4880 page_len = PAGE_CACHE_SIZE -
4881 (inode->i_size & (PAGE_CACHE_SIZE - 1));
4882
4883 if (page_len > 0) {
4884 err = ext4_discard_partial_page_buffers(handle,
4885 mapping, inode->i_size, page_len, 0);
4886
4887 if (err)
4888 goto out;
4889 }
4890 }
4891
4892 first_block = (offset + sb->s_blocksize - 1) >>
4893 EXT4_BLOCK_SIZE_BITS(sb);
4894 stop_block = (offset + length) >> EXT4_BLOCK_SIZE_BITS(sb);
4895
4833 /* If there are no blocks to remove, return now */
4896 /* If there are no blocks to remove, return now */
4834 if (first_block >= last_block)
4897 if (first_block >= stop_block)
4835 goto out;
4836
4837 down_write(&EXT4_I(inode)->i_data_sem);
4838 ext4_ext_invalidate_cache(inode);
4839 ext4_discard_preallocations(inode);
4840
4898 goto out;
4899
4900 down_write(&EXT4_I(inode)->i_data_sem);
4901 ext4_ext_invalidate_cache(inode);
4902 ext4_discard_preallocations(inode);
4903
4841 /*
4842 * Loop over all the blocks and identify blocks
4843 * that need to be punched out
4844 */
4845 iblock = first_block;
4846 blocks_released = 0;
4847 while (iblock < last_block) {
4848 max_blocks = last_block - iblock;
4849 num_blocks = 1;
4850 memset(&map, 0, sizeof(map));
4851 map.m_lblk = iblock;
4852 map.m_len = max_blocks;
4853 ret = ext4_ext_map_blocks(handle, inode, &map,
4854 EXT4_GET_BLOCKS_PUNCH_OUT_EXT);
4904 err = ext4_ext_remove_space(inode, first_block, stop_block - 1);
4855
4905
4856 if (ret > 0) {
4857 blocks_released += ret;
4858 num_blocks = ret;
4859 } else if (ret == 0) {
4860 /*
4861 * If map blocks could not find the block,
4862 * then it is in a hole. If the hole was
4863 * not already cached, then map blocks should
4864 * put it in the cache. So we can get the hole
4865 * out of the cache
4866 */
4867 memset(&cache_ex, 0, sizeof(cache_ex));
4868 if ((ext4_ext_check_cache(inode, iblock, &cache_ex)) &&
4869 !cache_ex.ec_start) {
4906 ext4_ext_invalidate_cache(inode);
4907 ext4_discard_preallocations(inode);
4870
4908
4871 /* The hole is cached */
4872 num_blocks = cache_ex.ec_block +
4873 cache_ex.ec_len - iblock;
4874
4875 } else {
4876 /* The block could not be identified */
4877 err = -EIO;
4878 break;
4879 }
4880 } else {
4881 /* Map blocks error */
4882 err = ret;
4883 break;
4884 }
4885
4886 if (num_blocks == 0) {
4887 /* This condition should never happen */
4888 ext_debug("Block lookup failed");
4889 err = -EIO;
4890 break;
4891 }
4892
4893 iblock += num_blocks;
4894 }
4895
4896 if (blocks_released > 0) {
4897 ext4_ext_invalidate_cache(inode);
4898 ext4_discard_preallocations(inode);
4899 }
4900
4901 if (IS_SYNC(inode))
4902 ext4_handle_sync(handle);
4903
4904 up_write(&EXT4_I(inode)->i_data_sem);
4905
4906out:
4907 ext4_orphan_del(handle, inode);
4908 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);

--- 40 unchanged lines hidden ---
4909 if (IS_SYNC(inode))
4910 ext4_handle_sync(handle);
4911
4912 up_write(&EXT4_I(inode)->i_data_sem);
4913
4914out:
4915 ext4_orphan_del(handle, inode);
4916 inode->i_mtime = inode->i_ctime = ext4_current_time(inode);

--- 40 unchanged lines hidden ---