LCOV - code coverage report
Current view: top level - fs/btrfs - orphan.c (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc3-djwx @ Mon Jul 31 20:08:22 PDT 2023 Lines: 28 31 90.3 %
Date: 2023-07-31 20:08:22 Functions: 2 2 100.0 %

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : /*
       3             :  * Copyright (C) 2008 Red Hat.  All rights reserved.
       4             :  */
       5             : 
       6             : #include "ctree.h"
       7             : #include "disk-io.h"
       8             : #include "orphan.h"
       9             : 
      10     1776894 : int btrfs_insert_orphan_item(struct btrfs_trans_handle *trans,
      11             :                              struct btrfs_root *root, u64 offset)
      12             : {
      13     1776894 :         struct btrfs_path *path;
      14     1776894 :         struct btrfs_key key;
      15     1776894 :         int ret = 0;
      16             : 
      17     1776894 :         key.objectid = BTRFS_ORPHAN_OBJECTID;
      18     1776894 :         key.type = BTRFS_ORPHAN_ITEM_KEY;
      19     1776894 :         key.offset = offset;
      20             : 
      21     1776894 :         path = btrfs_alloc_path();
      22     1776873 :         if (!path)
      23             :                 return -ENOMEM;
      24             : 
      25     1776873 :         ret = btrfs_insert_empty_item(trans, root, path, &key, 0);
      26             : 
      27     1776904 :         btrfs_free_path(path);
      28     1776904 :         return ret;
      29             : }
      30             : 
      31     1776856 : int btrfs_del_orphan_item(struct btrfs_trans_handle *trans,
      32             :                           struct btrfs_root *root, u64 offset)
      33             : {
      34     1776856 :         struct btrfs_path *path;
      35     1776856 :         struct btrfs_key key;
      36     1776856 :         int ret = 0;
      37             : 
      38     1776856 :         key.objectid = BTRFS_ORPHAN_OBJECTID;
      39     1776856 :         key.type = BTRFS_ORPHAN_ITEM_KEY;
      40     1776856 :         key.offset = offset;
      41             : 
      42     1776856 :         path = btrfs_alloc_path();
      43     1776858 :         if (!path)
      44             :                 return -ENOMEM;
      45             : 
      46     1776858 :         ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
      47     1776858 :         if (ret < 0)
      48           0 :                 goto out;
      49     1776858 :         if (ret) { /* JDM: Really? */
      50           0 :                 ret = -ENOENT;
      51           0 :                 goto out;
      52             :         }
      53             : 
      54     1776858 :         ret = btrfs_del_item(trans, root, path);
      55             : 
      56     1776860 : out:
      57     1776860 :         btrfs_free_path(path);
      58     1776860 :         return ret;
      59             : }

Generated by: LCOV version 1.14