hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/fs/btrfs/inode-map.c
....@@ -525,58 +525,3 @@
525525 extent_changeset_free(data_reserved);
526526 return ret;
527527 }
528
-
529
-int btrfs_find_highest_objectid(struct btrfs_root *root, u64 *objectid)
530
-{
531
- struct btrfs_path *path;
532
- int ret;
533
- struct extent_buffer *l;
534
- struct btrfs_key search_key;
535
- struct btrfs_key found_key;
536
- int slot;
537
-
538
- path = btrfs_alloc_path();
539
- if (!path)
540
- return -ENOMEM;
541
-
542
- search_key.objectid = BTRFS_LAST_FREE_OBJECTID;
543
- search_key.type = -1;
544
- search_key.offset = (u64)-1;
545
- ret = btrfs_search_slot(NULL, root, &search_key, path, 0, 0);
546
- if (ret < 0)
547
- goto error;
548
- BUG_ON(ret == 0); /* Corruption */
549
- if (path->slots[0] > 0) {
550
- slot = path->slots[0] - 1;
551
- l = path->nodes[0];
552
- btrfs_item_key_to_cpu(l, &found_key, slot);
553
- *objectid = max_t(u64, found_key.objectid,
554
- BTRFS_FIRST_FREE_OBJECTID - 1);
555
- } else {
556
- *objectid = BTRFS_FIRST_FREE_OBJECTID - 1;
557
- }
558
- ret = 0;
559
-error:
560
- btrfs_free_path(path);
561
- return ret;
562
-}
563
-
564
-int btrfs_find_free_objectid(struct btrfs_root *root, u64 *objectid)
565
-{
566
- int ret;
567
- mutex_lock(&root->objectid_mutex);
568
-
569
- if (unlikely(root->highest_objectid >= BTRFS_LAST_FREE_OBJECTID)) {
570
- btrfs_warn(root->fs_info,
571
- "the objectid of root %llu reaches its highest value",
572
- root->root_key.objectid);
573
- ret = -ENOSPC;
574
- goto out;
575
- }
576
-
577
- *objectid = ++root->highest_objectid;
578
- ret = 0;
579
-out:
580
- mutex_unlock(&root->objectid_mutex);
581
- return ret;
582
-}