* [PATCH 1/2] bcachefs: Use bkey_eq instead of bpos_eq
@ 2025-05-12 18:44 Alan Huang
2025-05-12 18:44 ` [PATCH 2/2] bcachefs: Early return to avoid unnecessary lock Alan Huang
0 siblings, 1 reply; 3+ messages in thread
From: Alan Huang @ 2025-05-12 18:44 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs, Alan Huang
Since we are using bpos_nosnap_successor, it's more reasonable to use
bkey_eq instead of bpos_eq.
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
---
fs/bcachefs/alloc_background.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 81e2ae4bb400..ac27735c11e5 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -1057,7 +1057,7 @@ static struct bkey_s_c bch2_get_key_or_hole(struct btree_trans *trans, struct bt
bch2_trans_copy_iter(trans, &iter2, iter);
struct btree_path *path = btree_iter_path(trans, iter);
- if (!bpos_eq(path->l[0].b->key.k.p, SPOS_MAX))
+ if (!bkey_eq(path->l[0].b->key.k.p, POS_MAX))
end = bkey_min(end, bpos_nosnap_successor(path->l[0].b->key.k.p));
end = bkey_min(end, POS(iter->pos.inode, iter->pos.offset + U32_MAX - 1));
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] bcachefs: Early return to avoid unnecessary lock
2025-05-12 18:44 [PATCH 1/2] bcachefs: Use bkey_eq instead of bpos_eq Alan Huang
@ 2025-05-12 18:44 ` Alan Huang
2025-05-15 17:06 ` Kent Overstreet
0 siblings, 1 reply; 3+ messages in thread
From: Alan Huang @ 2025-05-12 18:44 UTC (permalink / raw)
To: kent.overstreet; +Cc: linux-bcachefs, Alan Huang
Signed-off-by: Alan Huang <mmpgouride@gmail.com>
---
fs/bcachefs/alloc_background.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index ac27735c11e5..043f4814a0d0 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -2585,19 +2585,18 @@ u64 bch2_min_rw_member_capacity(struct bch_fs *c)
static bool bch2_dev_has_open_write_point(struct bch_fs *c, struct bch_dev *ca)
{
struct open_bucket *ob;
- bool ret = false;
for (ob = c->open_buckets;
ob < c->open_buckets + ARRAY_SIZE(c->open_buckets);
ob++) {
- spin_lock(&ob->lock);
- if (ob->valid && !ob->on_partial_list &&
- ob->dev == ca->dev_idx)
- ret = true;
- spin_unlock(&ob->lock);
+ scoped_guard(spinlock, &ob->lock) {
+ if (ob->valid && !ob->on_partial_list &&
+ ob->dev == ca->dev_idx)
+ return true;
+ }
}
- return ret;
+ return false;
}
void bch2_dev_allocator_set_rw(struct bch_fs *c, struct bch_dev *ca, bool rw)
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] bcachefs: Early return to avoid unnecessary lock
2025-05-12 18:44 ` [PATCH 2/2] bcachefs: Early return to avoid unnecessary lock Alan Huang
@ 2025-05-15 17:06 ` Kent Overstreet
0 siblings, 0 replies; 3+ messages in thread
From: Kent Overstreet @ 2025-05-15 17:06 UTC (permalink / raw)
To: Alan Huang; +Cc: linux-bcachefs
On Tue, May 13, 2025 at 02:44:26AM +0800, Alan Huang wrote:
> Signed-off-by: Alan Huang <mmpgouride@gmail.com>
Applied
> ---
> fs/bcachefs/alloc_background.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
> index ac27735c11e5..043f4814a0d0 100644
> --- a/fs/bcachefs/alloc_background.c
> +++ b/fs/bcachefs/alloc_background.c
> @@ -2585,19 +2585,18 @@ u64 bch2_min_rw_member_capacity(struct bch_fs *c)
> static bool bch2_dev_has_open_write_point(struct bch_fs *c, struct bch_dev *ca)
> {
> struct open_bucket *ob;
> - bool ret = false;
>
> for (ob = c->open_buckets;
> ob < c->open_buckets + ARRAY_SIZE(c->open_buckets);
> ob++) {
> - spin_lock(&ob->lock);
> - if (ob->valid && !ob->on_partial_list &&
> - ob->dev == ca->dev_idx)
> - ret = true;
> - spin_unlock(&ob->lock);
> + scoped_guard(spinlock, &ob->lock) {
> + if (ob->valid && !ob->on_partial_list &&
> + ob->dev == ca->dev_idx)
> + return true;
> + }
> }
>
> - return ret;
> + return false;
> }
>
> void bch2_dev_allocator_set_rw(struct bch_fs *c, struct bch_dev *ca, bool rw)
> --
> 2.48.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-15 17:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12 18:44 [PATCH 1/2] bcachefs: Use bkey_eq instead of bpos_eq Alan Huang
2025-05-12 18:44 ` [PATCH 2/2] bcachefs: Early return to avoid unnecessary lock Alan Huang
2025-05-15 17:06 ` Kent Overstreet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).