backref.c (355a47ae7ebcf9d605aa809b259d380422e81b8d) backref.c (5911c8fe05c54c9f74a6467650e6493e4808cd01)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2011 STRATO. All rights reserved.
4 */
5
6#include <linux/mm.h>
7#include <linux/rbtree.h>
8#include <trace/events/btrfs.h>

--- 1451 unchanged lines hidden (view full) ---

1460 * callers (such as fiemap) which want to know whether the extent is
1461 * shared but do not need a ref count.
1462 *
1463 * This attempts to attach to the running transaction in order to account for
1464 * delayed refs, but continues on even when no running transaction exists.
1465 *
1466 * Return: 0 if extent is not shared, 1 if it is shared, < 0 on error.
1467 */
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2011 STRATO. All rights reserved.
4 */
5
6#include <linux/mm.h>
7#include <linux/rbtree.h>
8#include <trace/events/btrfs.h>

--- 1451 unchanged lines hidden (view full) ---

1460 * callers (such as fiemap) which want to know whether the extent is
1461 * shared but do not need a ref count.
1462 *
1463 * This attempts to attach to the running transaction in order to account for
1464 * delayed refs, but continues on even when no running transaction exists.
1465 *
1466 * Return: 0 if extent is not shared, 1 if it is shared, < 0 on error.
1467 */
1468int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr)
1468int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr,
1469 struct ulist *roots, struct ulist *tmp)
1469{
1470 struct btrfs_fs_info *fs_info = root->fs_info;
1471 struct btrfs_trans_handle *trans;
1470{
1471 struct btrfs_fs_info *fs_info = root->fs_info;
1472 struct btrfs_trans_handle *trans;
1472 struct ulist *tmp = NULL;
1473 struct ulist *roots = NULL;
1474 struct ulist_iterator uiter;
1475 struct ulist_node *node;
1476 struct seq_list elem = SEQ_LIST_INIT(elem);
1477 int ret = 0;
1478 struct share_check shared = {
1479 .root_objectid = root->root_key.objectid,
1480 .inum = inum,
1481 .share_count = 0,
1482 };
1483
1473 struct ulist_iterator uiter;
1474 struct ulist_node *node;
1475 struct seq_list elem = SEQ_LIST_INIT(elem);
1476 int ret = 0;
1477 struct share_check shared = {
1478 .root_objectid = root->root_key.objectid,
1479 .inum = inum,
1480 .share_count = 0,
1481 };
1482
1484 tmp = ulist_alloc(GFP_NOFS);
1485 roots = ulist_alloc(GFP_NOFS);
1486 if (!tmp || !roots) {
1487 ret = -ENOMEM;
1488 goto out;
1489 }
1483 ulist_init(roots);
1484 ulist_init(tmp);
1490
1491 trans = btrfs_attach_transaction(root);
1492 if (IS_ERR(trans)) {
1493 if (PTR_ERR(trans) != -ENOENT && PTR_ERR(trans) != -EROFS) {
1494 ret = PTR_ERR(trans);
1495 goto out;
1496 }
1497 trans = NULL;

--- 24 unchanged lines hidden (view full) ---

1522
1523 if (trans) {
1524 btrfs_put_tree_mod_seq(fs_info, &elem);
1525 btrfs_end_transaction(trans);
1526 } else {
1527 up_read(&fs_info->commit_root_sem);
1528 }
1529out:
1485
1486 trans = btrfs_attach_transaction(root);
1487 if (IS_ERR(trans)) {
1488 if (PTR_ERR(trans) != -ENOENT && PTR_ERR(trans) != -EROFS) {
1489 ret = PTR_ERR(trans);
1490 goto out;
1491 }
1492 trans = NULL;

--- 24 unchanged lines hidden (view full) ---

1517
1518 if (trans) {
1519 btrfs_put_tree_mod_seq(fs_info, &elem);
1520 btrfs_end_transaction(trans);
1521 } else {
1522 up_read(&fs_info->commit_root_sem);
1523 }
1524out:
1530 ulist_free(tmp);
1531 ulist_free(roots);
1525 ulist_release(roots);
1526 ulist_release(tmp);
1532 return ret;
1533}
1534
1535int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
1536 u64 start_off, struct btrfs_path *path,
1537 struct btrfs_inode_extref **ret_extref,
1538 u64 *found_off)
1539{

--- 720 unchanged lines hidden ---
1527 return ret;
1528}
1529
1530int btrfs_find_one_extref(struct btrfs_root *root, u64 inode_objectid,
1531 u64 start_off, struct btrfs_path *path,
1532 struct btrfs_inode_extref **ret_extref,
1533 u64 *found_off)
1534{

--- 720 unchanged lines hidden ---