diff options
author | Sage Weil <sage@newdream.net> | 2008-11-14 01:48:15 +0100 |
---|---|---|
committer | Sage Weil <sage@newdream.net> | 2008-11-14 01:48:15 +0100 |
commit | 1dd420957f9ba0e3991512a4627748bf38592d53 (patch) | |
tree | ff7ca04c3bc126b92207e5ab108d1fcf2513b575 | |
parent | osd: only trim pg log if pg contains complete set of osds (diff) | |
download | ceph-1dd420957f9ba0e3991512a4627748bf38592d53.tar.xz ceph-1dd420957f9ba0e3991512a4627748bf38592d53.zip |
journal: detect size of raw block devices properlyv0.5
-rw-r--r-- | src/os/FileJournal.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/os/FileJournal.cc b/src/os/FileJournal.cc index f9185e00a81..dce6a174531 100644 --- a/src/os/FileJournal.cc +++ b/src/os/FileJournal.cc @@ -18,6 +18,7 @@ #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> +#include <sys/mount.h> #include <fcntl.h> @@ -51,8 +52,28 @@ int FileJournal::_open(bool forwrite) assert(r == 0); max_size = st.st_size; block_size = st.st_blksize; + + if (max_size == 0) { + // hmm, is this a raw block device? +#ifdef BLKGETSIZE64 + // ioctl block device + uint64_t bytes; + r = ::ioctl(fd, BLKGETSIZE64, &bytes); + assert(r == 0); + max_size = bytes; +#else +# ifdef BLKGETSIZE + // hrm, try the 32 bit ioctl? + unsigned long sectors = 0; + r = ioctl(fd, BLKGETSIZE, §ors); + assert(r == 0); + max_size = sectors * 512ULL; +# endif +#endif + } + dout(2) << "_open " << fn << " fd " << fd - << ": " << st.st_size << " bytes, block size " << block_size << dendl; + << ": " << max_size << " bytes, block size " << block_size << dendl; return 0; } |