void bch2_do_discards(struct bch_fs *c)
{
- if (percpu_ref_tryget(&c->writes) &&
+ if (percpu_ref_tryget_live(&c->writes) &&
!queue_work(system_long_wq, &c->discard_work))
percpu_ref_put(&c->writes);
}
void bch2_do_invalidates(struct bch_fs *c)
{
- if (percpu_ref_tryget(&c->writes))
+ if (percpu_ref_tryget_live(&c->writes))
queue_work(system_long_wq, &c->invalidate_work);
}
{
struct async_btree_rewrite *a;
- if (!percpu_ref_tryget(&c->writes))
+ if (!percpu_ref_tryget_live(&c->writes))
return;
a = kmalloc(sizeof(*a), GFP_NOFS);
}
if (!(trans->flags & BTREE_INSERT_NOCHECK_RW) &&
- unlikely(!percpu_ref_tryget(&c->writes))) {
+ unlikely(!percpu_ref_tryget_live(&c->writes))) {
ret = bch2_trans_commit_get_rw_cold(trans);
if (ret)
goto out_reset;
BUG_ON(!s->allocated);
- if (!percpu_ref_tryget(&c->writes))
+ if (!percpu_ref_tryget_live(&c->writes))
goto err;
ec_generate_ec(&s->new_stripe);
struct bch_fs *c = inode->v.i_sb->s_fs_info;
long ret;
- if (!percpu_ref_tryget(&c->writes))
+ if (!percpu_ref_tryget_live(&c->writes))
return -EROFS;
inode_lock(&inode->v);
}
if (c->opts.nochanges ||
- !percpu_ref_tryget(&c->writes)) {
+ !percpu_ref_tryget_live(&c->writes)) {
op->error = -EROFS;
goto err;
}
unsigned pages = DIV_ROUND_UP(sectors, PAGE_SECTORS);
int ret;
- if (!percpu_ref_tryget(&c->writes))
+ if (!percpu_ref_tryget_live(&c->writes))
return NULL;
op = kzalloc(sizeof(*op) + sizeof(struct bio_vec) * pages, GFP_NOIO);
u32 dst_snapshot, src_snapshot;
int ret = 0, ret2 = 0;
- if (!percpu_ref_tryget(&c->writes))
+ if (!percpu_ref_tryget_live(&c->writes))
return -EROFS;
bch2_check_set_feature(c, BCH_FEATURE_reflink);
static void bch2_delete_dead_snapshots(struct bch_fs *c)
{
- if (unlikely(!percpu_ref_tryget(&c->writes)))
+ if (unlikely(!percpu_ref_tryget_live(&c->writes)))
return;
if (!queue_work(system_long_wq, &c->snapshot_delete_work))
if (ret)
return ret;
- if (unlikely(!percpu_ref_tryget(&c->writes)))
+ if (unlikely(!percpu_ref_tryget_live(&c->writes)))
return -EROFS;
if (!queue_work(system_long_wq, &c->snapshot_wait_for_pagecache_and_delete_work))
* We don't need to take c->writes for correctness, but it eliminates an
* unsightly error message in the dmesg log when we're RO:
*/
- if (unlikely(!percpu_ref_tryget(&c->writes)))
+ if (unlikely(!percpu_ref_tryget_live(&c->writes)))
return -EROFS;
tmp = kstrdup(buf, GFP_KERNEL);