]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
struct ceph_file_layout -> file_layout_t
authorSage Weil <sage@redhat.com>
Mon, 4 Jan 2016 15:44:53 +0000 (10:44 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Mar 2016 16:18:16 +0000 (11:18 -0500)
- 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 <sage@redhat.com>
50 files changed:
src/client/Client.cc
src/client/Client.h
src/client/Inode.cc
src/client/Inode.h
src/client/fuse_ll.cc
src/cls/cephfs/cls_cephfs_client.cc
src/cls/cephfs/cls_cephfs_client.h
src/common/config.cc
src/common/config.h
src/common/config_opts.h
src/include/fs_types.h
src/libcephfs.cc
src/libradosstriper/RadosStriperImpl.cc
src/librbd/AioImageRequest.cc
src/librbd/AioObjectRequest.cc
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/LibrbdWriteback.cc
src/librbd/internal.cc
src/mds/CInode.cc
src/mds/Locker.cc
src/mds/Locker.h
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDLog.cc
src/mds/Server.cc
src/mds/Server.h
src/mds/StrayManager.cc
src/mds/mdstypes.cc
src/mds/mdstypes.h
src/messages/MClientCaps.h
src/messages/MClientReply.h
src/osd/OSDMap.h
src/osdc/Filer.cc
src/osdc/Filer.h
src/osdc/Journaler.cc
src/osdc/Journaler.h
src/osdc/ObjectCacher.h
src/osdc/Striper.cc
src/osdc/Striper.h
src/test/encoding/types.h
src/test/librbd/mock/MockImageCtx.h
src/test/test_striper.cc
src/tools/cephfs/DataScan.cc
src/tools/cephfs/DataScan.h
src/tools/cephfs/Dumper.cc
src/tools/cephfs/JournalScanner.cc
src/tools/cephfs/JournalTool.cc
src/tools/cephfs/Resetter.cc
src/tools/psim.cc

index 03049d028df2cb537e30ed6b2fd166c6bc42e6ff..2171f913a63c1e0892da8c04923f5bdeecfe7896 100644 (file)
@@ -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<uint64_t> 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<int> 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<int>& 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<int64_t, int>::iterator it = pool_perms.find(pool);
index ccee4862016d797bd001edde705681e421335653..34fc602e918df426d599b3dc3bf658eeadd15e44 100644 (file)
@@ -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<entity_addr_t>& address);
   int get_file_extent_osds(int fd, loff_t off, loff_t *len, vector<int>& 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);
index 14ff341e0d09c58c1bf1a2c66392cf5ac0268101..51c9d6299018c556822016883764465e1ddef7ad 100644 (file)
@@ -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);
index dd2ad995e83ebb14f24d7c31defbaf6548bf296b..928aaee88187dccbeb795aee1aba5369c4a52875 100644 (file)
@@ -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<MetaRequest*> 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(&quota, 0, sizeof(quota));
   }
   ~Inode() { }
index bc55ffdf8226fa92c89bbf9f2e0eb75078104fa3..793cc4d1ab990e551ade3537f3f933cf0c399722 100644 (file)
@@ -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;
index dc945282b90740cf0bb6ea1261b87c67fb843b21..9bc97aeb055fb7cc5ed4dbfe038d4668e13c78b2 100644 (file)
@@ -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);
index ddd84566d067f307b7a979c7e5920c4e916ccaaf..51d12231230eb98cf11eb126c732be394b19d108 100644 (file)
@@ -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(
index 28067b0607df166aa42e077b8726d49e0b410496..562582b11e8d509af59c914841619c690ce552b2 100644 (file)
@@ -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)
 
index 79c443786cf845bd11607cb500c4d238d7cc12c4..7663c8f54696dfcc64ffd4a875f79808d2ae2154 100644 (file)
@@ -15,8 +15,6 @@
 #ifndef CEPH_CONFIG_H
 #define CEPH_CONFIG_H
 
