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
0e57996c
Commit
0e57996c
authored
May 03, 2024
by
Kent Overstreet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bcachefs: bch2_dev_get_ioref2(); alloc_background.c
Signed-off-by:
Kent Overstreet
<
kent.overstreet@linux.dev
>
parent
b6fb4269
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
fs/bcachefs/alloc_background.c
fs/bcachefs/alloc_background.c
+8
-11
fs/bcachefs/sb-members.h
fs/bcachefs/sb-members.h
+18
-0
No files found.
fs/bcachefs/alloc_background.c
View file @
0e57996c
...
@@ -1657,9 +1657,8 @@ static void discard_buckets_next_dev(struct bch_fs *c, struct discard_buckets_st
...
@@ -1657,9 +1657,8 @@ static void discard_buckets_next_dev(struct bch_fs *c, struct discard_buckets_st
bch2_dev_usage_read
(
s
->
ca
).
d
[
BCH_DATA_free
].
buckets
)
bch2_dev_usage_read
(
s
->
ca
).
d
[
BCH_DATA_free
].
buckets
)
bch2_journal_flush_async
(
&
c
->
journal
,
NULL
);
bch2_journal_flush_async
(
&
c
->
journal
,
NULL
);
bch2_dev_put
(
s
->
ca
);
if
(
s
->
ca
)
if
(
ca
)
percpu_ref_put
(
&
s
->
ca
->
io_ref
);
bch2_dev_get
(
ca
);
s
->
ca
=
ca
;
s
->
ca
=
ca
;
s
->
need_journal_commit_this_dev
=
0
;
s
->
need_journal_commit_this_dev
=
0
;
}
}
...
@@ -1673,15 +1672,15 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
...
@@ -1673,15 +1672,15 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
struct
bpos
pos
=
need_discard_iter
->
pos
;
struct
bpos
pos
=
need_discard_iter
->
pos
;
struct
btree_iter
iter
=
{
NULL
};
struct
btree_iter
iter
=
{
NULL
};
struct
bkey_s_c
k
;
struct
bkey_s_c
k
;
struct
bch_dev
*
ca
;
struct
bkey_i_alloc_v4
*
a
;
struct
bkey_i_alloc_v4
*
a
;
struct
printbuf
buf
=
PRINTBUF
;
struct
printbuf
buf
=
PRINTBUF
;
bool
discard_locked
=
false
;
bool
discard_locked
=
false
;
int
ret
=
0
;
int
ret
=
0
;
ca
=
bch2_dev_bkey_exists
(
c
,
pos
.
inode
);
struct
bch_dev
*
ca
=
s
->
ca
&&
s
->
ca
->
dev_idx
==
pos
.
inode
?
s
->
ca
if
(
!
percpu_ref_tryget
(
&
ca
->
io_ref
))
{
:
bch2_dev_get_ioref2
(
c
,
pos
.
inode
,
WRITE
);
if
(
!
ca
)
{
bch2_btree_iter_set_pos
(
need_discard_iter
,
POS
(
pos
.
inode
+
1
,
0
));
bch2_btree_iter_set_pos
(
need_discard_iter
,
POS
(
pos
.
inode
+
1
,
0
));
return
0
;
return
0
;
}
}
...
@@ -1787,7 +1786,6 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
...
@@ -1787,7 +1786,6 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
discard_in_flight_remove
(
c
,
iter
.
pos
);
discard_in_flight_remove
(
c
,
iter
.
pos
);
s
->
seen
++
;
s
->
seen
++
;
bch2_trans_iter_exit
(
trans
,
&
iter
);
bch2_trans_iter_exit
(
trans
,
&
iter
);
percpu_ref_put
(
&
ca
->
io_ref
);
printbuf_exit
(
&
buf
);
printbuf_exit
(
&
buf
);
return
ret
;
return
ret
;
}
}
...
@@ -1862,9 +1860,8 @@ static void bch2_do_discards_fast_work(struct work_struct *work)
...
@@ -1862,9 +1860,8 @@ static void bch2_do_discards_fast_work(struct work_struct *work)
if
(
i
->
snapshot
)
if
(
i
->
snapshot
)
continue
;
continue
;
ca
=
bch2_dev_bkey_exists
(
c
,
i
->
inode
);
ca
=
bch2_dev_get_ioref2
(
c
,
i
->
inode
,
WRITE
);
if
(
!
ca
)
{
if
(
!
percpu_ref_tryget
(
&
ca
->
io_ref
))
{
darray_remove_item
(
&
c
->
discard_buckets_in_flight
,
i
);
darray_remove_item
(
&
c
->
discard_buckets_in_flight
,
i
);
continue
;
continue
;
}
}
...
...
fs/bcachefs/sb-members.h
View file @
0e57996c
...
@@ -285,6 +285,24 @@ static inline struct bch_dev *bch2_dev_iterate(struct bch_fs *c, struct bch_dev
...
@@ -285,6 +285,24 @@ static inline struct bch_dev *bch2_dev_iterate(struct bch_fs *c, struct bch_dev
return
bch2_dev_tryget
(
c
,
dev_idx
);
return
bch2_dev_tryget
(
c
,
dev_idx
);
}
}
static
inline
struct
bch_dev
*
bch2_dev_get_ioref2
(
struct
bch_fs
*
c
,
unsigned
dev
,
int
rw
)
{
rcu_read_lock
();
struct
bch_dev
*
ca
=
bch2_dev_rcu
(
c
,
dev
);
if
(
ca
&&
!
percpu_ref_tryget
(
&
ca
->
io_ref
))
ca
=
NULL
;
rcu_read_unlock
();
if
(
ca
&&
(
ca
->
mi
.
state
==
BCH_MEMBER_STATE_rw
||
(
ca
->
mi
.
state
==
BCH_MEMBER_STATE_ro
&&
rw
==
READ
)))
return
ca
;
if
(
ca
)
percpu_ref_put
(
&
ca
->
io_ref
);
return
NULL
;
}
/* XXX kill, move to struct bch_fs */
/* XXX kill, move to struct bch_fs */
static
inline
struct
bch_devs_mask
bch2_online_devs
(
struct
bch_fs
*
c
)
static
inline
struct
bch_devs_mask
bch2_online_devs
(
struct
bch_fs
*
c
)
{
{
...
...
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