BKEY_EXTENT_U64s_MAX))
break;
- if ((op->flags & BCH_WRITE_FROM_INTERNAL) &&
- percpu_ref_is_dying(&c->writes)) {
- ret = -EROFS;
- goto err;
- }
-
/*
* The copygc thread is now global, which means it's no longer
* freeing up space on specific disks, which means that
static void move_free(struct moving_io *io)
{
struct moving_context *ctxt = io->write.ctxt;
+ struct bch_fs *c = ctxt->c;
bch2_data_update_exit(&io->write);
wake_up(&ctxt->wait);
+ percpu_ref_put(&c->writes);
kfree(io);
}
unsigned sectors = k.k->size, pages;
int ret = -ENOMEM;
+ if (!percpu_ref_tryget_live(&c->writes))
+ return -EROFS;
+
/* write path might have to decompress data: */
bkey_for_each_ptr_decode(k.k, ptrs, p, entry)
sectors = max_t(unsigned, sectors, p.crc.uncompressed_size);
err_free:
kfree(io);
err:
+ percpu_ref_put(&c->writes);
trace_move_alloc_mem_fail(k.k);
return ret;
}