-extern struct ceph_file_layout g_default_file_layout;
-
 #include <iosfwd>
 #include <vector>
 #include <map>
index 03d4c6abf00844b41054e75ffb6df109afa58d39..9681762dfac4a2325f4cef39299dc78bb6e3cb39 100644 (file)
@@ -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
index bc5ef204032319bea4fd63105299ae55e8bd1721..388508b1d5e82b0cbeeac07d949ed48d292adb94 100644 (file)
@@ -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
index 400669abbaa8872287df0049f469ba69de121adc..5ad03a980050bef231125c2423ded1ffcaaeb0d6 100644 (file)
@@ -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)
index 5fdb8563b78195ee3f41d200e40791ebbd149db8..26833eab75db157552deaa26d99eded75ca52a8a 100644 (file)
@@ -467,7 +467,10 @@ int libradosstriper::RadosStriperImpl::aio_read(const std::string& soid,
   vector<ObjectExtent> *extents = new vector<ObjectExtent>();
   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<ObjectExtent> 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<ObjectExtent>::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<std::string, bufferlist> 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);
index 7e0e0fb861dec1182c5e82663383a406e705241d..e7cfd393167ea929120a09e5ee804b73a250344b 100644 (file)
@@ -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);
index 96669eadbe472af456a872bc9585e98b9228a331..9dee9025c141785b65bdb97562411ab96da32fd8 100644 (file)
@@ -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);
index e91000357a0503f31edb9f2947c90c4b37d9d2ce..1603926d837fd9dceb877b4ef842e31965b6062d 100644 (file)
@@ -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<ThreadPoolSingleton>(
@@ -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;
index 0d84f0caad3709e5459bbbfd4b85638eeaeeb600..01e7c4371ed7bd1afee24f39cff2220ca11018d0 100644 (file)
@@ -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;
index 7a02e6a1a3d28b03623370973f2ce0b942df324a..231c9b12e6dbcfd2fca96e1dce25960f46d304a3 100644 (file)
@@ -218,7 +218,7 @@ namespace librbd {
     // reverse map this object extent onto the parent
     vector<pair<uint64_t,uint64_t> > 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;
index 1d76a2e5beacb69dbc030e8258638229395c14e8..f195bb976aa598d22abc78efcb2806319a2879cf 100644 (file)
@@ -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;
index c9fe8ee3645a4d607e36c879154cff876ee9755a..cd247cb14a63cef8032c83545ab849b3d7721b14 100644 (file)
@@ -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<string,bufferptr> *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;
index 25977fbe26be3e21650276370d63307ebd6703bf..d500f4fb047bc28403011611ef433f81205f9b30 100644 (file)
@@ -155,7 +155,7 @@ void Locker::include_snap_rdlocks(set<SimpleLock*>& rdlocks, CInode *in)
 }
 
 void Locker::include_snap_rdlocks_wlayout(set<SimpleLock*>& rdlocks, CInode *in,
-                                  ceph_file_layout **layout)
+                                         file_layout_t **layout)
 {
   //rdlock ancestor snaps
   CInode *t = in;
index 8a6581f063dd25d563e354d5dbe5169f6f85b424..653988ecfb756169dfcbd4ceb5f186df3f9cadbb 100644 (file)
@@ -72,7 +72,7 @@ protected:
 public:
   void include_snap_rdlocks(set<SimpleLock*>& rdlocks, CInode *in);
   void include_snap_rdlocks_wlayout(set<SimpleLock*>& rdlocks, CInode *in,
-                                    ceph_file_layout **layout);
+                                    file_layout_t **layout);
 
   bool acquire_locks(MDRequestRef& mdr,
                     set<SimpleLock*> &rdlocks,
index aff51be39a5b604856257d36d3a379d3121941ef..6c5d1e3cbd53147ea3dc346c9898d9ab314f1c3a 100644 (file)
 
 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);
   }
