All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 4/5] btrfs: rename btrfs_punch_hole_range() to a more generic name
@ 2020-09-08 17:36 kernel test robot
  0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-09-08 17:36 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 20591 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <7e911d8b38d65c426738e53ac205eac94105c87f.1599560101.git.fdmanana@suse.com>
References: <7e911d8b38d65c426738e53ac205eac94105c87f.1599560101.git.fdmanana@suse.com>
TO: fdmanana(a)kernel.org

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kdave/for-next]
[also build test WARNING on v5.9-rc4 next-20200908]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/fdmanana-kernel-org/btrfs-fix-enospc-and-transaction-aborts-during-fallocate/20200908-183018
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
:::::: branch date: 7 hours ago
:::::: commit date: 7 hours ago
config: x86_64-randconfig-m001-20200907 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
fs/btrfs/file.c:2841 btrfs_replace_file_extents() error: uninitialized symbol 'drop_end'.

# https://github.com/0day-ci/linux/commit/b34638b375b87679b2f17a719e03cd765e5db48e
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review fdmanana-kernel-org/btrfs-fix-enospc-and-transaction-aborts-during-fallocate/20200908-183018
git checkout b34638b375b87679b2f17a719e03cd765e5db48e
vim +/drop_end +2841 fs/btrfs/file.c

