]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Journaler: use uint64_6 instead of int64_t.
authorGreg Farnum <gregf@hq.newdream.net>
Fri, 19 Nov 2010 18:36:40 +0000 (10:36 -0800)
committerGreg Farnum <gregf@hq.newdream.net>
Thu, 6 Jan 2011 18:35:24 +0000 (10:35 -0800)
Since the values can never be negative, this is far more appropriate,
and it results in fewer casts than the other way around.

Signed-off-by: Greg Farnum <gregf@hq.newdream.net>
src/osdc/Journaler.cc
src/osdc/Journaler.h

index 8462e1b9d48b790ea68610aac3213aaf332e579e..5d98aeb1b692b31bbcc6cb99df3acc90a89c16c0 100644 (file)
@@ -79,7 +79,7 @@ public:
 class Journaler::C_ProbeEnd : public Context {
   Journaler *ls;
 public:
-  int64_t end;
+  uint64_t end;
   C_ProbeEnd(Journaler *l) : ls(l), end(-1) {}
   void finish(int r) {
     ls->_finish_probe_end(r, end);
@@ -185,7 +185,7 @@ void Journaler::_finish_read_head(int r, bufferlist& bl)
   dout(1) << "_finish_read_head " << h << ".  probing for end of log (from " << write_pos << ")..." << dendl;
   C_ProbeEnd *fin = new C_ProbeEnd(this);
   state = STATE_PROBING;
-  probe(fin, (uint64_t*)&fin->end);
+  probe(fin, &fin->end);
 }
 
 void Journaler::probe(Context *finish, uint64_t *end)
@@ -216,11 +216,11 @@ void Journaler::reprobe()
   state = STATE_ACTIVE;
 }
 