index 6b054130dd8c05ac7af34f1e13eba75e70ee52ba..36ec842be7c7e2f974d5c2f661aef50b2cab65b8 100644 (file)
@@ -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();
 
index fce20124687a2f82fce3029a337298693e23c195..b3218a8ec3dac3847c125eb5dda92c2f7f3cfb53 100644 (file)
@@ -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);
 
index ecd45a321aeb0b33f3f5dcea6eb0cc972a65387d..a08296f7a9fa7c75ae9db4db51ef6b4144b98e1f 100644 (file)
@@ -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<SimpleLock*>& rdlocks, set<SimpleLock*>& wrlocks, set<SimpleLock*>& 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<SimpleLock*> 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<SimpleLock*> 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<unsigned>(value);
+      layout->object_size = boost::lexical_cast<unsigned>(value);
     } else if (name == "layout.stripe_unit") {
-      layout->fl_stripe_unit = boost::lexical_cast<unsigned>(value);
+      layout->stripe_unit = boost::lexical_cast<unsigned>(value);
     } else if (name == "layout.stripe_count") {
-      layout->fl_stripe_count = boost::lexical_cast<unsigned>(value);
+      layout->stripe_count = boost::lexical_cast<unsigned>(value);
     } else if (name == "layout.pool") {
       try {
-       layout->fl_pg_pool = boost::lexical_cast<unsigned>(value);
+       layout->pool_id = boost::lexical_cast<unsigned>(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<SimpleLock*> rdlocks,
                               set<SimpleLock*> wrlocks,
                               set<SimpleLock*> 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<SimpleLock*> 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<SimpleLock*> 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<SimpleLock*> 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
index 40c71f76fc87f51e8461375a944477235c50b7a8..66aa6b9e4449de9efdbfe15103fa9c6d2f6e5c22 100644 (file)
@@ -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<SimpleLock*>& 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<SimpleLock*>& rdlocks,
                                     set<SimpleLock*>& wrlocks,
                                    set<SimpleLock*>& 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<SimpleLock*> rdlocks,
                         set<SimpleLock*> wrlocks,
                         set<SimpleLock*> xlocks);
index 6547a264120c45bad578c73337c56caf616c3058..868d49a1d1f3d5fb59d9a554a784ea078d199040 100644 (file)
@@ -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
index 63c95eb0457d08024a7e30775a5a6b175868720d..8fcf03a7c92c7b3cf820f13628c868babfe2d220 100644 (file)
@@ -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<int64_t>::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<const ceph_file_layout&>(*this), f);
-}
 
index 173995d111f4755f1d2141aa47e1b9e687ca90ad..02e09cd59a424accdccab24a2bd2b2d3d8de380e 100644 (file)
@@ -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 <int64_t> 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<const ceph_file_layout&>(*this), bl);
-  }
-
-  void decode(bufferlist::iterator &p)
-  {
-    ::decode(static_cast<ceph_file_layout&>(*this), p);
-  }
-
-  static void generate_test_instances(std::list<ceph_file_layout_wrapper*>& ls)
-  {
-  }
-
-  void dump(Formatter *f) const;
-};
-
 // parse a map of keys/values.
 namespace qi = boost::spirit::qi;
 
index d9450dfff41dd7839010e55e7a43ec0c37b88345..f668ea73097aaee521d5846b351fada9dc3beaee 100644 (file)
@@ -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);
index f0e51ab3cd488ea2c1fff2bc5dd2b4007958cf5c..e723557fd3b36b01d119613f72a0f02dc6c59451 100644 (file)
@@ -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;
index 46b51f36a1027d24d4444621017a3ea3e53f5f56..9a5cd88a7adca422103b416e6d05a1833e0362b7 100644 (file)
@@ -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
   {
index bf5f23c131b18bfe254136f4bc56db3aa9544d84..f64a122534841c7fa276d2e79ad57b9d0d92c81b 100644 (file)
@@ -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<std::mutex> lock_guard;
   typedef std::unique_lock<std::mutex> 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,
index 0c7b862de0330c23d4738104149ff8f2021f8b02..96c11b80461a065eef146d89cb5fae22e9bada0b 100644 (file)
@@ -56,7 +56,7 @@ class Filer {
     typedef std::lock_guard<std::mutex> lock_guard;
     typedef std::unique_lock<std::mutex> 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<ObjectExtent> 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<ObjectExtent>::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);
 };
 