690a5dbfc51315 Filipe Manana   2019-07-05  2652  
9cba40a693e69b Filipe Manana   2019-06-28  2653  /*
9cba40a693e69b Filipe Manana   2019-06-28  2654   * The respective range must have been previously locked, as well as the inode.
9cba40a693e69b Filipe Manana   2019-06-28  2655   * The end offset is inclusive (last byte of the range).
5a61ac50b95241 Filipe Manana   2020-09-08  2656   * @extent_info is NULL for fallocate's hole punching and non-NULL when replacing
5a61ac50b95241 Filipe Manana   2020-09-08  2657   * the file range with an extent.
5a61ac50b95241 Filipe Manana   2020-09-08  2658   * When not punching a hole, we don't want to end up in a state where we dropped
5a61ac50b95241 Filipe Manana   2020-09-08  2659   * extents without inserting a new one, so we must abort the transaction to avoid
5a61ac50b95241 Filipe Manana   2020-09-08  2660   * a corruption.
9cba40a693e69b Filipe Manana   2019-06-28  2661   */
b34638b375b876 Filipe Manana   2020-09-08  2662  int btrfs_replace_file_extents(struct inode *inode, struct btrfs_path *path,
9cba40a693e69b Filipe Manana   2019-06-28  2663  			   const u64 start, const u64 end,
5a61ac50b95241 Filipe Manana   2020-09-08  2664  			   struct btrfs_replace_extent_info *extent_info,
9cba40a693e69b Filipe Manana   2019-06-28  2665  			   struct btrfs_trans_handle **trans_out)
9cba40a693e69b Filipe Manana   2019-06-28  2666  {
9cba40a693e69b Filipe Manana   2019-06-28  2667  	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2bd36e7b4fd60d Josef Bacik     2019-08-22  2668  	u64 min_size = btrfs_calc_insert_metadata_size(fs_info, 1);
9cba40a693e69b Filipe Manana   2019-06-28  2669  	u64 ino_size = round_up(inode->i_size, fs_info->sectorsize);
9cba40a693e69b Filipe Manana   2019-06-28  2670  	struct btrfs_root *root = BTRFS_I(inode)->root;
9cba40a693e69b Filipe Manana   2019-06-28  2671  	struct btrfs_trans_handle *trans = NULL;
9cba40a693e69b Filipe Manana   2019-06-28  2672  	struct btrfs_block_rsv *rsv;
9cba40a693e69b Filipe Manana   2019-06-28  2673  	unsigned int rsv_count;
9cba40a693e69b Filipe Manana   2019-06-28  2674  	u64 cur_offset;
9cba40a693e69b Filipe Manana   2019-06-28  2675  	u64 drop_end;
9cba40a693e69b Filipe Manana   2019-06-28  2676  	u64 len = end - start;
9cba40a693e69b Filipe Manana   2019-06-28  2677  	int ret = 0;
9cba40a693e69b Filipe Manana   2019-06-28  2678  
9cba40a693e69b Filipe Manana   2019-06-28  2679  	if (end <= start)
9cba40a693e69b Filipe Manana   2019-06-28  2680  		return -EINVAL;
9cba40a693e69b Filipe Manana   2019-06-28  2681  
9cba40a693e69b Filipe Manana   2019-06-28  2682  	rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP);
9cba40a693e69b Filipe Manana   2019-06-28  2683  	if (!rsv) {
9cba40a693e69b Filipe Manana   2019-06-28  2684  		ret = -ENOMEM;
9cba40a693e69b Filipe Manana   2019-06-28  2685  		goto out;
9cba40a693e69b Filipe Manana   2019-06-28  2686  	}
2bd36e7b4fd60d Josef Bacik     2019-08-22  2687  	rsv->size = btrfs_calc_insert_metadata_size(fs_info, 1);
9cba40a693e69b Filipe Manana   2019-06-28  2688  	rsv->failfast = 1;
9cba40a693e69b Filipe Manana   2019-06-28  2689  
9cba40a693e69b Filipe Manana   2019-06-28  2690  	/*
9cba40a693e69b Filipe Manana   2019-06-28  2691  	 * 1 - update the inode
9cba40a693e69b Filipe Manana   2019-06-28  2692  	 * 1 - removing the extents in the range
5a61ac50b95241 Filipe Manana   2020-09-08  2693  	 * 1 - adding the hole extent if no_holes isn't set or if we are
5a61ac50b95241 Filipe Manana   2020-09-08  2694  	 *     replacing the range with a new extent
9cba40a693e69b Filipe Manana   2019-06-28  2695  	 */
5a61ac50b95241 Filipe Manana   2020-09-08  2696  	if (!btrfs_fs_incompat(fs_info, NO_HOLES) || extent_info)
690a5dbfc51315 Filipe Manana   2019-07-05  2697  		rsv_count = 3;
690a5dbfc51315 Filipe Manana   2019-07-05  2698  	else
690a5dbfc51315 Filipe Manana   2019-07-05  2699  		rsv_count = 2;
690a5dbfc51315 Filipe Manana   2019-07-05  2700  
9cba40a693e69b Filipe Manana   2019-06-28  2701  	trans = btrfs_start_transaction(root, rsv_count);
9cba40a693e69b Filipe Manana   2019-06-28  2702  	if (IS_ERR(trans)) {
9cba40a693e69b Filipe Manana   2019-06-28  2703  		ret = PTR_ERR(trans);
9cba40a693e69b Filipe Manana   2019-06-28  2704  		trans = NULL;
9cba40a693e69b Filipe Manana   2019-06-28  2705  		goto out_free;
9cba40a693e69b Filipe Manana   2019-06-28  2706  	}
9cba40a693e69b Filipe Manana   2019-06-28  2707  
9cba40a693e69b Filipe Manana   2019-06-28  2708  	ret = btrfs_block_rsv_migrate(&fs_info->trans_block_rsv, rsv,
9cba40a693e69b Filipe Manana   2019-06-28  2709  				      min_size, false);
9cba40a693e69b Filipe Manana   2019-06-28  2710  	BUG_ON(ret);
9cba40a693e69b Filipe Manana   2019-06-28  2711  	trans->block_rsv = rsv;
9cba40a693e69b Filipe Manana   2019-06-28  2712  
9cba40a693e69b Filipe Manana   2019-06-28  2713  	cur_offset = start;
9cba40a693e69b Filipe Manana   2019-06-28  2714  	while (cur_offset < end) {
906c448c3dc318 Nikolay Borisov 2020-06-03  2715  		ret = __btrfs_drop_extents(trans, root, BTRFS_I(inode), path,
9cba40a693e69b Filipe Manana   2019-06-28  2716  					   cur_offset, end + 1, &drop_end,
9cba40a693e69b Filipe Manana   2019-06-28  2717  					   1, 0, 0, NULL);
690a5dbfc51315 Filipe Manana   2019-07-05  2718  		if (ret != -ENOSPC) {
690a5dbfc51315 Filipe Manana   2019-07-05  2719  			/*
690a5dbfc51315 Filipe Manana   2019-07-05  2720  			 * When cloning we want to avoid transaction aborts when
690a5dbfc51315 Filipe Manana   2019-07-05  2721  			 * nothing was done and we are attempting to clone parts
690a5dbfc51315 Filipe Manana   2019-07-05  2722  			 * of inline extents, in such cases -EOPNOTSUPP is
690a5dbfc51315 Filipe Manana   2019-07-05  2723  			 * returned by __btrfs_drop_extents() without having
690a5dbfc51315 Filipe Manana   2019-07-05  2724  			 * changed anything in the file.
690a5dbfc51315 Filipe Manana   2019-07-05  2725  			 */
5a61ac50b95241 Filipe Manana   2020-09-08  2726  			if (extent_info && !extent_info->is_new_extent &&
40d4c070df6afc Filipe Manana   2020-09-08  2727  			    ret && ret != -EOPNOTSUPP)
690a5dbfc51315 Filipe Manana   2019-07-05  2728  				btrfs_abort_transaction(trans, ret);
9cba40a693e69b Filipe Manana   2019-06-28  2729  			break;
690a5dbfc51315 Filipe Manana   2019-07-05  2730  		}
9cba40a693e69b Filipe Manana   2019-06-28  2731  
9cba40a693e69b Filipe Manana   2019-06-28  2732  		trans->block_rsv = &fs_info->trans_block_rsv;
9cba40a693e69b Filipe Manana   2019-06-28  2733  
5a61ac50b95241 Filipe Manana   2020-09-08  2734  		if (!extent_info && cur_offset < drop_end &&
690a5dbfc51315 Filipe Manana   2019-07-05  2735  		    cur_offset < ino_size) {
9cba40a693e69b Filipe Manana   2019-06-28  2736  			ret = fill_holes(trans, BTRFS_I(inode), path,
9cba40a693e69b Filipe Manana   2019-06-28  2737  					cur_offset, drop_end);
9cba40a693e69b Filipe Manana   2019-06-28  2738  			if (ret) {
9cba40a693e69b Filipe Manana   2019-06-28  2739  				/*
9cba40a693e69b Filipe Manana   2019-06-28  2740  				 * If we failed then we didn't insert our hole
9cba40a693e69b Filipe Manana   2019-06-28  2741  				 * entries for the area we dropped, so now the
9cba40a693e69b Filipe Manana   2019-06-28  2742  				 * fs is corrupted, so we must abort the
9cba40a693e69b Filipe Manana   2019-06-28  2743  				 * transaction.
9cba40a693e69b Filipe Manana   2019-06-28  2744  				 */
9cba40a693e69b Filipe Manana   2019-06-28  2745  				btrfs_abort_transaction(trans, ret);
9cba40a693e69b Filipe Manana   2019-06-28  2746  				break;
9cba40a693e69b Filipe Manana   2019-06-28  2747  			}
5a61ac50b95241 Filipe Manana   2020-09-08  2748  		} else if (!extent_info && cur_offset < drop_end) {
9ddc959e802bf7 Josef Bacik     2020-01-17  2749  			/*
9ddc959e802bf7 Josef Bacik     2020-01-17  2750  			 * We are past the i_size here, but since we didn't
9ddc959e802bf7 Josef Bacik     2020-01-17  2751  			 * insert holes we need to clear the mapped area so we
9ddc959e802bf7 Josef Bacik     2020-01-17  2752  			 * know to not set disk_i_size in this area until a new
9ddc959e802bf7 Josef Bacik     2020-01-17  2753  			 * file extent is inserted here.
9ddc959e802bf7 Josef Bacik     2020-01-17  2754  			 */
9ddc959e802bf7 Josef Bacik     2020-01-17  2755  			ret = btrfs_inode_clear_file_extent_range(BTRFS_I(inode),
9ddc959e802bf7 Josef Bacik     2020-01-17  2756  					cur_offset, drop_end - cur_offset);
9ddc959e802bf7 Josef Bacik     2020-01-17  2757  			if (ret) {
9ddc959e802bf7 Josef Bacik     2020-01-17  2758  				/*
9ddc959e802bf7 Josef Bacik     2020-01-17  2759  				 * We couldn't clear our area, so we could
9ddc959e802bf7 Josef Bacik     2020-01-17  2760  				 * presumably adjust up and corrupt the fs, so
9ddc959e802bf7 Josef Bacik     2020-01-17  2761  				 * we need to abort.
9ddc959e802bf7 Josef Bacik     2020-01-17  2762  				 */
9ddc959e802bf7 Josef Bacik     2020-01-17  2763  				btrfs_abort_transaction(trans, ret);
9ddc959e802bf7 Josef Bacik     2020-01-17  2764  				break;
9ddc959e802bf7 Josef Bacik     2020-01-17  2765  			}
9cba40a693e69b Filipe Manana   2019-06-28  2766  		}
9cba40a693e69b Filipe Manana   2019-06-28  2767  
5a61ac50b95241 Filipe Manana   2020-09-08  2768  		if (extent_info && drop_end > extent_info->file_offset) {
5a61ac50b95241 Filipe Manana   2020-09-08  2769  			u64 replace_len = drop_end - extent_info->file_offset;
690a5dbfc51315 Filipe Manana   2019-07-05  2770  
690a5dbfc51315 Filipe Manana   2019-07-05  2771  			ret = btrfs_insert_clone_extent(trans, inode, path,
5a61ac50b95241 Filipe Manana   2020-09-08  2772  							extent_info, replace_len);
690a5dbfc51315 Filipe Manana   2019-07-05  2773  			if (ret) {
690a5dbfc51315 Filipe Manana   2019-07-05  2774  				btrfs_abort_transaction(trans, ret);
690a5dbfc51315 Filipe Manana   2019-07-05  2775  				break;
690a5dbfc51315 Filipe Manana   2019-07-05  2776  			}
5a61ac50b95241 Filipe Manana   2020-09-08  2777  			extent_info->data_len -= replace_len;
5a61ac50b95241 Filipe Manana   2020-09-08  2778  			extent_info->data_offset += replace_len;
5a61ac50b95241 Filipe Manana   2020-09-08  2779  			extent_info->file_offset += replace_len;
690a5dbfc51315 Filipe Manana   2019-07-05  2780  		}
690a5dbfc51315 Filipe Manana   2019-07-05  2781  
9cba40a693e69b Filipe Manana   2019-06-28  2782  		cur_offset = drop_end;
9cba40a693e69b Filipe Manana   2019-06-28  2783  
9cba40a693e69b Filipe Manana   2019-06-28  2784  		ret = btrfs_update_inode(trans, root, inode);
9cba40a693e69b Filipe Manana   2019-06-28  2785  		if (ret)
9cba40a693e69b Filipe Manana   2019-06-28  2786  			break;
9cba40a693e69b Filipe Manana   2019-06-28  2787  
9cba40a693e69b Filipe Manana   2019-06-28  2788  		btrfs_end_transaction(trans);
9cba40a693e69b Filipe Manana   2019-06-28  2789  		btrfs_btree_balance_dirty(fs_info);
9cba40a693e69b Filipe Manana   2019-06-28  2790  
9cba40a693e69b Filipe Manana   2019-06-28  2791  		trans = btrfs_start_transaction(root, rsv_count);
9cba40a693e69b Filipe Manana   2019-06-28  2792  		if (IS_ERR(trans)) {
9cba40a693e69b Filipe Manana   2019-06-28  2793  			ret = PTR_ERR(trans);
9cba40a693e69b Filipe Manana   2019-06-28  2794  			trans = NULL;
9cba40a693e69b Filipe Manana   2019-06-28  2795  			break;
9cba40a693e69b Filipe Manana   2019-06-28  2796  		}
9cba40a693e69b Filipe Manana   2019-06-28  2797  
9cba40a693e69b Filipe Manana   2019-06-28  2798  		ret = btrfs_block_rsv_migrate(&fs_info->trans_block_rsv,
9cba40a693e69b Filipe Manana   2019-06-28  2799  					      rsv, min_size, false);
9cba40a693e69b Filipe Manana   2019-06-28  2800  		BUG_ON(ret);	/* shouldn't happen */
9cba40a693e69b Filipe Manana   2019-06-28  2801  		trans->block_rsv = rsv;
9cba40a693e69b Filipe Manana   2019-06-28  2802  
5a61ac50b95241 Filipe Manana   2020-09-08  2803  		if (!extent_info) {
9cba40a693e69b Filipe Manana   2019-06-28  2804  			ret = find_first_non_hole(inode, &cur_offset, &len);
9cba40a693e69b Filipe Manana   2019-06-28  2805  			if (unlikely(ret < 0))
9cba40a693e69b Filipe Manana   2019-06-28  2806  				break;
9cba40a693e69b Filipe Manana   2019-06-28  2807  			if (ret && !len) {
9cba40a693e69b Filipe Manana   2019-06-28  2808  				ret = 0;
9cba40a693e69b Filipe Manana   2019-06-28  2809  				break;
9cba40a693e69b Filipe Manana   2019-06-28  2810  			}
9cba40a693e69b Filipe Manana   2019-06-28  2811  		}
690a5dbfc51315 Filipe Manana   2019-07-05  2812  	}
690a5dbfc51315 Filipe Manana   2019-07-05  2813  
690a5dbfc51315 Filipe Manana   2019-07-05  2814  	/*
690a5dbfc51315 Filipe Manana   2019-07-05  2815  	 * If we were cloning, force the next fsync to be a full one since we
690a5dbfc51315 Filipe Manana   2019-07-05  2816  	 * we replaced (or just dropped in the case of cloning holes when
690a5dbfc51315 Filipe Manana   2019-07-05  2817  	 * NO_HOLES is enabled) extents and extent maps.
690a5dbfc51315 Filipe Manana   2019-07-05  2818  	 * This is for the sake of simplicity, and cloning into files larger
690a5dbfc51315 Filipe Manana   2019-07-05  2819  	 * than 16Mb would force the full fsync any way (when
690a5dbfc51315 Filipe Manana   2019-07-05  2820  	 * try_release_extent_mapping() is invoked during page cache truncation.
690a5dbfc51315 Filipe Manana   2019-07-05  2821  	 */
5a61ac50b95241 Filipe Manana   2020-09-08  2822  	if (extent_info && !extent_info->is_new_extent)
690a5dbfc51315 Filipe Manana   2019-07-05  2823  		set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
690a5dbfc51315 Filipe Manana   2019-07-05  2824  			&BTRFS_I(inode)->runtime_flags);
9cba40a693e69b Filipe Manana   2019-06-28  2825  
9cba40a693e69b Filipe Manana   2019-06-28  2826  	if (ret)
9cba40a693e69b Filipe Manana   2019-06-28  2827  		goto out_trans;
9cba40a693e69b Filipe Manana   2019-06-28  2828  
9cba40a693e69b Filipe Manana   2019-06-28  2829  	trans->block_rsv = &fs_info->trans_block_rsv;
9cba40a693e69b Filipe Manana   2019-06-28  2830  	/*
9cba40a693e69b Filipe Manana   2019-06-28  2831  	 * If we are using the NO_HOLES feature we might have had already an
9cba40a693e69b Filipe Manana   2019-06-28  2832  	 * hole that overlaps a part of the region [lockstart, lockend] and
9cba40a693e69b Filipe Manana   2019-06-28  2833  	 * ends at (or beyond) lockend. Since we have no file extent items to
9cba40a693e69b Filipe Manana   2019-06-28  2834  	 * represent holes, drop_end can be less than lockend and so we must
9cba40a693e69b Filipe Manana   2019-06-28  2835  	 * make sure we have an extent map representing the existing hole (the
9cba40a693e69b Filipe Manana   2019-06-28  2836  	 * call to __btrfs_drop_extents() might have dropped the existing extent
9cba40a693e69b Filipe Manana   2019-06-28  2837  	 * map representing the existing hole), otherwise the fast fsync path
9cba40a693e69b Filipe Manana   2019-06-28  2838  	 * will not record the existence of the hole region
9cba40a693e69b Filipe Manana   2019-06-28  2839  	 * [existing_hole_start, lockend].
9cba40a693e69b Filipe Manana   2019-06-28  2840  	 */
9cba40a693e69b Filipe Manana   2019-06-28 @2841  	if (drop_end <= end)
9cba40a693e69b Filipe Manana   2019-06-28  2842  		drop_end = end + 1;
9cba40a693e69b Filipe Manana   2019-06-28  2843  	/*
9cba40a693e69b Filipe Manana   2019-06-28  2844  	 * Don't insert file hole extent item if it's for a range beyond eof
9cba40a693e69b Filipe Manana   2019-06-28  2845  	 * (because it's useless) or if it represents a 0 bytes range (when
9cba40a693e69b Filipe Manana   2019-06-28  2846  	 * cur_offset == drop_end).
9cba40a693e69b Filipe Manana   2019-06-28  2847  	 */
5a61ac50b95241 Filipe Manana   2020-09-08  2848  	if (!extent_info && cur_offset < ino_size && cur_offset < drop_end) {
9cba40a693e69b Filipe Manana   2019-06-28  2849  		ret = fill_holes(trans, BTRFS_I(inode), path,
9cba40a693e69b Filipe Manana   2019-06-28  2850  				cur_offset, drop_end);
9cba40a693e69b Filipe Manana   2019-06-28  2851  		if (ret) {
9cba40a693e69b Filipe Manana   2019-06-28  2852  			/* Same comment as above. */
9cba40a693e69b Filipe Manana   2019-06-28  2853  			btrfs_abort_transaction(trans, ret);
9cba40a693e69b Filipe Manana   2019-06-28  2854  			goto out_trans;
9cba40a693e69b Filipe Manana   2019-06-28  2855  		}
5a61ac50b95241 Filipe Manana   2020-09-08  2856  	} else if (!extent_info && cur_offset < drop_end) {
9ddc959e802bf7 Josef Bacik     2020-01-17  2857  		/* See the comment in the loop above for the reasoning here. */
9ddc959e802bf7 Josef Bacik     2020-01-17  2858  		ret = btrfs_inode_clear_file_extent_range(BTRFS_I(inode),
9ddc959e802bf7 Josef Bacik     2020-01-17  2859  					cur_offset, drop_end - cur_offset);
9ddc959e802bf7 Josef Bacik     2020-01-17  2860  		if (ret) {
9ddc959e802bf7 Josef Bacik     2020-01-17  2861  			btrfs_abort_transaction(trans, ret);
9ddc959e802bf7 Josef Bacik     2020-01-17  2862  			goto out_trans;
9ddc959e802bf7 Josef Bacik     2020-01-17  2863  		}
9ddc959e802bf7 Josef Bacik     2020-01-17  2864  
9cba40a693e69b Filipe Manana   2019-06-28  2865  	}
5a61ac50b95241 Filipe Manana   2020-09-08  2866  	if (extent_info) {
5a61ac50b95241 Filipe Manana   2020-09-08  2867  		ret = btrfs_insert_clone_extent(trans, inode, path, extent_info,
5a61ac50b95241 Filipe Manana   2020-09-08  2868  						extent_info->data_len);
690a5dbfc51315 Filipe Manana   2019-07-05  2869  		if (ret) {
690a5dbfc51315 Filipe Manana   2019-07-05  2870  			btrfs_abort_transaction(trans, ret);
690a5dbfc51315 Filipe Manana   2019-07-05  2871  			goto out_trans;
690a5dbfc51315 Filipe Manana   2019-07-05  2872  		}
690a5dbfc51315 Filipe Manana   2019-07-05  2873  	}
9cba40a693e69b Filipe Manana   2019-06-28  2874  
9cba40a693e69b Filipe Manana   2019-06-28  2875  out_trans:
9cba40a693e69b Filipe Manana   2019-06-28  2876  	if (!trans)
9cba40a693e69b Filipe Manana   2019-06-28  2877  		goto out_free;
9cba40a693e69b Filipe Manana   2019-06-28  2878  
9cba40a693e69b Filipe Manana   2019-06-28  2879  	trans->block_rsv = &fs_info->trans_block_rsv;
9cba40a693e69b Filipe Manana   2019-06-28  2880  	if (ret)
9cba40a693e69b Filipe Manana   2019-06-28  2881  		btrfs_end_transaction(trans);
9cba40a693e69b Filipe Manana   2019-06-28  2882  	else
9cba40a693e69b Filipe Manana   2019-06-28  2883  		*trans_out = trans;
9cba40a693e69b Filipe Manana   2019-06-28  2884  out_free:
9cba40a693e69b Filipe Manana   2019-06-28  2885  	btrfs_free_block_rsv(fs_info, rsv);
9cba40a693e69b Filipe Manana   2019-06-28  2886  out:
9cba40a693e69b Filipe Manana   2019-06-28  2887  	return ret;
9cba40a693e69b Filipe Manana   2019-06-28  2888  }
9cba40a693e69b Filipe Manana   2019-06-28  2889  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38592 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 4/5] btrfs: rename btrfs_punch_hole_range() to a more generic name
  2020-09-08 10:27 ` [PATCH 4/5] btrfs: rename btrfs_punch_hole_range() to a more generic name fdmanana
@ 2020-09-10 14:49   ` Josef Bacik
  0 siblings, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2020-09-10 14:49 UTC (permalink / raw)
  To: fdmanana, linux-btrfs; +Cc: Filipe Manana

