mirror of
https://github.com/ceph/ceph
synced 2025-01-20 01:51:34 +00:00
Merge remote-tracking branch 'gh/jewel'
This commit is contained in:
commit
4b97cd7bf5
@ -235,9 +235,7 @@ void FSMap::decode(bufferlist::iterator& p)
|
||||
// Because the mon used to store an MDSMap where we now
|
||||
// store an FSMap, FSMap knows how to decode the legacy
|
||||
// MDSMap format (it never needs to encode it though).
|
||||
Filesystem legacy_fs;
|
||||
MDSMap &legacy_mds_map = legacy_fs.mds_map;
|
||||
bool enabled = false;
|
||||
MDSMap legacy_mds_map;
|
||||
|
||||
// The highest MDSMap encoding version before we changed the
|
||||
// MDSMonitor to store an FSMap instead of an MDSMap was
|
||||
@ -308,34 +306,61 @@ void FSMap::decode(bufferlist::iterator& p)
|
||||
|
||||
if (ev >= 8) {
|
||||
assert(struct_v >= 5);
|
||||
::decode(enabled, p);
|
||||
::decode(legacy_mds_map.enabled, p);
|
||||
::decode(legacy_mds_map.fs_name, p);
|
||||
} else {
|
||||
legacy_mds_map.fs_name = "default";
|
||||
if (epoch > 1) {
|
||||
// If an MDS has ever been started, epoch will be greater than 1,
|
||||
// assume filesystem is enabled.
|
||||
enabled = true;
|
||||
legacy_mds_map.enabled = true;
|
||||
} else {
|
||||
// Upgrading from a cluster that never used an MDS, switch off
|
||||
// filesystem until it's explicitly enabled.
|
||||
enabled = false;
|
||||
legacy_mds_map.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ev >= 9) {
|
||||
::decode(legacy_mds_map.damaged, p);
|
||||
}
|
||||
// We're upgrading, populate fs_list from the legacy fields
|
||||
assert(filesystems.empty());
|
||||
auto migrate_fs = std::make_shared<Filesystem>();
|
||||
|
||||
*migrate_fs = legacy_fs;
|
||||
migrate_fs->fscid = FS_CLUSTER_ID_ANONYMOUS;
|
||||
migrate_fs->mds_map.fs_name = "default";
|
||||
legacy_client_fscid = migrate_fs->fscid;
|
||||
filesystems[migrate_fs->fscid] = migrate_fs;
|
||||
compat = migrate_fs->mds_map.compat;
|
||||
// We're upgrading, populate filesystems from the legacy fields
|
||||
filesystems.clear();
|
||||
standby_daemons.clear();
|
||||
standby_epochs.clear();
|
||||
mds_roles.clear();
|
||||
compat = legacy_mds_map.compat;
|
||||
enable_multiple = false;
|
||||
|
||||
// Synthesise a Filesystem from legacy_mds_map, if enabled
|
||||
if (legacy_mds_map.enabled) {
|
||||
// Construct a Filesystem from the legacy MDSMap
|
||||
auto migrate_fs = std::make_shared<Filesystem>();
|
||||
migrate_fs->fscid = FS_CLUSTER_ID_ANONYMOUS;
|
||||
migrate_fs->mds_map = legacy_mds_map;
|
||||
migrate_fs->mds_map.epoch = epoch;
|
||||
filesystems[migrate_fs->fscid] = migrate_fs;
|
||||
|
||||
// Construct mds_roles, standby_daemons, and remove
|
||||
// standbys from the MDSMap in the Filesystem.
|
||||
for (const auto &p : migrate_fs->mds_map.mds_info) {
|
||||
if (p.second.rank == MDS_RANK_NONE) {
|
||||
standby_daemons[p.first] = p.second;
|
||||
standby_epochs[p.first] = epoch;
|
||||
mds_roles[p.first] = FS_CLUSTER_ID_NONE;
|
||||
} else {
|
||||
mds_roles[p.first] = migrate_fs->fscid;
|
||||
}
|
||||
}
|
||||
for (const auto &p : standby_daemons) {
|
||||
migrate_fs->mds_map.mds_info.erase(p.first);
|
||||
}
|
||||
|
||||
legacy_client_fscid = migrate_fs->fscid;
|
||||
} else {
|
||||
legacy_client_fscid = FS_CLUSTER_ID_NONE;
|
||||
}
|
||||
} else {
|
||||
::decode(epoch, p);
|
||||
::decode(next_filesystem_id, p);
|
||||
|
@ -128,15 +128,14 @@ void StrayManager::purge(CDentry *dn, uint32_t op_allowance)
|
||||
}
|
||||
|
||||
if (in->is_file()) {
|
||||
uint64_t period = in->inode.layout.get_period();
|
||||
uint64_t to = in->inode.get_max_size();
|
||||
to = MAX(in->inode.size, to);
|
||||
// when truncating a file, the filer does not delete stripe objects that are
|
||||
// truncated to zero. so we need to purge stripe objects up to the max size
|
||||
// the file has ever been.
|
||||
to = MAX(in->inode.max_size_ever, to);
|
||||
if (to && period) {
|
||||
uint64_t num = (to + period - 1) / period;
|
||||
if (to > 0) {
|
||||
uint64_t num = Striper::get_num_objects(in->inode.layout, to);
|
||||
dout(10) << __func__ << " 0~" << to << " objects 0~" << num
|
||||
<< " snapc " << snapc << " on " << *in << dendl;
|
||||
filer.purge_range(in->inode.ino, &in->inode.layout, *snapc,
|
||||
@ -437,11 +436,10 @@ uint32_t StrayManager::_calculate_ops_required(CInode *in, bool trunc)
|
||||
ops_required = 1 + ls.size();
|
||||
} else {
|
||||
// File, work out concurrent Filer::purge deletes
|
||||
const uint64_t period = in->inode.layout.get_period();
|
||||
const uint64_t to = MAX(in->inode.max_size_ever,
|
||||
MAX(in->inode.size, in->inode.get_max_size()));
|
||||
|
||||
const uint64_t num = MAX(1, (to + period - 1) / period);
|
||||
const uint64_t num = (to > 0) ? Striper::get_num_objects(in->inode.layout, to) : 1;
|
||||
ops_required = MIN(num, g_conf->filer_max_purge_ops);
|
||||
|
||||
// Account for removing (or zeroing) backtrace
|
||||
@ -805,26 +803,26 @@ void StrayManager::truncate(CDentry *dn, uint32_t op_allowance)
|
||||
dout(10) << " realm " << *realm << dendl;
|
||||
const SnapContext *snapc = &realm->get_snap_context();
|
||||
|
||||
uint64_t period = in->inode.layout.get_period();
|
||||
uint64_t to = in->inode.get_max_size();
|
||||
to = MAX(in->inode.size, to);
|
||||
// when truncating a file, the filer does not delete stripe objects that are
|
||||
// truncated to zero. so we need to purge stripe objects up to the max size
|
||||
// the file has ever been.
|
||||
to = MAX(in->inode.max_size_ever, to);
|
||||
if (period && to > period) {
|
||||
uint64_t num = (to - 1) / period;
|
||||
if (to > 0) {
|
||||
uint64_t num = Striper::get_num_objects(in->inode.layout, to);
|
||||
dout(10) << __func__ << " 0~" << to << " objects 0~" << num
|
||||
<< " snapc " << snapc << " on " << *in << dendl;
|
||||
filer.purge_range(in->ino(), &in->inode.layout, *snapc,
|
||||
1, num, ceph::real_clock::now(g_ceph_context),
|
||||
0, gather.new_sub());
|
||||
}
|
||||
<< " snapc " << snapc << " on " << *in << dendl;
|
||||
|
||||
// keep backtrace object
|
||||
if (period && to > 0) {
|
||||
// keep backtrace object
|
||||
if (num > 1) {
|
||||
filer.purge_range(in->ino(), &in->inode.layout, *snapc,
|
||||
1, num - 1, ceph::real_clock::now(g_ceph_context),
|
||||
0, gather.new_sub());
|
||||
}
|
||||
filer.zero(in->ino(), &in->inode.layout, *snapc,
|
||||
0, period, ceph::real_clock::now(g_ceph_context),
|
||||
0, in->inode.layout.object_size,
|
||||
ceph::real_clock::now(g_ceph_context),
|
||||
0, true, NULL, gather.new_sub());
|
||||
}
|
||||
|
||||
|
@ -1568,14 +1568,6 @@ int MDSMonitor::management_command(
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (pending_fsmap.any_filesystems()
|
||||
&& !pending_fsmap.get_enable_multiple()) {
|
||||
ss << "Creation of multiple filesystems is disabled. To enable "
|
||||
"this experimental feature, use 'ceph fs flag set enable_multiple "
|
||||
"true'";
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (pending_fsmap.get_filesystem(fs_name)) {
|
||||
auto fs = pending_fsmap.get_filesystem(fs_name);
|
||||
if (*(fs->mds_map.data_pools.begin()) == data
|
||||
@ -1589,6 +1581,14 @@ int MDSMonitor::management_command(
|
||||
}
|
||||
}
|
||||
|
||||
if (pending_fsmap.any_filesystems()
|
||||
&& !pending_fsmap.get_enable_multiple()) {
|
||||
ss << "Creation of multiple filesystems is disabled. To enable "
|
||||
"this experimental feature, use 'ceph fs flag set enable_multiple "
|
||||
"true'";
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
pg_pool_t const *data_pool = mon->osdmon()->osdmap.get_pg_pool(data);
|
||||
assert(data_pool != NULL); // Checked it existed above
|
||||
pg_pool_t const *metadata_pool = mon->osdmon()->osdmap.get_pg_pool(metadata);
|
||||
|
@ -177,6 +177,38 @@ int DataScan::main(const std::vector<const char*> &args)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (command == "tmap_upgrade") {
|
||||
// Special case tmap_upgrade away from other modes, as this is a
|
||||
// specialized command that will only exist in the Jewel series,
|
||||
// and doesn't require the initialization of the `driver` member
|
||||
// that is done below.
|
||||
rados.connect();
|
||||
|
||||
// Initialize metadata_io from pool on command line
|
||||
if (metadata_pool_name.empty()) {
|
||||
std::cerr << "Metadata pool not specified" << std::endl;
|
||||
usage();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
long metadata_pool_id = rados.pool_lookup(metadata_pool_name.c_str());
|
||||
if (metadata_pool_id < 0) {
|
||||
std::cerr << "Pool '" << metadata_pool_name << "' not found!" << std::endl;
|
||||
return -ENOENT;
|
||||
} else {
|
||||
dout(4) << "pool '" << metadata_pool_name
|
||||
<< "' has ID " << metadata_pool_id << dendl;
|
||||
}
|
||||
|
||||
r = rados.ioctx_create(metadata_pool_name.c_str(), metadata_io);
|
||||
if (r != 0) {
|
||||
return r;
|
||||
}
|
||||
std::cerr << "Created ioctx for " << metadata_pool_name << std::endl;
|
||||
|
||||
return tmap_upgrade();
|
||||
}
|
||||
|
||||
// If caller didn't specify a namespace, try to pick
|
||||
// one if only one exists
|
||||
if (fscid == FS_CLUSTER_ID_NONE) {
|
||||
@ -263,30 +295,6 @@ int DataScan::main(const std::vector<const char*> &args)
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize metadata_io from pool on command line for tmap_upgrade
|
||||
if (command == "tmap_upgrade") {
|
||||
if (metadata_pool_name.empty()) {
|
||||
std::cerr << "Metadata pool not specified" << std::endl;
|
||||
usage();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
long metadata_pool_id = rados.pool_lookup(metadata_pool_name.c_str());
|
||||
if (metadata_pool_id < 0) {
|
||||
std::cerr << "Pool '" << metadata_pool_name << "' not found!" << std::endl;
|
||||
return -ENOENT;
|
||||
} else {
|
||||
dout(4) << "pool '" << metadata_pool_name
|
||||
<< "' has ID " << metadata_pool_id << dendl;
|
||||
}
|
||||
|
||||
r = rados.ioctx_create(metadata_pool_name.c_str(), metadata_io);
|
||||
if (r != 0) {
|
||||
return r;
|
||||
}
|
||||
std::cerr << "Created ioctx for " << metadata_pool_name << std::endl;
|
||||
}
|
||||
|
||||
// Finally, dispatch command
|
||||
if (command == "scan_inodes") {
|
||||
return scan_inodes();
|
||||
@ -294,8 +302,6 @@ int DataScan::main(const std::vector<const char*> &args)
|
||||
return scan_extents();
|
||||
} else if (command == "scan_frags") {
|
||||
return scan_frags();
|
||||
} else if (command == "tmap_upgrade") {
|
||||
return tmap_upgrade();
|
||||
} else if (command == "init") {
|
||||
return driver->init_roots(fs->mds_map.get_first_data_pool());
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user