All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume
@ 2021-06-28 10:16 Qu Wenruo
  2021-06-28 10:16 ` [PATCH 1/3] btrfs: return -EINVAL if some user wants to remove uuid/data_reloc tree Qu Wenruo
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Qu Wenruo @ 2021-06-28 10:16 UTC (permalink / raw)
  To: linux-btrfs

Since we're busting ghost subvolumes, the branch is now called
ghost_busters:
https://github.com/adam900710/linux/tree/ghost_busters

The first two patches are just cleanup found during the development.

The first is a missing check for subvolid range, the missing check
itself won't cause any harm, just returning -ENOENT from dentry lookup,
other than the expected -EINVAL.

The 2nd is a super old dead comment from the early age of btrfs.

The final patch is the real work to allow patched "btrfs subvolume delete -i"
to delete ghost subvolume.
Tested with the image dump of previous submitted btrfs-progs patchset.

Qu Wenruo (3):
  btrfs: return -EINVAL if some user wants to remove uuid/data_reloc
    tree
  btrfs: remove dead comment on btrfs_add_dead_root()
  btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume

 fs/btrfs/ioctl.c       | 81 +++++++++++++++++++++++++++++++++++++++++-
 fs/btrfs/transaction.c |  7 ++--
 2 files changed, 84 insertions(+), 4 deletions(-)

-- 
2.32.0


^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: [PATCH 3/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume
  2021-06-28 10:16 ` [PATCH 3/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume Qu Wenruo
  2021-06-28 16:22     ` kernel test robot
@ 2021-06-29  7:04 ` Dan Carpenter
  2021-06-30 13:16   ` David Sterba
  2 siblings, 0 replies; 22+ messages in thread
From: kernel test robot @ 2021-06-28 17:18 UTC (permalink / raw)
  To: kbuild

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

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210628101637.349718-4-wqu@suse.com>
References: <20210628101637.349718-4-wqu@suse.com>
TO: Qu Wenruo <wqu@suse.com>
TO: linux-btrfs(a)vger.kernel.org

Hi Qu,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kdave/for-next]
[also build test WARNING on v5.13 next-20210628]
[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/Qu-Wenruo/btrfs-allow-BTRFS_IOC_SNAP_DESTROY_V2-to-remove-ghost-subvolume/20210628-181747
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: i386-randconfig-m021-20210628 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 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>

New smatch warnings:
fs/btrfs/ioctl.c:2967 remove_ghost_subvol() error: uninitialized symbol 'ret'.

Old smatch warnings:
fs/btrfs/ioctl.c:808 create_snapshot() warn: '&pending_snapshot->list' not removed from list
fs/btrfs/ioctl.c:1568 btrfs_defrag_file() warn: should 'ret << 12' be a 64 bit type?

vim +/ret +2967 fs/btrfs/ioctl.c

42e4b520c812da Tomohiro Misono 2018-05-21  2894  
391ab0041fef57 Qu Wenruo       2021-06-28  2895  /*
391ab0041fef57 Qu Wenruo       2021-06-28  2896   * Special case that some subvolume has missing ORPHAN_ITEM, but its refs is
391ab0041fef57 Qu Wenruo       2021-06-28  2897   * already 0 (without any ROOT_REF/BACKREF).
391ab0041fef57 Qu Wenruo       2021-06-28  2898   * In that case such subvolume is only taking space while unable to be deleted.
391ab0041fef57 Qu Wenruo       2021-06-28  2899   *
391ab0041fef57 Qu Wenruo       2021-06-28  2900   * No reproducer to reproduce such corruption, but it won't hurt to cleanup them
391ab0041fef57 Qu Wenruo       2021-06-28  2901   * as we can reuse existing code since we only need to insert an orphan item and
391ab0041fef57 Qu Wenruo       2021-06-28  2902   * queue them to be deleted.
391ab0041fef57 Qu Wenruo       2021-06-28  2903   */
391ab0041fef57 Qu Wenruo       2021-06-28  2904  static int __cold remove_ghost_subvol(struct btrfs_fs_info *fs_info,
391ab0041fef57 Qu Wenruo       2021-06-28  2905  				      u64 rootid)
391ab0041fef57 Qu Wenruo       2021-06-28  2906  {
391ab0041fef57 Qu Wenruo       2021-06-28  2907  	struct btrfs_trans_handle *trans;
391ab0041fef57 Qu Wenruo       2021-06-28  2908  	struct btrfs_root *root;
391ab0041fef57 Qu Wenruo       2021-06-28  2909  	struct btrfs_path *path;
391ab0041fef57 Qu Wenruo       2021-06-28  2910  	struct btrfs_key key;
391ab0041fef57 Qu Wenruo       2021-06-28  2911  	int ret;
391ab0041fef57 Qu Wenruo       2021-06-28  2912  
391ab0041fef57 Qu Wenruo       2021-06-28  2913  	root = btrfs_get_fs_root(fs_info, rootid, false);
391ab0041fef57 Qu Wenruo       2021-06-28  2914  	if (IS_ERR(root)) {
391ab0041fef57 Qu Wenruo       2021-06-28  2915  		ret = PTR_ERR(root);
391ab0041fef57 Qu Wenruo       2021-06-28  2916  		return ret;
391ab0041fef57 Qu Wenruo       2021-06-28  2917  	}
391ab0041fef57 Qu Wenruo       2021-06-28  2918  
391ab0041fef57 Qu Wenruo       2021-06-28  2919  	/* A ghost subvolume is already a problem, better to output a warning */
391ab0041fef57 Qu Wenruo       2021-06-28  2920  	btrfs_warn(fs_info, "root %llu has no refs nor orphan item", rootid); 
391ab0041fef57 Qu Wenruo       2021-06-28  2921  	if (btrfs_root_refs(&root->root_item) != 0) {
391ab0041fef57 Qu Wenruo       2021-06-28  2922  		/* We get some strange root */
391ab0041fef57 Qu Wenruo       2021-06-28  2923  		btrfs_warn(fs_info,
391ab0041fef57 Qu Wenruo       2021-06-28  2924  			"root %llu has %u refs, but no proper root backref",
391ab0041fef57 Qu Wenruo       2021-06-28  2925  			rootid, btrfs_root_refs(&root->root_item));
391ab0041fef57 Qu Wenruo       2021-06-28  2926  		ret = -EUCLEAN;
391ab0041fef57 Qu Wenruo       2021-06-28  2927  		goto out;
391ab0041fef57 Qu Wenruo       2021-06-28  2928  	}
391ab0041fef57 Qu Wenruo       2021-06-28  2929  
391ab0041fef57 Qu Wenruo       2021-06-28  2930  	/* Already has orphan inserted */
391ab0041fef57 Qu Wenruo       2021-06-28  2931  	if (test_bit(BTRFS_ROOT_ORPHAN_ITEM_INSERTED, &root->state))
391ab0041fef57 Qu Wenruo       2021-06-28  2932  		goto out;
391ab0041fef57 Qu Wenruo       2021-06-28  2933  
391ab0041fef57 Qu Wenruo       2021-06-28  2934  	path = btrfs_alloc_path();
391ab0041fef57 Qu Wenruo       2021-06-28  2935  	if (!path) {
391ab0041fef57 Qu Wenruo       2021-06-28  2936  		ret = -ENOMEM;
391ab0041fef57 Qu Wenruo       2021-06-28  2937  		goto out;
391ab0041fef57 Qu Wenruo       2021-06-28  2938  	}
391ab0041fef57 Qu Wenruo       2021-06-28  2939  	key.objectid = BTRFS_ORPHAN_OBJECTID;
391ab0041fef57 Qu Wenruo       2021-06-28  2940  	key.type = BTRFS_ORPHAN_ITEM_KEY;
391ab0041fef57 Qu Wenruo       2021-06-28  2941  	key.offset = rootid;
391ab0041fef57 Qu Wenruo       2021-06-28  2942  
391ab0041fef57 Qu Wenruo       2021-06-28  2943  	ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
391ab0041fef57 Qu Wenruo       2021-06-28  2944  	btrfs_free_path(path);
391ab0041fef57 Qu Wenruo       2021-06-28  2945  	/* Either error or there is already an orphan item */
391ab0041fef57 Qu Wenruo       2021-06-28  2946  	if (ret <= 0)
391ab0041fef57 Qu Wenruo       2021-06-28  2947  		goto out;
391ab0041fef57 Qu Wenruo       2021-06-28  2948  
391ab0041fef57 Qu Wenruo       2021-06-28  2949  	trans = btrfs_start_transaction(fs_info->tree_root, 1);
391ab0041fef57 Qu Wenruo       2021-06-28  2950  	if (IS_ERR(trans)) {
391ab0041fef57 Qu Wenruo       2021-06-28  2951  		ret = PTR_ERR(trans);
391ab0041fef57 Qu Wenruo       2021-06-28  2952  		goto out;
391ab0041fef57 Qu Wenruo       2021-06-28  2953  	}
391ab0041fef57 Qu Wenruo       2021-06-28  2954  
391ab0041fef57 Qu Wenruo       2021-06-28  2955  	ret = btrfs_insert_orphan_item(trans, fs_info->tree_root, rootid);
391ab0041fef57 Qu Wenruo       2021-06-28  2956  	if (ret < 0 && ret != -EEXIST) {
391ab0041fef57 Qu Wenruo       2021-06-28  2957  		btrfs_abort_transaction(trans, ret);
391ab0041fef57 Qu Wenruo       2021-06-28  2958  		goto end_trans;
391ab0041fef57 Qu Wenruo       2021-06-28  2959  	}
391ab0041fef57 Qu Wenruo       2021-06-28  2960  	ret = 0;
391ab0041fef57 Qu Wenruo       2021-06-28  2961  	btrfs_add_dead_root(root);
391ab0041fef57 Qu Wenruo       2021-06-28  2962  
391ab0041fef57 Qu Wenruo       2021-06-28  2963  end_trans:
391ab0041fef57 Qu Wenruo       2021-06-28  2964  	btrfs_end_transaction(trans);
391ab0041fef57 Qu Wenruo       2021-06-28  2965  out:
391ab0041fef57 Qu Wenruo       2021-06-28  2966  	btrfs_put_root(root);
391ab0041fef57 Qu Wenruo       2021-06-28 @2967  	return ret;
391ab0041fef57 Qu Wenruo       2021-06-28  2968  }
391ab0041fef57 Qu Wenruo       2021-06-28  2969  

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

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

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

end of thread, other threads:[~2021-08-20  5:45 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-06-28 10:16 [PATCH 0/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume Qu Wenruo
2021-06-28 10:16 ` [PATCH 1/3] btrfs: return -EINVAL if some user wants to remove uuid/data_reloc tree Qu Wenruo
2021-06-28 10:59   ` Anand Jain
2021-06-28 10:16 ` [PATCH 2/3] btrfs: remove dead comment on btrfs_add_dead_root() Qu Wenruo
2021-06-28 11:01   ` Anand Jain
2021-06-28 10:16 ` [PATCH 3/3] btrfs: allow BTRFS_IOC_SNAP_DESTROY_V2 to remove ghost subvolume Qu Wenruo
2021-06-28 16:22   ` kernel test robot
2021-06-28 16:22     ` kernel test robot
2021-06-28 16:23   ` kernel test robot
2021-06-28 16:23     ` kernel test robot
2021-06-30 13:16   ` David Sterba
2021-06-30 13:26     ` Qu Wenruo
2021-06-30 13:30       ` David Sterba
2021-06-30 13:35         ` Qu Wenruo
2021-07-20  4:05 ` [PATCH 0/3] " Zygo Blaxell
2021-07-20  4:33   ` Qu Wenruo
2021-07-20 15:41     ` Zygo Blaxell
2021-07-20 22:40       ` Qu Wenruo
2021-08-20  5:45 ` Qu Wenruo
  -- strict thread matches above, loose matches on Subject: below --
2021-06-28 17:18 [PATCH 3/3] " kernel test robot
2021-06-29  7:04 ` [kbuild] " Dan Carpenter
2021-06-29  7:04 ` Dan Carpenter

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.