]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
FileJournal: don't overflow the journal size.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 21 Jan 2011 22:20:16 +0000 (14:20 -0800)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Fri, 21 Jan 2011 22:20:16 +0000 (14:20 -0800)
Previously we were casting it to a uint64_t, but the left shift
occurs before the cast, so we were overflowing in some circumstances.
Split these up to prevent it.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/os/FileJournal.cc

index 54e0f0503905037d801507670fa8f0ab681ac6c6..54f6bfa09ac969af7ac1b7a5a9c871c402ac72d0 100644 (file)
@@ -223,7 +223,8 @@ int FileJournal::_open_file(int64_t oldsize, blksize_t blksize,
   }
 
   if (create && (oldsize < conf_journal_sz)) {
-    uint64_t newsize = (uint64_t)g_conf.osd_journal_size << 20;
+    uint64_t newsize(g_conf.osd_journal_size);
+    newsize <<= 20;
     dout(10) << "_open extending to " << newsize << " bytes" << dendl;
     ret = ::ftruncate(fd, newsize);
     if (ret < 0) {