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
Kirill Smelkov
linux
Commits
17758a6c
Commit
17758a6c
authored
May 11, 2019
by
Kent Overstreet
Committed by
Kent Overstreet
Oct 22, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: bch2_btree_delete_at_range()
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
42c7d748
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
39 deletions
+57
-39
fs/bcachefs/btree_update.h
fs/bcachefs/btree_update.h
+2
-0
fs/bcachefs/btree_update_leaf.c
fs/bcachefs/btree_update_leaf.c
+55
-39
No files found.
fs/bcachefs/btree_update.h
View file @
17758a6c
...
@@ -106,6 +106,8 @@ int bch2_btree_delete_at(struct btree_trans *, struct btree_iter *, unsigned);
...
@@ -106,6 +106,8 @@ int bch2_btree_delete_at(struct btree_trans *, struct btree_iter *, unsigned);
int
bch2_btree_insert
(
struct
bch_fs
*
,
enum
btree_id
,
struct
bkey_i
*
,
int
bch2_btree_insert
(
struct
bch_fs
*
,
enum
btree_id
,
struct
bkey_i
*
,
struct
disk_reservation
*
,
u64
*
,
int
flags
);
struct
disk_reservation
*
,
u64
*
,
int
flags
);
int
bch2_btree_delete_at_range
(
struct
btree_trans
*
,
struct
btree_iter
*
,
struct
bpos
,
u64
*
);
int
bch2_btree_delete_range
(
struct
bch_fs
*
,
enum
btree_id
,
int
bch2_btree_delete_range
(
struct
bch_fs
*
,
enum
btree_id
,
struct
bpos
,
struct
bpos
,
u64
*
);
struct
bpos
,
struct
bpos
,
u64
*
);
...
...
fs/bcachefs/btree_update_leaf.c
View file @
17758a6c
...
@@ -955,20 +955,6 @@ struct btree_insert_entry *bch2_trans_update(struct btree_trans *trans,
...
@@ -955,20 +955,6 @@ struct btree_insert_entry *bch2_trans_update(struct btree_trans *trans,
return
i
;
return
i
;
}
}
int
bch2_btree_delete_at
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
,
unsigned
flags
)
{
struct
bkey_i
k
;
bkey_init
(
&
k
.
k
);
k
.
k
.
p
=
iter
->
pos
;
bch2_trans_update
(
trans
,
BTREE_INSERT_ENTRY
(
iter
,
&
k
));
return
bch2_trans_commit
(
trans
,
NULL
,
NULL
,
BTREE_INSERT_NOFAIL
|
BTREE_INSERT_USE_RESERVE
|
flags
);
}
/**
/**
* bch2_btree_insert - insert keys into the extent btree
* bch2_btree_insert - insert keys into the extent btree
* @c: pointer to struct bch_fs
* @c: pointer to struct bch_fs
...
@@ -998,30 +984,17 @@ int bch2_btree_insert(struct bch_fs *c, enum btree_id id,
...
@@ -998,30 +984,17 @@ int bch2_btree_insert(struct bch_fs *c, enum btree_id id,
return
ret
;
return
ret
;
}
}
/*
int
bch2_btree_delete_at_range
(
struct
btree_trans
*
trans
,
* bch_btree_delete_range - delete everything within a given range
struct
btree_iter
*
iter
,
*
struct
bpos
end
,
* Range is a half open interval - [start, end)
*/
int
bch2_btree_delete_range
(
struct
bch_fs
*
c
,
enum
btree_id
id
,
struct
bpos
start
,
struct
bpos
end
,
u64
*
journal_seq
)
u64
*
journal_seq
)
{
{
struct
btree_trans
trans
;
struct
btree_iter
*
iter
;
struct
bkey_s_c
k
;
struct
bkey_s_c
k
;
int
ret
=
0
;
int
ret
=
0
;
retry:
bch2_trans_init
(
&
trans
,
c
);
bch2_trans_preload_iters
(
&
trans
);
iter
=
bch2_trans_get_iter
(
&
trans
,
id
,
start
,
BTREE_ITER_INTENT
);
while
((
k
=
bch2_btree_iter_peek
(
iter
)).
k
&&
while
((
k
=
bch2_btree_iter_peek
(
iter
)).
k
&&
!
(
ret
=
bkey_err
(
k
))
&&
!
(
ret
=
bkey_err
(
k
))
&&
bkey_cmp
(
iter
->
pos
,
end
)
<
0
)
{
bkey_cmp
(
iter
->
pos
,
end
)
<
0
)
{
unsigned
max_sectors
=
KEY_SIZE_MAX
&
(
~
0
<<
c
->
block_bits
);
/* really shouldn't be using a bare, unpadded bkey_i */
struct
bkey_i
delete
;
struct
bkey_i
delete
;
bkey_init
(
&
delete
.
k
);
bkey_init
(
&
delete
.
k
);
...
@@ -1039,26 +1012,69 @@ int bch2_btree_delete_range(struct bch_fs *c, enum btree_id id,
...
@@ -1039,26 +1012,69 @@ int bch2_btree_delete_range(struct bch_fs *c, enum btree_id id,
delete
.
k
.
p
=
iter
->
pos
;
delete
.
k
.
p
=
iter
->
pos
;
if
(
iter
->
flags
&
BTREE_ITER_IS_EXTENTS
)
{
if
(
iter
->
flags
&
BTREE_ITER_IS_EXTENTS
)
{
unsigned
max_sectors
=
KEY_SIZE_MAX
&
(
~
0
<<
trans
->
c
->
block_bits
);
/* create the biggest key we can */
/* create the biggest key we can */
bch2_key_resize
(
&
delete
.
k
,
max_sectors
);
bch2_key_resize
(
&
delete
.
k
,
max_sectors
);
bch2_cut_back
(
end
,
&
delete
.
k
);
bch2_cut_back
(
end
,
&
delete
.
k
);
bch2_extent_trim_atomic
(
&
delete
,
iter
);
bch2_extent_trim_atomic
(
&
delete
,
iter
);
}
}
bch2_trans_update
(
&
trans
,
BTREE_INSERT_ENTRY
(
iter
,
&
delete
));
bch2_trans_update
(
trans
,
BTREE_INSERT_ENTRY
(
iter
,
&
delete
));
ret
=
bch2_trans_commit
(
trans
,
NULL
,
journal_seq
,
ret
=
bch2_trans_commit
(
&
trans
,
NULL
,
journal_seq
,
BTREE_INSERT_ATOMIC
|
BTREE_INSERT_ATOMIC
|
BTREE_INSERT_NOFAIL
);
BTREE_INSERT_NOFAIL
);
if
(
ret
==
-
EINTR
)
ret
=
0
;
if
(
ret
)
if
(
ret
)
break
;
break
;
bch2_trans_cond_resched
(
&
trans
);
bch2_trans_cond_resched
(
trans
);
}
}
bch2_trans_exit
(
&
trans
);
if
(
ret
==
-
EINTR
)
{
ret
=
0
;
goto
retry
;
}
return
ret
;
}
int
bch2_btree_delete_at
(
struct
btree_trans
*
trans
,
struct
btree_iter
*
iter
,
unsigned
flags
)
{
struct
bkey_i
k
;
bkey_init
(
&
k
.
k
);
k
.
k
.
p
=
iter
->
pos
;
bch2_trans_update
(
trans
,
BTREE_INSERT_ENTRY
(
iter
,
&
k
));
return
bch2_trans_commit
(
trans
,
NULL
,
NULL
,
BTREE_INSERT_NOFAIL
|
BTREE_INSERT_USE_RESERVE
|
flags
);
}
/*
* bch_btree_delete_range - delete everything within a given range
*
* Range is a half open interval - [start, end)
*/
int
bch2_btree_delete_range
(
struct
bch_fs
*
c
,
enum
btree_id
id
,
struct
bpos
start
,
struct
bpos
end
,
u64
*
journal_seq
)
{
struct
btree_trans
trans
;
struct
btree_iter
*
iter
;
int
ret
=
0
;
bch2_trans_init
(
&
trans
,
c
);
bch2_trans_preload_iters
(
&
trans
);
iter
=
bch2_trans_get_iter
(
&
trans
,
id
,
start
,
BTREE_ITER_INTENT
);
ret
=
bch2_btree_delete_at_range
(
&
trans
,
iter
,
end
,
journal_seq
);
ret
=
bch2_trans_exit
(
&
trans
)
?:
ret
;
BUG_ON
(
ret
==
-
EINTR
);
BUG_ON
(
ret
==
-
EINTR
);
return
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