Lines Matching refs:root

217 	struct btrfs_root *root = ip->root;  in btrfs_ioctl_setflags()  local
228 if (btrfs_root_readonly(root)) in btrfs_ioctl_setflags()
325 if (root->fs_info->compress_type == BTRFS_COMPRESS_LZO) in btrfs_ioctl_setflags()
341 trans = btrfs_start_transaction(root, 1); in btrfs_ioctl_setflags()
350 ret = btrfs_update_inode(trans, root, inode); in btrfs_ioctl_setflags()
352 btrfs_end_transaction(trans, root); in btrfs_ioctl_setflags()
442 struct btrfs_root *root = BTRFS_I(dir)->root; in create_subvol() local
455 ret = btrfs_find_free_objectid(root->fs_info->tree_root, &objectid); in create_subvol()
471 ret = btrfs_subvolume_reserve_metadata(root, &block_rsv, in create_subvol()
476 trans = btrfs_start_transaction(root, 0); in create_subvol()
479 btrfs_subvolume_release_metadata(root, &block_rsv, in create_subvol()
486 ret = btrfs_qgroup_inherit(trans, root->fs_info, 0, objectid, inherit); in create_subvol()
490 leaf = btrfs_alloc_tree_block(trans, root, 0, objectid, NULL, 0, 0, 0); in create_subvol()
502 write_extent_buffer(leaf, root->fs_info->fsid, btrfs_header_fsid(), in create_subvol()
504 write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid, in create_subvol()
515 btrfs_set_stack_inode_nbytes(inode_item, root->nodesize); in create_subvol()
548 ret = btrfs_insert_root(trans, root->fs_info->tree_root, &key, in create_subvol()
554 new_root = btrfs_read_fs_root_no_name(root->fs_info, &key); in create_subvol()
556 btrfs_abort_transaction(trans, root, PTR_ERR(new_root)); in create_subvol()
563 ret = btrfs_create_subvol_root(trans, new_root, root, new_dirid); in create_subvol()
566 btrfs_abort_transaction(trans, root, ret); in create_subvol()
579 btrfs_abort_transaction(trans, root, ret); in create_subvol()
583 ret = btrfs_insert_dir_item(trans, root, in create_subvol()
587 btrfs_abort_transaction(trans, root, ret); in create_subvol()
592 ret = btrfs_update_inode(trans, root, dir); in create_subvol()
595 ret = btrfs_add_root_ref(trans, root->fs_info->tree_root, in create_subvol()
596 objectid, root->root_key.objectid, in create_subvol()
600 ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root, in create_subvol()
604 btrfs_abort_transaction(trans, root, ret); in create_subvol()
609 btrfs_subvolume_release_metadata(root, &block_rsv, qgroup_reserved); in create_subvol()
613 err = btrfs_commit_transaction_async(trans, root, 1); in create_subvol()
615 err = btrfs_commit_transaction(trans, root); in create_subvol()
617 err = btrfs_commit_transaction(trans, root); in create_subvol()
631 static void btrfs_wait_for_no_snapshoting_writes(struct btrfs_root *root) in btrfs_wait_for_no_snapshoting_writes() argument
637 prepare_to_wait(&root->subv_writers->wait, &wait, in btrfs_wait_for_no_snapshoting_writes()
640 writers = percpu_counter_sum(&root->subv_writers->counter); in btrfs_wait_for_no_snapshoting_writes()
644 finish_wait(&root->subv_writers->wait, &wait); in btrfs_wait_for_no_snapshoting_writes()
648 static int create_snapshot(struct btrfs_root *root, struct inode *dir, in create_snapshot() argument
658 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state)) in create_snapshot()
661 atomic_inc(&root->will_be_snapshoted); in create_snapshot()
663 btrfs_wait_for_no_snapshoting_writes(root); in create_snapshot()
665 ret = btrfs_start_delalloc_inodes(root, 0); in create_snapshot()
669 btrfs_wait_ordered_extents(root, -1); in create_snapshot()
687 ret = btrfs_subvolume_reserve_metadata(BTRFS_I(dir)->root, in create_snapshot()
695 pending_snapshot->root = root; in create_snapshot()
700 trans = btrfs_start_transaction(root, 0); in create_snapshot()
706 spin_lock(&root->fs_info->trans_lock); in create_snapshot()
709 spin_unlock(&root->fs_info->trans_lock); in create_snapshot()
713 root->fs_info->extent_root, 1); in create_snapshot()
715 ret = btrfs_commit_transaction(trans, root); in create_snapshot()
718 root->fs_info->extent_root); in create_snapshot()
740 btrfs_subvolume_release_metadata(BTRFS_I(dir)->root, in create_snapshot()
746 if (atomic_dec_and_test(&root->will_be_snapshoted)) in create_snapshot()
747 wake_up_atomic_t(&root->will_be_snapshoted); in create_snapshot()
849 error = btrfs_check_dir_item_collision(BTRFS_I(dir)->root, in btrfs_mksubvol()
855 down_read(&BTRFS_I(dir)->root->fs_info->subvol_sem); in btrfs_mksubvol()
857 if (btrfs_root_refs(&BTRFS_I(dir)->root->root_item) == 0) in btrfs_mksubvol()
870 up_read(&BTRFS_I(dir)->root->fs_info->subvol_sem); in btrfs_mksubvol()
918 static int find_new_extents(struct btrfs_root *root, in find_new_extents() argument
939 ret = btrfs_search_forward(root, &min_key, path, newer_than); in find_new_extents()
1246 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_defrag_file() local
1310 ret = find_new_extents(root, inode, newer_than, in btrfs_defrag_file()
1343 if (btrfs_defrag_cancelled(root->fs_info)) { in btrfs_defrag_file()
1401 ret = find_new_extents(root, inode, in btrfs_defrag_file()
1433 atomic_inc(&root->fs_info->async_submit_draining); in btrfs_defrag_file()
1434 while (atomic_read(&root->fs_info->nr_async_submits) || in btrfs_defrag_file()
1435 atomic_read(&root->fs_info->async_delalloc_pages)) { in btrfs_defrag_file()
1436 wait_event(root->fs_info->async_submit_wait, in btrfs_defrag_file()
1437 (atomic_read(&root->fs_info->nr_async_submits) == 0 && in btrfs_defrag_file()
1438 atomic_read(&root->fs_info->async_delalloc_pages) == 0)); in btrfs_defrag_file()
1440 atomic_dec(&root->fs_info->async_submit_draining); in btrfs_defrag_file()
1444 btrfs_set_fs_incompat(root->fs_info, COMPRESS_LZO); in btrfs_defrag_file()
1467 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_resize() local
1484 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_resize()
1490 mutex_lock(&root->fs_info->volume_mutex); in btrfs_ioctl_resize()
1512 btrfs_info(root->fs_info, "resizing devid %llu", devid); in btrfs_ioctl_resize()
1515 device = btrfs_find_device(root->fs_info, devid, NULL, NULL); in btrfs_ioctl_resize()
1517 btrfs_info(root->fs_info, "resizer unable to find device %llu", in btrfs_ioctl_resize()
1524 btrfs_info(root->fs_info, in btrfs_ioctl_resize()
1578 new_size = div_u64(new_size, root->sectorsize); in btrfs_ioctl_resize()
1579 new_size *= root->sectorsize; in btrfs_ioctl_resize()
1585 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_resize()
1591 btrfs_commit_transaction(trans, root); in btrfs_ioctl_resize()
1599 mutex_unlock(&root->fs_info->volume_mutex); in btrfs_ioctl_resize()
1600 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); in btrfs_ioctl_resize()
1642 btrfs_info(BTRFS_I(src_inode)->root->fs_info, in btrfs_ioctl_snap_create_transid()
1653 BTRFS_I(src_inode)->root, in btrfs_ioctl_snap_create_transid()
1744 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_subvol_getflags() local
1751 down_read(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_getflags()
1752 if (btrfs_root_readonly(root)) in btrfs_ioctl_subvol_getflags()
1754 up_read(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_getflags()
1766 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_subvol_setflags() local
1799 down_write(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_setflags()
1802 if (!!(flags & BTRFS_SUBVOL_RDONLY) == btrfs_root_readonly(root)) in btrfs_ioctl_subvol_setflags()
1805 root_flags = btrfs_root_flags(&root->root_item); in btrfs_ioctl_subvol_setflags()
1807 btrfs_set_root_flags(&root->root_item, in btrfs_ioctl_subvol_setflags()
1814 spin_lock(&root->root_item_lock); in btrfs_ioctl_subvol_setflags()
1815 if (root->send_in_progress == 0) { in btrfs_ioctl_subvol_setflags()
1816 btrfs_set_root_flags(&root->root_item, in btrfs_ioctl_subvol_setflags()
1818 spin_unlock(&root->root_item_lock); in btrfs_ioctl_subvol_setflags()
1820 spin_unlock(&root->root_item_lock); in btrfs_ioctl_subvol_setflags()
1821 btrfs_warn(root->fs_info, in btrfs_ioctl_subvol_setflags()
1823 root->root_key.objectid); in btrfs_ioctl_subvol_setflags()
1829 trans = btrfs_start_transaction(root, 1); in btrfs_ioctl_subvol_setflags()
1835 ret = btrfs_update_root(trans, root->fs_info->tree_root, in btrfs_ioctl_subvol_setflags()
1836 &root->root_key, &root->root_item); in btrfs_ioctl_subvol_setflags()
1838 btrfs_commit_transaction(trans, root); in btrfs_ioctl_subvol_setflags()
1841 btrfs_set_root_flags(&root->root_item, root_flags); in btrfs_ioctl_subvol_setflags()
1843 up_write(&root->fs_info->subvol_sem); in btrfs_ioctl_subvol_setflags()
1853 static noinline int may_destroy_subvol(struct btrfs_root *root) in may_destroy_subvol() argument
1866 dir_id = btrfs_super_root_dir(root->fs_info->super_copy); in may_destroy_subvol()
1867 di = btrfs_lookup_dir_item(NULL, root->fs_info->tree_root, path, in may_destroy_subvol()
1871 if (key.objectid == root->root_key.objectid) { in may_destroy_subvol()
1873 btrfs_err(root->fs_info, "deleting default subvolume " in may_destroy_subvol()
1880 key.objectid = root->root_key.objectid; in may_destroy_subvol()
1884 ret = btrfs_search_slot(NULL, root->fs_info->tree_root, in may_destroy_subvol()
1894 if (key.objectid == root->root_key.objectid && in may_destroy_subvol()
1927 static noinline int copy_to_sk(struct btrfs_root *root, in copy_to_sk() argument
2051 struct btrfs_root *root; in search_ioctl() local
2054 struct btrfs_fs_info *info = BTRFS_I(inode)->root->fs_info; in search_ioctl()
2070 root = BTRFS_I(inode)->root; in search_ioctl()
2075 root = btrfs_read_fs_root_no_name(info, &key); in search_ioctl()
2076 if (IS_ERR(root)) { in search_ioctl()
2089 ret = btrfs_search_forward(root, &key, path, sk->min_transid); in search_ioctl()
2095 ret = copy_to_sk(root, path, &key, sk, buf_size, ubuf, in search_ioctl()
2190 struct btrfs_root *root; in btrfs_search_path_in_tree() local
2215 root = btrfs_read_fs_root_no_name(info, &key); in btrfs_search_path_in_tree()
2216 if (IS_ERR(root)) { in btrfs_search_path_in_tree()
2227 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_search_path_in_tree()
2231 ret = btrfs_previous_item(root, path, dirid, in btrfs_search_path_in_tree()
2290 args->treeid = BTRFS_I(inode)->root->root_key.objectid; in btrfs_ioctl_ino_lookup()
2292 ret = btrfs_search_path_in_tree(BTRFS_I(inode)->root->fs_info, in btrfs_ioctl_ino_lookup()
2310 struct btrfs_root *root = BTRFS_I(dir)->root; in btrfs_ioctl_snap_destroy() local
2353 dest = BTRFS_I(inode)->root; in btrfs_ioctl_snap_destroy()
2369 if (!btrfs_test_opt(root, USER_SUBVOL_RM_ALLOWED)) in btrfs_ioctl_snap_destroy()
2380 if (root == dest) in btrfs_ioctl_snap_destroy()
2413 btrfs_warn(root->fs_info, in btrfs_ioctl_snap_destroy()
2420 down_write(&root->fs_info->subvol_sem); in btrfs_ioctl_snap_destroy()
2431 err = btrfs_subvolume_reserve_metadata(root, &block_rsv, in btrfs_ioctl_snap_destroy()
2436 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_snap_destroy()
2444 ret = btrfs_unlink_subvol(trans, root, dir, in btrfs_ioctl_snap_destroy()
2450 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2463 root->fs_info->tree_root, in btrfs_ioctl_snap_destroy()
2466 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2472 ret = btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root, in btrfs_ioctl_snap_destroy()
2476 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2481 ret = btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root, in btrfs_ioctl_snap_destroy()
2486 btrfs_abort_transaction(trans, root, ret); in btrfs_ioctl_snap_destroy()
2495 ret = btrfs_end_transaction(trans, root); in btrfs_ioctl_snap_destroy()
2500 btrfs_subvolume_release_metadata(root, &block_rsv, qgroup_reserved); in btrfs_ioctl_snap_destroy()
2502 up_write(&root->fs_info->subvol_sem); in btrfs_ioctl_snap_destroy()
2538 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_defrag() local
2546 if (btrfs_root_readonly(root)) { in btrfs_ioctl_defrag()
2557 ret = btrfs_defrag_root(root); in btrfs_ioctl_defrag()
2560 ret = btrfs_defrag_root(root->fs_info->extent_root); in btrfs_ioctl_defrag()
2604 static long btrfs_ioctl_add_dev(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_add_dev() argument
2612 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_add_dev()
2617 mutex_lock(&root->fs_info->volume_mutex); in btrfs_ioctl_add_dev()
2625 ret = btrfs_init_new_device(root, vol_args->name); in btrfs_ioctl_add_dev()
2628 btrfs_info(root->fs_info, "disk added %s",vol_args->name); in btrfs_ioctl_add_dev()
2632 mutex_unlock(&root->fs_info->volume_mutex); in btrfs_ioctl_add_dev()
2633 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); in btrfs_ioctl_add_dev()
2639 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_rm_dev() local
2658 if (atomic_xchg(&root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_rm_dev()
2664 mutex_lock(&root->fs_info->volume_mutex); in btrfs_ioctl_rm_dev()
2665 ret = btrfs_rm_device(root, vol_args->name); in btrfs_ioctl_rm_dev()
2666 mutex_unlock(&root->fs_info->volume_mutex); in btrfs_ioctl_rm_dev()
2667 atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0); in btrfs_ioctl_rm_dev()
2670 btrfs_info(root->fs_info, "disk deleted %s",vol_args->name); in btrfs_ioctl_rm_dev()
2679 static long btrfs_ioctl_fs_info(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_fs_info() argument
2684 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_ioctl_fs_info()
2693 memcpy(&fi_args->fsid, root->fs_info->fsid, sizeof(fi_args->fsid)); in btrfs_ioctl_fs_info()
2701 fi_args->nodesize = root->fs_info->super_copy->nodesize; in btrfs_ioctl_fs_info()
2702 fi_args->sectorsize = root->fs_info->super_copy->sectorsize; in btrfs_ioctl_fs_info()
2703 fi_args->clone_alignment = root->fs_info->super_copy->sectorsize; in btrfs_ioctl_fs_info()
2712 static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_dev_info() argument
2716 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_ioctl_dev_info()
2728 dev = btrfs_find_device(root->fs_info, di_args->devid, s_uuid, NULL); in btrfs_ioctl_dev_info()
2886 u64 bs = BTRFS_I(inode)->root->fs_info->sb->s_blocksize; in extent_same_check_offsets()
2953 u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; in btrfs_ioctl_file_extent_same()
3054 static int check_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, in check_ref() argument
3063 if (!root->fs_info->quota_enabled) in check_ref()
3066 btrfs_get_tree_mod_seq(root->fs_info, &tree_mod_seq_elem); in check_ref()
3067 ret = btrfs_find_all_roots(trans, root->fs_info, disko, in check_ref()
3074 if (root_node->val == root->objectid) { in check_ref()
3081 btrfs_put_tree_mod_seq(root->fs_info, &tree_mod_seq_elem); in check_ref()
3091 struct btrfs_root *root = BTRFS_I(inode)->root; in clone_finish_inode_update() local
3105 ret = btrfs_update_inode(trans, root, inode); in clone_finish_inode_update()
3107 btrfs_abort_transaction(trans, root, ret); in clone_finish_inode_update()
3108 btrfs_end_transaction(trans, root); in clone_finish_inode_update()
3111 ret = btrfs_end_transaction(trans, root); in clone_finish_inode_update()
3209 struct btrfs_root *root = BTRFS_I(dst)->root; in clone_copy_inline_extent() local
3211 root->sectorsize); in clone_copy_inline_extent()
3221 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in clone_copy_inline_extent()
3226 ret = btrfs_next_leaf(root, path); in clone_copy_inline_extent()
3261 ret = btrfs_next_item(root, path); in clone_copy_inline_extent()
3295 ret = btrfs_drop_extents(trans, root, dst, drop_start, aligned_end, 1); in clone_copy_inline_extent()
3298 ret = btrfs_insert_empty_item(trans, root, path, new_key, size); in clone_copy_inline_extent()
3332 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_clone() local
3347 buf = vmalloc(root->nodesize); in btrfs_clone()
3371 ret = btrfs_search_slot(NULL, BTRFS_I(src)->root, &key, path, in btrfs_clone()
3391 ret = btrfs_next_leaf(BTRFS_I(src)->root, path); in btrfs_clone()
3479 trans = btrfs_start_transaction(root, 3); in btrfs_clone()
3502 ret = btrfs_drop_extents(trans, root, inode, in btrfs_clone()
3509 root, ret); in btrfs_clone()
3510 btrfs_end_transaction(trans, root); in btrfs_clone()
3514 ret = btrfs_insert_empty_item(trans, root, path, in btrfs_clone()
3517 btrfs_abort_transaction(trans, root, in btrfs_clone()
3519 btrfs_end_transaction(trans, root); in btrfs_clone()
3547 if (disko && root != BTRFS_I(src)->root && in btrfs_clone()
3549 no_quota = check_ref(trans, root, in btrfs_clone()
3553 root, in btrfs_clone()
3556 root); in btrfs_clone()
3564 ret = btrfs_inc_extent_ref(trans, root, in btrfs_clone()
3566 root->root_key.objectid, in btrfs_clone()
3572 root, in btrfs_clone()
3575 root); in btrfs_clone()
3594 btrfs_end_transaction(trans, root); in btrfs_clone()
3609 root, in btrfs_clone()
3611 btrfs_end_transaction(trans, root); in btrfs_clone()
3630 root->sectorsize); in btrfs_clone()
3655 trans = btrfs_start_transaction(root, 2); in btrfs_clone()
3660 ret = btrfs_drop_extents(trans, root, inode, in btrfs_clone()
3664 btrfs_abort_transaction(trans, root, ret); in btrfs_clone()
3665 btrfs_end_transaction(trans, root); in btrfs_clone()
3684 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_clone() local
3689 u64 bs = root->fs_info->sb->s_blocksize; in btrfs_ioctl_clone()
3707 if (btrfs_root_readonly(root)) in btrfs_ioctl_clone()
3864 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_trans_start() local
3877 if (btrfs_root_readonly(root)) in btrfs_ioctl_trans_start()
3884 atomic_inc(&root->fs_info->open_ioctl_trans); in btrfs_ioctl_trans_start()
3887 trans = btrfs_start_ioctl_transaction(root); in btrfs_ioctl_trans_start()
3895 atomic_dec(&root->fs_info->open_ioctl_trans); in btrfs_ioctl_trans_start()
3904 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_default_subvol() local
3934 new_root = btrfs_read_fs_root_no_name(root->fs_info, &location); in btrfs_ioctl_default_subvol()
3947 trans = btrfs_start_transaction(root, 1); in btrfs_ioctl_default_subvol()
3954 dir_id = btrfs_super_root_dir(root->fs_info->super_copy); in btrfs_ioctl_default_subvol()
3955 di = btrfs_lookup_dir_item(trans, root->fs_info->tree_root, path, in btrfs_ioctl_default_subvol()
3959 btrfs_end_transaction(trans, root); in btrfs_ioctl_default_subvol()
3971 btrfs_set_fs_incompat(root->fs_info, DEFAULT_SUBVOL); in btrfs_ioctl_default_subvol()
3972 btrfs_end_transaction(trans, root); in btrfs_ioctl_default_subvol()
3994 static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_space_info() argument
4022 list_for_each_entry_rcu(tmp, &root->fs_info->space_info, in btrfs_ioctl_space_info()
4078 list_for_each_entry_rcu(tmp, &root->fs_info->space_info, in btrfs_ioctl_space_info()
4109 struct btrfs_block_rsv *block_rsv = &root->fs_info->global_block_rsv; in btrfs_ioctl_space_info()
4143 struct btrfs_root *root = BTRFS_I(inode)->root; in btrfs_ioctl_trans_end() local
4151 btrfs_end_transaction(trans, root); in btrfs_ioctl_trans_end()
4153 atomic_dec(&root->fs_info->open_ioctl_trans); in btrfs_ioctl_trans_end()
4159 static noinline long btrfs_ioctl_start_sync(struct btrfs_root *root, in btrfs_ioctl_start_sync() argument
4166 trans = btrfs_attach_transaction_barrier(root); in btrfs_ioctl_start_sync()
4172 transid = root->fs_info->last_trans_committed; in btrfs_ioctl_start_sync()
4176 ret = btrfs_commit_transaction_async(trans, root, 0); in btrfs_ioctl_start_sync()
4178 btrfs_end_transaction(trans, root); in btrfs_ioctl_start_sync()
4188 static noinline long btrfs_ioctl_wait_sync(struct btrfs_root *root, in btrfs_ioctl_wait_sync() argument
4199 return btrfs_wait_for_commit(root, transid); in btrfs_ioctl_wait_sync()
4204 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_scrub() local
4221 ret = btrfs_scrub_dev(root->fs_info, sa->devid, sa->start, sa->end, in btrfs_ioctl_scrub()
4235 static long btrfs_ioctl_scrub_cancel(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_scrub_cancel() argument
4240 return btrfs_scrub_cancel(root->fs_info); in btrfs_ioctl_scrub_cancel()
4243 static long btrfs_ioctl_scrub_progress(struct btrfs_root *root, in btrfs_ioctl_scrub_progress() argument
4256 ret = btrfs_scrub_progress(root, sa->devid, &sa->progress); in btrfs_ioctl_scrub_progress()
4265 static long btrfs_ioctl_get_dev_stats(struct btrfs_root *root, in btrfs_ioctl_get_dev_stats() argument
4280 ret = btrfs_get_dev_stats(root, sa); in btrfs_ioctl_get_dev_stats()
4289 static long btrfs_ioctl_dev_replace(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_dev_replace() argument
4303 if (root->fs_info->sb->s_flags & MS_RDONLY) { in btrfs_ioctl_dev_replace()
4308 &root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_dev_replace()
4312 ret = btrfs_dev_replace_start(root, p); in btrfs_ioctl_dev_replace()
4314 &root->fs_info->mutually_exclusive_operation_running, in btrfs_ioctl_dev_replace()
4319 btrfs_dev_replace_status(root->fs_info, p); in btrfs_ioctl_dev_replace()
4323 ret = btrfs_dev_replace_cancel(root->fs_info, p); in btrfs_ioctl_dev_replace()
4337 static long btrfs_ioctl_ino_to_path(struct btrfs_root *root, void __user *arg) in btrfs_ioctl_ino_to_path() argument
4364 ipath = init_ipath(size, root, path); in btrfs_ioctl_ino_to_path()
4396 static int build_ino_list(u64 inum, u64 offset, u64 root, void *ctx) in build_ino_list() argument
4405 inodes->val[inodes->elem_cnt + 2] = root; in build_ino_list()
4416 static long btrfs_ioctl_logical_to_ino(struct btrfs_root *root, in btrfs_ioctl_logical_to_ino() argument
4449 ret = iterate_inodes_from_logical(loi->logical, root->fs_info, path, in btrfs_ioctl_logical_to_ino()
4498 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_balance() local
4499 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_ioctl_balance()
4645 static long btrfs_ioctl_balance_ctl(struct btrfs_root *root, int cmd) in btrfs_ioctl_balance_ctl() argument
4652 return btrfs_pause_balance(root->fs_info); in btrfs_ioctl_balance_ctl()
4654 return btrfs_cancel_balance(root->fs_info); in btrfs_ioctl_balance_ctl()
4660 static long btrfs_ioctl_balance_progress(struct btrfs_root *root, in btrfs_ioctl_balance_progress() argument
4663 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_ioctl_balance_progress()
4695 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_ctl() local
4714 down_write(&root->fs_info->subvol_sem); in btrfs_ioctl_quota_ctl()
4715 trans = btrfs_start_transaction(root->fs_info->tree_root, 2); in btrfs_ioctl_quota_ctl()
4723 ret = btrfs_quota_enable(trans, root->fs_info); in btrfs_ioctl_quota_ctl()
4726 ret = btrfs_quota_disable(trans, root->fs_info); in btrfs_ioctl_quota_ctl()
4733 err = btrfs_commit_transaction(trans, root->fs_info->tree_root); in btrfs_ioctl_quota_ctl()
4738 up_write(&root->fs_info->subvol_sem); in btrfs_ioctl_quota_ctl()
4746 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_qgroup_assign() local
4765 trans = btrfs_join_transaction(root); in btrfs_ioctl_qgroup_assign()
4773 ret = btrfs_add_qgroup_relation(trans, root->fs_info, in btrfs_ioctl_qgroup_assign()
4776 ret = btrfs_del_qgroup_relation(trans, root->fs_info, in btrfs_ioctl_qgroup_assign()
4781 err = btrfs_run_qgroups(trans, root->fs_info); in btrfs_ioctl_qgroup_assign()
4783 btrfs_error(root->fs_info, ret, in btrfs_ioctl_qgroup_assign()
4785 err = btrfs_end_transaction(trans, root); in btrfs_ioctl_qgroup_assign()
4798 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_qgroup_create() local
4822 trans = btrfs_join_transaction(root); in btrfs_ioctl_qgroup_create()
4830 ret = btrfs_create_qgroup(trans, root->fs_info, sa->qgroupid); in btrfs_ioctl_qgroup_create()
4832 ret = btrfs_remove_qgroup(trans, root->fs_info, sa->qgroupid); in btrfs_ioctl_qgroup_create()
4835 err = btrfs_end_transaction(trans, root); in btrfs_ioctl_qgroup_create()
4848 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_qgroup_limit() local
4868 trans = btrfs_join_transaction(root); in btrfs_ioctl_qgroup_limit()
4877 qgroupid = root->root_key.objectid; in btrfs_ioctl_qgroup_limit()
4881 ret = btrfs_limit_qgroup(trans, root->fs_info, qgroupid, &sa->lim); in btrfs_ioctl_qgroup_limit()
4883 err = btrfs_end_transaction(trans, root); in btrfs_ioctl_qgroup_limit()
4896 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_rescan() local
4918 ret = btrfs_qgroup_rescan(root->fs_info); in btrfs_ioctl_quota_rescan()
4929 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_rescan_status() local
4940 if (root->fs_info->qgroup_flags & BTRFS_QGROUP_STATUS_FLAG_RESCAN) { in btrfs_ioctl_quota_rescan_status()
4942 qsa->progress = root->fs_info->qgroup_rescan_progress.objectid; in btrfs_ioctl_quota_rescan_status()
4954 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_quota_rescan_wait() local
4959 return btrfs_qgroup_wait_for_completion(root->fs_info); in btrfs_ioctl_quota_rescan_wait()
4966 struct btrfs_root *root = BTRFS_I(inode)->root; in _btrfs_ioctl_set_received_subvol() local
4967 struct btrfs_root_item *root_item = &root->root_item; in _btrfs_ioctl_set_received_subvol()
4980 down_write(&root->fs_info->subvol_sem); in _btrfs_ioctl_set_received_subvol()
4987 if (btrfs_root_readonly(root)) { in _btrfs_ioctl_set_received_subvol()
4996 trans = btrfs_start_transaction(root, 3); in _btrfs_ioctl_set_received_subvol()
5011 btrfs_uuid_tree_rem(trans, root->fs_info->uuid_root, in _btrfs_ioctl_set_received_subvol()
5014 root->root_key.objectid); in _btrfs_ioctl_set_received_subvol()
5023 ret = btrfs_update_root(trans, root->fs_info->tree_root, in _btrfs_ioctl_set_received_subvol()
5024 &root->root_key, &root->root_item); in _btrfs_ioctl_set_received_subvol()
5026 btrfs_end_transaction(trans, root); in _btrfs_ioctl_set_received_subvol()
5030 ret = btrfs_uuid_tree_add(trans, root->fs_info->uuid_root, in _btrfs_ioctl_set_received_subvol()
5033 root->root_key.objectid); in _btrfs_ioctl_set_received_subvol()
5035 btrfs_abort_transaction(trans, root, ret); in _btrfs_ioctl_set_received_subvol()
5039 ret = btrfs_commit_transaction(trans, root); in _btrfs_ioctl_set_received_subvol()
5041 btrfs_abort_transaction(trans, root, ret); in _btrfs_ioctl_set_received_subvol()
5046 up_write(&root->fs_info->subvol_sem); in _btrfs_ioctl_set_received_subvol()
5134 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_get_fslabel() local
5139 spin_lock(&root->fs_info->super_lock); in btrfs_ioctl_get_fslabel()
5140 memcpy(label, root->fs_info->super_copy->label, BTRFS_LABEL_SIZE); in btrfs_ioctl_get_fslabel()
5141 spin_unlock(&root->fs_info->super_lock); in btrfs_ioctl_get_fslabel()
5146 btrfs_warn(root->fs_info, in btrfs_ioctl_get_fslabel()
5157 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_set_fslabel() local
5158 struct btrfs_super_block *super_block = root->fs_info->super_copy; in btrfs_ioctl_set_fslabel()
5170 btrfs_err(root->fs_info, "unable to set label with more than %d bytes", in btrfs_ioctl_set_fslabel()
5179 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_set_fslabel()
5185 spin_lock(&root->fs_info->super_lock); in btrfs_ioctl_set_fslabel()
5187 spin_unlock(&root->fs_info->super_lock); in btrfs_ioctl_set_fslabel()
5188 ret = btrfs_commit_transaction(trans, root); in btrfs_ioctl_set_fslabel()
5217 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_get_features() local
5218 struct btrfs_super_block *super_block = root->fs_info->super_copy; in btrfs_ioctl_get_features()
5231 static int check_feature_bits(struct btrfs_root *root, in check_feature_bits() argument
5246 btrfs_warn(root->fs_info, in check_feature_bits()
5251 btrfs_warn(root->fs_info, in check_feature_bits()
5261 btrfs_warn(root->fs_info, in check_feature_bits()
5266 btrfs_warn(root->fs_info, in check_feature_bits()
5276 btrfs_warn(root->fs_info, in check_feature_bits()
5281 btrfs_warn(root->fs_info, in check_feature_bits()
5290 #define check_feature(root, change_mask, flags, mask_base) \ argument
5291 check_feature_bits(root, FEAT_##mask_base, change_mask, flags, \
5298 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl_set_features() local
5299 struct btrfs_super_block *super_block = root->fs_info->super_copy; in btrfs_ioctl_set_features()
5316 ret = check_feature(root, flags[0].compat_flags, in btrfs_ioctl_set_features()
5321 ret = check_feature(root, flags[0].compat_ro_flags, in btrfs_ioctl_set_features()
5326 ret = check_feature(root, flags[0].incompat_flags, in btrfs_ioctl_set_features()
5331 trans = btrfs_start_transaction(root, 0); in btrfs_ioctl_set_features()
5335 spin_lock(&root->fs_info->super_lock); in btrfs_ioctl_set_features()
5350 spin_unlock(&root->fs_info->super_lock); in btrfs_ioctl_set_features()
5352 return btrfs_commit_transaction(trans, root); in btrfs_ioctl_set_features()
5358 struct btrfs_root *root = BTRFS_I(file_inode(file))->root; in btrfs_ioctl() local
5393 return btrfs_ioctl_add_dev(root, argp); in btrfs_ioctl()
5397 return btrfs_ioctl_fs_info(root, argp); in btrfs_ioctl()
5399 return btrfs_ioctl_dev_info(root, argp); in btrfs_ioctl()
5417 return btrfs_ioctl_ino_to_path(root, argp); in btrfs_ioctl()
5419 return btrfs_ioctl_logical_to_ino(root, argp); in btrfs_ioctl()
5421 return btrfs_ioctl_space_info(root, argp); in btrfs_ioctl()
5425 ret = btrfs_start_delalloc_roots(root->fs_info, 0, -1); in btrfs_ioctl()
5434 wake_up_process(root->fs_info->transaction_kthread); in btrfs_ioctl()
5438 return btrfs_ioctl_start_sync(root, argp); in btrfs_ioctl()
5440 return btrfs_ioctl_wait_sync(root, argp); in btrfs_ioctl()
5444 return btrfs_ioctl_scrub_cancel(root, argp); in btrfs_ioctl()
5446 return btrfs_ioctl_scrub_progress(root, argp); in btrfs_ioctl()
5450 return btrfs_ioctl_balance_ctl(root, arg); in btrfs_ioctl()
5452 return btrfs_ioctl_balance_progress(root, argp); in btrfs_ioctl()
5462 return btrfs_ioctl_get_dev_stats(root, argp); in btrfs_ioctl()
5478 return btrfs_ioctl_dev_replace(root, argp); in btrfs_ioctl()