On 9/8/20 6:27 AM, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
> 
> The function btrfs_punch_hole_range() is now used to replace all the file
> extents in a given file range with an extent described in the given struct
> btrfs_replace_extent_info argument. This extent can either be an existing
> extent that is being cloned or it can be a new extent (namely a prealloc
> extent). When that argument is NULL it only punches a hole (drop alls the
> existing extents) in the file range.
> 
> So rename the function to btrfs_replace_file_extents().
> 
> Signed-off-by: Filipe Manana <fdmanana@suse.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 4/5] btrfs: rename btrfs_punch_hole_range() to a more generic name
  2020-09-08 10:27 [PATCH 0/5] btrfs: fix enospc and transaction aborts during fallocate fdmanana
@ 2020-09-08 10:27 ` fdmanana
  2020-09-10 14:49   ` Josef Bacik
  0 siblings, 1 reply; 3+ messages in thread
From: fdmanana @ 2020-09-08 10:27 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Filipe Manana

From: Filipe Manana <fdmanana@suse.com>

The function btrfs_punch_hole_range() is now used to replace all the file
extents in a given file range with an extent described in the given struct
btrfs_replace_extent_info argument. This extent can either be an existing
extent that is being cloned or it can be a new extent (namely a prealloc
extent). When that argument is NULL it only punches a hole (drop alls the
existing extents) in the file range.

