]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/newstore: set alloc hint on new frags
authorSage Weil <sage@redhat.com>
Tue, 6 Oct 2015 01:42:09 +0000 (21:42 -0400)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:05:17 +0000 (13:05 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/newstore/NewStore.cc
src/os/newstore/NewStore.h

index d02561ba23db419ba34b2d5c03426a235ae77839..19daad887cb2b9c70807043d9ef3df24f976f562 100644 (file)
@@ -2077,7 +2077,8 @@ int NewStore::_open_fid(fid_t fid, unsigned flags)
   return fd;
 }
 
-int NewStore::_create_fid(TransContext *txc, fid_t *fid, unsigned flags)
+int NewStore::_create_fid(TransContext *txc, OnodeRef o,
+                         fid_t *fid, unsigned flags)
 {
   {
     Mutex::Locker l(fid_lock);
@@ -2088,7 +2089,8 @@ int NewStore::_create_fid(TransContext *txc, fid_t *fid, unsigned flags)
       ++fid_last.fno;
       if (fid_last.fno >= fid_max.fno) {
        // raise fid_max, same fset, capping to max_dir_size
-       fid_max.fno = min(fid_max.fno + g_conf->newstore_fid_prealloc, g_conf->newstore_max_dir_size);
+       fid_max.fno = min(fid_max.fno + g_conf->newstore_fid_prealloc,
+                         g_conf->newstore_max_dir_size);
        assert(fid_max.fno >= fid_last.fno);
        bufferlist bl;
        ::encode(fid_max, bl);
@@ -2139,6 +2141,13 @@ int NewStore::_create_fid(TransContext *txc, fid_t *fid, unsigned flags)
     return r;
   }
 
+  if (o->onode.expected_object_size) {
+    unsigned hint = MIN(o->onode.expected_object_size,
+                       o->onode.frag_size);
+    dout(20) << __func__ << " set alloc hint to " << hint << dendl;
+    fs->set_alloc_hint(fd, hint);
+  }
+
   if (g_conf->newstore_open_by_handle) {
     int r = fs->get_handle(fd, &fid->handle);
     if (r < 0) {
@@ -3349,7 +3358,7 @@ int NewStore::_do_write_all_overlays(TransContext *txc,
        f->offset = 0;
        f->length = p->first + p->second.length - frag_first;
        assert(f->length <= o->onode.frag_size);
-       int fd = _create_fid(txc, &f->fid, O_RDWR);
+       int fd = _create_fid(txc, o, &f->fid, O_RDWR);
        if (fd < 0) {
          return fd;
        }
@@ -3591,7 +3600,7 @@ int NewStore::_do_write(TransContext *txc,
       f.offset = 0;
       f.length = MIN(frag_size, o->onode.size - frag_first);
       assert(f.length <= frag_size);
-      fd = _create_fid(txc, &f.fid, flags);
+      fd = _create_fid(txc, o, &f.fid, flags);
       if (fd < 0) {
        r = fd;
        goto out;
@@ -3635,7 +3644,7 @@ int NewStore::_do_write(TransContext *txc,
       op->fid = fp->second.fid;
 
       f.length = length;
-      fd = _create_fid(txc, &f.fid, O_RDWR);
+      fd = _create_fid(txc, o, &f.fid, O_RDWR);
       if (fd < 0) {
        r = fd;
        goto out;
index fa7b5042bab98f3ec7dc3d3f7327dba2dd3d46df..bef60cdd70d0fd6385737848c45fd02894c675fc 100644 (file)
@@ -536,7 +536,7 @@ private:
   void _reap_collections();
 
   int _recover_next_fid();
-  int _create_fid(TransContext *txc, fid_t *fid, unsigned flags);
+  int _create_fid(TransContext *txc, OnodeRef o, fid_t *fid, unsigned flags);
   int _open_fid(fid_t fid, unsigned flags);
   int _remove_fid(fid_t fid);