aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index af1931a5960d..cac4a3f76323 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -837,7 +837,7 @@ int btrfs_wait_marked_extents(struct btrfs_root *root,
837 * them in one of two extent_io trees. This is used to make sure all of 837 * them in one of two extent_io trees. This is used to make sure all of
838 * those extents are on disk for transaction or log commit 838 * those extents are on disk for transaction or log commit
839 */ 839 */
840int btrfs_write_and_wait_marked_extents(struct btrfs_root *root, 840static int btrfs_write_and_wait_marked_extents(struct btrfs_root *root,
841 struct extent_io_tree *dirty_pages, int mark) 841 struct extent_io_tree *dirty_pages, int mark)
842{ 842{
843 int ret; 843 int ret;
@@ -1225,8 +1225,8 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1225 btrfs_set_root_stransid(new_root_item, 0); 1225 btrfs_set_root_stransid(new_root_item, 0);
1226 btrfs_set_root_rtransid(new_root_item, 0); 1226 btrfs_set_root_rtransid(new_root_item, 0);
1227 } 1227 }
1228 new_root_item->otime.sec = cpu_to_le64(cur_time.tv_sec); 1228 btrfs_set_stack_timespec_sec(&new_root_item->otime, cur_time.tv_sec);
1229 new_root_item->otime.nsec = cpu_to_le32(cur_time.tv_nsec); 1229 btrfs_set_stack_timespec_nsec(&new_root_item->otime, cur_time.tv_nsec);
1230 btrfs_set_root_otransid(new_root_item, trans->transid); 1230 btrfs_set_root_otransid(new_root_item, trans->transid);
1231 1231
1232 old = btrfs_lock_root_node(root); 1232 old = btrfs_lock_root_node(root);
@@ -1311,8 +1311,26 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
1311 dentry->d_name.len * 2); 1311 dentry->d_name.len * 2);
1312 parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME; 1312 parent_inode->i_mtime = parent_inode->i_ctime = CURRENT_TIME;
1313 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode); 1313 ret = btrfs_update_inode_fallback(trans, parent_root, parent_inode);
1314 if (ret) 1314 if (ret) {
1315 btrfs_abort_transaction(trans, root, ret);
1316 goto fail;
1317 }
1318 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, new_uuid.b,
1319 BTRFS_UUID_KEY_SUBVOL, objectid);
1320 if (ret) {
1315 btrfs_abort_transaction(trans, root, ret); 1321 btrfs_abort_transaction(trans, root, ret);
1322 goto fail;
1323 }
1324 if (!btrfs_is_empty_uuid(new_root_item->received_uuid)) {
1325 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root,
1326 new_root_item->received_uuid,
1327 BTRFS_UUID_KEY_RECEIVED_SUBVOL,
1328 objectid);
1329 if (ret && ret != -EEXIST) {
1330 btrfs_abort_transaction(trans, root, ret);
1331 goto fail;
1332 }
1333 }
1316fail: 1334fail:
1317 pending->error = ret; 1335 pending->error = ret;
1318dir_item_existed: 1336dir_item_existed:
@@ -1362,6 +1380,8 @@ static void update_super_roots(struct btrfs_root *root)
1362 super->root_level = root_item->level; 1380 super->root_level = root_item->level;
1363 if (btrfs_test_opt(root, SPACE_CACHE)) 1381 if (btrfs_test_opt(root, SPACE_CACHE))
1364 super->cache_generation = root_item->generation; 1382 super->cache_generation = root_item->generation;
1383 if (root->fs_info->update_uuid_tree_gen)
1384 super->uuid_tree_generation = root_item->generation;
1365} 1385}
1366 1386
1367int btrfs_transaction_in_commit(struct btrfs_fs_info *info) 1387int btrfs_transaction_in_commit(struct btrfs_fs_info *info)
@@ -1928,8 +1948,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
1928 list_del_init(&root->root_list); 1948 list_del_init(&root->root_list);
1929 spin_unlock(&fs_info->trans_lock); 1949 spin_unlock(&fs_info->trans_lock);
1930 1950
1931 pr_debug("btrfs: cleaner removing %llu\n", 1951 pr_debug("btrfs: cleaner removing %llu\n", root->objectid);
1932 (unsigned long long)root->objectid);
1933 1952
1934 btrfs_kill_all_delayed_nodes(root); 1953 btrfs_kill_all_delayed_nodes(root);
1935 1954
@@ -1942,6 +1961,5 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
1942 * If we encounter a transaction abort during snapshot cleaning, we 1961 * If we encounter a transaction abort during snapshot cleaning, we
1943 * don't want to crash here 1962 * don't want to crash here
1944 */ 1963 */
1945 BUG_ON(ret < 0 && ret != -EAGAIN && ret != -EROFS); 1964 return (ret < 0) ? 0 : 1;
1946 return 1;
1947} 1965}