Lines Matching refs:root

218 	struct btrfs_root *root = ip->root;  in btrfs_ioctl_setflags()  local
229 if (btrfs_root_readonly(root)) in btrfs_ioctl_setflags()
326 if (root->fs_info->compress_type == BTRFS_COMPRESS_LZO) in btrfs_ioctl_setflags()
342 trans = btrfs_start_transaction(root, 1); in btrfs_ioctl_setflags()
351 ret = btrfs_update_inode(trans, root, inode); in btrfs_ioctl_setflags()
353 btrfs_end_transaction(trans, root); in btrfs_ioctl_setflags()
443 struct btrfs_root *root = BTRFS_I(dir)->root; in create_subvol() local
456 ret = btrfs_find_free_objectid(root->fs_info->tree_root, &objectid); in create_subvol()
472 ret = btrfs_subvolume_reserve_metadata(root, &block_rsv, in create_subvol()
477 trans = btrfs_start_transaction(root, 0); in create_subvol()
480 btrfs_subvolume_release_metadata(root, &block_rsv, in create_subvol()
487 ret = btrfs_qgroup_inherit(trans, root->fs_info, 0, objectid, inherit); in create_subvol()
491 leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0); in create_subvol()
503 write_extent_buffer(leaf, root->fs_info->fsid, btrfs_header_fsid(), in create_subvol()
505 write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid, in create_subvol()
516 btrfs_set_stack_inode_nbytes(inode_item, root->nodesize); in create_subvol()
549 ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key, in create_subvol()
555 new_root = btrfs_read_fs_root_no_name(root->fs_info, &key); in create_subvol()
558 btrfs_abort_transaction(trans, root, ret); in create_subvol()
564 ret = btrfs_create_subvol_root(trans, new_root, root, new_dirid); in create_subvol()
567 btrfs_abort_transaction(trans, root, ret); in create_subvol()
580 btrfs_abort_transaction(trans, root, ret); in create_subvol()
584 ret = btrfs_insert_dir_item(trans, root, in create_subvol()
588 btrfs_abort_transaction(trans, root, ret); in create_subvol()
593 ret = btrfs_update_inode(trans, root, dir); in create_subvol()
596 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, in create_subvol()
597 objectid, root->root_key.objectid, in create_subvol()
601 ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root, in create_subvol()
605 btrfs_abort_transaction(trans, root, ret); in create_subvol()
610 btrfs_subvolume_release_metadata(root, &block_rsv, qgroup_reserved); in create_subvol()
614 err = btrfs_commit_transaction_async(trans, root, 1); in create_subvol()
616 err = btrfs_commit_transaction(trans, root); in create_subvol()
618 err = btrfs_commit_transaction(trans, root); in create_subvol()
632 static void btrfs_wait_for_no_snapshoting_writes(struct btrfs_root *root) in btrfs_wait_for_no_snapshoting_writes() argument
638 prepare_to_wait(&root->subv_writers->wait, &wait, in btrfs_wait_for_no_snapshoting_writes()
641 writers = percpu_counter_sum(&root->subv_writers->counter); in btrfs_wait_for_no_snapshoting_writes()
645 finish_wait(&root->subv_writers->wait, &wait); in btrfs_wait_for_no_snapshoting_writes()
649 static int create_snapshot(struct btrfs_root *root, struct inode *dir, in create_snapshot() argument
659 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in create_snapshot()
662 atomic_inc(&root->will_be_snapshoted); in create_snapshot()
664 btrfs_wait_for_no_snapshoting_writes(root); in create_snapshot()
666 ret = btrfs_start_delalloc_inodes(root, 0); in create_snapshot()
670 btrfs_wait_ordered_extents(root, -1); in create_snapshot()
688 ret = btrfs_subvolume_reserve_metadata(BTRFS_I(dir)->root, in create_snapshot()
696 pending_snapshot->root = root; in create_snapshot()
701 trans = btrfs_start_transaction(root, 0); in create_snapshot()
707 spin_lock(&root->fs_info->trans_lock); in create_snapshot()
710 spin_unlock(&root->fs_info->trans_lock); in create_snapshot()
714 root->fs_info->extent_root, 1); in create_snapshot()
716 ret = btrfs_commit_transaction(trans, root); in create_snapshot()
719 root->fs_info->extent_root); in create_snapshot()
741 btrfs_subvolume_release_metadata(BTRFS_I(dir)->root, in create_snapshot()
747 if (atomic_dec_and_test(&root->will_be_snapshoted)) in create_snapshot()
748 wake_up_atomic_t(&root->will_be_snapshoted); in create_snapshot()
850 error = btrfs_check_dir_item_collision(BTRFS_I(dir)->root, in btrfs_mksubvol()
856 down_read(&BTRFS_I(dir)->root->fs_info->subvol_sem); in btrfs_mksubvol()
858 if (btrfs_root_refs(&BTRFS_I(dir)->root->root_item) == 0) in btrfs_mksubvol()
871 up_read(&BTRFS_I(dir)->root->fs_info->subvol_sem); in btrfs_mksubvol()
919 static int find_new_extents(struct btrfs_root *root, in find_new_extents() argument
940 ret = btrfs_search_forward(root, &min_key, path, newer_than); in find_new_extents()
1255 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_defrag_file() local
1319 ret = find_new_extents(root, inode, newer_than, in btrfs_defrag_file()
1352 if (btrfs_defrag_cancelled(root->fs_info)) { in btrfs_defrag_file()
1353 btrfs_debug(root->fs_info, "defrag_file cancelled"); in btrfs_defrag_file()
1410 ret = find_new_extents(root, inode, in btrfs_defrag_file()
1442 atomic_inc(&root->fs_info->async_submit_draining); in btrfs_defrag_file()
1443 while (atomic_read(&root->fs_info->nr_async_submits) || in btrfs_defrag_file()
1444 atomic_read(&root->fs_info->async_delalloc_pages)) { in btrfs_defrag_file()
1445 wait_event(root->fs_info->async_submit_wait, in btrfs_defrag_file()
1446 (atomic_read(&root->fs_info->nr_async_submits) == 0 && in btrfs_defrag_file()
1447 atomic_read(&root->fs_info->async_delalloc_pages) == 0)); in btrfs_defrag_file()
1449 atomic_dec(&root->fs_info->async_submit_draining); in btrfs_defrag_file()
1453 btrfs_set_fs_incompat(root->fs_info, COMPRESS_LZO); in btrfs_defrag_file()
1476 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_resize() local
1493 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_resize()
1499 mutex_lock(&root->fs_info->volume_mutex); in btrfs_ioctl_resize()
1521 btrfs_info(root->fs_info, "resizing devid %llu", devid); in btrfs_ioctl_resize()
1524 device = btrfs_find_device(root->fs_info, devid, NULL, NULL); in btrfs_ioctl_resize()
1526 btrfs_info(root->fs_info, "resizer unable to find device %llu", in btrfs_ioctl_resize()
1533 btrfs_info(root->fs_info, in btrfs_ioctl_resize()
1587 new_size = div_u64(new_size, root->sectorsize); in btrfs_ioctl_resize()
1588 new_size *= root->sectorsize; in btrfs_ioctl_resize()
1590 btrfs_info_in_rcu(root->fs_info, "new size for %s is %llu", in btrfs_ioctl_resize()
1594 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_resize()
1600 btrfs_commit_transaction(trans, root); in btrfs_ioctl_resize()
1608 mutex_unlock(&root->fs_info->volume_mutex); in btrfs_ioctl_resize()
1609 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); in btrfs_ioctl_resize()
1651 btrfs_info(BTRFS_I(file_inode(file))->root->fs_info, in btrfs_ioctl_snap_create_transid()
1662 BTRFS_I(src_inode)->root, in btrfs_ioctl_snap_create_transid()
1753 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_subvol_getflags() local
1760 down_read(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_getflags()
1761 if (btrfs_root_readonly(root)) in btrfs_ioctl_subvol_getflags()
1763 up_read(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_getflags()
1775 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_subvol_setflags() local
1808 down_write(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_setflags()
1811 if (!!(flags & BTRFS_SUBVOL_RDONLY) == btrfs_root_readonly(root)) in btrfs_ioctl_subvol_setflags()
1814 root_flags = btrfs_root_flags(&root->root_item); in btrfs_ioctl_subvol_setflags()
1816 btrfs_set_root_flags(&root->root_item, in btrfs_ioctl_subvol_setflags()
1823 spin_lock(&root->root_item_lock); in btrfs_ioctl_subvol_setflags()
1824 if (root->send_in_progress == 0) { in btrfs_ioctl_subvol_setflags()
1825 btrfs_set_root_flags(&root->root_item, in btrfs_ioctl_subvol_setflags()
1827 spin_unlock(&root->root_item_lock); in btrfs_ioctl_subvol_setflags()
1829 spin_unlock(&root->root_item_lock); in btrfs_ioctl_subvol_setflags()
1830 btrfs_warn(root->fs_info, in btrfs_ioctl_subvol_setflags()
1832 root->root_key.objectid); in btrfs_ioctl_subvol_setflags()
1838 trans = btrfs_start_transaction(root, 1); in btrfs_ioctl_subvol_setflags()
1844 ret = btrfs_update_root(trans, root->fs_info->tree_root, in btrfs_ioctl_subvol_setflags()
1845 &root->root_key, &root->root_item); in btrfs_ioctl_subvol_setflags()
1847 btrfs_commit_transaction(trans, root); in btrfs_ioctl_subvol_setflags()
1850 btrfs_set_root_flags(&root->root_item, root_flags); in btrfs_ioctl_subvol_setflags()
1852 up_write(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_setflags()
1862 static noinline int may_destroy_subvol(struct btrfs_root *root) in may_destroy_subvol() argument
1875 dir_id = btrfs_super_root_dir(root->fs_info->super_copy); in may_destroy_subvol()
1876 di = btrfs_lookup_dir_item(NULL, root->fs_info->tree_root, path, in may_destroy_subvol()
1880 if (key.objectid == root->root_key.objectid) { in may_destroy_subvol()
1882 btrfs_err(root->fs_info, "deleting default subvolume " in may_destroy_subvol()
1889 key.objectid = root->root_key.objectid; in may_destroy_subvol()
1893 ret = btrfs_search_slot(NULL, root->fs_info->tree_root, in may_destroy_subvol()
1903 if (key.objectid == root->root_key.objectid && in may_destroy_subvol()
1936 static noinline int copy_to_sk(struct btrfs_root *root, in copy_to_sk() argument
2066 struct btrfs_root *root; in search_ioctl() local
2069 struct btrfs_fs_info *info = BTRFS_I(inode)->root->fs_info; in search_ioctl()
2085 root = BTRFS_I(inode)->root; in search_ioctl()
2090 root = btrfs_read_fs_root_no_name(info, &key); in search_ioctl()
2091 if (IS_ERR(root)) { in search_ioctl()
2104 ret = btrfs_search_forward(root, &key, path, sk->min_transid); in search_ioctl()
2110 ret = copy_to_sk(root, path, &key, sk, buf_size, ubuf, in search_ioctl()
2205 struct btrfs_root *root; in btrfs_search_path_in_tree() local
2230 root = btrfs_read_fs_root_no_name(info, &key); in btrfs_search_path_in_tree()
2231 if (IS_ERR(root)) { in btrfs_search_path_in_tree()
2242 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_search_path_in_tree()
2246 ret = btrfs_previous_item(root, path, dirid, in btrfs_search_path_in_tree()
2306 args->treeid = BTRFS_I(inode)->root->root_key.objectid; in btrfs_ioctl_ino_lookup()
2318 ret = btrfs_search_path_in_tree(BTRFS_I(inode)->root->fs_info, in btrfs_ioctl_ino_lookup()
2337 struct btrfs_root *root = BTRFS_I(dir)->root; in btrfs_ioctl_snap_destroy() local
2380 dest = BTRFS_I(inode)->root; in btrfs_ioctl_snap_destroy()
2396 if (!btrfs_test_opt(root, USER_SUBVOL_RM_ALLOWED)) in btrfs_ioctl_snap_destroy()
2407 if (root == dest) in btrfs_ioctl_snap_destroy()
2440 btrfs_warn(root->fs_info, in btrfs_ioctl_snap_destroy()
2447 down_write(&root->fs_info->subvol_sem); in btrfs_ioctl_snap_destroy()
2458 err = btrfs_subvolume_reserve_metadata(root, &block_rsv, in btrfs_ioctl_snap_destroy()
2463 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_snap_destroy()
2471 ret = btrfs_unlink_subvol(trans, root, dir, in btrfs_ioctl_snap_destroy()
2477 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2490 root->fs_info->tree_root, in btrfs_ioctl_snap_destroy()
2493 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2499 ret = btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root, in btrfs_ioctl_snap_destroy()
2503 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2508 ret = btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root, in btrfs_ioctl_snap_destroy()
2513 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2522 ret = btrfs_end_transaction(trans, root); in btrfs_ioctl_snap_destroy()
2527 btrfs_subvolume_release_metadata(root, &block_rsv, qgroup_reserved); in btrfs_ioctl_snap_destroy()
2529 up_write(&root->fs_info->subvol_sem); in btrfs_ioctl_snap_destroy()
2565 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_defrag() local
2573 if (btrfs_root_readonly(root)) { in btrfs_ioctl_defrag()
2584 ret = btrfs_defrag_root(root); in btrfs_ioctl_defrag()
2587 ret = btrfs_defrag_root(root->fs_info->extent_root); in btrfs_ioctl_defrag()
2631 static long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_add_dev() argument
2639 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_add_dev()
2644 mutex_lock(&root->fs_info->volume_mutex); in btrfs_ioctl_add_dev()
2652 ret = btrfs_init_new_device(root, vol_args->name); in btrfs_ioctl_add_dev()
2655 btrfs_info(root->fs_info, "disk added %s",vol_args->name); in btrfs_ioctl_add_dev()
2659 mutex_unlock(&root->fs_info->volume_mutex); in btrfs_ioctl_add_dev()
2660 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); in btrfs_ioctl_add_dev()
2666 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_rm_dev() local
2685 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_rm_dev()
2691 mutex_lock(&root->fs_info->volume_mutex); in btrfs_ioctl_rm_dev()
2692 ret = btrfs_rm_device(root, vol_args->name); in btrfs_ioctl_rm_dev()
2693 mutex_unlock(&root->fs_info->volume_mutex); in btrfs_ioctl_rm_dev()
2694 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); in btrfs_ioctl_rm_dev()
2697 btrfs_info(root->fs_info, "disk deleted %s",vol_args->name); in btrfs_ioctl_rm_dev()
2706 static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_fs_info() argument
2710 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_ioctl_fs_info()
2719 memcpy(&fi_args->fsid, root->fs_info->fsid, sizeof(fi_args->fsid)); in btrfs_ioctl_fs_info()
2727 fi_args->nodesize = root->fs_info->super_copy->nodesize; in btrfs_ioctl_fs_info()
2728 fi_args->sectorsize = root->fs_info->super_copy->sectorsize; in btrfs_ioctl_fs_info()
2729 fi_args->clone_alignment = root->fs_info->super_copy->sectorsize; in btrfs_ioctl_fs_info()
2738 static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_dev_info() argument
2742 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_ioctl_dev_info()
2754 dev = btrfs_find_device(root->fs_info, di_args->devid, s_uuid, NULL); in btrfs_ioctl_dev_info()
3025 u64 bs = BTRFS_I(inode)->root->fs_info->sb->s_blocksize; in extent_same_check_offsets()
3185 u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; in btrfs_ioctl_file_extent_same()
3289 struct btrfs_root *root = BTRFS_I(inode)->root; in clone_finish_inode_update() local
3304 ret = btrfs_update_inode(trans, root, inode); in clone_finish_inode_update()
3306 btrfs_abort_transaction(trans, root, ret); in clone_finish_inode_update()
3307 btrfs_end_transaction(trans, root); in clone_finish_inode_update()
3310 ret = btrfs_end_transaction(trans, root); in clone_finish_inode_update()
3408 struct btrfs_root *root = BTRFS_I(dst)->root; in clone_copy_inline_extent() local
3410 root->sectorsize); in clone_copy_inline_extent()
3420 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in clone_copy_inline_extent()
3425 ret = btrfs_next_leaf(root, path); in clone_copy_inline_extent()
3460 ret = btrfs_next_item(root, path); in clone_copy_inline_extent()
3494 ret = btrfs_drop_extents(trans, root, dst, drop_start, aligned_end, 1); in clone_copy_inline_extent()
3497 ret = btrfs_insert_empty_item(trans, root, path, new_key, size); in clone_copy_inline_extent()
3531 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_clone() local
3544 buf = vmalloc(root->nodesize); in btrfs_clone()
3568 ret = btrfs_search_slot(NULL, BTRFS_I(src)->root, &key, path, in btrfs_clone()
3587 ret = btrfs_next_leaf(BTRFS_I(src)->root, path); in btrfs_clone()
3675 trans = btrfs_start_transaction(root, 3); in btrfs_clone()
3698 ret = btrfs_drop_extents(trans, root, inode, in btrfs_clone()
3705 root, ret); in btrfs_clone()
3706 btrfs_end_transaction(trans, root); in btrfs_clone()
3710 ret = btrfs_insert_empty_item(trans, root, path, in btrfs_clone()
3713 btrfs_abort_transaction(trans, root, in btrfs_clone()
3715 btrfs_end_transaction(trans, root); in btrfs_clone()
3739 ret = btrfs_inc_extent_ref(trans, root, in btrfs_clone()
3741 root->root_key.objectid, in btrfs_clone()
3746 root, in btrfs_clone()
3749 root); in btrfs_clone()
3768 btrfs_end_transaction(trans, root); in btrfs_clone()
3783 root, in btrfs_clone()
3785 btrfs_end_transaction(trans, root); in btrfs_clone()
3804 root->sectorsize); in btrfs_clone()
3830 trans = btrfs_start_transaction(root, 2); in btrfs_clone()
3835 ret = btrfs_drop_extents(trans, root, inode, in btrfs_clone()
3839 btrfs_abort_transaction(trans, root, ret); in btrfs_clone()
3840 btrfs_end_transaction(trans, root); in btrfs_clone()
3859 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_clone() local
3864 u64 bs = root->fs_info->sb->s_blocksize; in btrfs_ioctl_clone()
3882 if (btrfs_root_readonly(root)) in btrfs_ioctl_clone()
4029 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_trans_start() local
4042 if (btrfs_root_readonly(root)) in btrfs_ioctl_trans_start()
4049 atomic_inc(&root->fs_info->open_ioctl_trans); in btrfs_ioctl_trans_start()
4052 trans = btrfs_start_ioctl_transaction(root); in btrfs_ioctl_trans_start()
4060 atomic_dec(&root->fs_info->open_ioctl_trans); in btrfs_ioctl_trans_start()
4069 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_default_subvol() local
4099 new_root = btrfs_read_fs_root_no_name(root->fs_info, &location); in btrfs_ioctl_default_subvol()
4112 trans = btrfs_start_transaction(root, 1); in btrfs_ioctl_default_subvol()
4119 dir_id = btrfs_super_root_dir(root->fs_info->super_copy); in btrfs_ioctl_default_subvol()
4120 di = btrfs_lookup_dir_item(trans, root->fs_info->tree_root, path, in btrfs_ioctl_default_subvol()
4124 btrfs_end_transaction(trans, root); in btrfs_ioctl_default_subvol()
4136 btrfs_set_fs_incompat(root->fs_info, DEFAULT_SUBVOL); in btrfs_ioctl_default_subvol()
4137 btrfs_end_transaction(trans, root); in btrfs_ioctl_default_subvol()
4159 static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_space_info() argument
4187 list_for_each_entry_rcu(tmp, &root->fs_info->space_info, in btrfs_ioctl_space_info()
4243 list_for_each_entry_rcu(tmp, &root->fs_info->space_info, in btrfs_ioctl_space_info()
4274 struct btrfs_block_rsv *block_rsv = &root->fs_info->global_block_rsv; in btrfs_ioctl_space_info()
4308 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_trans_end() local
4316 btrfs_end_transaction(trans, root); in btrfs_ioctl_trans_end()
4318 atomic_dec(&root->fs_info->open_ioctl_trans); in btrfs_ioctl_trans_end()
4324 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, in btrfs_ioctl_start_sync() argument
4331 trans = btrfs_attach_transaction_barrier(root); in btrfs_ioctl_start_sync()
4337 transid = root->fs_info->last_trans_committed; in btrfs_ioctl_start_sync()
4341 ret = btrfs_commit_transaction_async(trans, root, 0); in btrfs_ioctl_start_sync()
4343 btrfs_end_transaction(trans, root); in btrfs_ioctl_start_sync()
4353 static noinline long btrfs_ioctl_wait_sync(struct btrfs_root *root, in btrfs_ioctl_wait_sync() argument
4364 return btrfs_wait_for_commit(root, transid); in btrfs_ioctl_wait_sync()
4369 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_scrub() local
4386 ret = btrfs_scrub_dev(root->fs_info, sa->devid, sa->start, sa->end, in btrfs_ioctl_scrub()
4400 static long btrfs_ioctl_scrub_cancel(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_scrub_cancel() argument
4405 return btrfs_scrub_cancel(root->fs_info); in btrfs_ioctl_scrub_cancel()
4408 static long btrfs_ioctl_scrub_progress(struct btrfs_root *root, in btrfs_ioctl_scrub_progress() argument
4421 ret = btrfs_scrub_progress(root, sa->devid, &sa->progress); in btrfs_ioctl_scrub_progress()
4430 static long btrfs_ioctl_get_dev_stats(struct btrfs_root *root, in btrfs_ioctl_get_dev_stats() argument
4445 ret = btrfs_get_dev_stats(root, sa); in btrfs_ioctl_get_dev_stats()
4454 static long btrfs_ioctl_dev_replace(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_dev_replace() argument
4468 if (root->fs_info->sb->s_flags & MS_RDONLY) { in btrfs_ioctl_dev_replace()
4473 &root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_dev_replace()
4477 ret = btrfs_dev_replace_start(root, p); in btrfs_ioctl_dev_replace()
4479 &root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_dev_replace()
4484 btrfs_dev_replace_status(root->fs_info, p); in btrfs_ioctl_dev_replace()
4488 ret = btrfs_dev_replace_cancel(root->fs_info, p); in btrfs_ioctl_dev_replace()
4502 static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_ino_to_path() argument
4529 ipath = init_ipath(size, root, path); in btrfs_ioctl_ino_to_path()
4561 static int build_ino_list(u64 inum, u64 offset, u64 root, void *ctx) in build_ino_list() argument
4570 inodes->val[inodes->elem_cnt + 2] = root; in build_ino_list()
4581 static long btrfs_ioctl_logical_to_ino(struct btrfs_root *root, in btrfs_ioctl_logical_to_ino() argument
4614 ret = iterate_inodes_from_logical(loi->logical, root->fs_info, path, in btrfs_ioctl_logical_to_ino()
4663 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_balance() local
4664 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_ioctl_balance()
4810 static long btrfs_ioctl_balance_ctl(struct btrfs_root *root, int cmd) in btrfs_ioctl_balance_ctl() argument
4817 return btrfs_pause_balance(root->fs_info); in btrfs_ioctl_balance_ctl()
4819 return btrfs_cancel_balance(root->fs_info); in btrfs_ioctl_balance_ctl()
4825 static long btrfs_ioctl_balance_progress(struct btrfs_root *root, in btrfs_ioctl_balance_progress() argument
4828 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_ioctl_balance_progress()
4860 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_ctl() local
4879 down_write(&root->fs_info->subvol_sem); in btrfs_ioctl_quota_ctl()
4880 trans = btrfs_start_transaction(root->fs_info->tree_root, 2); in btrfs_ioctl_quota_ctl()
4888 ret = btrfs_quota_enable(trans, root->fs_info); in btrfs_ioctl_quota_ctl()
4891 ret = btrfs_quota_disable(trans, root->fs_info); in btrfs_ioctl_quota_ctl()
4898 err = btrfs_commit_transaction(trans, root->fs_info->tree_root); in btrfs_ioctl_quota_ctl()
4903 up_write(&root->fs_info->subvol_sem); in btrfs_ioctl_quota_ctl()
4911 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_qgroup_assign() local
4930 trans = btrfs_join_transaction(root); in btrfs_ioctl_qgroup_assign()
4938 ret = btrfs_add_qgroup_relation(trans, root->fs_info, in btrfs_ioctl_qgroup_assign()
4941 ret = btrfs_del_qgroup_relation(trans, root->fs_info, in btrfs_ioctl_qgroup_assign()
4946 err = btrfs_run_qgroups(trans, root->fs_info); in btrfs_ioctl_qgroup_assign()
4948 btrfs_std_error(root->fs_info, ret, in btrfs_ioctl_qgroup_assign()
4950 err = btrfs_end_transaction(trans, root); in btrfs_ioctl_qgroup_assign()
4963 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_qgroup_create() local
4987 trans = btrfs_join_transaction(root); in btrfs_ioctl_qgroup_create()
4995 ret = btrfs_create_qgroup(trans, root->fs_info, sa->qgroupid); in btrfs_ioctl_qgroup_create()
4997 ret = btrfs_remove_qgroup(trans, root->fs_info, sa->qgroupid); in btrfs_ioctl_qgroup_create()
5000 err = btrfs_end_transaction(trans, root); in btrfs_ioctl_qgroup_create()
5013 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_qgroup_limit() local
5033 trans = btrfs_join_transaction(root); in btrfs_ioctl_qgroup_limit()
5042 qgroupid = root->root_key.objectid; in btrfs_ioctl_qgroup_limit()
5046 ret = btrfs_limit_qgroup(trans, root->fs_info, qgroupid, &sa->lim); in btrfs_ioctl_qgroup_limit()
5048 err = btrfs_end_transaction(trans, root); in btrfs_ioctl_qgroup_limit()
5061 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_rescan() local
5083 ret = btrfs_qgroup_rescan(root->fs_info); in btrfs_ioctl_quota_rescan()
5094 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_rescan_status() local
5105 if (root->fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) { in btrfs_ioctl_quota_rescan_status()
5107 qsa->progress = root->fs_info->qgroup_rescan_progress.objectid; in btrfs_ioctl_quota_rescan_status()
5119 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_rescan_wait() local
5124 return btrfs_qgroup_wait_for_completion(root->fs_info); in btrfs_ioctl_quota_rescan_wait()
5131 struct btrfs_root *root = BTRFS_I(inode)->root; in _btrfs_ioctl_set_received_subvol() local
5132 struct btrfs_root_item *root_item = &root->root_item; in _btrfs_ioctl_set_received_subvol()
5145 down_write(&root->fs_info->subvol_sem); in _btrfs_ioctl_set_received_subvol()
5152 if (btrfs_root_readonly(root)) { in _btrfs_ioctl_set_received_subvol()
5161 trans = btrfs_start_transaction(root, 3); in _btrfs_ioctl_set_received_subvol()
5176 btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root, in _btrfs_ioctl_set_received_subvol()
5179 root->root_key.objectid); in _btrfs_ioctl_set_received_subvol()
5188 ret = btrfs_update_root(trans, root->fs_info->tree_root, in _btrfs_ioctl_set_received_subvol()
5189 &root->root_key, &root->root_item); in _btrfs_ioctl_set_received_subvol()
5191 btrfs_end_transaction(trans, root); in _btrfs_ioctl_set_received_subvol()
5195 ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root, in _btrfs_ioctl_set_received_subvol()
5198 root->root_key.objectid); in _btrfs_ioctl_set_received_subvol()
5200 btrfs_abort_transaction(trans, root, ret); in _btrfs_ioctl_set_received_subvol()
5204 ret = btrfs_commit_transaction(trans, root); in _btrfs_ioctl_set_received_subvol()
5206 btrfs_abort_transaction(trans, root, ret); in _btrfs_ioctl_set_received_subvol()
5211 up_write(&root->fs_info->subvol_sem); in _btrfs_ioctl_set_received_subvol()
5299 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_get_fslabel() local
5304 spin_lock(&root->fs_info->super_lock); in btrfs_ioctl_get_fslabel()
5305 memcpy(label, root->fs_info->super_copy->label, BTRFS_LABEL_SIZE); in btrfs_ioctl_get_fslabel()
5306 spin_unlock(&root->fs_info->super_lock); in btrfs_ioctl_get_fslabel()
5311 btrfs_warn(root->fs_info, in btrfs_ioctl_get_fslabel()
5322 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_set_fslabel() local
5323 struct btrfs_super_block *super_block = root->fs_info->super_copy; in btrfs_ioctl_set_fslabel()
5335 btrfs_err(root->fs_info, "unable to set label with more than %d bytes", in btrfs_ioctl_set_fslabel()
5344 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_set_fslabel()
5350 spin_lock(&root->fs_info->super_lock); in btrfs_ioctl_set_fslabel()
5352 spin_unlock(&root->fs_info->super_lock); in btrfs_ioctl_set_fslabel()
5353 ret = btrfs_commit_transaction(trans, root); in btrfs_ioctl_set_fslabel()
5382 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_get_features() local
5383 struct btrfs_super_block *super_block = root->fs_info->super_copy; in btrfs_ioctl_get_features()
5396 static int check_feature_bits(struct btrfs_root *root, in check_feature_bits() argument
5411 btrfs_warn(root->fs_info, in check_feature_bits()
5416 btrfs_warn(root->fs_info, in check_feature_bits()
5426 btrfs_warn(root->fs_info, in check_feature_bits()
5431 btrfs_warn(root->fs_info, in check_feature_bits()
5441 btrfs_warn(root->fs_info, in check_feature_bits()
5446 btrfs_warn(root->fs_info, in check_feature_bits()
5455 #define check_feature(root, change_mask, flags, mask_base) \ argument
5456 check_feature_bits(root, FEAT_##mask_base, change_mask, flags, \
5463 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_set_features() local
5464 struct btrfs_super_block *super_block = root->fs_info->super_copy; in btrfs_ioctl_set_features()
5481 ret = check_feature(root, flags[0].compat_flags, in btrfs_ioctl_set_features()
5486 ret = check_feature(root, flags[0].compat_ro_flags, in btrfs_ioctl_set_features()
5491 ret = check_feature(root, flags[0].incompat_flags, in btrfs_ioctl_set_features()
5496 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_set_features()
5500 spin_lock(&root->fs_info->super_lock); in btrfs_ioctl_set_features()
5515 spin_unlock(&root->fs_info->super_lock); in btrfs_ioctl_set_features()
5517 return btrfs_commit_transaction(trans, root); in btrfs_ioctl_set_features()
5523 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl() local
5558 return btrfs_ioctl_add_dev(root, argp); in btrfs_ioctl()
5562 return btrfs_ioctl_fs_info(root, argp); in btrfs_ioctl()
5564 return btrfs_ioctl_dev_info(root, argp); in btrfs_ioctl()
5582 return btrfs_ioctl_ino_to_path(root, argp); in btrfs_ioctl()
5584 return btrfs_ioctl_logical_to_ino(root, argp); in btrfs_ioctl()
5586 return btrfs_ioctl_space_info(root, argp); in btrfs_ioctl()
5590 ret = btrfs_start_delalloc_roots(root->fs_info, 0, -1); in btrfs_ioctl()
5599 wake_up_process(root->fs_info->transaction_kthread); in btrfs_ioctl()
5603 return btrfs_ioctl_start_sync(root, argp); in btrfs_ioctl()
5605 return btrfs_ioctl_wait_sync(root, argp); in btrfs_ioctl()
5609 return btrfs_ioctl_scrub_cancel(root, argp); in btrfs_ioctl()
5611 return btrfs_ioctl_scrub_progress(root, argp); in btrfs_ioctl()
5615 return btrfs_ioctl_balance_ctl(root, arg); in btrfs_ioctl()
5617 return btrfs_ioctl_balance_progress(root, argp); in btrfs_ioctl()
5627 return btrfs_ioctl_get_dev_stats(root, argp); in btrfs_ioctl()
5643 return btrfs_ioctl_dev_replace(root, argp); in btrfs_ioctl()