Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
952fccac
Commit
952fccac
authored
Feb 18, 2008
by
Chris Mason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Btrfs: Remove extent back refs in batches, and avoid duplicate searches
Signed-off-by:
Chris Mason
<
chris.mason@oracle.com
>
parent
d7fc640e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
9 deletions
+54
-9
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+54
-9
No files found.
fs/btrfs/extent-tree.c
View file @
952fccac
...
...
@@ -1251,6 +1251,9 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
struct
btrfs_root
*
extent_root
=
info
->
extent_root
;
struct
extent_buffer
*
leaf
;
int
ret
;
int
extent_slot
=
0
;
int
found_extent
=
0
;
int
num_to_del
=
1
;
struct
btrfs_extent_item
*
ei
;
u32
refs
;
...
...
@@ -1267,6 +1270,23 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
ref_generation
,
owner_objectid
,
owner_offset
,
1
);
if
(
ret
==
0
)
{
struct
btrfs_key
found_key
;
extent_slot
=
path
->
slots
[
0
];
while
(
extent_slot
>
0
)
{
extent_slot
--
;
btrfs_item_key_to_cpu
(
path
->
nodes
[
0
],
&
found_key
,
extent_slot
);
if
(
found_key
.
objectid
!=
bytenr
)
break
;
if
(
found_key
.
type
==
BTRFS_EXTENT_ITEM_KEY
&&
found_key
.
offset
==
num_bytes
)
{
found_extent
=
1
;
break
;
}
if
(
path
->
slots
[
0
]
-
extent_slot
>
5
)
break
;
}
if
(
!
found_extent
)
ret
=
btrfs_del_item
(
trans
,
extent_root
,
path
);
}
else
{
btrfs_print_leaf
(
extent_root
,
path
->
nodes
[
0
]);
...
...
@@ -1276,21 +1296,46 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
root_objectid
,
ref_generation
,
owner_objectid
,
owner_offset
);
}
if
(
!
found_extent
)
{
btrfs_release_path
(
extent_root
,
path
);
ret
=
btrfs_search_slot
(
trans
,
extent_root
,
&
key
,
path
,
-
1
,
1
);
if
(
ret
<
0
)
return
ret
;
BUG_ON
(
ret
);
extent_slot
=
path
->
slots
[
0
];
}
leaf
=
path
->
nodes
[
0
];
ei
=
btrfs_item_ptr
(
leaf
,
path
->
slots
[
0
]
,
ei
=
btrfs_item_ptr
(
leaf
,
extent_slot
,
struct
btrfs_extent_item
);
refs
=
btrfs_extent_refs
(
leaf
,
ei
);
BUG_ON
(
refs
==
0
);
refs
-=
1
;
btrfs_set_extent_refs
(
leaf
,
ei
,
refs
);
btrfs_mark_buffer_dirty
(
leaf
);
if
(
refs
==
0
&&
found_extent
&&
path
->
slots
[
0
]
==
extent_slot
+
1
)
{
/* if the back ref and the extent are next to each other
* they get deleted below in one shot
*/
path
->
slots
[
0
]
=
extent_slot
;
num_to_del
=
2
;
}
else
if
(
found_extent
)
{
/* otherwise delete the extent back ref */
ret
=
btrfs_del_item
(
trans
,
extent_root
,
path
);
BUG_ON
(
ret
);
/* if refs are 0, we need to setup the path for deletion */
if
(
refs
==
0
)
{
btrfs_release_path
(
extent_root
,
path
);
ret
=
btrfs_search_slot
(
trans
,
extent_root
,
&
key
,
path
,
-
1
,
1
);
if
(
ret
<
0
)
return
ret
;
BUG_ON
(
ret
);
}
}
if
(
refs
==
0
)
{
u64
super_used
;
u64
root_used
;
...
...
@@ -1311,8 +1356,8 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
root_used
=
btrfs_root_used
(
&
root
->
root_item
);
btrfs_set_root_used
(
&
root
->
root_item
,
root_used
-
num_bytes
);
ret
=
btrfs_del_item
(
trans
,
extent_root
,
path
);
ret
=
btrfs_del_items
(
trans
,
extent_root
,
path
,
path
->
slots
[
0
],
num_to_del
);
if
(
ret
)
{
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment