From 99f1f6478d7851d7b51da3b79e0207a3bb2bce86 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 4 Jan 2016 10:44:53 -0500 Subject: [PATCH] struct ceph_file_layout -> file_layout_t - drop the global - do not memset! - encode with features - field names are different - use get_period() method where appropriate - fix is layout empty checks Signed-off-by: Sage Weil --- src/client/Client.cc | 84 ++++++++-------- src/client/Client.h | 14 +-- src/client/Inode.cc | 4 +- src/client/Inode.h | 7 +- src/client/fuse_ll.cc | 10 +- src/cls/cephfs/cls_cephfs_client.cc | 2 +- src/cls/cephfs/cls_cephfs_client.h | 2 +- src/common/config.cc | 11 --- src/common/config.h | 2 - src/common/config_opts.h | 3 +- src/include/fs_types.h | 2 + src/libcephfs.cc | 93 ++++++++++-------- src/libradosstriper/RadosStriperImpl.cc | 29 ++++-- src/librbd/AioImageRequest.cc | 4 +- src/librbd/AioObjectRequest.cc | 2 +- src/librbd/ImageCtx.cc | 13 ++- src/librbd/ImageCtx.h | 2 +- src/librbd/LibrbdWriteback.cc | 2 +- src/librbd/internal.cc | 14 +-- src/mds/CInode.cc | 22 ++--- src/mds/Locker.cc | 2 +- src/mds/Locker.h | 2 +- src/mds/MDCache.cc | 33 +++---- src/mds/MDCache.h | 8 +- src/mds/MDLog.cc | 2 +- src/mds/Server.cc | 125 +++++++++++------------- src/mds/Server.h | 10 +- src/mds/StrayManager.cc | 11 +-- src/mds/mdstypes.cc | 10 +- src/mds/mdstypes.h | 33 +------ src/messages/MClientCaps.h | 8 +- src/messages/MClientReply.h | 2 +- src/osd/OSDMap.h | 14 +-- src/osdc/Filer.cc | 18 ++-- src/osdc/Filer.h | 34 +++---- src/osdc/Journaler.cc | 18 ++-- src/osdc/Journaler.h | 30 ++---- src/osdc/ObjectCacher.h | 8 +- src/osdc/Striper.cc | 35 +++---- src/osdc/Striper.h | 12 +-- src/test/encoding/types.h | 1 - src/test/librbd/mock/MockImageCtx.h | 2 +- src/test/test_striper.cc | 27 +++-- src/tools/cephfs/DataScan.cc | 84 ++++++++-------- src/tools/cephfs/DataScan.h | 4 +- src/tools/cephfs/Dumper.cc | 8 +- src/tools/cephfs/JournalScanner.cc | 2 +- src/tools/cephfs/JournalTool.cc | 2 +- src/tools/cephfs/Resetter.cc | 2 +- src/tools/psim.cc | 1 - 50 files changed, 400 insertions(+), 470 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 03049d028df2c..2171f913a63c1 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2287,7 +2287,7 @@ void Client::_handle_full_flag(int64_t pool) { Inode *inode = i->second; if (inode->oset.dirty_or_tx - && (pool == -1 || inode->layout.fl_pg_pool == pool)) { + && (pool == -1 || inode->layout.pool_id == pool)) { ldout(cct, 4) << __func__ << ": FULL: inode 0x" << std::hex << i->first << std::dec << " has dirty objects, purging and setting ENOSPC" << dendl; objectcacher->purge_set(&inode->oset); @@ -3542,7 +3542,7 @@ bool Client::_flush(Inode *in, Context *onfinish) return true; } - if (objecter->osdmap_pool_full(in->layout.fl_pg_pool)) { + if (objecter->osdmap_pool_full(in->layout.pool_id)) { ldout(cct, 1) << __func__ << ": FULL, purging for ENOSPC" << dendl; objectcacher->purge_set(&in->oset); if (onfinish) { @@ -6479,7 +6479,7 @@ int Client::fill_stat(Inode *in, struct stat *st, frag_info_t *dirstat, nest_inf st->st_size = in->size; st->st_blocks = (in->size + 511) >> 9; } - st->st_blksize = MAX(in->layout.fl_stripe_unit, 4096); + st->st_blksize = MAX(in->layout.stripe_unit, 4096); if (dirstat) *dirstat = in->dirstat; @@ -7545,7 +7545,7 @@ Fh *Client::_create_fh(Inode *in, int flags, int cmode) } const md_config_t *conf = cct->_conf; - loff_t p = in->layout.fl_stripe_count * in->layout.fl_object_size; + loff_t p = in->layout.stripe_count * in->layout.object_size; f->readahead.set_trigger_requests(1); f->readahead.set_min_readahead_size(conf->client_readahead_min); uint64_t max_readahead = Readahead::NO_LIMIT; @@ -7558,7 +7558,7 @@ Fh *Client::_create_fh(Inode *in, int flags, int cmode) f->readahead.set_max_readahead_size(max_readahead); vector alignments; alignments.push_back(p); - alignments.push_back(in->layout.fl_stripe_unit); + alignments.push_back(in->layout.stripe_unit); f->readahead.set_alignments(alignments); return f; @@ -8218,7 +8218,7 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, //ldout(cct, 7) << "write fh " << fh << " size " << size << " offset " << offset << dendl; Inode *in = f->inode.get(); - if (objecter->osdmap_pool_full(in->layout.fl_pg_pool)) { + if (objecter->osdmap_pool_full(in->layout.pool_id)) { return -ENOSPC; } @@ -9971,50 +9971,46 @@ size_t Client::_vxattrcb_quota_max_files(Inode *in, char *val, size_t size) bool Client::_vxattrcb_layout_exists(Inode *in) { - char *p = (char *)&in->layout; - for (size_t s = 0; s < sizeof(in->layout); s++, p++) - if (*p) - return true; - return false; + return in->layout != file_layout_t(); } size_t Client::_vxattrcb_layout(Inode *in, char *val, size_t size) { int r = snprintf(val, size, "stripe_unit=%lld stripe_count=%lld object_size=%lld pool=", - (unsigned long long)in->layout.fl_stripe_unit, - (unsigned long long)in->layout.fl_stripe_count, - (unsigned long long)in->layout.fl_object_size); + (unsigned long long)in->layout.stripe_unit, + (unsigned long long)in->layout.stripe_count, + (unsigned long long)in->layout.object_size); objecter->with_osdmap([&](const OSDMap& o) { - if (o.have_pg_pool(in->layout.fl_pg_pool)) + if (o.have_pg_pool(in->layout.pool_id)) r += snprintf(val + r, size - r, "%s", - o.get_pool_name(in->layout.fl_pg_pool).c_str()); + o.get_pool_name(in->layout.pool_id).c_str()); else r += snprintf(val + r, size - r, "%" PRIu64, - (uint64_t)in->layout.fl_pg_pool); + (uint64_t)in->layout.pool_id); }); return r; } size_t Client::_vxattrcb_layout_stripe_unit(Inode *in, char *val, size_t size) { - return snprintf(val, size, "%lld", (unsigned long long)in->layout.fl_stripe_unit); + return snprintf(val, size, "%lld", (unsigned long long)in->layout.stripe_unit); } size_t Client::_vxattrcb_layout_stripe_count(Inode *in, char *val, size_t size) { - return snprintf(val, size, "%lld", (unsigned long long)in->layout.fl_stripe_count); + return snprintf(val, size, "%lld", (unsigned long long)in->layout.stripe_count); } size_t Client::_vxattrcb_layout_object_size(Inode *in, char *val, size_t size) { - return snprintf(val, size, "%lld", (unsigned long long)in->layout.fl_object_size); + return snprintf(val, size, "%lld", (unsigned long long)in->layout.object_size); } size_t Client::_vxattrcb_layout_pool(Inode *in, char *val, size_t size) { size_t r; objecter->with_osdmap([&](const OSDMap& o) { - if (o.have_pg_pool(in->layout.fl_pg_pool)) + if (o.have_pg_pool(in->layout.pool_id)) r = snprintf(val, size, "%s", o.get_pool_name( - in->layout.fl_pg_pool).c_str()); + in->layout.pool_id).c_str()); else - r = snprintf(val, size, "%" PRIu64, (uint64_t)in->layout.fl_pg_pool); + r = snprintf(val, size, "%" PRIu64, (uint64_t)in->layout.pool_id); }); return r; } @@ -10884,7 +10880,7 @@ int Client::ll_osdaddr(int osd, uint32_t *addr) uint32_t Client::ll_stripe_unit(Inode *in) { Mutex::Locker lock(client_lock); - return in->layout.fl_stripe_unit; + return in->layout.stripe_unit; } uint64_t Client::ll_snap_seq(Inode *in) @@ -10893,14 +10889,14 @@ uint64_t Client::ll_snap_seq(Inode *in) return in->snaprealm->seq; } -int Client::ll_file_layout(Inode *in, ceph_file_layout *layout) +int Client::ll_file_layout(Inode *in, file_layout_t *layout) { Mutex::Locker lock(client_lock); *layout = in->layout; return 0; } -int Client::ll_file_layout(Fh *fh, ceph_file_layout *layout) +int Client::ll_file_layout(Fh *fh, file_layout_t *layout) { return ll_file_layout(fh->inode.get(), layout); } @@ -10913,13 +10909,13 @@ int Client::ll_file_layout(Fh *fh, ceph_file_layout *layout) tractable and works for demonstration purposes. */ int Client::ll_get_stripe_osd(Inode *in, uint64_t blockno, - ceph_file_layout* layout) + file_layout_t* layout) { Mutex::Locker lock(client_lock); inodeno_t ino = ll_get_inodeno(in); - uint32_t object_size = layout->fl_object_size; - uint32_t su = layout->fl_stripe_unit; - uint32_t stripe_count = layout->fl_stripe_count; + uint32_t object_size = layout->object_size; + uint32_t su = layout->stripe_unit; + uint32_t stripe_count = layout->stripe_count; uint64_t stripes_per_object = object_size / su; uint64_t stripeno = blockno / stripe_count; // which horizontal stripe (Y) @@ -10930,7 +10926,7 @@ int Client::ll_get_stripe_osd(Inode *in, uint64_t blockno, object_t oid = file_object_t(ino, objectno); return objecter->with_osdmap([&](const OSDMap& o) { ceph_object_layout olayout = - o.file_to_object_layout(oid, *layout, string()); + o.file_to_object_layout(oid, *layout); pg_t pg = (pg_t)olayout.ol_pgid; vector osds; int primary; @@ -10944,9 +10940,9 @@ int Client::ll_get_stripe_osd(Inode *in, uint64_t blockno, uint64_t Client::ll_get_internal_offset(Inode *in, uint64_t blockno) { Mutex::Locker lock(client_lock); - ceph_file_layout *layout=&(in->layout); - uint32_t object_size = layout->fl_object_size; - uint32_t su = layout->fl_stripe_unit; + file_layout_t *layout=&(in->layout); + uint32_t object_size = layout->object_size; + uint32_t su = layout->stripe_unit; uint64_t stripes_per_object = object_size / su; return (blockno % stripes_per_object) * su; @@ -11144,7 +11140,7 @@ int Client::ll_read_block(Inode *in, uint64_t blockid, char *buf, uint64_t offset, uint64_t length, - ceph_file_layout* layout) + file_layout_t* layout) { Mutex::Locker lock(client_lock); Mutex flock("Client::ll_read_block flock"); @@ -11157,7 +11153,7 @@ int Client::ll_read_block(Inode *in, uint64_t blockid, bufferlist bl; objecter->read(oid, - object_locator_t(layout->fl_pg_pool), + object_locator_t(layout->pool_id), offset, length, vino.snapid, @@ -11181,7 +11177,7 @@ int Client::ll_read_block(Inode *in, uint64_t blockid, int Client::ll_write_block(Inode *in, uint64_t blockid, char* buf, uint64_t offset, - uint64_t length, ceph_file_layout* layout, + uint64_t length, file_layout_t* layout, uint64_t snapseq, uint32_t sync) { Mutex flock("Client::ll_write_block flock"); @@ -11226,7 +11222,7 @@ int Client::ll_write_block(Inode *in, uint64_t blockid, client_lock.Lock(); objecter->write(oid, - object_locator_t(layout->fl_pg_pool), + object_locator_t(layout->pool_id), offset, length, fakesnap, @@ -11328,8 +11324,8 @@ int Client::_fallocate(Fh *fh, int mode, int64_t offset, int64_t length) Inode *in = fh->inode.get(); - if (objecter->osdmap_pool_full(in->layout.fl_pg_pool) - && !(mode & FALLOC_FL_PUNCH_HOLE)) { + if (objecter->osdmap_pool_full(in->layout.pool_id) && + !(mode & FALLOC_FL_PUNCH_HOLE)) { return -ENOSPC; } @@ -11559,7 +11555,7 @@ void Client::ll_interrupt(void *d) // expose file layouts -int Client::describe_layout(const char *relpath, ceph_file_layout *lp) +int Client::describe_layout(const char *relpath, file_layout_t *lp) { Mutex::Locker lock(client_lock); @@ -11575,7 +11571,7 @@ int Client::describe_layout(const char *relpath, ceph_file_layout *lp) return 0; } -int Client::fdescribe_layout(int fd, ceph_file_layout *lp) +int Client::fdescribe_layout(int fd, file_layout_t *lp) { Mutex::Locker lock(client_lock); @@ -11652,7 +11648,7 @@ int Client::get_file_extent_osds(int fd, loff_t off, loff_t *len, vector& o * remainder. */ if (len) { - uint64_t su = in->layout.fl_stripe_unit; + uint64_t su = in->layout.stripe_unit; *len = su - (off % su); } @@ -11983,7 +11979,7 @@ int Client::check_pool_perm(Inode *in, int need) if (!cct->_conf->client_check_pool_perm) return 0; - int64_t pool = in->layout.fl_pg_pool; + int64_t pool = in->layout.pool_id; int have = 0; while (true) { std::map::iterator it = pool_perms.find(pool); diff --git a/src/client/Client.h b/src/client/Client.h index ccee4862016d7..34fc602e918df 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -994,8 +994,8 @@ public: int lazyio_synchronize(int fd, loff_t offset, size_t count); // expose file layout - int describe_layout(const char *path, ceph_file_layout* layout); - int fdescribe_layout(int fd, ceph_file_layout* layout); + int describe_layout(const char *path, file_layout_t* layout); + int fdescribe_layout(int fd, file_layout_t* layout); int get_file_stripe_address(int fd, loff_t offset, vector& address); int get_file_extent_osds(int fd, loff_t off, loff_t *len, vector& osds); int get_osd_addr(int osd, entity_addr_t& addr); @@ -1064,11 +1064,11 @@ public: struct stat *attr, Inode **out, Fh **fhp, int uid = -1, int gid = -1); int ll_read_block(Inode *in, uint64_t blockid, char *buf, uint64_t offset, - uint64_t length, ceph_file_layout* layout); + uint64_t length, file_layout_t* layout); int ll_write_block(Inode *in, uint64_t blockid, char* buf, uint64_t offset, - uint64_t length, ceph_file_layout* layout, + uint64_t length, file_layout_t* layout, uint64_t snapseq, uint32_t sync); int ll_commit_blocks(Inode *in, uint64_t offset, uint64_t length); @@ -1077,7 +1077,7 @@ public: int ll_listxattr_chunks(Inode *in, char *names, size_t size, int *cookie, int *eol, int uid, int gid); uint32_t ll_stripe_unit(Inode *in); - int ll_file_layout(Inode *in, ceph_file_layout *layout); + int ll_file_layout(Inode *in, file_layout_t *layout); uint64_t ll_snap_seq(Inode *in); int ll_read(Fh *fh, loff_t off, loff_t len, bufferlist *bl); @@ -1090,14 +1090,14 @@ public: int ll_getlk(Fh *fh, struct flock *fl, uint64_t owner); int ll_setlk(Fh *fh, struct flock *fl, uint64_t owner, int sleep); int ll_flock(Fh *fh, int cmd, uint64_t owner); - int ll_file_layout(Fh *fh, ceph_file_layout *layout); + int ll_file_layout(Fh *fh, file_layout_t *layout); void ll_interrupt(void *d); bool ll_handle_umask() { return acl_type != NO_ACL; } int ll_get_stripe_osd(struct Inode *in, uint64_t blockno, - ceph_file_layout* layout); + file_layout_t* layout); uint64_t ll_get_internal_offset(struct Inode *in, uint64_t blockno); int ll_num_osds(void); diff --git a/src/client/Inode.cc b/src/client/Inode.cc index 14ff341e0d09c..51c9d6299018c 100644 --- a/src/client/Inode.cc +++ b/src/client/Inode.cc @@ -329,9 +329,7 @@ void Inode::dump(Formatter *f) const f->dump_stream("atime") << atime; f->dump_int("time_warp_seq", time_warp_seq); - f->open_object_section("layout"); - ::dump(layout, f); - f->close_section(); + f->dump_object("layout", layout); if (is_dir()) { f->open_object_section("dir_layout"); ::dump(dir_layout, f); diff --git a/src/client/Inode.h b/src/client/Inode.h index dd2ad995e83eb..928aaee88187d 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -177,7 +177,7 @@ struct Inode { // file (data access) ceph_dir_layout dir_layout; - ceph_file_layout layout; + file_layout_t layout; uint64_t size; // on directory, # dentries uint32_t truncate_seq; uint64_t truncate_size; @@ -298,7 +298,7 @@ struct Inode { xlist unsafe_ops; - Inode(Client *c, vinodeno_t vino, ceph_file_layout *newlayout) + Inode(Client *c, vinodeno_t vino, file_layout_t *newlayout) : client(c), ino(vino.ino), snapid(vino.snapid), faked_ino(0), rdev(0), mode(0), uid(0), gid(0), nlink(0), size(0), truncate_seq(1), truncate_size(-1), @@ -312,14 +312,13 @@ struct Inode { snap_caps(0), snap_cap_refs(0), cap_item(this), flushing_cap_item(this), snaprealm(0), snaprealm_item(this), - oset((void *)this, newlayout->fl_pg_pool, ino), + oset((void *)this, newlayout->pool_id, ino), reported_size(0), wanted_max_size(0), requested_max_size(0), _ref(0), ll_ref(0), dir(0), dn_set(), fcntl_locks(NULL), flock_locks(NULL), async_err(0) { memset(&dir_layout, 0, sizeof(dir_layout)); - memset(&layout, 0, sizeof(layout)); memset("a, 0, sizeof(quota)); } ~Inode() { } diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index bc55ffdf8226f..793cc4d1ab990 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -507,14 +507,14 @@ static void fuse_ll_ioctl(fuse_req_t req, fuse_ino_t ino, int cmd, void *arg, st switch(cmd) { case CEPH_IOC_GET_LAYOUT: { - struct ceph_file_layout layout; + file_layout_t layout; struct ceph_ioctl_layout l; Fh *fh = (Fh*)fi->fh; cfuse->client->ll_file_layout(fh, &layout); - l.stripe_unit = layout.fl_stripe_unit; - l.stripe_count = layout.fl_stripe_count; - l.object_size = layout.fl_object_size; - l.data_pool = layout.fl_pg_pool; + l.stripe_unit = layout.stripe_unit; + l.stripe_count = layout.stripe_count; + l.object_size = layout.object_size; + l.data_pool = layout.pool_id; fuse_reply_ioctl(req, 0, &l, sizeof(struct ceph_ioctl_layout)); } break; diff --git a/src/cls/cephfs/cls_cephfs_client.cc b/src/cls/cephfs/cls_cephfs_client.cc index dc945282b9074..9bc97aeb055fb 100644 --- a/src/cls/cephfs/cls_cephfs_client.cc +++ b/src/cls/cephfs/cls_cephfs_client.cc @@ -54,7 +54,7 @@ int ClsCephFSClient::fetch_inode_accumulate_result( librados::IoCtx &ctx, const std::string &oid, inode_backtrace_t *backtrace, - ceph_file_layout *layout, + file_layout_t *layout, AccumulateResult *result) { assert(backtrace != NULL); diff --git a/src/cls/cephfs/cls_cephfs_client.h b/src/cls/cephfs/cls_cephfs_client.h index ddd84566d067f..51d12231230eb 100644 --- a/src/cls/cephfs/cls_cephfs_client.h +++ b/src/cls/cephfs/cls_cephfs_client.h @@ -20,7 +20,7 @@ class ClsCephFSClient librados::IoCtx &ctx, const std::string &oid, inode_backtrace_t *backtrace, - ceph_file_layout *layout, + file_layout_t *layout, AccumulateResult *result); static void build_tag_filter( diff --git a/src/common/config.cc b/src/common/config.cc index 28067b0607df1..562582b11e8d5 100644 --- a/src/common/config.cc +++ b/src/common/config.cc @@ -58,17 +58,6 @@ using std::string; const char *CEPH_CONF_FILE_DEFAULT = "$data_dir/config, /etc/ceph/$cluster.conf, ~/.ceph/$cluster.conf, $cluster.conf"; -// file layouts -struct ceph_file_layout g_default_file_layout = { - fl_stripe_unit: init_le32(1<<22), - fl_stripe_count: init_le32(1), - fl_object_size: init_le32(1<<22), - fl_cas_hash: init_le32(0), - fl_object_stripe_unit: init_le32(0), - fl_unused: init_le32(-1), - fl_pg_pool : init_le32(-1), -}; - #define _STR(x) #x #define STRINGIFY(x) _STR(x) diff --git a/src/common/config.h b/src/common/config.h index 79c443786cf84..7663c8f54696d 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -15,8 +15,6 @@ #ifndef CEPH_CONFIG_H #define CEPH_CONFIG_H -extern struct ceph_file_layout g_default_file_layout; - #include #include #include diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 03d4c6abf0084..9681762dfac4a 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -454,8 +454,7 @@ OPTION(mds_log_pause, OPT_BOOL, false) OPTION(mds_log_skip_corrupt_events, OPT_BOOL, false) OPTION(mds_log_max_events, OPT_INT, -1) OPTION(mds_log_events_per_segment, OPT_INT, 1024) -OPTION(mds_log_segment_size, OPT_INT, 0) // segment size for mds log, - // defaults to g_default_file_layout.fl_object_size (4MB) +OPTION(mds_log_segment_size, OPT_INT, 0) // segment size for mds log, default to default file_layout_t OPTION(mds_log_max_segments, OPT_U32, 30) OPTION(mds_log_max_expiring, OPT_INT, 20) OPTION(mds_bal_sample_interval, OPT_FLOAT, 3.0) // every 5 seconds diff --git a/src/include/fs_types.h b/src/include/fs_types.h index bc5ef20403231..388508b1d5e82 100644 --- a/src/include/fs_types.h +++ b/src/include/fs_types.h @@ -101,4 +101,6 @@ struct file_layout_t { }; WRITE_CLASS_ENCODER_FEATURES(file_layout_t) +WRITE_EQ_OPERATORS_5(file_layout_t, stripe_unit, stripe_count, object_size, pool_id, pool_ns); + #endif diff --git a/src/libcephfs.cc b/src/libcephfs.cc index 400669abbaa88..5ad03a980050b 100644 --- a/src/libcephfs.cc +++ b/src/libcephfs.cc @@ -880,7 +880,7 @@ extern "C" int ceph_sync_fs(struct ceph_mount_info *cmount) extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -888,12 +888,12 @@ extern "C" int ceph_get_file_stripe_unit(struct ceph_mount_info *cmount, int fh) r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; - return l.fl_stripe_unit; + return l.stripe_unit; } extern "C" int ceph_get_path_stripe_unit(struct ceph_mount_info *cmount, const char *path) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -901,12 +901,12 @@ extern "C" int ceph_get_path_stripe_unit(struct ceph_mount_info *cmount, const c r = cmount->get_client()->describe_layout(path, &l); if (r < 0) return r; - return l.fl_stripe_unit; + return l.stripe_unit; } extern "C" int ceph_get_file_stripe_count(struct ceph_mount_info *cmount, int fh) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -914,12 +914,12 @@ extern "C" int ceph_get_file_stripe_count(struct ceph_mount_info *cmount, int fh r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; - return l.fl_stripe_count; + return l.stripe_count; } extern "C" int ceph_get_path_stripe_count(struct ceph_mount_info *cmount, const char *path) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -927,12 +927,12 @@ extern "C" int ceph_get_path_stripe_count(struct ceph_mount_info *cmount, const r = cmount->get_client()->describe_layout(path, &l); if (r < 0) return r; - return l.fl_stripe_count; + return l.stripe_count; } extern "C" int ceph_get_file_object_size(struct ceph_mount_info *cmount, int fh) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -940,12 +940,12 @@ extern "C" int ceph_get_file_object_size(struct ceph_mount_info *cmount, int fh) r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; - return l.fl_object_size; + return l.object_size; } extern "C" int ceph_get_path_object_size(struct ceph_mount_info *cmount, const char *path) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -953,12 +953,12 @@ extern "C" int ceph_get_path_object_size(struct ceph_mount_info *cmount, const c r = cmount->get_client()->describe_layout(path, &l); if (r < 0) return r; - return l.fl_object_size; + return l.object_size; } extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -966,12 +966,12 @@ extern "C" int ceph_get_file_pool(struct ceph_mount_info *cmount, int fh) r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; - return l.fl_pg_pool; + return l.pool_id; } extern "C" int ceph_get_path_pool(struct ceph_mount_info *cmount, const char *path) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -979,12 +979,12 @@ extern "C" int ceph_get_path_pool(struct ceph_mount_info *cmount, const char *pa r = cmount->get_client()->describe_layout(path, &l); if (r < 0) return r; - return l.fl_pg_pool; + return l.pool_id; } extern "C" int ceph_get_file_pool_name(struct ceph_mount_info *cmount, int fh, char *buf, size_t len) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -992,7 +992,7 @@ extern "C" int ceph_get_file_pool_name(struct ceph_mount_info *cmount, int fh, c r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; - string name = cmount->get_client()->get_pool_name(l.fl_pg_pool); + string name = cmount->get_client()->get_pool_name(l.pool_id); if (len == 0) return name.length(); if (name.length() > len) @@ -1016,7 +1016,7 @@ extern "C" int ceph_get_pool_name(struct ceph_mount_info *cmount, int pool, char extern "C" int ceph_get_path_pool_name(struct ceph_mount_info *cmount, const char *path, char *buf, size_t len) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -1024,7 +1024,7 @@ extern "C" int ceph_get_path_pool_name(struct ceph_mount_info *cmount, const cha r = cmount->get_client()->describe_layout(path, &l); if (r < 0) return r; - string name = cmount->get_client()->get_pool_name(l.fl_pg_pool); + string name = cmount->get_client()->get_pool_name(l.pool_id); if (len == 0) return name.length(); if (name.length() > len) @@ -1035,7 +1035,7 @@ extern "C" int ceph_get_path_pool_name(struct ceph_mount_info *cmount, const cha extern "C" int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -1044,19 +1044,19 @@ extern "C" int ceph_get_file_layout(struct ceph_mount_info *cmount, int fh, int if (r < 0) return r; if (stripe_unit) - *stripe_unit = l.fl_stripe_unit; + *stripe_unit = l.stripe_unit; if (stripe_count) - *stripe_count = l.fl_stripe_count; + *stripe_count = l.stripe_count; if (object_size) - *object_size = l.fl_object_size; + *object_size = l.object_size; if (pg_pool) - *pg_pool = l.fl_pg_pool; + *pg_pool = l.pool_id; return 0; } extern "C" int ceph_get_path_layout(struct ceph_mount_info *cmount, const char *path, int *stripe_unit, int *stripe_count, int *object_size, int *pg_pool) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -1065,19 +1065,19 @@ extern "C" int ceph_get_path_layout(struct ceph_mount_info *cmount, const char * if (r < 0) return r; if (stripe_unit) - *stripe_unit = l.fl_stripe_unit; + *stripe_unit = l.stripe_unit; if (stripe_count) - *stripe_count = l.fl_stripe_count; + *stripe_count = l.stripe_count; if (object_size) - *object_size = l.fl_object_size; + *object_size = l.object_size; if (pg_pool) - *pg_pool = l.fl_pg_pool; + *pg_pool = l.pool_id; return 0; } extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -1085,13 +1085,13 @@ extern "C" int ceph_get_file_replication(struct ceph_mount_info *cmount, int fh) r = cmount->get_client()->fdescribe_layout(fh, &l); if (r < 0) return r; - int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool); + int rep = cmount->get_client()->get_pool_replication(l.pool_id); return rep; } extern "C" int ceph_get_path_replication(struct ceph_mount_info *cmount, const char *path) { - struct ceph_file_layout l; + file_layout_t l; int r; if (!cmount->is_mounted()) @@ -1099,7 +1099,7 @@ extern "C" int ceph_get_path_replication(struct ceph_mount_info *cmount, const c r = cmount->get_client()->describe_layout(path, &l); if (r < 0) return r; - int rep = cmount->get_client()->get_pool_replication(l.fl_pg_pool); + int rep = cmount->get_client()->get_pool_replication(l.pool_id); return rep; } @@ -1436,9 +1436,11 @@ extern "C" int ceph_ll_read_block(class ceph_mount_info *cmount, uint64_t length, struct ceph_file_layout* layout) { - - return (cmount->get_client()->ll_read_block(in, blockid, buf, offset, - length, layout)); + file_layout_t l; + int r = (cmount->get_client()->ll_read_block(in, blockid, buf, offset, + length, &l)); + l.to_legacy(layout); + return r; } extern "C" int ceph_ll_write_block(class ceph_mount_info *cmount, @@ -1448,8 +1450,11 @@ extern "C" int ceph_ll_write_block(class ceph_mount_info *cmount, struct ceph_file_layout *layout, uint64_t snapseq, uint32_t sync) { - return (cmount->get_client()->ll_write_block(in, blockid, buf, offset, - length, layout, snapseq, sync)); + file_layout_t l; + int r = (cmount->get_client()->ll_write_block(in, blockid, buf, offset, + length, &l, snapseq, sync)); + l.to_legacy(layout); + return r; } extern "C" int ceph_ll_commit_blocks(class ceph_mount_info *cmount, @@ -1640,7 +1645,10 @@ extern "C" uint32_t ceph_ll_file_layout(class ceph_mount_info *cmount, Inode *in, struct ceph_file_layout *layout) { - return (cmount->get_client()->ll_file_layout(in, layout)); + file_layout_t l; + int r = (cmount->get_client()->ll_file_layout(in, &l)); + l.to_legacy(layout); + return r; } uint64_t ceph_ll_snap_seq(class ceph_mount_info *cmount, Inode *in) @@ -1652,7 +1660,10 @@ extern "C" int ceph_ll_get_stripe_osd(class ceph_mount_info *cmount, Inode *in, uint64_t blockno, struct ceph_file_layout* layout) { - return (cmount->get_client()->ll_get_stripe_osd(in, blockno, layout)); + file_layout_t l; + int r = (cmount->get_client()->ll_get_stripe_osd(in, blockno, &l)); + l.to_legacy(layout); + return r; } extern "C" int ceph_ll_num_osds(class ceph_mount_info *cmount) diff --git a/src/libradosstriper/RadosStriperImpl.cc b/src/libradosstriper/RadosStriperImpl.cc index 5fdb8563b7819..26833eab75db1 100644 --- a/src/libradosstriper/RadosStriperImpl.cc +++ b/src/libradosstriper/RadosStriperImpl.cc @@ -467,7 +467,10 @@ int libradosstriper::RadosStriperImpl::aio_read(const std::string& soid, vector *extents = new vector(); if (read_len > 0) { std::string format = soid + RADOS_OBJECT_EXTENSION_FORMAT; - Striper::file_to_extents(cct(), format.c_str(), &layout, off, read_len, 0, *extents); + file_layout_t l; + l.from_legacy(layout); + Striper::file_to_extents(cct(), format.c_str(), &l, off, read_len, + 0, *extents); } // create a completion object and transfer ownership of extents and resultbl @@ -770,7 +773,9 @@ libradosstriper::RadosStriperImpl::internal_aio_write(const std::string& soid, // get list of extents to be written to vector extents; std::string format = soid + RADOS_OBJECT_EXTENSION_FORMAT; - Striper::file_to_extents(cct(), format.c_str(), &layout, off, len, 0, extents); + file_layout_t l; + l.from_legacy(layout); + Striper::file_to_extents(cct(), format.c_str(), &l, off, len, 0, extents); // go through the extents int r = 0; for (vector::iterator p = extents.begin(); p != extents.end(); ++p) { @@ -838,9 +843,10 @@ int libradosstriper::RadosStriperImpl::extract_sizet_attr return 0; } -int libradosstriper::RadosStriperImpl::internal_get_layout_and_size(const std::string& oid, - ceph_file_layout *layout, - uint64_t *size) +int libradosstriper::RadosStriperImpl::internal_get_layout_and_size( + const std::string& oid, + ceph_file_layout *layout, + uint64_t *size) { // get external attributes of the first rados object std::map attrs; @@ -862,10 +868,11 @@ int libradosstriper::RadosStriperImpl::internal_get_layout_and_size(const std::s return rc; } -int libradosstriper::RadosStriperImpl::openStripedObjectForRead(const std::string& soid, - ceph_file_layout *layout, - uint64_t *size, - std::string *lockCookie) +int libradosstriper::RadosStriperImpl::openStripedObjectForRead( + const std::string& soid, + ceph_file_layout *layout, + uint64_t *size, + std::string *lockCookie) { // take a lock the first rados object, if it exists and gets its size // check, lock and size reading must be atomic and are thus done within a single operation @@ -1042,7 +1049,9 @@ int libradosstriper::RadosStriperImpl::truncate(const std::string& soid, } if (exists) { // truncate - uint64_t new_object_size = Striper::object_truncate_size(cct(), &layout, objectno, size); + file_layout_t l; + l.from_legacy(layout); + uint64_t new_object_size = Striper::object_truncate_size(cct(), &l, objectno, size); int rc; if (new_object_size > 0 or 0 == objectno) { rc = m_ioCtx.trunc(getObjectId(soid, objectno), new_object_size); diff --git a/src/librbd/AioImageRequest.cc b/src/librbd/AioImageRequest.cc index 7e0e0fb861dec..e7cfd393167ea 100644 --- a/src/librbd/AioImageRequest.cc +++ b/src/librbd/AioImageRequest.cc @@ -414,11 +414,11 @@ AioObjectRequest *AioImageDiscard::create_object_request( CephContext *cct = m_image_ctx.cct; AioObjectRequest *req; - if (object_extent.length == m_image_ctx.layout.fl_object_size) { + if (object_extent.length == m_image_ctx.layout.object_size) { req = new AioObjectRemove(&m_image_ctx, object_extent.oid.name, object_extent.objectno, snapc, on_finish); } else if (object_extent.offset + object_extent.length == - m_image_ctx.layout.fl_object_size) { + m_image_ctx.layout.object_size) { req = new AioObjectTruncate(&m_image_ctx, object_extent.oid.name, object_extent.objectno, object_extent.offset, snapc, on_finish); diff --git a/src/librbd/AioObjectRequest.cc b/src/librbd/AioObjectRequest.cc index 96669eadbe472..9dee9025c1417 100644 --- a/src/librbd/AioObjectRequest.cc +++ b/src/librbd/AioObjectRequest.cc @@ -37,7 +37,7 @@ namespace librbd { m_hide_enoent(hide_enoent) { Striper::extent_to_file(m_ictx->cct, &m_ictx->layout, m_object_no, - 0, m_ictx->layout.fl_object_size, m_parent_extents); + 0, m_ictx->layout.object_size, m_parent_extents); RWLock::RLocker snap_locker(m_ictx->snap_lock); RWLock::RLocker parent_locker(m_ictx->parent_lock); diff --git a/src/librbd/ImageCtx.cc b/src/librbd/ImageCtx.cc index e91000357a050..1603926d837fd 100644 --- a/src/librbd/ImageCtx.cc +++ b/src/librbd/ImageCtx.cc @@ -176,7 +176,6 @@ struct C_InvalidateCache : public Context { snap_name = snap; memset(&header, 0, sizeof(header)); - memset(&layout, 0, sizeof(layout)); ThreadPoolSingleton *thread_pool_singleton; cct->lookup_or_create_singleton_object( @@ -308,11 +307,11 @@ struct C_InvalidateCache : public Context { alignments.push_back(stripe_unit); // stripe unit readahead.set_alignments(alignments); - memset(&layout, 0, sizeof(layout)); - layout.fl_stripe_unit = stripe_unit; - layout.fl_stripe_count = stripe_count; - layout.fl_object_size = 1ull << order; - layout.fl_pg_pool = data_ctx.get_id(); // FIXME: pool id overflow? + layout = file_layout_t(); + layout.stripe_unit = stripe_unit; + layout.stripe_count = stripe_count; + layout.object_size = 1ull << order; + layout.pool_id = data_ctx.get_id(); // FIXME: pool id overflow? delete[] format_string; size_t len = object_prefix.length() + 16; @@ -325,7 +324,7 @@ struct C_InvalidateCache : public Context { ldout(cct, 10) << "init_layout stripe_unit " << stripe_unit << " stripe_count " << stripe_count - << " object_size " << layout.fl_object_size + << " object_size " << layout.object_size << " prefix " << object_prefix << " format " << format_string << dendl; diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index 0d84f0caad370..01e7c4371ed7b 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -122,7 +122,7 @@ namespace librbd { uint64_t stripe_unit, stripe_count; uint64_t flags; - ceph_file_layout layout; + file_layout_t layout; ObjectCacher *object_cacher; LibrbdWriteback *writeback_handler; diff --git a/src/librbd/LibrbdWriteback.cc b/src/librbd/LibrbdWriteback.cc index 7a02e6a1a3d28..231c9b12e6dbc 100644 --- a/src/librbd/LibrbdWriteback.cc +++ b/src/librbd/LibrbdWriteback.cc @@ -218,7 +218,7 @@ namespace librbd { // reverse map this object extent onto the parent vector > objectx; Striper::extent_to_file(m_ictx->cct, &m_ictx->layout, - object_no, 0, m_ictx->layout.fl_object_size, + object_no, 0, m_ictx->layout.object_size, objectx); uint64_t object_overlap = m_ictx->prune_parent_extents(objectx, overlap); bool may = object_overlap > 0; diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index 1d76a2e5beacb..f195bb976aa59 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -762,7 +762,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) { ostringstream oss; CephContext *cct = (CephContext *)io_ctx.cct(); - ceph_file_layout layout; + file_layout_t layout; int r = validate_pool(io_ctx, cct); if (r < 0) { @@ -825,14 +825,14 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) { goto err_remove_header; } - memset(&layout, 0, sizeof(layout)); - layout.fl_object_size = 1ull << order; + layout = file_layout_t(); + layout.object_size = 1ull << order; if (stripe_unit == 0 || stripe_count == 0) { - layout.fl_stripe_unit = layout.fl_object_size; - layout.fl_stripe_count = 1; + layout.stripe_unit = layout.object_size; + layout.stripe_count = 1; } else { - layout.fl_stripe_unit = stripe_unit; - layout.fl_stripe_count = stripe_count; + layout.stripe_unit = stripe_unit; + layout.stripe_count = stripe_count; } librados::ObjectWriteOperation op; diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index c9fe8ee3645a4..cd247cb14a63c 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -385,13 +385,13 @@ void CInode::pop_and_dirty_projected_inode(LogSegment *ls) assert(!projected_nodes.empty()); dout(15) << "pop_and_dirty_projected_inode " << projected_nodes.front()->inode << " v" << projected_nodes.front()->inode->version << dendl; - int64_t old_pool = inode.layout.fl_pg_pool; + int64_t old_pool = inode.layout.pool_id; mark_dirty(projected_nodes.front()->inode->version, ls); inode = *projected_nodes.front()->inode; if (inode.is_backtrace_updated()) - _mark_dirty_parent(ls, old_pool != inode.layout.fl_pg_pool); + _mark_dirty_parent(ls, old_pool != inode.layout.pool_id); map *px = projected_nodes.front()->xattrs; if (px) { @@ -1147,7 +1147,7 @@ void CInode::store_backtrace(MDSInternalContextBase *fin, int op_prio) if (is_dir()) { pool = mdcache->mds->mdsmap->get_metadata_pool(); } else { - pool = inode.layout.fl_pg_pool; + pool = inode.layout.pool_id; } inode_backtrace_t bt; @@ -1161,7 +1161,7 @@ void CInode::store_backtrace(MDSInternalContextBase *fin, int op_prio) op.setxattr("parent", parent_bl); bufferlist layout_bl; - ::encode(inode.layout, layout_bl); + ::encode(inode.layout, layout_bl, mdcache->mds->mdsmap->get_up_features()); op.setxattr("layout", layout_bl); SnapContext snapc; @@ -1233,7 +1233,7 @@ void CInode::fetch_backtrace(Context *fin, bufferlist *backtrace) if (is_dir()) pool = mdcache->mds->mdsmap->get_metadata_pool(); else - pool = inode.layout.fl_pg_pool; + pool = inode.layout.pool_id; mdcache->fetch_backtrace(inode.ino, pool, *backtrace, fin); } @@ -1435,7 +1435,7 @@ void CInode::encode_lock_state(int type, bufferlist& bl) ::encode(inode.atime, bl); ::encode(inode.time_warp_seq, bl); if (!is_dir()) { - ::encode(inode.layout, bl); + ::encode(inode.layout, bl, mdcache->mds->mdsmap->get_up_features()); ::encode(inode.size, bl); ::encode(inode.truncate_seq, bl); ::encode(inode.truncate_size, bl); @@ -1530,7 +1530,7 @@ void CInode::encode_lock_state(int type, bufferlist& bl) case CEPH_LOCK_IPOLICY: if (inode.is_dir()) { ::encode(inode.version, bl); - ::encode(inode.layout, bl); + ::encode(inode.layout, bl, mdcache->mds->mdsmap->get_up_features()); ::encode(inode.quota, bl); } break; @@ -3105,7 +3105,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, // file inode_t *file_i = pfile ? pi:oi; - ceph_file_layout layout; + file_layout_t layout; if (is_dir()) { layout = (ppolicy ? pi : oi)->layout; } else { @@ -3283,7 +3283,7 @@ int CInode::encode_inodestat(bufferlist& bl, Session *session, ::encode(ecap, bl); - ::encode(layout, bl); + ::encode(layout, bl, session->connection->get_features()); ::encode(any_i->ctime, bl); ::encode(file_i->mtime, bl); ::encode(file_i->atime, bl); @@ -3716,7 +3716,7 @@ void CInode::validate_disk_state(CInode::validated_data *results, if (in->is_dir()) pool = in->mdcache->mds->mdsmap->get_metadata_pool(); else - pool = in->inode.layout.fl_pg_pool; + pool = in->inode.layout.pool_id; object_t oid = CInode::get_object_name(in->ino(), frag_t(), ""); @@ -3812,7 +3812,7 @@ void CInode::validate_disk_state(CInode::validated_data *results, if (in->is_dir()) pool = in->mdcache->mds->mdsmap->get_metadata_pool(); else - pool = in->inode.layout.fl_pg_pool; + pool = in->inode.layout.pool_id; inode_backtrace_t& memory_backtrace = results->backtrace.memory_value; in->build_backtrace(pool, memory_backtrace); bool equivalent, divergent; diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 25977fbe26be3..d500f4fb047bc 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -155,7 +155,7 @@ void Locker::include_snap_rdlocks(set& rdlocks, CInode *in) } void Locker::include_snap_rdlocks_wlayout(set& rdlocks, CInode *in, - ceph_file_layout **layout) + file_layout_t **layout) { //rdlock ancestor snaps CInode *t = in; diff --git a/src/mds/Locker.h b/src/mds/Locker.h index 8a6581f063dd2..653988ecfb756 100644 --- a/src/mds/Locker.h +++ b/src/mds/Locker.h @@ -72,7 +72,7 @@ protected: public: void include_snap_rdlocks(set& rdlocks, CInode *in); void include_snap_rdlocks_wlayout(set& rdlocks, CInode *in, - ceph_file_layout **layout); + file_layout_t **layout); bool acquire_locks(MDRequestRef& mdr, set &rdlocks, diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index aff51be39a5b6..6c5d1e3cbd531 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -100,8 +100,6 @@ using namespace std; -extern struct ceph_file_layout g_default_file_layout; - #include "common/config.h" #include "include/assert.h" @@ -213,9 +211,6 @@ MDCache::MDCache(MDSRank *m) : decayrate.set_halflife(g_conf->mds_decay_halflife); - memset(&default_file_layout, 0, sizeof(default_file_layout)); - memset(&default_log_layout, 0, sizeof(default_log_layout)); - did_shutdown_log_cap = false; } @@ -327,23 +322,21 @@ void MDCache::remove_inode(CInode *o) delete o; } -ceph_file_layout MDCache::gen_default_file_layout(const MDSMap &mdsmap) +file_layout_t MDCache::gen_default_file_layout(const MDSMap &mdsmap) { - ceph_file_layout result = g_default_file_layout; - result.fl_pg_pool = mdsmap.get_first_data_pool(); - + file_layout_t result = file_layout_t::get_default(); + result.pool_id = mdsmap.get_first_data_pool(); return result; } -ceph_file_layout MDCache::gen_default_log_layout(const MDSMap &mdsmap) +file_layout_t MDCache::gen_default_log_layout(const MDSMap &mdsmap) { - ceph_file_layout result = g_default_file_layout; - result.fl_pg_pool = mdsmap.get_metadata_pool(); + file_layout_t result = file_layout_t::get_default(); + result.pool_id = mdsmap.get_metadata_pool(); if (g_conf->mds_log_segment_size > 0) { - result.fl_object_size = g_conf->mds_log_segment_size; - result.fl_stripe_unit = g_conf->mds_log_segment_size; + result.object_size = g_conf->mds_log_segment_size; + result.stripe_unit = g_conf->mds_log_segment_size; } - return result; } @@ -351,7 +344,6 @@ void MDCache::init_layouts() { default_file_layout = gen_default_file_layout(*(mds->mdsmap)); default_log_layout = gen_default_log_layout(*(mds->mdsmap)); - } void MDCache::create_unlinked_system_inode(CInode *in, inodeno_t ino, @@ -369,7 +361,6 @@ void MDCache::create_unlinked_system_inode(CInode *in, inodeno_t ino, memset(&in->inode.dir_layout, 0, sizeof(in->inode.dir_layout)); if (in->inode.is_dir()) { - memset(&in->inode.layout, 0, sizeof(in->inode.layout)); in->inode.dir_layout.dl_dir_hash = g_conf->mds_default_dir_hash; ++in->inode.rstat.rsubdirs; } else { @@ -404,7 +395,7 @@ CInode *MDCache::create_root_inode() i->inode.uid = g_conf->mds_root_ino_uid; i->inode.gid = g_conf->mds_root_ino_gid; i->inode.layout = default_file_layout; - i->inode.layout.fl_pg_pool = mds->mdsmap->get_first_data_pool(); + i->inode.layout.pool_id = mds->mdsmap->get_first_data_pool(); return i; } @@ -1721,8 +1712,8 @@ void MDCache::journal_dirty_inode(MutationImpl *mut, EMetaBlob *metablob, CInode if (!dn->get_projected_linkage()->is_null()) // no need to cow a null dentry journal_cow_dentry(mut, metablob, dn, follows); if (in->get_projected_inode()->is_backtrace_updated()) { - bool dirty_pool = in->get_projected_inode()->layout.fl_pg_pool != - in->get_previous_projected_inode()->layout.fl_pg_pool; + bool dirty_pool = in->get_projected_inode()->layout.pool_id != + in->get_previous_projected_inode()->layout.pool_id; metablob->add_primary_dentry(dn, in, true, true, dirty_pool); } else { metablob->add_primary_dentry(dn, in, true); @@ -8557,7 +8548,7 @@ void MDCache::open_ino(inodeno_t ino, int64_t pool, MDSInternalContextBase* fin, info.want_replica = want_replica; info.want_xlocked = want_xlocked; info.tid = ++open_ino_last_tid; - info.pool = pool >= 0 ? pool : default_file_layout.fl_pg_pool; + info.pool = pool >= 0 ? pool : default_file_layout.pool_id; info.waiters.push_back(fin); do_open_ino(ino, info, 0); } diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 6b054130dd8c0..36ec842be7c7e 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -170,11 +170,11 @@ public: unsigned max_dir_commit_size; - static ceph_file_layout gen_default_file_layout(const MDSMap &mdsmap); - static ceph_file_layout gen_default_log_layout(const MDSMap &mdsmap); + static file_layout_t gen_default_file_layout(const MDSMap &mdsmap); + static file_layout_t gen_default_log_layout(const MDSMap &mdsmap); - ceph_file_layout default_file_layout; - ceph_file_layout default_log_layout; + file_layout_t default_file_layout; + file_layout_t default_log_layout; void register_perfcounters(); diff --git a/src/mds/MDLog.cc b/src/mds/MDLog.cc index fce20124687a2..b3218a8ec3dac 100644 --- a/src/mds/MDLog.cc +++ b/src/mds/MDLog.cc @@ -1038,7 +1038,7 @@ void MDLog::_reformat_journal(JournalPointer const &jp_in, Journaler *old_journa Journaler *new_journal = new Journaler(jp.back, mds->mdsmap->get_metadata_pool(), CEPH_FS_ONDISK_MAGIC, mds->objecter, logger, l_mdl_jlat, &mds->timer, mds->finisher); dout(4) << "Writing new journal header " << jp.back << dendl; - ceph_file_layout new_layout = old_journal->get_layout(); + file_layout_t new_layout = old_journal->get_layout(); new_journal->set_writeable(); new_journal->create(&new_layout, g_conf->mds_journal_format); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index ecd45a321aeb0..a08296f7a9fa7 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -2248,7 +2248,7 @@ CDentry* Server::prepare_stray_dentry(MDRequestRef& mdr, CInode *in) * create a new inode. set c/m/atime. hit dir pop. */ CInode* Server::prepare_new_inode(MDRequestRef& mdr, CDir *dir, inodeno_t useino, unsigned mode, - ceph_file_layout *layout) + file_layout_t *layout) { CInode *in = new CInode(mdcache); @@ -2294,7 +2294,6 @@ CInode* Server::prepare_new_inode(MDRequestRef& mdr, CDir *dir, inodeno_t useino memset(&in->inode.dir_layout, 0, sizeof(in->inode.dir_layout)); if (in->inode.is_dir()) { in->inode.dir_layout.dl_dir_hash = g_conf->mds_default_dir_hash; - memset(&in->inode.layout, 0, sizeof(in->inode.layout)); } else if (layout) { in->inode.layout = *layout; } else { @@ -2435,7 +2434,7 @@ CInode* Server::rdlock_path_pin_ref(MDRequestRef& mdr, int n, bool want_auth, bool no_want_auth, /* for readdir, who doesn't want auth _even_if_ it's a snapped dir */ - ceph_file_layout **layout, + file_layout_t **layout, bool no_lookup) // true if we cannot return a null dentry lease { const filepath& refpath = n ? mdr->get_filepath2() : mdr->get_filepath(); @@ -2530,7 +2529,7 @@ CInode* Server::rdlock_path_pin_ref(MDRequestRef& mdr, int n, CDentry* Server::rdlock_path_xlock_dentry(MDRequestRef& mdr, int n, set& rdlocks, set& wrlocks, set& xlocks, bool okexist, bool mustexist, bool alwaysxlock, - ceph_file_layout **layout) + file_layout_t **layout) { const filepath& refpath = n ? mdr->get_filepath2() : mdr->get_filepath(); @@ -3073,7 +3072,7 @@ void Server::handle_client_openc(MDRequestRef& mdr) bool excl = (req->head.args.open.flags & O_EXCL); set rdlocks, wrlocks, xlocks; - ceph_file_layout *dir_layout = NULL; + file_layout_t *dir_layout = NULL; CDentry *dn = rdlock_path_xlock_dentry(mdr, 0, rdlocks, wrlocks, xlocks, !excl, false, false, &dir_layout); if (!dn) return; @@ -3082,7 +3081,7 @@ void Server::handle_client_openc(MDRequestRef& mdr) return; } // set layout - ceph_file_layout layout; + file_layout_t layout; if (dir_layout) layout = *dir_layout; else @@ -3093,23 +3092,23 @@ void Server::handle_client_openc(MDRequestRef& mdr) // fill in any special params from client if (req->head.args.open.stripe_unit) - layout.fl_stripe_unit = req->head.args.open.stripe_unit; + layout.stripe_unit = req->head.args.open.stripe_unit; if (req->head.args.open.stripe_count) - layout.fl_stripe_count = req->head.args.open.stripe_count; + layout.stripe_count = req->head.args.open.stripe_count; if (req->head.args.open.object_size) - layout.fl_object_size = req->head.args.open.object_size; + layout.object_size = req->head.args.open.object_size; if (req->get_connection()->has_feature(CEPH_FEATURE_CREATEPOOLID) && (__s32)req->head.args.open.pool >= 0) { - layout.fl_pg_pool = req->head.args.open.pool; + layout.pool_id = req->head.args.open.pool; // If client doesn't have capability to modify layout pools, then // only permit this request if the requested pool matches what the // file would have inherited anyway from its parent. CDir *parent = dn->get_dir(); CInode *parent_in = parent->get_inode(); - int64_t parent_pool = parent_in->inode.layout.fl_pg_pool; + int64_t parent_pool = parent_in->inode.layout.pool_id; - if (layout.fl_pg_pool != parent_pool) { + if (layout.pool_id != parent_pool) { access |= MAY_SET_POOL; } @@ -3120,13 +3119,13 @@ void Server::handle_client_openc(MDRequestRef& mdr) } } - if (!ceph_file_layout_is_valid(&layout)) { + if (!layout.is_valid()) { dout(10) << " invalid initial file layout" << dendl; respond_to_request(mdr, -EINVAL); return; } - if (!mds->mdsmap->is_data_pool(layout.fl_pg_pool)) { - dout(10) << " invalid data pool " << layout.fl_pg_pool << dendl; + if (!mds->mdsmap->is_data_pool(layout.pool_id)) { + dout(10) << " invalid data pool " << layout.pool_id << dendl; respond_to_request(mdr, -EINVAL); return; } @@ -3165,8 +3164,8 @@ void Server::handle_client_openc(MDRequestRef& mdr) dn->push_projected_linkage(in); in->inode.version = dn->pre_dirty(); - if (layout.fl_pg_pool != mdcache->default_file_layout.fl_pg_pool) - in->inode.add_old_pool(mdcache->default_file_layout.fl_pg_pool); + if (layout.pool_id != mdcache->default_file_layout.pool_id) + in->inode.add_old_pool(mdcache->default_file_layout.pool_id); in->inode.update_backtrace(); if (cmode & CEPH_FILE_MODE_WR) { in->inode.client_ranges[client].range.first = 0; @@ -3813,26 +3812,22 @@ void Server::handle_client_setlayout(MDRequestRef& mdr) } // validate layout - ceph_file_layout layout = cur->get_projected_inode()->layout; + file_layout_t layout = cur->get_projected_inode()->layout; // save existing layout for later - int64_t old_pool = layout.fl_pg_pool; + int64_t old_pool = layout.pool_id; int access = MAY_WRITE; if (req->head.args.setlayout.layout.fl_object_size > 0) - layout.fl_object_size = req->head.args.setlayout.layout.fl_object_size; + layout.object_size = req->head.args.setlayout.layout.fl_object_size; if (req->head.args.setlayout.layout.fl_stripe_unit > 0) - layout.fl_stripe_unit = req->head.args.setlayout.layout.fl_stripe_unit; + layout.stripe_unit = req->head.args.setlayout.layout.fl_stripe_unit; if (req->head.args.setlayout.layout.fl_stripe_count > 0) - layout.fl_stripe_count=req->head.args.setlayout.layout.fl_stripe_count; - if (req->head.args.setlayout.layout.fl_cas_hash > 0) - layout.fl_cas_hash = req->head.args.setlayout.layout.fl_cas_hash; - if (req->head.args.setlayout.layout.fl_object_stripe_unit > 0) - layout.fl_object_stripe_unit = req->head.args.setlayout.layout.fl_object_stripe_unit; + layout.stripe_count=req->head.args.setlayout.layout.fl_stripe_count; if (req->head.args.setlayout.layout.fl_pg_pool > 0) { - layout.fl_pg_pool = req->head.args.setlayout.layout.fl_pg_pool; + layout.pool_id = req->head.args.setlayout.layout.fl_pg_pool; - if (layout.fl_pg_pool != old_pool) { + if (layout.pool_id != old_pool) { access |= MAY_SET_POOL; } @@ -3842,13 +3837,13 @@ void Server::handle_client_setlayout(MDRequestRef& mdr) return; } } - if (!ceph_file_layout_is_valid(&layout)) { + if (!layout.is_valid()) { dout(10) << "bad layout" << dendl; respond_to_request(mdr, -EINVAL); return; } - if (!mds->mdsmap->is_data_pool(layout.fl_pg_pool)) { - dout(10) << " invalid data pool " << layout.fl_pg_pool << dendl; + if (!mds->mdsmap->is_data_pool(layout.pool_id)) { + dout(10) << " invalid data pool " << layout.pool_id << dendl; respond_to_request(mdr, -EINVAL); return; } @@ -3883,7 +3878,7 @@ void Server::handle_client_setdirlayout(MDRequestRef& mdr) { MClientRequest *req = mdr->client_request; set rdlocks, wrlocks, xlocks; - ceph_file_layout *dir_layout = NULL; + file_layout_t *dir_layout = NULL; CInode *cur = rdlock_path_pin_ref(mdr, 0, rdlocks, true, false, &dir_layout); if (!cur) return; @@ -3903,7 +3898,7 @@ void Server::handle_client_setdirlayout(MDRequestRef& mdr) // validate layout const inode_t *old_pi = cur->get_projected_inode(); - ceph_file_layout layout; + file_layout_t layout; if (old_pi->has_layout()) layout = old_pi->layout; else if (dir_layout) @@ -3915,33 +3910,29 @@ void Server::handle_client_setdirlayout(MDRequestRef& mdr) int access = MAY_WRITE; if (req->head.args.setlayout.layout.fl_object_size > 0) - layout.fl_object_size = req->head.args.setlayout.layout.fl_object_size; + layout.object_size = req->head.args.setlayout.layout.fl_object_size; if (req->head.args.setlayout.layout.fl_stripe_unit > 0) - layout.fl_stripe_unit = req->head.args.setlayout.layout.fl_stripe_unit; + layout.stripe_unit = req->head.args.setlayout.layout.fl_stripe_unit; if (req->head.args.setlayout.layout.fl_stripe_count > 0) - layout.fl_stripe_count=req->head.args.setlayout.layout.fl_stripe_count; - if (req->head.args.setlayout.layout.fl_cas_hash > 0) - layout.fl_cas_hash = req->head.args.setlayout.layout.fl_cas_hash; - if (req->head.args.setlayout.layout.fl_object_stripe_unit > 0) - layout.fl_object_stripe_unit = req->head.args.setlayout.layout.fl_object_stripe_unit; + layout.stripe_count=req->head.args.setlayout.layout.fl_stripe_count; if (req->head.args.setlayout.layout.fl_pg_pool > 0) { - if (req->head.args.setlayout.layout.fl_pg_pool != layout.fl_pg_pool) { + if (req->head.args.setlayout.layout.fl_pg_pool != layout.pool_id) { access |= MAY_SET_POOL; } - layout.fl_pg_pool = req->head.args.setlayout.layout.fl_pg_pool; + layout.pool_id = req->head.args.setlayout.layout.fl_pg_pool; // make sure we have as new a map as the client if (req->get_mdsmap_epoch() > mds->mdsmap->get_epoch()) { mds->wait_for_mdsmap(req->get_mdsmap_epoch(), new C_MDS_RetryRequest(mdcache, mdr)); return; } } - if (!ceph_file_layout_is_valid(&layout)) { + if (!layout.is_valid()) { dout(10) << "bad layout" << dendl; respond_to_request(mdr, -EINVAL); return; } - if (!mds->mdsmap->is_data_pool(layout.fl_pg_pool)) { - dout(10) << " invalid data pool " << layout.fl_pg_pool << dendl; + if (!mds->mdsmap->is_data_pool(layout.pool_id)) { + dout(10) << " invalid data pool " << layout.pool_id << dendl; respond_to_request(mdr, -EINVAL); return; } @@ -3967,7 +3958,7 @@ void Server::handle_client_setdirlayout(MDRequestRef& mdr) // XATTRS int Server::parse_layout_vxattr(string name, string value, const OSDMap& osdmap, - ceph_file_layout *layout, bool validate) + file_layout_t *layout, bool validate) { dout(20) << "parse_layout_vxattr name " << name << " value '" << value << "'" << dendl; try { @@ -3992,21 +3983,21 @@ int Server::parse_layout_vxattr(string name, string value, const OSDMap& osdmap, return r; } } else if (name == "layout.object_size") { - layout->fl_object_size = boost::lexical_cast(value); + layout->object_size = boost::lexical_cast(value); } else if (name == "layout.stripe_unit") { - layout->fl_stripe_unit = boost::lexical_cast(value); + layout->stripe_unit = boost::lexical_cast(value); } else if (name == "layout.stripe_count") { - layout->fl_stripe_count = boost::lexical_cast(value); + layout->stripe_count = boost::lexical_cast(value); } else if (name == "layout.pool") { try { - layout->fl_pg_pool = boost::lexical_cast(value); + layout->pool_id = boost::lexical_cast(value); } catch (boost::bad_lexical_cast const&) { int64_t pool = osdmap.lookup_pg_pool_name(value); if (pool < 0) { dout(10) << " unknown pool " << value << dendl; return -ENOENT; } - layout->fl_pg_pool = pool; + layout->pool_id = pool; } } else { dout(10) << " unknown layout vxattr " << name << dendl; @@ -4017,12 +4008,12 @@ int Server::parse_layout_vxattr(string name, string value, const OSDMap& osdmap, return -EINVAL; } - if (validate && !ceph_file_layout_is_valid(layout)) { + if (validate && !layout->is_valid()) { dout(10) << "bad layout" << dendl; return -EINVAL; } - if (!mds->mdsmap->is_data_pool(layout->fl_pg_pool)) { - dout(10) << " invalid data pool " << layout->fl_pg_pool << dendl; + if (!mds->mdsmap->is_data_pool(layout->pool_id)) { + dout(10) << " invalid data pool " << layout->pool_id << dendl; return -EINVAL; } return 0; @@ -4076,7 +4067,7 @@ int Server::parse_quota_vxattr(string name, string value, quota_info_t *quota) } void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur, - ceph_file_layout *dir_layout, + file_layout_t *dir_layout, set rdlocks, set wrlocks, set xlocks) @@ -4096,7 +4087,7 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur, return; } - ceph_file_layout layout; + file_layout_t layout; if (cur->get_projected_inode()->has_layout()) layout = cur->get_projected_inode()->layout; else if (dir_layout) @@ -4123,7 +4114,7 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur, // One day if COMPACT_VERSION of MClientRequest >=3, we can remove those code. mdr->waited_for_osdmap = true; mds->objecter->wait_for_latest_osdmap( - new C_OnFinisher(new C_IO_Wrapper(mds, new C_MDS_RetryRequest(mdcache, mdr)), mds->finisher)); + new C_OnFinisher(new C_IO_Wrapper(mds, new C_MDS_RetryRequest(mdcache, mdr)), mds->finisher)); return; } r = -EINVAL; @@ -4136,7 +4127,7 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur, if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks)) return; - if (cur->inode.layout.fl_pg_pool != layout.fl_pg_pool) { + if (cur->inode.layout.pool_id != layout.pool_id) { if (!check_access(mdr, cur, MAY_SET_POOL)) { return; } @@ -4154,7 +4145,7 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur, respond_to_request(mdr, -ENOTEMPTY); return; } - ceph_file_layout layout = cur->get_projected_inode()->layout; + file_layout_t layout = cur->get_projected_inode()->layout; rest = name.substr(name.find("layout")); int r; epoch_t epoch; @@ -4187,14 +4178,14 @@ void Server::handle_set_vxattr(MDRequestRef& mdr, CInode *cur, if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks)) return; - if (cur->inode.layout.fl_pg_pool != layout.fl_pg_pool) { + if (cur->inode.layout.pool_id != layout.pool_id) { if (!check_access(mdr, cur, MAY_SET_POOL)) { return; } } pi = cur->project_inode(); - int64_t old_pool = pi->layout.fl_pg_pool; + int64_t old_pool = pi->layout.pool_id; pi->add_old_pool(old_pool); pi->layout = layout; pi->ctime = mdr->get_op_stamp(); @@ -4315,7 +4306,7 @@ void Server::handle_client_setxattr(MDRequestRef& mdr) set rdlocks, wrlocks, xlocks; CInode *cur; - ceph_file_layout *dir_layout = NULL; + file_layout_t *dir_layout = NULL; if (name.compare(0, 15, "ceph.dir.layout") == 0) cur = rdlock_path_pin_ref(mdr, 0, rdlocks, true, false, &dir_layout); else @@ -4387,7 +4378,7 @@ void Server::handle_client_removexattr(MDRequestRef& mdr) MClientRequest *req = mdr->client_request; string name(req->get_path2()); set rdlocks, wrlocks, xlocks; - ceph_file_layout *dir_layout = NULL; + file_layout_t *dir_layout = NULL; CInode *cur; if (name == "ceph.dir.layout") cur = rdlock_path_pin_ref(mdr, 0, rdlocks, true, false, &dir_layout); @@ -4498,7 +4489,7 @@ void Server::handle_client_mknod(MDRequestRef& mdr) MClientRequest *req = mdr->client_request; client_t client = mdr->get_client(); set rdlocks, wrlocks, xlocks; - ceph_file_layout *dir_layout = NULL; + file_layout_t *dir_layout = NULL; CDentry *dn = rdlock_path_xlock_dentry(mdr, 0, rdlocks, wrlocks, xlocks, false, false, false, &dir_layout); if (!dn) return; @@ -4519,7 +4510,7 @@ void Server::handle_client_mknod(MDRequestRef& mdr) mode |= S_IFREG; // set layout - ceph_file_layout layout; + file_layout_t layout; if (dir_layout && S_ISREG(mode)) layout = *dir_layout; else @@ -4536,8 +4527,8 @@ void Server::handle_client_mknod(MDRequestRef& mdr) newi->inode.rdev = req->head.args.mknod.rdev; newi->inode.version = dn->pre_dirty(); newi->inode.rstat.rfiles = 1; - if (layout.fl_pg_pool != mdcache->default_file_layout.fl_pg_pool) - newi->inode.add_old_pool(mdcache->default_file_layout.fl_pg_pool); + if (layout.pool_id != mdcache->default_file_layout.pool_id) + newi->inode.add_old_pool(mdcache->default_file_layout.pool_id); newi->inode.update_backtrace(); // if the client created a _regular_ file via MKNOD, it's highly likely they'll diff --git a/src/mds/Server.h b/src/mds/Server.h index 40c71f76fc87f..66aa6b9e4449d 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -141,20 +141,20 @@ public: CDentry *prepare_null_dentry(MDRequestRef& mdr, CDir *dir, const string& dname, bool okexist=false); CDentry *prepare_stray_dentry(MDRequestRef& mdr, CInode *in); CInode* prepare_new_inode(MDRequestRef& mdr, CDir *dir, inodeno_t useino, unsigned mode, - ceph_file_layout *layout=NULL); + file_layout_t *layout=NULL); void journal_allocated_inos(MDRequestRef& mdr, EMetaBlob *blob); void apply_allocated_inos(MDRequestRef& mdr); CInode* rdlock_path_pin_ref(MDRequestRef& mdr, int n, set& rdlocks, bool want_auth, bool no_want_auth=false, - ceph_file_layout **layout=NULL, + file_layout_t **layout=NULL, bool no_lookup=false); CDentry* rdlock_path_xlock_dentry(MDRequestRef& mdr, int n, set& rdlocks, set& wrlocks, set& xlocks, bool okexist, bool mustexist, bool alwaysxlock, - ceph_file_layout **layout=NULL); + file_layout_t **layout=NULL); CDir* try_open_auth_dirfrag(CInode *diri, frag_t fg, MDRequestRef& mdr); @@ -173,10 +173,10 @@ public: void handle_client_setdirlayout(MDRequestRef& mdr); int parse_layout_vxattr(string name, string value, const OSDMap& osdmap, - ceph_file_layout *layout, bool validate=true); + file_layout_t *layout, bool validate=true); int parse_quota_vxattr(string name, string value, quota_info_t *quota); void handle_set_vxattr(MDRequestRef& mdr, CInode *cur, - ceph_file_layout *dir_layout, + file_layout_t *dir_layout, set rdlocks, set wrlocks, set xlocks); diff --git a/src/mds/StrayManager.cc b/src/mds/StrayManager.cc index 6547a264120c4..868d49a1d1f3d 100644 --- a/src/mds/StrayManager.cc +++ b/src/mds/StrayManager.cc @@ -128,8 +128,7 @@ void StrayManager::purge(CDentry *dn, uint32_t op_allowance) } if (in->is_file()) { - uint64_t period = (uint64_t)in->inode.layout.fl_object_size * - (uint64_t)in->inode.layout.fl_stripe_count; + 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 @@ -150,7 +149,7 @@ void StrayManager::purge(CDentry *dn, uint32_t op_allowance) object_t oid = CInode::get_object_name(pi->ino, frag_t(), ""); // remove the backtrace object if it was not purged if (!gather.has_subs()) { - object_locator_t oloc(pi->layout.fl_pg_pool); + object_locator_t oloc(pi->layout.pool_id, pi->layout.pool_ns); dout(10) << __func__ << " remove backtrace object " << oid << " pool " << oloc.pool << " snapc " << snapc << dendl; mds->objecter->remove(oid, oloc, *snapc, @@ -444,8 +443,7 @@ 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 = (uint64_t)in->inode.layout.fl_object_size * - (uint64_t)in->inode.layout.fl_stripe_count; + 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())); @@ -804,8 +802,7 @@ void StrayManager::truncate(CDentry *dn, uint32_t op_allowance) dout(10) << " realm " << *realm << dendl; const SnapContext *snapc = &realm->get_snap_context(); - uint64_t period = (uint64_t)in->inode.layout.fl_object_size * - (uint64_t)in->inode.layout.fl_stripe_count; + 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 diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 63c95eb0457d0..8fcf03a7c92c7 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -256,7 +256,7 @@ void inode_t::encode(bufferlist &bl, uint64_t features) const } ::encode(dir_layout, bl); - ::encode(layout, bl); + ::encode(layout, bl, features); ::encode(size, bl); ::encode(truncate_seq, bl); ::encode(truncate_size, bl); @@ -381,9 +381,7 @@ void inode_t::dump(Formatter *f) const ::dump(dir_layout, f); f->close_section(); - f->open_object_section("layout"); - ::dump(layout, f); - f->close_section(); + f->dump_object("layout", layout); f->open_array_section("old_pools"); for (compact_set::const_iterator i = old_pools.begin(); @@ -1100,8 +1098,4 @@ void MDSCacheObject::dump_states(Formatter *f) const f->dump_string("state", "rejoinundef"); } -void ceph_file_layout_wrapper::dump(Formatter *f) const -{ - ::dump(static_cast(*this), f); -} diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 173995d111f47..02e09cd59a424 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -439,7 +439,7 @@ struct inode_t { // file (data access) ceph_dir_layout dir_layout; // [dir only] - ceph_file_layout layout; + file_layout_t layout; compact_set old_pools; uint64_t size; // on directory, # dentries uint64_t max_size_ever; // max size the file has ever been @@ -506,20 +506,15 @@ struct inode_t { } bool has_layout() const { - // why on earth is there no converse of memchr() in string.h? - const char *p = (const char *)&layout; - for (size_t i = 0; i < sizeof(layout); i++) - if (p[i] != '\0') - return true; - return false; + return layout != file_layout_t(); } void clear_layout() { - memset(&layout, 0, sizeof(layout)); + layout = file_layout_t(); } uint64_t get_layout_size_increment() { - return (uint64_t)layout.fl_object_size * (uint64_t)layout.fl_stripe_count; + return layout.get_period(); } bool is_dirty_rstat() const { return !(rstat == accounted_rstat); } @@ -1605,26 +1600,6 @@ inline std::ostream& operator<<(std::ostream& out, mdsco_db_line_prefix o) { return out; } -class ceph_file_layout_wrapper : public ceph_file_layout -{ -public: - void encode(bufferlist &bl) const - { - ::encode(static_cast(*this), bl); - } - - void decode(bufferlist::iterator &p) - { - ::decode(static_cast(*this), p); - } - - static void generate_test_instances(std::list& ls) - { - } - - void dump(Formatter *f) const; -}; - // parse a map of keys/values. namespace qi = boost::spirit::qi; diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h index d9450dfff41dd..f668ea73097aa 100644 --- a/src/messages/MClientCaps.h +++ b/src/messages/MClientCaps.h @@ -29,7 +29,7 @@ class MClientCaps : public Message { uint64_t size, max_size, truncate_size; uint32_t truncate_seq; utime_t mtime, atime, ctime; - ceph_file_layout layout; + file_layout_t layout; uint32_t time_warp_seq; struct ceph_mds_cap_peer peer; @@ -66,7 +66,7 @@ class MClientCaps : public Message { utime_t get_atime() { return atime; } __u32 get_time_warp_seq() { return time_warp_seq; } - const ceph_file_layout& get_layout() { + const file_layout_t& get_layout() { return layout; } @@ -202,7 +202,7 @@ public: mtime = utime_t(body.mtime); atime = utime_t(body.atime); ctime = utime_t(body.ctime); - layout = body.layout; + layout.from_legacy(body.layout); time_warp_seq = body.time_warp_seq; } } else { @@ -286,7 +286,7 @@ public: mtime.encode_timeval(&body.mtime); atime.encode_timeval(&body.atime); ctime.encode_timeval(&body.ctime); - body.layout = layout; + layout.to_legacy(&body.layout); body.time_warp_seq = time_warp_seq; } ::encode(body, payload); diff --git a/src/messages/MClientReply.h b/src/messages/MClientReply.h index f0e51ab3cd488..e723557fd3b36 100644 --- a/src/messages/MClientReply.h +++ b/src/messages/MClientReply.h @@ -101,7 +101,7 @@ struct InodeStat { version_t version; version_t xattr_version; ceph_mds_reply_cap cap; - ceph_file_layout layout; + file_layout_t layout; utime_t ctime, mtime, atime; uint32_t time_warp_seq; uint64_t size, max_size; diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index 46b51f36a1027..9a5cd88a7adca 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -608,17 +608,17 @@ public: return pg; } - static object_locator_t file_to_object_locator(const ceph_file_layout& layout) { - return object_locator_t(layout.fl_pg_pool); + static object_locator_t file_to_object_locator(const file_layout_t& layout) { + return object_locator_t(layout.pool_id, layout.pool_ns); } - // XXX: not used, mentioned in psim.cc comment - // oid -> pg - ceph_object_layout file_to_object_layout(object_t oid, ceph_file_layout& layout, string nspace) const { - return make_object_layout(oid, layout.fl_pg_pool, nspace); + ceph_object_layout file_to_object_layout(object_t oid, + file_layout_t& layout) const { + return make_object_layout(oid, layout.pool_id, layout.pool_ns); } - ceph_object_layout make_object_layout(object_t oid, int pg_pool, string nspace) const; + ceph_object_layout make_object_layout(object_t oid, int pg_pool, + string nspace) const; int get_pg_num(int pg_pool) const { diff --git a/src/osdc/Filer.cc b/src/osdc/Filer.cc index bf5f23c131b18..f64a122534841 100644 --- a/src/osdc/Filer.cc +++ b/src/osdc/Filer.cc @@ -67,7 +67,7 @@ public: }; int Filer::probe(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, snapid_t snapid, uint64_t start_from, uint64_t *end, // LB, when !fwd @@ -90,7 +90,7 @@ int Filer::probe(inodeno_t ino, } int Filer::probe(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, snapid_t snapid, uint64_t start_from, uint64_t *end, // LB, when !fwd @@ -111,12 +111,11 @@ int Filer::probe(inodeno_t ino, return probe_impl(probe, layout, start_from, end); } -int Filer::probe_impl(Probe* probe, ceph_file_layout *layout, +int Filer::probe_impl(Probe* probe, file_layout_t *layout, uint64_t start_from, uint64_t *end) // LB, when !fwd { // period (bytes before we jump unto a new set of object(s)) - uint64_t period = (uint64_t)layout->fl_stripe_count * - (uint64_t)layout->fl_object_size; + uint64_t period = layout->get_period(); // start with 1+ periods. probe->probing_len = period; @@ -268,8 +267,7 @@ bool Filer::_probed(Probe *probe, const object_t& oid, uint64_t size, // keep probing! ldout(cct, 10) << "_probed probing further" << dendl; - uint64_t period = (uint64_t)probe->layout.fl_stripe_count * - (uint64_t)probe->layout.fl_object_size; + uint64_t period = probe->layout.get_period(); if (probe->fwd) { probe->probing_off += probe->probing_len; assert(probe->probing_off % period == 0); @@ -303,14 +301,14 @@ struct PurgeRange { typedef std::lock_guard lock_guard; typedef std::unique_lock unique_lock; inodeno_t ino; - ceph_file_layout layout; + file_layout_t layout; SnapContext snapc; uint64_t first, num; ceph::real_time mtime; int flags; Context *oncommit; int uncommitted; - PurgeRange(inodeno_t i, ceph_file_layout& l, const SnapContext& sc, + PurgeRange(inodeno_t i, file_layout_t& l, const SnapContext& sc, uint64_t fo, uint64_t no, ceph::real_time t, int fl, Context *fin) : ino(i), layout(l), snapc(sc), first(fo), num(no), mtime(t), flags(fl), @@ -318,7 +316,7 @@ struct PurgeRange { }; int Filer::purge_range(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, const SnapContext& snapc, uint64_t first_obj, uint64_t num_obj, ceph::real_time mtime, diff --git a/src/osdc/Filer.h b/src/osdc/Filer.h index 0c7b862de0330..96c11b80461a0 100644 --- a/src/osdc/Filer.h +++ b/src/osdc/Filer.h @@ -56,7 +56,7 @@ class Filer { typedef std::lock_guard lock_guard; typedef std::unique_lock unique_lock; inodeno_t ino; - ceph_file_layout layout; + file_layout_t layout; snapid_t snapid; uint64_t *psize; @@ -80,7 +80,7 @@ class Filer { int err; bool found_size; - Probe(inodeno_t i, ceph_file_layout &l, snapid_t sn, + Probe(inodeno_t i, file_layout_t &l, snapid_t sn, uint64_t f, uint64_t *e, ceph::real_time *m, int fl, bool fw, Context *c) : ino(i), layout(l), snapid(sn), @@ -88,7 +88,7 @@ class Filer { probing_off(f), probing_len(0), err(0), found_size(false) {} - Probe(inodeno_t i, ceph_file_layout &l, snapid_t sn, + Probe(inodeno_t i, file_layout_t &l, snapid_t sn, uint64_t f, uint64_t *e, utime_t *m, int fl, bool fw, Context *c) : ino(i), layout(l), snapid(sn), @@ -118,7 +118,7 @@ class Filer { /*** async file interface. scatter/gather as needed. ***/ int read(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, snapid_t snap, uint64_t offset, uint64_t len, @@ -134,7 +134,7 @@ class Filer { } int read_trunc(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, snapid_t snap, uint64_t offset, uint64_t len, @@ -154,7 +154,7 @@ class Filer { } int write(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, const SnapContext& snapc, uint64_t offset, uint64_t len, @@ -172,7 +172,7 @@ class Filer { } int write_trunc(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, const SnapContext& snapc, uint64_t offset, uint64_t len, @@ -193,7 +193,7 @@ class Filer { } int truncate(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, const SnapContext& snapc, uint64_t offset, uint64_t len, @@ -232,7 +232,7 @@ class Filer { } int zero(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, const SnapContext& snapc, uint64_t offset, uint64_t len, @@ -244,7 +244,7 @@ class Filer { vector extents; Striper::file_to_extents(cct, ino, layout, offset, len, 0, extents); if (extents.size() == 1) { - if (extents[0].offset == 0 && extents[0].length == layout->fl_object_size + if (extents[0].offset == 0 && extents[0].length == layout->object_size && (!keep_first || extents[0].objectno != 0)) objecter->remove(extents[0].oid, extents[0].oloc, snapc, mtime, flags, onack, oncommit); @@ -258,7 +258,7 @@ class Filer { for (vector::iterator p = extents.begin(); p != extents.end(); ++p) { - if (p->offset == 0 && p->length == layout->fl_object_size && + if (p->offset == 0 && p->length == layout->object_size && (!keep_first || p->objectno != 0)) objecter->remove(p->oid, p->oloc, snapc, mtime, flags, @@ -277,7 +277,7 @@ class Filer { } int zero(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, const SnapContext& snapc, uint64_t offset, uint64_t len, @@ -294,7 +294,7 @@ class Filer { } // purge range of ino.### objects int purge_range(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, const SnapContext& snapc, uint64_t first_obj, uint64_t num_obj, ceph::real_time mtime, @@ -307,7 +307,7 @@ class Filer { * and whether we stop when we find data, or hole. */ int probe(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, snapid_t snapid, uint64_t start_from, uint64_t *end, @@ -317,7 +317,7 @@ class Filer { Context *onfinish); int probe(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, snapid_t snapid, uint64_t start_from, uint64_t *end, @@ -329,7 +329,7 @@ class Filer { } int probe(inodeno_t ino, - ceph_file_layout *layout, + file_layout_t *layout, snapid_t snapid, uint64_t start_from, uint64_t *end, @@ -339,7 +339,7 @@ class Filer { Context *onfinish); private: - int probe_impl(Probe* probe, ceph_file_layout *layout, + int probe_impl(Probe* probe, file_layout_t *layout, uint64_t start_from, uint64_t *end); }; diff --git a/src/osdc/Journaler.cc b/src/osdc/Journaler.cc index 487bb60b5a63b..fb38a08cd1836 100644 --- a/src/osdc/Journaler.cc +++ b/src/osdc/Journaler.cc @@ -45,7 +45,7 @@ void Journaler::set_writeable() readonly = false; } -void Journaler::create(ceph_file_layout *l, stream_format_t const sf) +void Journaler::create(file_layout_t *l, stream_format_t const sf) { lock_guard lk(lock); @@ -58,24 +58,23 @@ void Journaler::create(ceph_file_layout *l, stream_format_t const sf) prezeroing_pos = prezero_pos = write_pos = flush_pos = safe_pos = read_pos = requested_pos = received_pos = - expire_pos = trimming_pos = trimmed_pos = - (uint64_t)layout.fl_stripe_count * layout.fl_object_size; + expire_pos = trimming_pos = trimmed_pos = layout.get_period(); ldout(cct, 1) << "created blank journal at inode 0x" << std::hex << ino << std::dec << ", format=" << stream_format << dendl; } -void Journaler::set_layout(ceph_file_layout const *l) +void Journaler::set_layout(file_layout_t const *l) { lock_guard lk(lock); _set_layout(l); } -void Journaler::_set_layout(ceph_file_layout const *l) +void Journaler::_set_layout(file_layout_t const *l) { layout = *l; - assert(layout.fl_pg_pool == pg_pool); + assert(layout.pool_id == pg_pool); last_written.layout = layout; last_committed.layout = layout; @@ -84,7 +83,7 @@ void Journaler::_set_layout(ceph_file_layout const *l) uint64_t periods = cct->_conf->journaler_prefetch_periods; if (periods < 2) periods = 2; // we need at least 2 periods to make progress. - fetch_len = layout.fl_stripe_count * layout.fl_object_size * periods; + fetch_len = layout.get_period() * periods; } @@ -536,9 +535,8 @@ uint64_t Journaler::append_entry(bufferlist& bl) if (!cct->_conf->journaler_allow_split_entries) { // will we span a stripe boundary? - int p = layout.fl_stripe_unit; - if (write_pos / p != (write_pos + (int64_t)(bl.length() + - sizeof(s))) / p) { + int p = layout.stripe_unit; + if (write_pos / p != (write_pos + (int64_t)(bl.length() + sizeof(s))) / p) { // yes. // move write_pos forward. int64_t owp = write_pos; diff --git a/src/osdc/Journaler.h b/src/osdc/Journaler.h index da397f6391b9b..c37cfce489756 100644 --- a/src/osdc/Journaler.h +++ b/src/osdc/Journaler.h @@ -130,14 +130,14 @@ public: uint64_t unused_field; uint64_t write_pos; string magic; - ceph_file_layout layout; //< The mapping from byte stream offsets + file_layout_t layout; //< The mapping from byte stream offsets // to RADOS objects stream_format_t stream_format; //< The encoding of LogEvents // within the journal byte stream Header(const char *m="") : trimmed_pos(0), expire_pos(0), unused_field(0), write_pos(0), magic(m), - stream_format(-1) {memset(&layout, 0, sizeof(layout)); + stream_format(-1) { } void encode(bufferlist &bl) const { @@ -147,7 +147,7 @@ public: ::encode(expire_pos, bl); ::encode(unused_field, bl); ::encode(write_pos, bl); - ::encode(layout, bl); + ::encode(layout, bl, 0); // encode in legacy format ::encode(stream_format, bl); ENCODE_FINISH(bl); } @@ -175,16 +175,7 @@ public: f->dump_unsigned("expire_pos", expire_pos); f->dump_unsigned("trimmed_pos", trimmed_pos); f->dump_unsigned("stream_format", stream_format); - f->open_object_section("layout"); - { - f->dump_unsigned("stripe_unit", layout.fl_stripe_unit); - f->dump_unsigned("stripe_count", layout.fl_stripe_count); - f->dump_unsigned("object_size", layout.fl_object_size); - f->dump_unsigned("cas_hash", layout.fl_cas_hash); - f->dump_unsigned("object_stripe_unit", layout.fl_object_stripe_unit); - f->dump_unsigned("pg_pool", layout.fl_pg_pool); - } - f->close_section(); // layout + f->dump_object("layout", layout); } f->close_section(); // journal_header } @@ -223,7 +214,7 @@ private: inodeno_t ino; int64_t pg_pool; bool readonly; - ceph_file_layout layout; + file_layout_t layout; uint32_t stream_format; JournalStream journal_stream; @@ -281,7 +272,7 @@ private: friend class C_WriteHead; void _reread_head(Context *onfinish); - void _set_layout(ceph_file_layout const *l); + void _set_layout(file_layout_t const *l); list waitfor_recover; void _read_head(Context *on_finish, bufferlist *bl); void _finish_read_head(int r, bufferlist& bl); @@ -416,7 +407,6 @@ public: expire_pos(0), trimming_pos(0), trimmed_pos(0), readable(false), write_iohint(0), stopping(false) { - memset(&layout, 0, sizeof(layout)); } /* reset @@ -452,7 +442,7 @@ public: // Asynchronous operations // ======================= void erase(Context *completion); - void create(ceph_file_layout *layout, stream_format_t const sf); + void create(file_layout_t *layout, stream_format_t const sf); void recover(Context *onfinish); void reread_head(Context *onfinish); void reread_head_and_probe(Context *onfinish); @@ -463,7 +453,7 @@ public: // Synchronous setters // =================== - void set_layout(ceph_file_layout const *l); + void set_layout(file_layout_t const *l); void set_readonly(); void set_writeable(); void set_write_pos(int64_t p) { @@ -513,9 +503,9 @@ public: // =================== // TODO: need some locks on reads for true safety uint64_t get_layout_period() const { - return (uint64_t)layout.fl_stripe_count * (uint64_t)layout.fl_object_size; + return layout.get_period(); } - ceph_file_layout& get_layout() { return layout; } + file_layout_t& get_layout() { return layout; } bool is_active() { return state == STATE_ACTIVE; } int get_error() { return error; } bool is_readonly() { return readonly; } diff --git a/src/osdc/ObjectCacher.h b/src/osdc/ObjectCacher.h index 3bd9745f78b47..b95c3ba920179 100644 --- a/src/osdc/ObjectCacher.h +++ b/src/osdc/ObjectCacher.h @@ -741,7 +741,7 @@ public: // file functions /*** async+caching (non-blocking) file interface ***/ - int file_is_cached(ObjectSet *oset, ceph_file_layout *layout, + int file_is_cached(ObjectSet *oset, file_layout_t *layout, snapid_t snapid, loff_t offset, uint64_t len) { vector extents; Striper::file_to_extents(cct, oset->ino, layout, offset, len, @@ -749,7 +749,7 @@ public: return is_cached(oset, extents, snapid); } - int file_read(ObjectSet *oset, ceph_file_layout *layout, snapid_t snapid, + int file_read(ObjectSet *oset, file_layout_t *layout, snapid_t snapid, loff_t offset, uint64_t len, bufferlist *bl, int flags, Context *onfinish) { OSDRead *rd = prepare_read(snapid, bl, flags); @@ -758,7 +758,7 @@ public: return readx(rd, oset, onfinish); } - int file_write(ObjectSet *oset, ceph_file_layout *layout, + int file_write(ObjectSet *oset, file_layout_t *layout, const SnapContext& snapc, loff_t offset, uint64_t len, bufferlist& bl, ceph::real_time mtime, int flags) { OSDWrite *wr = prepare_write(snapc, bl, mtime, flags, 0); @@ -767,7 +767,7 @@ public: return writex(wr, oset, NULL); } - bool file_flush(ObjectSet *oset, ceph_file_layout *layout, + bool file_flush(ObjectSet *oset, file_layout_t *layout, const SnapContext& snapc, loff_t offset, uint64_t len, Context *onfinish) { vector extents; diff --git a/src/osdc/Striper.cc b/src/osdc/Striper.cc index f2bf8fbddcbb7..851f0673be435 100644 --- a/src/osdc/Striper.cc +++ b/src/osdc/Striper.cc @@ -27,7 +27,7 @@ void Striper::file_to_extents(CephContext *cct, const char *object_format, - const ceph_file_layout *layout, + const file_layout_t *layout, uint64_t offset, uint64_t len, uint64_t trunc_size, vector& extents, @@ -41,7 +41,7 @@ void Striper::file_to_extents(CephContext *cct, const char *object_format, void Striper::file_to_extents( CephContext *cct, const char *object_format, - const ceph_file_layout *layout, + const file_layout_t *layout, uint64_t offset, uint64_t len, uint64_t trunc_size, map >& object_extents, @@ -58,9 +58,9 @@ void Striper::file_to_extents( * buffer.. hence ObjectExtent.buffer_extents */ - __u32 object_size = layout->fl_object_size; - __u32 su = layout->fl_stripe_unit; - __u32 stripe_count = layout->fl_stripe_count; + __u32 object_size = layout->object_size; + __u32 su = layout->stripe_unit; + __u32 stripe_count = layout->stripe_count; assert(object_size >= su); if (stripe_count == 1) { ldout(cct, 20) << " sc is one, reset su to os" << dendl; @@ -161,16 +161,16 @@ void Striper::assimilate_extents( } } -void Striper::extent_to_file(CephContext *cct, ceph_file_layout *layout, +void Striper::extent_to_file(CephContext *cct, file_layout_t *layout, uint64_t objectno, uint64_t off, uint64_t len, vector >& extents) { ldout(cct, 10) << "extent_to_file " << objectno << " " << off << "~" << len << dendl; - __u32 object_size = layout->fl_object_size; - __u32 su = layout->fl_stripe_unit; - __u32 stripe_count = layout->fl_stripe_count; + __u32 object_size = layout->object_size; + __u32 su = layout->stripe_unit; + __u32 stripe_count = layout->stripe_count; assert(object_size >= su); uint64_t stripes_per_object = object_size / su; ldout(cct, 20) << " stripes_per_object " << stripes_per_object << dendl; @@ -199,16 +199,16 @@ void Striper::extent_to_file(CephContext *cct, ceph_file_layout *layout, } uint64_t Striper::object_truncate_size(CephContext *cct, - const ceph_file_layout *layout, + const file_layout_t *layout, uint64_t objectno, uint64_t trunc_size) { uint64_t obj_trunc_size; if (trunc_size == 0 || trunc_size == (uint64_t)-1) { obj_trunc_size = trunc_size; } else { - __u32 object_size = layout->fl_object_size; - __u32 su = layout->fl_stripe_unit; - __u32 stripe_count = layout->fl_stripe_count; + __u32 object_size = layout->object_size; + __u32 su = layout->stripe_unit; + __u32 stripe_count = layout->stripe_count; assert(object_size >= su); uint64_t stripes_per_object = object_size / su; @@ -237,12 +237,13 @@ uint64_t Striper::object_truncate_size(CephContext *cct, << trunc_size << "->" << obj_trunc_size << dendl; return obj_trunc_size; } -uint64_t Striper::get_num_objects(const ceph_file_layout& layout, + +uint64_t Striper::get_num_objects(const file_layout_t& layout, uint64_t size) { - __u32 object_size = layout.fl_object_size; - __u32 stripe_unit = layout.fl_stripe_unit; - __u32 stripe_count = layout.fl_stripe_count; + __u32 object_size = layout.object_size; + __u32 stripe_unit = layout.stripe_unit; + __u32 stripe_count = layout.stripe_count; uint64_t period = (uint64_t)stripe_count * object_size; uint64_t num_periods = (size + period - 1) / period; uint64_t remainder_bytes = size % period; diff --git a/src/osdc/Striper.h b/src/osdc/Striper.h index 6b5a4e3b67c02..6d110e9502fcf 100644 --- a/src/osdc/Striper.h +++ b/src/osdc/Striper.h @@ -29,21 +29,21 @@ class CephContext; * ranges in objects on (primary) osds) */ static void file_to_extents(CephContext *cct, const char *object_format, - const ceph_file_layout *layout, + const file_layout_t *layout, uint64_t offset, uint64_t len, uint64_t trunc_size, map >& extents, uint64_t buffer_offset=0); static void file_to_extents(CephContext *cct, const char *object_format, - const ceph_file_layout *layout, + const file_layout_t *layout, uint64_t offset, uint64_t len, uint64_t trunc_size, vector& extents, uint64_t buffer_offset=0); static void file_to_extents(CephContext *cct, inodeno_t ino, - const ceph_file_layout *layout, + const file_layout_t *layout, uint64_t offset, uint64_t len, uint64_t trunc_size, vector& extents) { @@ -61,15 +61,15 @@ class CephContext; /** * reverse map an object extent to file extents */ - static void extent_to_file(CephContext *cct, ceph_file_layout *layout, + static void extent_to_file(CephContext *cct, file_layout_t *layout, uint64_t objectno, uint64_t off, uint64_t len, vector >& extents); static uint64_t object_truncate_size( - CephContext *cct, const ceph_file_layout *layout, + CephContext *cct, const file_layout_t *layout, uint64_t objectno, uint64_t trunc_size); - static uint64_t get_num_objects(const ceph_file_layout& layout, + static uint64_t get_num_objects(const file_layout_t& layout, uint64_t size); /* * helper to assemble a striped result diff --git a/src/test/encoding/types.h b/src/test/encoding/types.h index fe68384033bb3..a1573da914f53 100644 --- a/src/test/encoding/types.h +++ b/src/test/encoding/types.h @@ -184,7 +184,6 @@ TYPE(quota_info_t) #include "include/fs_types.h" TYPE_FEATUREFUL(file_layout_t) -TYPE(ceph_file_layout_wrapper) #include "mds/CInode.h" TYPE_FEATUREFUL(InodeStore) diff --git a/src/test/librbd/mock/MockImageCtx.h b/src/test/librbd/mock/MockImageCtx.h index 41a6fbeb6e635..c7f2abfad3222 100644 --- a/src/test/librbd/mock/MockImageCtx.h +++ b/src/test/librbd/mock/MockImageCtx.h @@ -186,7 +186,7 @@ struct MockImageCtx { std::string id; parent_info parent_md; - ceph_file_layout layout; + file_layout_t layout; xlist*> resize_reqs; xlist*> async_requests; diff --git a/src/test/test_striper.cc b/src/test/test_striper.cc index 4676101766215..2e0c23fc6783d 100644 --- a/src/test/test_striper.cc +++ b/src/test/test_striper.cc @@ -8,12 +8,11 @@ TEST(Striper, Stripe1) { - ceph_file_layout l; - memset(&l, 0, sizeof(l)); + file_layout_t l; - l.fl_object_size = 262144; - l.fl_stripe_unit = 4096; - l.fl_stripe_count = 3; + l.object_size = 262144; + l.stripe_unit = 4096; + l.stripe_count = 3; vector ex; Striper::file_to_extents(g_ceph_context, 1, &l, 5006035, 46419, 5006035, ex); @@ -28,12 +27,11 @@ TEST(Striper, Stripe1) TEST(Striper, EmptyPartialResult) { - ceph_file_layout l; - memset(&l, 0, sizeof(l)); + file_layout_t l; - l.fl_object_size = 4194304; - l.fl_stripe_unit = 4194304; - l.fl_stripe_count = 1; + l.object_size = 4194304; + l.stripe_unit = 4194304; + l.stripe_count = 1; vector ex; Striper::file_to_extents(g_ceph_context, 1, &l, 725549056, 131072, 72554905600, ex); @@ -59,12 +57,11 @@ TEST(Striper, EmptyPartialResult) TEST(Striper, GetNumObj) { - ceph_file_layout l; - memset(&l, 0, sizeof(l)); + file_layout_t l; - l.fl_object_size = 262144; - l.fl_stripe_unit = 4096; - l.fl_stripe_count = 3; + l.object_size = 262144; + l.stripe_unit = 4096; + l.stripe_count = 3; uint64_t size,numobjs; size = 6999; numobjs = Striper::get_num_objects(l, size); diff --git a/src/tools/cephfs/DataScan.cc b/src/tools/cephfs/DataScan.cc index fd01d96ef0773..0a992a32e8f8c 100644 --- a/src/tools/cephfs/DataScan.cc +++ b/src/tools/cephfs/DataScan.cc @@ -279,8 +279,8 @@ int MetadataDriver::inject_unlinked_inode( // Force layout to default: should we let users override this so that // they don't have to mount the filesystem to correct it? - inode.inode.layout = g_default_file_layout; - inode.inode.layout.fl_pg_pool = data_pool_id; + inode.inode.layout = file_layout_t::get_default(); + inode.inode.layout.pool_id = data_pool_id; // Assume that we will get our stats wrong, and that we may // be ignoring dirfrags that exist @@ -576,7 +576,7 @@ int DataScan::scan_inodes() AccumulateResult accum_res; inode_backtrace_t backtrace; - ceph_file_layout loaded_layout = g_default_file_layout; + file_layout_t loaded_layout = file_layout_t::get_default(); r = ClsCephFSClient::fetch_inode_accumulate_result( data_io, oid, &backtrace, &loaded_layout, &accum_res); @@ -600,12 +600,12 @@ int DataScan::scan_inodes() // This is the layout we will use for injection, populated either // from loaded_layout or from best guesses - ceph_file_layout guessed_layout; - guessed_layout.fl_pg_pool = data_pool_id; + file_layout_t guessed_layout; + guessed_layout.pool_id = data_pool_id; // Calculate file_size, guess the layout if (accum_res.ceiling_obj_index > 0) { - uint32_t chunk_size = g_default_file_layout.fl_object_size; + uint32_t chunk_size = file_layout_t::get_default().object_size; // When there are multiple objects, the largest object probably // indicates the chunk size. But not necessarily, because files // can be sparse. Only make this assumption if size seen @@ -614,46 +614,46 @@ int DataScan::scan_inodes() chunk_size = accum_res.max_obj_size; } - if (loaded_layout.fl_pg_pool == uint32_t(-1)) { + if (loaded_layout.pool_id == -1) { // If no stashed layout was found, guess it - guessed_layout.fl_object_size = chunk_size; - guessed_layout.fl_stripe_unit = chunk_size; - guessed_layout.fl_stripe_count = 1; - } else if (!ceph_file_layout_is_valid(&loaded_layout) || - loaded_layout.fl_object_size < accum_res.max_obj_size) { + guessed_layout.object_size = chunk_size; + guessed_layout.stripe_unit = chunk_size; + guessed_layout.stripe_count = 1; + } else if (!loaded_layout.is_valid() || + loaded_layout.object_size < accum_res.max_obj_size) { // If the max size seen exceeds what the stashed layout claims, then // disbelieve it. Guess instead. Same for invalid layouts on disk. dout(4) << "bogus xattr layout on 0x" << std::hex << obj_name_ino << std::dec << ", ignoring in favour of best guess" << dendl; - guessed_layout.fl_object_size = chunk_size; - guessed_layout.fl_stripe_unit = chunk_size; - guessed_layout.fl_stripe_count = 1; + guessed_layout.object_size = chunk_size; + guessed_layout.stripe_unit = chunk_size; + guessed_layout.stripe_count = 1; } else { // We have a stashed layout that we can't disprove, so apply it guessed_layout = loaded_layout; dout(20) << "loaded layout from xattr:" - << " os: " << guessed_layout.fl_object_size - << " sc: " << guessed_layout.fl_stripe_count - << " su: " << guessed_layout.fl_stripe_unit + << " os: " << guessed_layout.object_size + << " sc: " << guessed_layout.stripe_count + << " su: " << guessed_layout.stripe_unit << dendl; // User might have transplanted files from a pool with a different // ID, so whatever the loaded_layout says, we'll force the injected // layout to point to the pool we really read from - guessed_layout.fl_pg_pool = data_pool_id; + guessed_layout.pool_id = data_pool_id; } - if (guessed_layout.fl_stripe_count == 1) { + if (guessed_layout.stripe_count == 1) { // Unstriped file: simple chunking - file_size = guessed_layout.fl_object_size * accum_res.ceiling_obj_index + file_size = guessed_layout.object_size * accum_res.ceiling_obj_index + accum_res.ceiling_obj_size; } else { - // Striped file: need to examine the last fl_stripe_count objects + // Striped file: need to examine the last stripe_count objects // in the file to determine the size. // How many complete (i.e. not last stripe) objects? uint64_t complete_objs = 0; - if (accum_res.ceiling_obj_index > guessed_layout.fl_stripe_count - 1) { - complete_objs = (accum_res.ceiling_obj_index / guessed_layout.fl_stripe_count) * guessed_layout.fl_stripe_count; + if (accum_res.ceiling_obj_index > guessed_layout.stripe_count - 1) { + complete_objs = (accum_res.ceiling_obj_index / guessed_layout.stripe_count) * guessed_layout.stripe_count; } else { complete_objs = 0; } @@ -681,11 +681,11 @@ int DataScan::scan_inodes() if (r == 0) { if (osize > 0) { // Upper bound within this object - uint64_t upper_size = (osize - 1) / guessed_layout.fl_stripe_unit - * (guessed_layout.fl_stripe_unit * guessed_layout.fl_stripe_count) - + (i % guessed_layout.fl_stripe_count) - * guessed_layout.fl_stripe_unit + (osize - 1) - % guessed_layout.fl_stripe_unit + 1; + uint64_t upper_size = (osize - 1) / guessed_layout.stripe_unit + * (guessed_layout.stripe_unit * guessed_layout.stripe_count) + + (i % guessed_layout.stripe_count) + * guessed_layout.stripe_unit + (osize - 1) + % guessed_layout.stripe_unit + 1; incomplete_size = MAX(incomplete_size, upper_size); } } else if (r == -ENOENT) { @@ -700,16 +700,16 @@ int DataScan::scan_inodes() << obj_name_ino << std::dec << ": " << cpp_strerror(r) << dendl; return r; } - file_size = complete_objs * guessed_layout.fl_object_size + file_size = complete_objs * guessed_layout.object_size + incomplete_size; } } else { file_size = accum_res.ceiling_obj_size; - if (loaded_layout.fl_pg_pool == uint32_t(-1) - || loaded_layout.fl_object_size < accum_res.max_obj_size) { + if (loaded_layout.pool_id < 0 + || loaded_layout.object_size < accum_res.max_obj_size) { // No layout loaded, or inconsistent layout, use default - guessed_layout = g_default_file_layout; - guessed_layout.fl_pg_pool = data_pool_id; + guessed_layout = file_layout_t::get_default(); + guessed_layout.pool_id = data_pool_id; } else { guessed_layout = loaded_layout; } @@ -815,8 +815,7 @@ int DataScan::scan_frags() // Default to inherit layout (i.e. no explicit layout on dir) which is // expressed as a zeroed layout struct (see inode_t::has_layout) - ceph_file_layout loaded_layout; - memset(&loaded_layout, 0, sizeof(loaded_layout)); + file_layout_t loaded_layout; int parent_r = 0; bufferlist parent_bl; @@ -1027,8 +1026,7 @@ int MetadataDriver::inject_lost_and_found( // To have a directory not specify a layout, give it zeros (see // inode_t::has_layout) - ceph_file_layout inherit_layout; - memset(&inherit_layout, 0, sizeof(inherit_layout)); + file_layout_t inherit_layout; // Construct LF inode build_dir_dentry(CEPH_INO_LOST_AND_FOUND, 1, 0, inherit_layout, &lf_ino); @@ -1531,7 +1529,8 @@ int LocalFileDriver::inject_with_backtrace( if (is_file) { // FIXME: inject_data won't cope with interesting (i.e. striped) // layouts (need a librados-compatible Filer to read these) - inject_data(path_builder, dentry.inode.size, dentry.inode.layout.fl_object_size, bt.ino); + inject_data(path_builder, dentry.inode.size, + dentry.inode.layout.object_size, bt.ino); } else { int r = mkdir(path_builder.c_str(), 0755); if (r != 0 && r != -EPERM) { @@ -1558,7 +1557,8 @@ int LocalFileDriver::inject_lost_and_found( } std::string file_path = lf_path + "/" + lost_found_dname(ino); - return inject_data(file_path, dentry.inode.size, dentry.inode.layout.fl_object_size, ino); + return inject_data(file_path, dentry.inode.size, + dentry.inode.layout.object_size, ino); } int LocalFileDriver::init_roots(int64_t data_pool_id) @@ -1598,7 +1598,7 @@ int LocalFileDriver::check_roots(bool *result) void MetadataTool::build_file_dentry( inodeno_t ino, uint64_t file_size, time_t file_mtime, - const ceph_file_layout &layout, InodeStore *out) + const file_layout_t &layout, InodeStore *out) { assert(out != NULL); @@ -1626,7 +1626,7 @@ void MetadataTool::build_file_dentry( void MetadataTool::build_dir_dentry( inodeno_t ino, uint64_t nfiles, - time_t mtime, const ceph_file_layout &layout, InodeStore *out) + time_t mtime, const file_layout_t &layout, InodeStore *out) { assert(out != NULL); diff --git a/src/tools/cephfs/DataScan.h b/src/tools/cephfs/DataScan.h index ad6309c928d28..67c076098c783 100644 --- a/src/tools/cephfs/DataScan.h +++ b/src/tools/cephfs/DataScan.h @@ -142,7 +142,7 @@ class MetadataTool */ void build_file_dentry( inodeno_t ino, uint64_t file_size, time_t file_mtime, - const ceph_file_layout &layout, + const file_layout_t &layout, InodeStore *out); /** @@ -151,7 +151,7 @@ class MetadataTool void build_dir_dentry( inodeno_t ino, uint64_t nfiles, time_t mtime, - const ceph_file_layout &layout, + const file_layout_t &layout, InodeStore *out); /** diff --git a/src/tools/cephfs/Dumper.cc b/src/tools/cephfs/Dumper.cc index 02e1202d89d91..3344b0daf6dec 100644 --- a/src/tools/cephfs/Dumper.cc +++ b/src/tools/cephfs/Dumper.cc @@ -204,7 +204,7 @@ int Dumper::undump(const char *dump_file) } else { // Old format dump, any untrimmed objects before expire_pos will // be discarded as trash. - trimmed_pos = start - (start % g_default_file_layout.fl_object_size); + trimmed_pos = start - (start % file_layout_t::get_default().object_size); } if (trimmed_pos > start) { @@ -234,8 +234,8 @@ int Dumper::undump(const char *dump_file) h.stream_format = format; h.magic = CEPH_FS_ONDISK_MAGIC; - h.layout = g_default_file_layout; - h.layout.fl_pg_pool = mdsmap->get_metadata_pool(); + h.layout = file_layout_t::get_default(); + h.layout.pool_id = mdsmap->get_metadata_pool(); bufferlist hbl; ::encode(h, hbl); @@ -267,7 +267,7 @@ int Dumper::undump(const char *dump_file) * will be taken care of during normal operation by Journaler's * prezeroing behaviour */ { - uint32_t const object_size = h.layout.fl_object_size; + uint32_t const object_size = h.layout.object_size; assert(object_size > 0); uint64_t const last_obj = h.write_pos / object_size; uint64_t const purge_count = 2; diff --git a/src/tools/cephfs/JournalScanner.cc b/src/tools/cephfs/JournalScanner.cc index f2d22d0c230d4..7df93900f0b76 100644 --- a/src/tools/cephfs/JournalScanner.cc +++ b/src/tools/cephfs/JournalScanner.cc @@ -137,7 +137,7 @@ int JournalScanner::scan_events() uint64_t object_size = g_conf->mds_log_segment_size; if (object_size == 0) { // Default layout object size - object_size = g_default_file_layout.fl_object_size; + object_size = file_layout_t::get_default().object_size; } uint64_t read_offset = header->expire_pos; diff --git a/src/tools/cephfs/JournalTool.cc b/src/tools/cephfs/JournalTool.cc index 9311eeaf5e3e4..4be47b2b239c9 100644 --- a/src/tools/cephfs/JournalTool.cc +++ b/src/tools/cephfs/JournalTool.cc @@ -1126,7 +1126,7 @@ int JournalTool::erase_region(JournalScanner const &js, uint64_t const pos, uint uint32_t object_size = g_conf->mds_log_segment_size; if (object_size == 0) { // Default layout object size - object_size = g_default_file_layout.fl_object_size; + object_size = file_layout_t::get_default().object_size; } uint64_t write_offset = pos; diff --git a/src/tools/cephfs/Resetter.cc b/src/tools/cephfs/Resetter.cc index 78f20cdd177e9..b255f9ee7bb83 100644 --- a/src/tools/cephfs/Resetter.cc +++ b/src/tools/cephfs/Resetter.cc @@ -126,7 +126,7 @@ int Resetter::reset_hard(int rank) objecter, 0, 0, &timer, &finisher); journaler.set_writeable(); - ceph_file_layout default_log_layout = MDCache::gen_default_log_layout(*mdsmap); + file_layout_t default_log_layout = MDCache::gen_default_log_layout(*mdsmap); journaler.create(&default_log_layout, g_conf->mds_journal_format); C_SaferCond cond; diff --git a/src/tools/psim.cc b/src/tools/psim.cc index 04a1987d2ec36..90e6fb95899fb 100644 --- a/src/tools/psim.cc +++ b/src/tools/psim.cc @@ -57,7 +57,6 @@ int main(int argc, char **argv) snprintf(foo, sizeof(foo), "%d.%d", f, b); object_t oid(foo); ceph_object_layout l = osdmap.make_object_layout(oid, 0, nspace); - //osdmap.file_to_object_layout(oid, g_default_file_layout); vector osds; pg_t pgid = pg_t(l.ol_pgid); //pgid.u.ps = f * 4 + b; -- 2.39.5