]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Merge branch 'next'
authorSage Weil <sage@newdream.net>
Thu, 23 Jun 2011 20:24:35 +0000 (13:24 -0700)
committerSage Weil <sage@newdream.net>
Thu, 23 Jun 2011 20:24:35 +0000 (13:24 -0700)
Conflicts:
src/librbd.cc

1  2 
src/Makefile.am
src/common/ProfLogger.cc
src/common/ceph_argparse.cc
src/librbd.cc

diff --cc src/Makefile.am
Simple merge
index a1a780a3204568d6b807ad369eea711a2fd30231,dee2f363ffb66d2bd3fa713e6577c867a2b1cf29..ac8ec2ff6617c72280b0d45c47966cabcb509919
  
  #include "common/Timer.h"
  
 -// per-process lock.  lame, but this way I protect ProfLogType too!
 -Mutex prof_logger_lock("prof_logger_lock");
 -SafeTimer logger_timer(prof_logger_lock);
 -Context *logger_event = 0;
 -list<ProfLogger*> logger_list;
 -utime_t start;
 -int last_flush = 0; // in seconds since start
 -
 -bool logger_need_reopen = true;
 -bool logger_need_reset = false;
 -
 -static void flush_all_loggers();
 -static void stop();
 -
 -struct FlusherStopper {
 -  ~FlusherStopper() {
 -    stop();
 +//////////////// C_FlushProfLoggers ////////////////
 +class C_FlushProfLoggers : public Context
 +{
 +public:
 +  C_FlushProfLoggers(ProfLoggerCollection *coll_)
 +    : coll(coll_)
 +  {
    }
 -} stopper;
  
 -class C_FlushProfLoggers : public Context {
 -public:
    void finish(int r) {
 -    if (logger_event == this) {
 -      logger_event = 0;
 -      flush_all_loggers();
 -    }
 +    coll->flush_all_loggers();
    }
 -};
  
 -ProfLoggerConfObs::~ProfLoggerConfObs()
 -{
 -}
 +private:
 +  ProfLoggerCollection *coll;
 +};
  
 -const char **ProfLoggerConfObs::get_tracked_conf_keys() const
 +//////////////// ProfLoggerCollection ////////////////
 +ProfLoggerCollection::
 +ProfLoggerCollection(CephContext *cct_)
 +  : lock("ProfLoggerCollection::lock"),
 +    logger_timer(cct_, lock), logger_event(NULL),
 +    last_flush(0), need_reopen(true), need_reset(false), cct(cct_)
  {
 -  static const char *KEYS[] = {
 -    "profiling_logger", "profiling_logger_interval", "profiling_logger_calc_variance",
 -    "profiling_logger_subdir", "profiling_logger_dir", NULL
 -  };
 -  return KEYS;
  }
  
 -void ProfLoggerConfObs::handle_conf_change(const md_config_t *conf,
 -                        const std::set <std::string> &changed)
 +ProfLoggerCollection::
 +~ProfLoggerCollection()
  {
 -  // This could be done a *lot* smarter, if anyone cares to spend time
 -  // fixing this up.
 -  // We could probably just take the mutex and call _open_log from here.
 -  logger_reopen_all();
 +  try {
 +    lock.Lock();
 +    logger_timer.shutdown();
 +    lock.Unlock();
 +  }
 +  catch (...) {
 +  }
  }
  
 -void logger_reopen_all()
 +void ProfLoggerCollection::
 +logger_reopen_all()
  {
 -  logger_need_reopen = true;
 +  Mutex::Locker l(lock);
 +  need_reopen = true;
  }
  
 -void logger_reset_all()
 +void ProfLoggerCollection::
 +logger_reset_all()
  {
 -  logger_need_reopen = true;
 -  logger_need_reset = true;
 +  Mutex::Locker l(lock);
 +  need_reopen = true;
 +  need_reset = true;
  }
  
 -void logger_start()
 +void ProfLoggerCollection::
 +logger_start()
  {
 -  Mutex::Locker l(prof_logger_lock);
 +  Mutex::Locker l(lock);
    logger_timer.init();
-   flush_all_loggers();
+   if (!logger_event)
+     flush_all_loggers();
  }
  
 -void logger_tare(utime_t s)
 +void ProfLoggerCollection::
 +logger_tare(utime_t s)
  {
 -  Mutex::Locker l(prof_logger_lock);
 +  Mutex::Locker l(lock);
  
 -  generic_dout(10) << "logger_tare " << s << dendl;
 +  ldout(cct, 10) << "logger_tare " << s << dendl;
  
    start = s;
  
Simple merge
diff --cc src/librbd.cc
index 1cd8df674c528207c6727e3c478c2a1a4fe46e9e,16e882fff57b71d2c90238f98026fa89c0f392f8..54daffbbe36f4891fadade49dbbbe7994487e7f1
@@@ -1261,29 -1256,32 +1261,32 @@@ void AioBlockCompletion::complete(ssize
    if ((r >= 0 || r == -ENOENT) && buf) { // this was a sparse_read operation
      map<uint64_t, uint64_t>::iterator iter;
      uint64_t bl_ofs = 0, buf_bl_pos = 0;
 -    dout(10) << "ofs=" << ofs << " len=" << len << dendl;
 +    ldout(cct, 10) << "ofs=" << ofs << " len=" << len << dendl;
+     uint64_t block_ofs = ofs;
      for (iter = m.begin(); iter != m.end(); ++iter) {
        uint64_t extent_ofs = iter->first;
        size_t extent_len = iter->second;
  
 -      dout(10) << "extent_ofs=" << extent_ofs << " extent_len=" << extent_len << dendl;
 -      dout(10) << "block_ofs=" << block_ofs << dendl;
 -
 +      ldout(cct, 10) << "extent_ofs=" << extent_ofs << " extent_len=" << extent_len << dendl;
++      ldout(cct, 10) << "block_ofs=" << block_ofs << dendl;
++      
        /* a hole? */
        if (extent_ofs - block_ofs > 0) {
 -      dout(10) << "<1>zeroing " << buf_bl_pos << "~" << extent_ofs << dendl;
 -        dout(10) << "buf=" << (void *)(buf + buf_bl_pos) << "~" << (void *)(buf + extent_ofs - ofs - 1) << dendl;
 +      ldout(cct, 10) << "<1>zeroing " << buf_bl_pos << "~" << extent_ofs << dendl;
-         ldout(cct, 10) << "buf=" << (void *)(buf + buf_bl_pos) << "~" << (void *)(buf + extent_ofs - ofs - 1) << dendl;
-         memset(buf + buf_bl_pos, 0, extent_ofs - ofs);
++      ldout(cct, 10) << "buf=" << (void *)(buf + buf_bl_pos) << "~" << (void *)(buf + extent_ofs - ofs - 1) << dendl;
+         memset(buf + buf_bl_pos, 0, extent_ofs - block_ofs);
        }
  
        if (bl_ofs + extent_len > len) {
          r = -EIO;
        break;
        }
-       buf_bl_pos += extent_ofs - ofs;
+       buf_bl_pos += extent_ofs - block_ofs;
+       block_ofs = extent_ofs;
  
        /* data */
 -      dout(10) << "<2>copying " << buf_bl_pos << "~" << extent_len << " from ofs=" << bl_ofs << dendl;
 -      dout(10) << "buf=" << (void *)(buf + buf_bl_pos) << "~" << (void *)(buf + buf_bl_pos + extent_len -1) << dendl;
 +      ldout(cct, 10) << "<2>copying " << buf_bl_pos << "~" << extent_len << " from ofs=" << bl_ofs << dendl;
 +      ldout(cct, 10) << "buf=" << (void *)(buf + buf_bl_pos) << "~" << (void *)(buf + buf_bl_pos + extent_len -1) << dendl;
        memcpy(buf + buf_bl_pos, data_bl.c_str() + bl_ofs, extent_len);
        bl_ofs += extent_len;
        buf_bl_pos += extent_len;