auth_pin(this);
- int64_t pool;
- if (is_dir()) {
- pool = mdcache->mds->mdsmap->get_metadata_pool();
- } else {
- pool = inode.layout.pool_id;
- }
-
+ const int64_t pool = get_backtrace_pool();
inode_backtrace_t bt;
build_backtrace(pool, bt);
bufferlist parent_bl;
{
if (r < 0) {
dout(1) << "store backtrace error " << r << " v " << v << dendl;
- mdcache->mds->clog->error() << "failed to store backtrace on dir ino "
- << ino() << " object, errno " << r << "\n";
+ mdcache->mds->clog->error() << "failed to store backtrace on ino "
+ << ino() << " object"
+ << ", pool " << get_backtrace_pool()
+ << ", errno " << r << "\n";
mdcache->mds->handle_write_error(r);
return;
}
void CInode::fetch_backtrace(Context *fin, bufferlist *backtrace)
{
- int64_t pool;
- if (is_dir())
- pool = mdcache->mds->mdsmap->get_metadata_pool();
- else
- pool = inode.layout.pool_id;
-
- mdcache->fetch_backtrace(inode.ino, pool, *backtrace, fin);
+ mdcache->fetch_backtrace(inode.ino, get_backtrace_pool(), *backtrace, fin);
}
void CInode::_mark_dirty_parent(LogSegment *ls, bool dirty_pool)
void fetch_backtrace_and_tag(CInode *in, std::string tag,
Context *fin, int *bt_r, bufferlist *bt)
{
- int64_t pool;
- if (in->is_dir())
- pool = in->mdcache->mds->mdsmap->get_metadata_pool();
- else
- pool = in->inode.layout.pool_id;
-
+ const int64_t pool = in->get_backtrace_pool();
object_t oid = CInode::get_object_name(in->ino(), frag_t(), "");
ObjectOperation fetch;
results->performed_validation = true; // at least, some of it!
results->backtrace.checked = true;
- int64_t pool;
- if (in->is_dir())
- pool = in->mdcache->mds->mdsmap->get_metadata_pool();
- else
- pool = in->inode.layout.pool_id;
+ const int64_t pool = in->get_backtrace_pool();
inode_backtrace_t& memory_backtrace = results->backtrace.memory_value;
in->build_backtrace(pool, memory_backtrace);
bool equivalent, divergent;
clog->info() << "scrub complete with tag '" << scrub_infop->header->tag << "'";
}
}
+
+int64_t CInode::get_backtrace_pool() const
+{
+ if (is_dir()) {
+ return mdcache->mds->mdsmap->get_metadata_pool();
+ } else {
+ // Files are required to have an explicit layout that specifies
+ // a pool
+ assert(inode.layout.pool_id != -1);
+ return inode.layout.pool_id;
+ }
+}
void store_backtrace(MDSInternalContextBase *fin, int op_prio=-1);
void _stored_backtrace(int r, version_t v, Context *fin);
void fetch_backtrace(Context *fin, bufferlist *backtrace);
+protected:
+ /**
+ * Return the pool ID where we currently write backtraces for
+ * this inode (in addition to inode.old_pools)
+ *
+ * @returns a pool ID >=0
+ */
+ int64_t get_backtrace_pool() const;
+public:
void _mark_dirty_parent(LogSegment *ls, bool dirty_pool=false);
void clear_dirty_parent();
void verify_diri_backtrace(bufferlist &bl, int err);