ghobject_t oid = i.decode_oid();
uint64_t off = i.decode_length();
uint64_t len = i.decode_length();
- bool replica = i.get_replica();
+ uint32_t fadvise_flags = i.get_fadvise_flags();
bufferlist bl;
i.decode_bl(bl);
tracepoint(objectstore, write_enter, osr_name, off, len);
if (_check_replay_guard(cid, oid, spos) > 0)
- r = _write(cid, oid, off, len, bl, replica);
+ r = _write(cid, oid, off, len, bl, fadvise_flags);
tracepoint(objectstore, write_exit, r);
}
break;
int FileStore::_write(coll_t cid, const ghobject_t& oid,
uint64_t offset, size_t len,
- const bufferlist& bl, bool replica)
+ const bufferlist& bl, uint32_t fadvise_flags)
{
dout(15) << "write " << cid << "/" << oid << " " << offset << "~" << len << dendl;
int r;
// flush?
if (!replaying &&
g_conf->filestore_wbthrottle_enable)
- wbthrottle.queue_wb(fd, oid, offset, len, replica);
+ wbthrottle.queue_wb(fd, oid, offset, len,
+ fadvise_flags & CEPH_OSD_OP_FLAG_FADVISE_DONTNEED);
lfn_close(fd);
out:
int fiemap(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, bufferlist& bl);
int _touch(coll_t cid, const ghobject_t& oid);
- int _write(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, const bufferlist& bl,
- bool replica = false);
+ int _write(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len,
+ const bufferlist& bl, uint32_t fadvise_flags = 0);
int _zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len);
int _truncate(coll_t cid, const ghobject_t& oid, uint64_t size);
int _clone(coll_t cid, const ghobject_t& oldoid, const ghobject_t& newoid,
ghobject_t oid = i.decode_oid();
uint64_t off = i.decode_length();
uint64_t len = i.decode_length();
- bool replica = i.get_replica();
+ uint32_t fadvise_flags = i.get_fadvise_flags();
bufferlist bl;
i.decode_bl(bl);
- r = _write(cid, oid, off, len, bl, t, replica);
+ r = _write(cid, oid, off, len, bl, t, fadvise_flags);
}
break;
int KeyValueStore::_generic_write(StripObjectMap::StripObjectHeaderRef header,
uint64_t offset, size_t len,
const bufferlist& bl, BufferTransaction &t,
- bool replica)
+ uint32_t fadvise_flags)
{
if (len > bl.length())
len = bl.length();
int KeyValueStore::_write(coll_t cid, const ghobject_t& oid,
uint64_t offset, size_t len, const bufferlist& bl,
- BufferTransaction &t, bool replica)
+ BufferTransaction &t, uint32_t fadvise_flags)
{
dout(15) << __func__ << " " << cid << "/" << oid << " " << offset << "~"
<< len << dendl;
return r;
}
- return _generic_write(header, offset, len, bl, t, replica);
+ return _generic_write(header, offset, len, bl, t, fadvise_flags);
}
int KeyValueStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset,
bool allow_eio = false, BufferTransaction *bt = 0);
int _generic_write(StripObjectMap::StripObjectHeaderRef header,
uint64_t offset, size_t len, const bufferlist& bl,
- BufferTransaction &t, bool replica = false);
+ BufferTransaction &t, uint32_t fadvise_flags = 0);
bool exists(coll_t cid, const ghobject_t& oid);
int stat(coll_t cid, const ghobject_t& oid, struct stat *st,
int _touch(coll_t cid, const ghobject_t& oid, BufferTransaction &t);
int _write(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len,
- const bufferlist& bl, BufferTransaction &t, bool replica = false);
+ const bufferlist& bl, BufferTransaction &t, uint32_t fadvise_flags = 0);
int _zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len,
BufferTransaction &t);
int _truncate(coll_t cid, const ghobject_t& oid, uint64_t size,
ghobject_t oid = i.decode_oid();
uint64_t off = i.decode_length();
uint64_t len = i.decode_length();
- bool replica = i.get_replica();
+ uint32_t fadvise_flags = i.get_fadvise_flags();
bufferlist bl;
i.decode_bl(bl);
- r = _write(cid, oid, off, len, bl, replica);
+ r = _write(cid, oid, off, len, bl, fadvise_flags);
}
break;
int MemStore::_write(coll_t cid, const ghobject_t& oid,
uint64_t offset, size_t len, const bufferlist& bl,
- bool replica)
+ uint32_t fadvise_flags)
{
dout(10) << __func__ << " " << cid << " " << oid << " "
<< offset << "~" << len << dendl;
void _write_into_bl(const bufferlist& src, unsigned offset, bufferlist *dst);
int _touch(coll_t cid, const ghobject_t& oid);
- int _write(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len, const bufferlist& bl,
- bool replica = false);
+ int _write(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len,
+ const bufferlist& bl, uint32_t fadvsie_flags = 0);
int _zero(coll_t cid, const ghobject_t& oid, uint64_t offset, size_t len);
int _truncate(coll_t cid, const ghobject_t& oid, uint64_t size);
int _remove(coll_t cid, const ghobject_t& oid);
bool sobject_encoding;
int64_t pool_override;
bool use_pool_override;
- bool replica;
+ uint32_t fadvise_flags; //record write flags
void *osr; // NULL on replay
list<Context *> on_applied;
void set_pool_override(int64_t pool) {
pool_override = pool;
}
- void set_replica() {
- replica = true;
+
+ void set_fadvise_flags(uint32_t flags) {
+ fadvise_flags = flags;
+ }
+
+ void set_fadvise_flag(uint32_t flag) {
+ fadvise_flags |= flag;
}
- bool get_replica() { return replica; }
+
+ uint32_t get_fadvise_flags() { return fadvise_flags; }
void swap(Transaction& other) {
std::swap(ops, other.ops);
std::swap(largest_data_len, other.largest_data_len);
std::swap(largest_data_off, other.largest_data_off);
std::swap(largest_data_off_in_tbl, other.largest_data_off_in_tbl);
+ std::swap(fadvise_flags, other.fadvise_flags);
std::swap(on_applied, other.on_applied);
std::swap(on_commit, other.on_commit);
std::swap(on_applied_sync, other.on_applied_sync);
/// How big is the encoded Transaction buffer?
uint64_t get_encoded_bytes() {
- return 1 + 8 + 8 + 4 + 4 + 4 + 4 + tbl.length();
+ return 1 + 8 + 8 + 4 + 4 + 4 + 4 + 4 + tbl.length();
}
uint64_t get_num_bytes() {
sizeof(largest_data_len) +
sizeof(largest_data_off) +
sizeof(largest_data_off_in_tbl) +
+ sizeof(fadvise_flags) +
sizeof(__u32); // tbl length
}
return 0; // none
bool sobject_encoding;
int64_t pool_override;
bool use_pool_override;
- bool replica;
+ uint32_t fadvise_flags;
iterator(Transaction *t)
: p(t->tbl.begin()),
sobject_encoding(t->sobject_encoding),
pool_override(t->pool_override),
use_pool_override(t->use_pool_override),
- replica(t->replica) {}
+ fadvise_flags(t->fadvise_flags) {}
friend class Transaction;
::decode(bits, p);
return bits;
}
- bool get_replica() { return replica; }
+
+ uint32_t get_fadvise_flags() { return fadvise_flags; }
};
iterator begin() {
* "hole" in the file.
*/
void write(coll_t cid, const ghobject_t& oid, uint64_t off, uint64_t len,
- const bufferlist& data) {
+ const bufferlist& data, uint32_t flags = 0) {
__u32 op = OP_WRITE;
::encode(op, tbl);
::encode(cid, tbl);
::encode(off, tbl);
::encode(len, tbl);
assert(len == data.length());
+ fadvise_flags |= flags;
if (data.length() > largest_data_len) {
largest_data_len = data.length();
largest_data_off = off;
Transaction() :
ops(0), pad_unused_bytes(0), largest_data_len(0), largest_data_off(0), largest_data_off_in_tbl(0),
sobject_encoding(false), pool_override(-1), use_pool_override(false),
- replica(false),
+ fadvise_flags(0),
osr(NULL) {}
Transaction(bufferlist::iterator &dp) :
ops(0), pad_unused_bytes(0), largest_data_len(0), largest_data_off(0), largest_data_off_in_tbl(0),
sobject_encoding(false), pool_override(-1), use_pool_override(false),
- replica(false),
+ fadvise_flags(0),
osr(NULL) {
decode(dp);
}
Transaction(bufferlist &nbl) :
ops(0), pad_unused_bytes(0), largest_data_len(0), largest_data_off(0), largest_data_off_in_tbl(0),
sobject_encoding(false), pool_override(-1), use_pool_override(false),
- replica(false),
+ fadvise_flags(0),
osr(NULL) {
bufferlist::iterator dp = nbl.begin();
decode(dp);
}
void encode(bufferlist& bl) const {
- ENCODE_START(7, 5, bl);
+ ENCODE_START(8, 5, bl);
::encode(ops, bl);
::encode(pad_unused_bytes, bl);
::encode(largest_data_len, bl);
bool tolerate_collection_add_enoent = 0;
::encode(tolerate_collection_add_enoent, bl);
}
+ ::encode(fadvise_flags, bl);
ENCODE_FINISH(bl);
}
void decode(bufferlist::iterator &bl) {
- DECODE_START_LEGACY_COMPAT_LEN(7, 5, 5, bl);
+ DECODE_START_LEGACY_COMPAT_LEN(8, 5, 5, bl);
DECODE_OLDEST(2);
if (struct_v < 4)
sobject_encoding = true;
bool tolerate_collection_add_enoent;
::decode(tolerate_collection_add_enoent, bl);
}
+ if (struct_v >= 8) {
+ ::decode(fadvise_flags, bl);
+ }
DECODE_FINISH(bl);
}
sinfo.logical_to_prev_chunk_offset(
offset),
enc_bl.length(),
- enc_bl);
+ enc_bl,
+ op.fadvise_flags);
i->second.setattr(
get_coll_ct(i->first, op.oid),
ghobject_t(op.oid, ghobject_t::NO_GEN, i->first),
uint32_t fadvise_flags
) {
written += len;
- t->write(get_coll_ct(hoid), hoid, off, len, bl);
+ t->write(get_coll_ct(hoid), hoid, off, len, bl, fadvise_flags);
}
void remove(
const hobject_t &hoid
}
rm->opt.set_pool_override(get_info().pgid.pool());
}
- rm->opt.set_replica();
-
+
+ rm->opt.set_fadvise_flag(CEPH_OSD_OP_FLAG_FADVISE_DONTNEED);
bool update_snaps = false;
if (!rm->opt.empty()) {
// If the opt is non-empty, we infer we are before
ghobject_t oid = i.decode_oid();
i.decode_length();
i.decode_length();
- i.get_replica();
+ i.get_fadvise_flags();
bufferlist bl;
i.decode_bl(bl);
}