Allow to disable zero fill

blocking-uring-test
Vitaliy Filippov 2020-01-06 21:01:11 +03:00
parent bf3eecc159
commit ba23824561
3 changed files with 14 additions and 4 deletions

View File

@ -195,7 +195,12 @@ class blockstore_impl_t
bool readonly = false;
// FIXME: separate flags for data, metadata and journal
// It is safe to disable fsync() if drive write cache is writethrough
bool disable_fsync = false;
// It is safe to disable zero fill if drive is zeroed before formatting.
// For example, with TRIM and Deterministic Read Zeroes after TRIM.
// FIXME: OP_DELETE should trim/zero out the block.
bool zerofill_enabled = false;
bool inmemory_meta = false;
void *metadata_buffer = NULL;

View File

@ -10,6 +10,10 @@ void blockstore_impl_t::calc_lengths(blockstore_config_t & config)
{
disable_fsync = true;
}
if (config["zerofill"] == "true" || config["zerofill"] == "1" || config["zerofill"] == "yes")
{
zerofill_enabled = true;
}
// data
data_len = data_size - data_offset;
if (data_fd == meta_fd && data_offset < meta_offset)

View File

@ -102,10 +102,10 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op)
#endif
data_alloc->set(loc, true);
int vcnt = 0;
if (op->version == 1 && op->len != block_size)
uint64_t stripe_offset = 0;
if (op->len != block_size && zerofill_enabled)
{
// Zero fill newly allocated object. First write is always a big write
// FIXME: Add "no-zero-fill" mode which will just leave random garbage (insecure, but may be useful)
// Zero fill newly allocated object if required
if (op->offset > 0)
PRIV(op)->iov_zerofill[vcnt++] = (struct iovec){ zero_object, op->offset };
PRIV(op)->iov_zerofill[vcnt++] = (struct iovec){ op->buf, op->len };
@ -118,10 +118,11 @@ int blockstore_impl_t::dequeue_write(blockstore_op_t *op)
vcnt = 1;
PRIV(op)->iov_zerofill[0] = (struct iovec){ op->buf, op->len };
data->iov.iov_len = op->len; // to check it in the callback
stripe_offset = op->offset;
}
data->callback = [this, op](ring_data_t *data) { handle_write_event(data, op); };
my_uring_prep_writev(
sqe, data_fd, PRIV(op)->iov_zerofill, vcnt, data_offset + (loc << block_order)
sqe, data_fd, PRIV(op)->iov_zerofill, vcnt, data_offset + (loc << block_order) + stripe_offset
);
PRIV(op)->pending_ops = 1;
PRIV(op)->min_used_journal_sector = PRIV(op)->max_used_journal_sector = 0;