Commit 1c6ff394 authored by Kent Overstreet's avatar Kent Overstreet Committed by Kent Overstreet

bcachefs: Fix refcount leak in bch2_do_invalidates()

If we fail to queue the work item because it's already in process, we
need to drop the ref we just took.
Signed-off-by: default avatarKent Overstreet <kent.overstreet@gmail.com>
parent a3d7afa5
...@@ -1192,8 +1192,9 @@ static void bch2_do_invalidates_work(struct work_struct *work) ...@@ -1192,8 +1192,9 @@ static void bch2_do_invalidates_work(struct work_struct *work)
void bch2_do_invalidates(struct bch_fs *c) void bch2_do_invalidates(struct bch_fs *c)
{ {
if (percpu_ref_tryget_live(&c->writes)) if (percpu_ref_tryget_live(&c->writes) &&
queue_work(system_long_wq, &c->invalidate_work); !queue_work(system_long_wq, &c->invalidate_work))
percpu_ref_put(&c->writes);
} }
static int bucket_freespace_init(struct btree_trans *trans, struct btree_iter *iter) static int bucket_freespace_init(struct btree_trans *trans, struct btree_iter *iter)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment