Lines Matching full:tr

54                              struct transaction* tr,
62 * @tr: Transaction object.
65 * Return: non-zero hash value that fits in @tr->fs->block_num_size bytes
68 static data_block_t path_hash(struct transaction* tr, const char* path) { in path_hash() argument
71 hash &= BIT_MASK(tr->fs->block_num_size * 8); in path_hash()
81 * @tr: Transaction object.
88 void file_block_map_init(struct transaction* tr, in file_block_map_init() argument
94 if (!block_mac_valid(tr, file)) { in file_block_map_init()
97 file_entry_ro = block_get(tr, file, NULL, &file_entry_ro_ref); in file_block_map_init()
102 block_map_init(tr, block_map, &file_entry_ro->block_map, in file_block_map_init()
103 tr->fs->dev->block_size); in file_block_map_init()
109 if (tr->failed) { in file_block_map_init()
111 block_mac_to_block(tr, file)); in file_block_map_init()
114 block_mac_to_block(tr, file)); in file_block_map_init()
115 transaction_fail(tr); in file_block_map_init()
121 * @tr: Transaction object.
124 void file_print(struct transaction* tr, in file_print() argument
130 file_block_map_init(tr, &block_map, &file->block_mac); in file_print()
131 file_entry_ro = block_get(tr, &file->block_mac, NULL, &file_entry_ro_ref); in file_print()
134 block_mac_to_block(tr, &file->block_mac)); in file_print()
140 block_mac_to_block(tr, &file->block_mac), file_entry_ro->info.path, in file_print()
141 file_entry_ro->info.size, path_hash(tr, file_entry_ro->info.path)); in file_print()
143 block_tree_print(tr, &block_map.tree); in file_print()
148 * @tr: Transaction object.
150 void files_print(struct transaction* tr) { in files_print() argument
155 block_tree_print(tr, &tr->fs->files); in files_print()
157 block_tree_walk(tr, &tr->fs->files, 0, true, &path); in files_print()
160 file_print(tr, &file); in files_print()
167 * @tr: Transaction object.
173 bool file_check(struct transaction* tr, in file_check() argument
176 data_block_t file_block_size = get_file_block_size(tr->fs); in file_check()
178 file_block_map_init(tr, &block_map, &file->block_mac); in file_check()
179 return block_map_check(tr, &block_map, in file_check()
185 * @tr: Transaction object.
190 static void file_block_map_update(struct transaction* tr, in file_block_map_update() argument
205 if (tr->failed) { in file_block_map_update()
210 assert(block_mac_valid(tr, &file->block_mac)); in file_block_map_update()
212 file_entry_ro = block_get(tr, &file->block_mac, NULL, &file_entry_ref); in file_block_map_update()
214 assert(tr->failed); in file_block_map_update()
219 found = file_tree_lookup(&block_mac, tr, &tr->files_added, &tree_path, in file_block_map_update()
222 found = file_tree_lookup(&block_mac, tr, &tr->fs->files, &tree_path, in file_block_map_update()
224 if (tr->failed) { in file_block_map_update()
231 block_tree_insert_block_mac(tr, &tr->files_removed, in file_block_map_update()
232 block_mac_to_block(tr, &block_mac), in file_block_map_update()
236 old_block = block_mac_to_block(tr, &block_mac); in file_block_map_update()
237 file_block = block_mac_to_block(tr, &file->block_mac); in file_block_map_update()
238 if (transaction_block_need_copy(tr, file_block)) { in file_block_map_update()
239 if (tr->failed) { in file_block_map_update()
246 new_block = block_allocate(tr); in file_block_map_update()
247 if (tr->failed) { in file_block_map_update()
252 block_mac_set_block(tr, &block_mac, new_block); in file_block_map_update()
258 * Use block_get_copy instead of block_move since tr->fs->files in file_block_map_update()
262 file_entry_rw = block_get_copy(tr, file_entry_ro, new_block, false, in file_block_map_update()
267 if (tr->failed) { in file_block_map_update()
272 block_tree_insert(tr, &tr->files_updated, file_block, new_block); in file_block_map_update()
273 block_free(tr, file_block); in file_block_map_update()
276 assert(!file_tree_lookup(NULL, tr, &tr->files_added, &tree_path, in file_block_map_update()
280 block_tree_walk(tr, &tr->files_updated, old_block, false, &tree_path); in file_block_map_update()
281 if (tr->failed) { in file_block_map_update()
287 assert(block_mac_to_block(tr, &block_mac) == in file_block_map_update()
288 block_mac_to_block(tr, &file->block_mac)); in file_block_map_update()
290 // assert(block_mac_eq(tr, &block_mac, &file->block_mac)); in file_block_map_update()
294 block_tree_remove(tr, &tr->files_updated, old_block, in file_block_map_update()
295 block_mac_to_block(tr, &block_mac)); in file_block_map_update()
299 file_entry_rw = block_dirty(tr, file_entry_ro, false); in file_block_map_update()
305 block_mac_to_block(tr, &block_mac), in file_block_map_update()
306 block_mac_to_block(tr, &file_entry_rw->block_map), in file_block_map_update()
307 block_mac_to_block(tr, &block_map->tree.root)); in file_block_map_update()
315 block_put_dirty(tr, file_entry_rw, &file_entry_ref, &block_mac, NULL); in file_block_map_update()
316 block_tree_insert_block_mac(tr, &tr->files_added, in file_block_map_update()
317 path_hash(tr, new_path), block_mac); in file_block_map_update()
318 if (tr->failed) { in file_block_map_update()
322 block_mac_copy(tr, &file->block_mac, &block_mac); in file_block_map_update()
324 block_tree_path_put_dirty(tr, &tree_path, tree_path.count, in file_block_map_update()
336 list_add_head(&tr->open_files, &file->node); in file_block_map_update()
361 * @tr: Transaction object.
371 static const void* file_get_block_etc(struct transaction* tr, in file_get_block_etc() argument
385 if (tr->failed) { in file_get_block_etc()
390 file_block_map_init(tr, &block_map, &file->block_mac); in file_get_block_etc()
391 if (tr->failed) { in file_get_block_etc()
398 found = block_map_get(tr, &block_map, file_block, &block_mac); in file_get_block_etc()
401 data = block_get(tr, &block_mac, NULL, ref); /* TODO: pass iv? */ in file_get_block_etc()
403 data = block_get_no_read(tr, block_mac_to_block(tr, &block_mac), in file_get_block_etc()
409 old_disk_block = found ? block_mac_to_block(tr, &block_mac) : 0; in file_get_block_etc()
410 if (write && (!found || transaction_block_need_copy(tr, old_disk_block))) { in file_get_block_etc()
411 new_block = block_allocate(tr); in file_get_block_etc()
412 if (tr->failed) { in file_get_block_etc()
417 block_mac_set_block(tr, &block_mac, new_block); in file_get_block_etc()
420 data = block_move(tr, data, new_block, false); in file_get_block_etc()
422 assert(!tr->failed); in file_get_block_etc()
423 block_free(tr, old_disk_block); in file_get_block_etc()
427 data = block_get_cleared(tr, new_block, false, ref); in file_get_block_etc()
430 data = block_get_no_read(tr, new_block, ref); in file_get_block_etc()
433 if (tr->failed) { in file_get_block_etc()
438 assert(!tr->failed); in file_get_block_etc()
439 block_map_set(tr, &block_map, file_block, &block_mac); in file_get_block_etc()
440 file_block_map_update(tr, &block_map, NULL, file); in file_get_block_etc()
441 if (tr->failed) { in file_get_block_etc()
447 data = block_dirty(tr, data, false); in file_get_block_etc()
465 * @tr: Transaction object.
473 const void* file_get_block(struct transaction* tr, in file_get_block() argument
477 return file_get_block_etc(tr, file, file_block, true, false, ref); in file_get_block()
482 * @tr: Transaction object.
490 void* file_get_block_write(struct transaction* tr, in file_get_block_write() argument
495 return (void*)file_get_block_etc(tr, file, file_block, read, true, ref); in file_get_block_write()
509 * @tr: Transaction
518 void file_block_put_dirty(struct transaction* tr, in file_block_put_dirty() argument
525 file_block_map_init(tr, &block_map, &file->block_mac); in file_block_put_dirty()
527 block_map_put_dirty(tr, &block_map, file_block, data - sizeof(struct iv), in file_block_put_dirty()
530 file_block_map_update(tr, &block_map, NULL, file); in file_block_put_dirty()
535 * @tr: Transaction object.
542 const struct file_info* file_get_info(struct transaction* tr, in file_get_info() argument
547 file_entry = block_get(tr, block_mac, NULL, ref); in file_get_info()
549 assert(tr->failed); in file_get_info()
572 * @tr: Transaction
577 * invalid or @tr has failed.
579 bool file_get_size(struct transaction* tr, in file_get_size() argument
582 if (tr->failed) { in file_get_size()
587 if (!block_mac_valid(tr, &file->block_mac)) { in file_get_size()
600 * @tr: Transaction
607 void file_set_size(struct transaction* tr, in file_set_size() argument
612 size_t file_block_size = get_file_block_size(tr->fs); in file_set_size()
614 if (tr->failed) { in file_set_size()
619 file_block_map_init(tr, &block_map, &file->block_mac); in file_set_size()
620 if (tr->failed) { in file_set_size()
629 block_map_truncate(tr, &block_map, file_block); in file_set_size()
632 file_block_map_update(tr, &block_map, NULL, file); in file_set_size()
638 * @tr: Transaction object.
647 struct transaction* tr, in file_tree_lookup() argument
653 data_block_t hash = path_hash(tr, file_path); in file_tree_lookup()
659 assert(sizeof(*file_entry) <= tr->fs->dev->block_size); in file_tree_lookup()
661 block_tree_walk(tr, tree, hash - 1, false, tree_path); in file_tree_lookup()
668 if (!block_mac_to_block(tr, &block_mac)) { in file_tree_lookup()
673 block_tree_print(tr, tree); in file_tree_lookup()
678 block_mac_to_block(tr, &block_mac), in file_tree_lookup()
681 if (tr->failed) { in file_tree_lookup()
685 assert(block_mac_to_block(tr, &block_mac)); in file_tree_lookup()
686 file_entry = block_get(tr, &block_mac, NULL, &file_entry_ref); in file_tree_lookup()
688 assert(tr->failed); in file_tree_lookup()
697 block_mac_to_block(tr, &block_mac), hash, found); in file_tree_lookup()
703 // block_tree_remove_path(tr, tree_path); in file_tree_lookup()
705 block_tree_remove(tr, tree, hash, in file_tree_lookup()
706 block_mac_to_block(tr, &block_mac)); in file_tree_lookup()
716 block_tree_print(tr, tree); in file_tree_lookup()
724 * @tr: Transaction object.
727 * Create a new file and insert it into &tr->files_added. Caller must make
733 struct transaction* tr, in file_create() argument
740 hash = path_hash(tr, path); in file_create()
742 block = block_allocate(tr); in file_create()
747 if (tr->failed) { in file_create()
753 block_mac_set_block(tr, block_mac_out, block); in file_create()
755 file_entry = block_get_cleared(tr, block, false, &file_entry_ref); in file_create()
759 block_put_dirty(tr, file_entry, &file_entry_ref, block_mac_out, NULL); in file_create()
760 if (tr->failed) { in file_create()
764 block_tree_insert_block_mac(tr, &tr->files_added, hash, *block_mac_out); in file_create()
765 if (tr->failed) { in file_create()
777 * @tr: Transaction object.
780 * Return: %true if file is removed in @tr, %false otherwise.
782 static bool file_is_removed(struct transaction* tr, data_block_t block) { in file_is_removed() argument
785 block_tree_walk(tr, &tr->files_removed, block, false, &tree_path); in file_is_removed()
792 * @tr: Transaction object.
795 * for the current state of the file in @tr.
797 * Return: %true if file is updated in @tr, %false otherwise.
799 static bool file_check_updated(struct transaction* tr, in file_check_updated() argument
803 data_block_t block = block_mac_to_block(tr, committed_block_mac); in file_check_updated()
805 block_tree_walk(tr, &tr->files_updated, block, false, &tree_path); in file_check_updated()
824 * @tr: Transaction object.
828 * Helper function to search for a file that existed before @tr was activated.
830 * Return: %true if @file_path was found in @tr->fs->files but not found in
831 * @tr->files_removed, %false otherwise.
835 struct transaction* tr, in file_lookup_not_removed() argument
841 found = file_tree_lookup(&block_mac, tr, &tr->fs->files, tree_path, in file_lookup_not_removed()
843 if (!found || file_is_removed(tr, block_mac_to_block(tr, &block_mac))) { in file_lookup_not_removed()
846 block_mac_to_block(tr, &block_mac)); in file_lookup_not_removed()
848 pr_read("file %s not in tr->fs->files\n", file_path); in file_lookup_not_removed()
854 block_tree_walk(tr, &tr->files_updated, block_mac_to_block(tr, &block_mac), in file_lookup_not_removed()
857 block_mac_to_block(tr, &block_mac)) { in file_lookup_not_removed()
861 file_path, block_mac_to_block(tr, &block_mac), in file_lookup_not_removed()
865 pr_read("file %s, %" PRIu64 ", found in tr->fs->files\n", file_path, in file_lookup_not_removed()
866 block_mac_to_block(tr, &block_mac)); in file_lookup_not_removed()
880 * @tr: Transaction object.
883 * Return: file handle of open file if file is open in @tr, NULL otherwise.
886 struct transaction* tr, in file_find_open() argument
890 list_for_every_entry(&tr->open_files, file, struct storage_file_handle, in file_find_open()
892 if (block_mac_same_block(tr, &file->block_mac, block_mac)) { in file_find_open()
902 * @tr: Transaction object.
905 * uncommitted files added by @tr.
913 enum file_op_result file_iterate(struct transaction* tr, in file_iterate() argument
920 struct block_tree* tree = added ? &tr->files_added : &tr->fs->files; in file_iterate()
925 assert(tr->fs); in file_iterate()
926 if (!fs_is_readable(tr->fs)) { in file_iterate()
929 if (!allow_repaired && (tr->repaired || fs_is_repaired(tr->fs))) { in file_iterate()
934 block_tree_walk(tr, tree, 0, true, &tree_path); in file_iterate()
936 found = file_tree_lookup(&block_mac, tr, tree, &tree_path, start_path, in file_iterate()
943 if (tr->failed) { in file_iterate()
950 removed = file_is_removed(tr, block_mac_to_block(tr, &block_mac)); in file_iterate()
951 file_check_updated(tr, &block_mac, &block_mac); in file_iterate()
953 if (tr->failed) { in file_iterate()
957 stop = state->file(state, tr, &block_mac, added, removed); in file_iterate()
959 if (tr->failed) { in file_iterate()
972 * @tr: Transaction object.
985 enum file_op_result file_open(struct transaction* tr, in file_open() argument
998 assert(tr->fs); in file_open()
999 if (!allow_repaired && (tr->repaired || fs_is_repaired(tr->fs))) { in file_open()
1003 if (!fs_is_readable(tr->fs)) { in file_open()
1007 found = file_tree_lookup(&block_mac, tr, &tr->files_added, &tree_path, path, in file_open()
1013 found = file_lookup_not_removed(&block_mac, &committed_block_mac, tr, in file_open()
1018 if (tr->failed) { in file_open()
1023 found = file_create(&block_mac, tr, path); in file_open()
1028 if (tr->failed) { in file_open()
1038 if (file_find_open(tr, &block_mac)) { in file_open()
1043 file_entry_ro = block_get(tr, &block_mac, NULL, &file_entry_ref); in file_open()
1045 assert(tr->failed); in file_open()
1050 list_add_head(&tr->open_files, &file->node); in file_open()
1073 * @tr: Transaction object.
1082 enum file_op_result file_delete(struct transaction* tr, in file_delete() argument
1095 assert(tr->fs); in file_delete()
1096 if (!fs_is_readable(tr->fs)) { in file_delete()
1099 if (!allow_repaired && (tr->repaired || fs_is_repaired(tr->fs))) { in file_delete()
1103 found = file_tree_lookup(&block_mac, tr, &tr->files_added, &tree_path, path, in file_delete()
1106 pr_read("file %s not in tr->files_added\n", path); in file_delete()
1107 found = file_lookup_not_removed(&block_mac, &old_block_mac, tr, in file_delete()
1111 return tr->failed ? FILE_OP_ERR_FAILED : FILE_OP_ERR_NOT_FOUND; in file_delete()
1117 block_mac_to_block(tr, &block_mac)); in file_delete()
1119 file_entry = block_get(tr, &block_mac, NULL, &file_entry_ref); in file_delete()
1121 assert(tr->failed); in file_delete()
1127 block_map_init(tr, &block_map, &file_entry->block_map, in file_delete()
1128 tr->fs->dev->block_size); in file_delete()
1129 if (!in_files || !block_mac_same_block(tr, &block_mac, &old_block_mac)) { in file_delete()
1134 if (!block_mac_same_block(tr, &block_mac, &old_block_mac)) { in file_delete()
1136 block_tree_remove(tr, &tr->files_updated, in file_delete()
1137 block_mac_to_block(tr, &old_block_mac), in file_delete()
1138 block_mac_to_block(tr, &block_mac)); in file_delete()
1139 if (tr->failed) { in file_delete()
1144 block_tree_insert_block_mac(tr, &tr->files_removed, in file_delete()
1145 block_mac_to_block(tr, &old_block_mac), in file_delete()
1148 block_free(tr, block_mac_to_block(tr, &block_mac)); in file_delete()
1149 block_map_free(tr, &block_map); in file_delete()
1151 open_file = file_find_open(tr, &block_mac); in file_delete()
1162 * @tr: Transaction object.
1176 enum file_op_result file_move(struct transaction* tr, in file_move() argument
1181 assert(tr->fs); in file_move()
1187 if (!fs_is_readable(tr->fs)) { in file_move()
1190 if (!allow_repaired && (tr->repaired || fs_is_repaired(tr->fs))) { in file_move()
1194 dest_found = file_tree_lookup(&block_mac, tr, &tr->files_added, &tree_path, in file_move()
1198 tr, &tree_path, dest_path); in file_move()
1200 if (tr->failed) { in file_move()
1209 if (block_mac_eq(tr, &file->block_mac, &block_mac)) { in file_move()
1212 file_delete(tr, dest_path, allow_repaired); in file_move()
1219 if (tr->failed) { in file_move()
1223 file_block_map_update(tr, NULL, dest_path, file); in file_move()
1224 if (tr->failed) { in file_move()
1233 * @tr: Transaction object.
1236 static void file_for_each_open(struct transaction* tr, in file_for_each_open() argument
1237 void (*func)(struct transaction* tr, in file_for_each_open() argument
1244 list_for_every_entry_safe(&tr->fs->transactions, other_tr, tmp_tr, in file_for_each_open()
1248 func(tr, other_tr, file); in file_for_each_open()
1255 * @tr: Current transaction.
1259 static void file_restore_to_commit(struct transaction* tr, in file_restore_to_commit() argument
1264 if (block_mac_same_block(tr, src, dest)) { in file_restore_to_commit()
1265 assert(block_mac_eq(tr, src, dest)); in file_restore_to_commit()
1270 block_mac_to_block(tr, &file->committed_block_mac), in file_restore_to_commit()
1271 block_mac_to_block(tr, &file->block_mac), in file_restore_to_commit()
1272 block_mac_to_block(tr, &file->to_commit_block_mac), file->size, in file_restore_to_commit()
1274 block_mac_copy(tr, dest, src); in file_restore_to_commit()
1279 * @tr: Current transaction.
1286 static void file_apply_to_commit(struct transaction* tr, in file_apply_to_commit() argument
1292 if (tr == file_tr) { in file_apply_to_commit()
1296 if (block_mac_same_block(tr, src, dest)) { in file_apply_to_commit()
1297 assert(block_mac_eq(tr, src, dest)); in file_apply_to_commit()
1299 block_mac_to_block(tr, &file->committed_block_mac)); in file_apply_to_commit()
1303 if (file_tr != tr) { in file_apply_to_commit()
1306 block_mac_to_block(tr, &file->committed_block_mac), in file_apply_to_commit()
1307 block_mac_to_block(tr, &file->block_mac), file->used_by_tr); in file_apply_to_commit()
1311 assert(block_mac_same_block(tr, dest, &file->block_mac)); in file_apply_to_commit()
1316 file, block_mac_to_block(tr, &file->committed_block_mac), in file_apply_to_commit()
1317 block_mac_to_block(tr, &file->block_mac), in file_apply_to_commit()
1318 block_mac_to_block(tr, &file->to_commit_block_mac), file->size, in file_apply_to_commit()
1321 block_mac_copy(tr, dest, src); in file_apply_to_commit()
1322 if (tr == file_tr) { in file_apply_to_commit()
1323 assert(block_mac_eq(tr, &file->block_mac, src)); in file_apply_to_commit()
1326 block_mac_copy(tr, &file->block_mac, src); in file_apply_to_commit()
1333 * @tr: Transaction object.
1337 void file_transaction_complete_failed(struct transaction* tr) { in file_transaction_complete_failed() argument
1338 file_for_each_open(tr, file_restore_to_commit); in file_transaction_complete_failed()
1343 * @tr: Current transaction object.
1352 static void file_update_block_mac_tr(struct transaction* tr, in file_update_block_mac_tr() argument
1360 assert(block_mac_valid(tr, old_block_mac) || other_tr == tr); in file_update_block_mac_tr()
1363 if (block_mac_valid(tr, old_block_mac) in file_update_block_mac_tr()
1364 ? !block_mac_same_block(tr, &file->committed_block_mac, in file_update_block_mac_tr()
1366 : !block_mac_same_block(tr, &file->block_mac, in file_update_block_mac_tr()
1369 file, block_mac_to_block(tr, &file->committed_block_mac), in file_update_block_mac_tr()
1370 block_mac_to_block(tr, new_block_mac)); in file_update_block_mac_tr()
1373 assert(old_block_no_mac || !block_mac_valid(tr, old_block_mac) || in file_update_block_mac_tr()
1374 block_mac_eq(tr, &file->committed_block_mac, old_block_mac)); in file_update_block_mac_tr()
1378 file, block_mac_to_block(tr, &file->committed_block_mac), in file_update_block_mac_tr()
1379 block_mac_to_block(tr, &file->block_mac), in file_update_block_mac_tr()
1380 block_mac_to_block(tr, new_block_mac), file->size, new_size); in file_update_block_mac_tr()
1382 block_mac_copy(tr, &file->to_commit_block_mac, new_block_mac); in file_update_block_mac_tr()
1389 * @tr: Transaction object.
1398 static void file_update_block_mac_all(struct transaction* tr, in file_update_block_mac_all() argument
1406 list_for_every_entry_safe(&tr->fs->transactions, other_tr, tmp_tr, in file_update_block_mac_all()
1408 file_update_block_mac_tr(tr, other_tr, old_block_mac, old_block_no_mac, in file_update_block_mac_all()
1415 * @tr: Transaction object.
1418 * Create a copy of @tr->fs->files and apply all file updates from @tr to it.
1420 * @tr->fs->files if the transaction succeeds.
1422 void file_transaction_complete(struct transaction* tr, in file_transaction_complete() argument
1435 block_tree_copy(&new_files, &tr->fs->files); in file_transaction_complete()
1437 block_tree_walk(tr, &tr->files_updated, 0, true, &tree_path); in file_transaction_complete()
1440 if (!block_mac_to_block(tr, &file)) { in file_transaction_complete()
1443 file_entry_ro = block_get(tr, &file, NULL, &file_entry_ref); in file_transaction_complete()
1445 assert(tr->failed); in file_transaction_complete()
1450 block_mac_set_block(tr, &old_file, block_tree_path_get_key(&tree_path)); in file_transaction_complete()
1453 block_mac_to_block(tr, &old_file), in file_transaction_complete()
1454 block_mac_to_block(tr, &file), file_entry_ro->info.path); in file_transaction_complete()
1456 file_update_block_mac_all(tr, &old_file, true, &file, in file_transaction_complete()
1459 hash = path_hash(tr, file_entry_ro->info.path); in file_transaction_complete()
1463 if (tr->failed) { in file_transaction_complete()
1468 block_tree_update_block_mac(tr, &new_files, hash, old_file, hash, file); in file_transaction_complete()
1470 if (tr->failed) { in file_transaction_complete()
1475 assert(block_mac_to_block(tr, &old_file) != in file_transaction_complete()
1476 block_mac_to_block(tr, &file)); in file_transaction_complete()
1480 block_tree_walk(tr, &tr->files_removed, 0, true, &tree_path); in file_transaction_complete()
1483 if (!block_mac_to_block(tr, &file)) { in file_transaction_complete()
1486 file_entry_ro = block_get(tr, &file, NULL, &file_entry_ref); in file_transaction_complete()
1488 assert(tr->failed); in file_transaction_complete()
1495 block_mac_to_block(tr, &file), file_entry_ro->info.path); in file_transaction_complete()
1497 file_update_block_mac_all(tr, &file, false, &clear_block_mac, 0); in file_transaction_complete()
1499 found = file_tree_lookup(&old_file, tr, &new_files, &tmp_tree_path, in file_transaction_complete()
1503 if (tr->failed) { in file_transaction_complete()
1509 assert(block_mac_to_block(tr, &old_file) == in file_transaction_complete()
1510 block_mac_to_block(tr, &file)); in file_transaction_complete()
1513 block_tree_walk(tr, &tr->files_added, 0, true, &tree_path); in file_transaction_complete()
1516 if (!block_mac_valid(tr, &file)) { in file_transaction_complete()
1519 file_entry_ro = block_get(tr, &file, NULL, &file_entry_ref); in file_transaction_complete()
1521 assert(tr->failed); in file_transaction_complete()
1526 pr_write("add file at %" PRIu64 ", %s\n", block_mac_to_block(tr, &file), in file_transaction_complete()
1529 if (file_tree_lookup(&old_file, tr, &new_files, &tmp_tree_path, in file_transaction_complete()
1534 block_mac_to_block(tr, &file), file_entry_ro->info.path, in file_transaction_complete()
1535 block_mac_to_block(tr, &old_file)); in file_transaction_complete()
1536 transaction_fail(tr); in file_transaction_complete()
1540 file_update_block_mac_tr(tr, tr, &clear_block_mac, false, &file, in file_transaction_complete()
1543 hash = path_hash(tr, file_entry_ro->info.path); in file_transaction_complete()
1546 if (tr->failed) { in file_transaction_complete()
1551 block_tree_insert_block_mac(tr, &new_files, hash, file); in file_transaction_complete()
1552 if (tr->failed) { in file_transaction_complete()
1564 * @tr: Transaction object.
1567 * Return: %true if @file was modified by @tr, %false otherwise.
1569 static bool transaction_changed_file(struct transaction* tr, in transaction_changed_file() argument
1571 return !block_mac_same_block(tr, &file->committed_block_mac, in transaction_changed_file()
1577 * @tr: Transaction object.
1579 void file_transaction_success(struct transaction* tr) { in file_transaction_success() argument
1580 file_for_each_open(tr, file_apply_to_commit); in file_transaction_success()
1585 * @tr: Transaction object.
1591 static bool file_read_size(struct transaction* tr, in file_read_size() argument
1597 if (!block_mac_valid(tr, block_mac)) { in file_read_size()
1602 file_entry_ro = block_get_no_tr_fail(tr, block_mac, NULL, &ref); in file_read_size()
1613 * @tr: Transaction object.
1615 * Revert all file handles modified by @tr to the state of the files before @tr
1616 * was activeted. File handles for files crreated by @tr become invalid.
1618 void file_transaction_failed(struct transaction* tr) { in file_transaction_failed() argument
1622 list_for_every_entry(&tr->open_files, file, struct storage_file_handle, in file_transaction_failed()
1625 if (transaction_changed_file(tr, file)) { in file_transaction_failed()
1627 success = file_read_size(tr, &file->block_mac, &file->size); in file_transaction_failed()
1630 block_mac_to_block(tr, &file->block_mac)); in file_transaction_failed()
1631 block_mac_clear(tr, &file->block_mac); in file_transaction_failed()
1632 block_mac_clear(tr, &file->committed_block_mac); in file_transaction_failed()
1641 * @tr: Transaction object
1651 static void file_rebuild_free_set(struct transaction* tr, in file_rebuild_free_set() argument
1659 block_set_remove_block(tr, new_free_set, in file_rebuild_free_set()
1660 block_mac_to_block(tr, &file->block_mac)); in file_rebuild_free_set()
1662 file_block_map_init(tr, &block_map, &file->block_mac); in file_rebuild_free_set()
1663 block_tree_walk(tr, &block_map.tree, 0, true, &path); in file_rebuild_free_set()
1672 block = block_mac_to_block(tr, &path.entry[i].block_mac); in file_rebuild_free_set()
1673 block_set_remove_block(tr, new_free_set, block); in file_rebuild_free_set()
1675 block_set_remove_block(tr, new_free_set, in file_rebuild_free_set()
1683 * @tr: Transaction object
1693 void files_rebuild_free_set(struct transaction* tr, in files_rebuild_free_set() argument
1702 fs_file_tree_init(tr->fs, &files); in files_rebuild_free_set()
1703 block_mac_copy(tr, &files.root, files_root); in files_rebuild_free_set()
1704 block_tree_walk(tr, &files, 0, true, &path); in files_rebuild_free_set()
1707 block_set_remove_block(tr, new_free_set, in files_rebuild_free_set()
1708 block_mac_to_block(tr, files_root)); in files_rebuild_free_set()
1719 block = block_mac_to_block(tr, &path.entry[i].block_mac); in files_rebuild_free_set()
1720 block_set_remove_block(tr, new_free_set, block); in files_rebuild_free_set()
1723 file_rebuild_free_set(tr, new_free_set, &file); in files_rebuild_free_set()