]> git.ipfire.org Git - people/ms/linux.git/commit - fs/btrfs/ioctl.c
btrfs: Factor out the main deletion process from btrfs_ioctl_snap_destroy()
authorMisono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Wed, 18 Apr 2018 02:34:52 +0000 (11:34 +0900)
committerDavid Sterba <dsterba@suse.com>
Mon, 28 May 2018 16:07:18 +0000 (18:07 +0200)
commitf60a2364a4eee4d8c335775a3a0c39aa955aa6b7
treef6652ea895eb50a948f0ed2e703a07d5f02b3c0b
parentec42f167348a1949ac309532aa34760cfc96c92f
btrfs: Factor out the main deletion process from btrfs_ioctl_snap_destroy()

Factor out the second half of btrfs_ioctl_snap_destroy() as
btrfs_delete_subvolume(), which performs some subvolume specific checks
before deletion:

1. send is not in progress
2. the subvolume is not the default subvolume
3. the subvolume does not contain other subvolumes

and actual deletion process. btrfs_delete_subvolume() requires
inode_lock for both @dir and inode of @dentry. The remaining part of
btrfs_ioctl_snap_destroy() is mainly permission checks.

Note that call of d_delete() is not included in btrfs_delete_subvolume()
as this function will also be used by btrfs_rmdir() to delete an empty
subvolume and in that case d_delete() is called in VFS layer.

As a result, btrfs_unlink_subvol() and may_destroy_subvol()
become static functions. No functional changes.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ minor comment updates ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/inode.c
fs/btrfs/ioctl.c