So rename the function to btrfs_replace_file_extents().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/ctree.h   | 2 +-
 fs/btrfs/file.c    | 4 ++--
 fs/btrfs/inode.c   | 2 +-
 fs/btrfs/reflink.c | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 0b1dadd44e53..74ddff3529df 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3074,7 +3074,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
 int btrfs_drop_extents(struct btrfs_trans_handle *trans,
 		       struct btrfs_root *root, struct inode *inode, u64 start,
 		       u64 end, int drop_cache);
-int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path,
+int btrfs_replace_file_extents(struct inode *inode, struct btrfs_path *path,
 			   const u64 start, const u64 end,
 			   struct btrfs_replace_extent_info *extent_info,
 			   struct btrfs_trans_handle **trans_out);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 7ac0a20119f3..241b34e44a6c 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2659,7 +2659,7 @@ static int btrfs_insert_clone_extent(struct btrfs_trans_handle *trans,
  * extents without inserting a new one, so we must abort the transaction to avoid
  * a corruption.
  */
-int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path,
+int btrfs_replace_file_extents(struct inode *inode, struct btrfs_path *path,
 			   const u64 start, const u64 end,
 			   struct btrfs_replace_extent_info *extent_info,
 			   struct btrfs_trans_handle **trans_out)
@@ -3007,7 +3007,7 @@ static int btrfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)
 		goto out;
 	}
 
