drm/panfrost: perfcnt: Reserve/use the AS attached to the perfcnt MMU context
[linux/fpc-iii.git] / fs / btrfs / orphan.c
blobaa534108c1e2ff713b1e16f9fac684c0ae16500b
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (C) 2008 Red Hat. All rights reserved.
4 */
6 #include "ctree.h"
7 #include "disk-io.h"
9 int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
10 struct btrfs_root *root, u64 offset)
12 struct btrfs_path *path;
13 struct btrfs_key key;
14 int ret = 0;
16 key.objectid = BTRFS_ORPHAN_OBJECTID;
17 key.type = BTRFS_ORPHAN_ITEM_KEY;
18 key.offset = offset;
20 path = btrfs_alloc_path();
21 if (!path)
22 return -ENOMEM;
24 ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
26 btrfs_free_path(path);
27 return ret;
30 int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
31 struct btrfs_root *root, u64 offset)
33 struct btrfs_path *path;
34 struct btrfs_key key;
35 int ret = 0;
37 key.objectid = BTRFS_ORPHAN_OBJECTID;
38 key.type = BTRFS_ORPHAN_ITEM_KEY;
39 key.offset = offset;
41 path = btrfs_alloc_path();
42 if (!path)
43 return -ENOMEM;
45 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
46 if (ret < 0)
47 goto out;
48 if (ret) { /* JDM: Really? */
49 ret = -ENOENT;
50 goto out;
53 ret = btrfs_del_item(trans, root, path);
55 out:
56 btrfs_free_path(path);
57 return ret;