-void Journaler::_finish_probe_end(int r, int64_t end)
+void Journaler::_finish_probe_end(int r, uint64_t end)
 {
   assert(state == STATE_PROBING);
   
-  if (end == -1) {
+  if (((int64_t)end) == -1) {
     end = write_pos;
     dout(1) << "_finish_probe_end write_pos = " << end 
            << " (header had " << write_pos << "). log was empty. recovered."
@@ -299,7 +299,7 @@ void Journaler::_finish_write_head(Header &wrote, Context *oncommit)
 
 class Journaler::C_Flush : public Context {
   Journaler *ls;
-  int64_t start;
+  uint64_t start;
   utime_t stamp;
   bool safe;
 public:
@@ -307,7 +307,7 @@ public:
   void finish(int r) { ls->_finish_flush(r, start, stamp, safe); }
 };
 
-void Journaler::_finish_flush(int r, int64_t start, utime_t stamp, bool safe)
+void Journaler::_finish_flush(int r, uint64_t start, utime_t stamp, bool safe)
 {
   assert(!readonly);
   assert(r>=0);
@@ -689,7 +689,7 @@ void Journaler::_issue_read(int64_t len)
 void Journaler::_prefetch()
 {
   // prefetch?
-  int64_t left = requested_pos - read_pos;
+  uint64_t left = requested_pos - read_pos;
   if (left <= prefetch_from &&      // should read more,
       !_is_reading() &&             // and not reading anything right now
       write_pos > requested_pos) {  // there's something more to read...
@@ -773,7 +773,7 @@ bool Journaler::is_readable()
   // start reading some more?
   if (!_is_reading()) {
     if (s)
-      fetch_len = MAX(fetch_len, (int64_t)(sizeof(s)+s-read_buf.length())); 
+      fetch_len = MAX(fetch_len, (sizeof(s)+s-read_buf.length()));
     _issue_read(fetch_len);
   }
 
@@ -851,7 +851,7 @@ void Journaler::wait_for_readable(Context *onreadable)
 
 class Journaler::C_Trim : public Context {
   Journaler *ls;
-  int64_t to;
+  uint64_t to;
 public:
   C_Trim(Journaler *l, int64_t t) : ls(l), to(t) {}
   void finish(int r) {
@@ -864,7 +864,7 @@ void Journaler::trim()
   assert(!readonly);
   uint64_t period = layout.fl_stripe_count * layout.fl_object_size;
 
-  int64_t trim_to = last_committed.expire_pos;
+  uint64_t trim_to = last_committed.expire_pos;
   trim_to -= trim_to % period;
   dout(10) << "trim last_commited head was " << last_committed
           << ", can trim to " << trim_to
@@ -898,7 +898,7 @@ void Journaler::trim()
   trimming_pos = trim_to;  
 }
 
-void Journaler::_trim_finish(int r, int64_t to)
+void Journaler::_trim_finish(int r, uint64_t to)
 {
   assert(!readonly);
   dout(10) << "_trim_finish trimmed_pos was " << trimmed_pos
index e09de89f37e6cd5cae174b85e2e1e928e50d4826..cc9ddb94a6d5b48c2c05689144ee2a35ecc48a4e 100644 (file)
@@ -64,10 +64,10 @@ class Journaler {
 public:
   // this goes at the head of the log "file".
   struct Header {
-    int64_t trimmed_pos;
-    int64_t expire_pos;
-    int64_t read_pos;
-    int64_t write_pos;
+    uint64_t trimmed_pos;
+    uint64_t expire_pos;
+    uint64_t read_pos;
+    uint64_t write_pos;
     string magic;
     ceph_file_layout layout;
 
@@ -146,7 +146,7 @@ private:
   void _finish_read_head(int r, bufferlist& bl);
   void probe(Context *finish, uint64_t *end);
   void reprobe();
-  void _finish_probe_end(int r, int64_t end);
+  void _finish_probe_end(int r, uint64_t end);
   class C_ReadHead;
   friend class C_ReadHead;
   class C_ProbeEnd;
@@ -155,31 +155,31 @@ private:
 
 
   // writer
-  int64_t write_pos;       // logical write position, where next entry will go
-  int64_t flush_pos;       // where we will flush. if write_pos>flush_pos, we're buffering writes.
-  int64_t ack_pos;         // what has been acked.
-  int64_t safe_pos;        // what has been committed safely to disk.
+  uint64_t write_pos;       // logical write position, where next entry will go
+  uint64_t flush_pos;       // where we will flush. if write_pos>flush_pos, we're buffering writes.
+  uint64_t ack_pos;         // what has been acked.
+  uint64_t safe_pos;        // what has been committed safely to disk.
   bufferlist write_buf;  // write buffer.  flush_pos + write_buf.length() == write_pos.
 
-  std::set<int64_t> pending_ack, pending_safe;
-  std::map<int64_t, std::list<Context*> > waitfor_ack;  // when flushed through given offset
-  std::map<int64_t, std::list<Context*> > waitfor_safe; // when safe through given offset
-  std::set<int64_t> ack_barrier;
+  std::set<uint64_t> pending_ack, pending_safe;
+  std::map<uint64_t, std::list<Context*> > waitfor_ack;  // when flushed through given offset
+  std::map<uint64_t, std::list<Context*> > waitfor_safe; // when safe through given offset
+  std::set<uint64_t> ack_barrier;
 
   void _do_flush(unsigned amount=0);
-  void _finish_flush(int r, int64_t start, utime_t stamp, bool safe);
+  void _finish_flush(int r, uint64_t start, utime_t stamp, bool safe);
   class C_Flush;
   friend class C_Flush;
 
   // reader
-  int64_t read_pos;      // logical read position, where next entry starts.
-  int64_t requested_pos; // what we've requested from OSD.
-  int64_t received_pos;  // what we've received from OSD.
+  uint64_t read_pos;      // logical read position, where next entry starts.
+  uint64_t requested_pos; // what we've requested from OSD.
+  uint64_t received_pos;  // what we've received from OSD.
   bufferlist read_buf; // read buffer.  read_pos + read_buf.length() == prefetch_pos.
   bufferlist reading_buf; // what i'm reading into
 
-  int64_t fetch_len;     // how much to read at a time
-  int64_t prefetch_from; // how far from end do we read next chunk
+  uint64_t fetch_len;     // how much to read at a time
+  uint64_t prefetch_from; // how far from end do we read next chunk
 
   int64_t junk_tail_pos; // for truncate
 
@@ -201,12 +201,12 @@ private:
   friend class C_RetryRead;
 
   // trimmer
-  int64_t expire_pos;    // what we're allowed to trim to
-  int64_t trimming_pos;      // what we've requested to trim through
-  int64_t trimmed_pos;   // what has been trimmed
-  map<int64_t, list<Context*> > waitfor_trim;
+  uint64_t expire_pos;    // what we're allowed to trim to
+  uint64_t trimming_pos;      // what we've requested to trim through
+  uint64_t trimmed_pos;   // what has been trimmed
+  map<uint64_t, list<Context*> > waitfor_trim;
 
-  void _trim_finish(int r, int64_t to);
+  void _trim_finish(int r, uint64_t to);
   class C_Trim;
   friend class C_Trim;