index 487bb60b5a63b598ccd7cd5803cc8c2e3c8ef125..fb38a08cd1836a322b68e9559ae1376e9a4e3414 100644 (file)
@@ -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;
index da397f6391b9b442b72d77ea689cbef923064a1b..c37cfce489756e97d682082d30e4fce33be611ac 100644 (file)
@@ -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<Context*> 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; }
index 3bd9745f78b473130722dfdc2e7c3323b44bfbe0..b95c3ba920179fb8d31d461d1500042e4f4c98ac 100644 (file)
@@ -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<ObjectExtent> 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<ObjectExtent> extents;
index f2bf8fbddcbb7c31695941fc349b9fc762a03c4e..851f0673be4351a55b021c4807551a51a5e3f6ed 100644 (file)
@@ -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<ObjectExtent>& 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_t,vector<ObjectExtent> >& 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<pair<uint64_t, uint64_t> >& 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;
index 6b5a4e3b67c029c60910a962bd61bb68de30fd08..6d110e9502fcf836c295ef12786b8a540b817fb3 100644 (file)
@@ -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<object_t, vector<ObjectExtent> >& 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<ObjectExtent>& 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<ObjectExtent>& 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<pair<uint64_t, uint64_t> >& 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
index fe68384033bb329758cc9178e055da14a19e7e06..a1573da914f53652f3e0cad3c6f8adc96240d293 100644 (file)
@@ -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)
index 41a6fbeb6e635687addfa05db6d0fe15d7888b0a..c7f2abfad3222b23054904763a974aaee67d9a9e 100644 (file)
@@ -186,7 +186,7 @@ struct MockImageCtx {
   std::string id;
   parent_info parent_md;
 
-  ceph_file_layout layout;
+  file_layout_t layout;
 
   xlist<operation::ResizeRequest<MockImageCtx>*> resize_reqs;
   xlist<AsyncRequest<MockImageCtx>*> async_requests;
index 4676101766215b4f286a4c7b4d336f49d01177e6..2e0c23fc6783d5e27627a7fea13d26a0790ce683 100644 (file)
@@ -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<ObjectExtent> 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<ObjectExtent> 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);
index fd01d96ef077394da44c9101a4726bf2fc2bc775..0a992a32e8f8ceea4f40ec8cd25a79664796ca06 100644 (file)
@@ -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);
 
index ad6309c928d285af8ef09b7d2b4f8758018cb05d..67c076098c783fee5feb9b2d08361e0c03e97c1b 100644 (file)
@@ -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);
 
   /**
index 02e1202d89d91567fc814ecafa7892fcb7e0fc9c..3344b0daf6dec393331fd11fe38eeb6bd3f61394 100644 (file)
@@ -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;
index f2d22d0c230d4686d4f05731c546148eb3817135..7df93900f0b76dbf884a6689bff416b0ca37d1b7 100644 (file)
@@ -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;
index 9311eeaf5e3e4d1853ed249d615a53ce12d6b7d8..4be47b2b239c92c45f871390272e60069938bb13 100644 (file)
@@ -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;
index 78f20cdd177e9fb7a9d1ce4f33908ffd5dc222ba..b255f9ee7bb8385610bbfac8b60cd456f0d8b452 100644 (file)
@@ -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;
index 04a1987d2ec36eabaa0ef9036b58434be0715100..90e6fb95899fb27f775e4f3b2e45bb8d4875ddf4 100644 (file)
@@ -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<int> osds;
       pg_t pgid = pg_t(l.ol_pgid);
       //pgid.u.ps = f * 4 + b;