-	ret = btrfs_punch_hole_range(inode, path, lockstart, lockend, NULL,
+	ret = btrfs_replace_file_extents(inode, path, lockstart, lockend, NULL,
 				     &trans);
 	btrfs_free_path(path);
 	if (ret)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a67b80979c48..9f6fb0ff33e7 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9624,7 +9624,7 @@ static struct btrfs_trans_handle *insert_prealloc_file_extent(
 	if (!path)
 		return ERR_PTR(-ENOMEM);
 
-	ret = btrfs_punch_hole_range(inode, path, file_offset,
+	ret = btrfs_replace_file_extents(inode, path, file_offset,
 				     file_offset + len - 1, &extent_info,
 				     &trans);
 	btrfs_free_path(path);
diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c
index dc8b5397e198..39b3269e5760 100644
--- a/fs/btrfs/reflink.c
+++ b/fs/btrfs/reflink.c
@@ -463,7 +463,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
 			clone_info.file_offset = new_key.offset;
 			clone_info.extent_buf = buf;
 			clone_info.is_new_extent = false;
-			ret = btrfs_punch_hole_range(inode, path, drop_start,
+			ret = btrfs_replace_file_extents(inode, path, drop_start,
 					new_key.offset + datal - 1, &clone_info,
 					&trans);
 			if (ret)
@@ -533,7 +533,7 @@ static int btrfs_clone(struct inode *src, struct inode *inode,
 		btrfs_release_path(path);
 		path->leave_spinning = 0;
 
-		ret = btrfs_punch_hole_range(inode, path, last_dest_end,
+		ret = btrfs_replace_file_extents(inode, path, last_dest_end,
 				destoff + len - 1, NULL, &trans);
 		if (ret)
 			goto out;
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-10 19:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 17:36 [PATCH 4/5] btrfs: rename btrfs_punch_hole_range() to a more generic name kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2020-09-08 10:27 [PATCH 0/5] btrfs: fix enospc and transaction aborts during fallocate fdmanana
2020-09-08 10:27 ` [PATCH 4/5] btrfs: rename btrfs_punch_hole_range() to a more generic name fdmanana
2020-09-10 14:49   ` Josef Bacik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.