[Kosmosfs-users] 32-bit operation
Status: Alpha
Brought to you by:
sriramsrao
|
From: James D. <fxm...@gm...> - 2008-02-10 13:06:11
|
I have installed KFS on a 32-bit fedora 8 machine and with the help of
previous posts it compiled just fine. After running I noticed a couple of
issues with diskspace and file offset computation in which it seemed to be
using 32 bit values and would not allow sizes over 2 or 4 GB. I went
through the code and resolved the issues that I saw preventing sizes above
4GB and I have tested it with a chunkserver allocation size of 200GB and
successfully uploaded a 4.3GB file into the system. I provide the diff of
my changes as suggestions if you want to look through it. The changes were
made to the current svn trunk, I hope this is useful.
Index: src/cc/tools/KfsPing_main.cc
===================================================================
--- src/cc/tools/KfsPing_main.cc (revision 54)
+++ src/cc/tools/KfsPing_main.cc (working copy)
@@ -50,7 +50,7 @@
static void
PingChunkServer(const ServerLocation &location);
-float convertToMB(long bytes)
+float convertToMB(int64_t bytes)
{
return bytes / (1024.0 * 1024.0);
}
Index: src/cc/tools/MonUtils.h
===================================================================
--- src/cc/tools/MonUtils.h (revision 54)
+++ src/cc/tools/MonUtils.h (working copy)
@@ -64,8 +64,8 @@
struct ChunkPingOp : public KfsMonOp {
KFS::ServerLocation location;
- size_t totalSpace;
- size_t usedSpace;
+ int64_t totalSpace;
+ int64_t usedSpace;
ChunkPingOp(int32_t s) :
KfsMonOp(CMD_CHUNKPING, s) { };
void Request(std::ostringstream &os);
Index: src/cc/tools/CMakeLists.txt
===================================================================
--- src/cc/tools/CMakeLists.txt (revision 54)
+++ src/cc/tools/CMakeLists.txt (working copy)
@@ -22,6 +22,7 @@
add_dependencies (tools kfsClient)
add_dependencies (tools-shared kfsClient-shared)
+add_definitions (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
set (exe_files
cpFs2Kfs
Index: src/cc/libkfsIO/CMakeLists.txt
===================================================================
--- src/cc/libkfsIO/CMakeLists.txt (revision 54)
+++ src/cc/libkfsIO/CMakeLists.txt (working copy)
@@ -8,6 +8,7 @@
set_target_properties (kfsIO PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties (kfsIO-shared PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+add_definitions (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
add_dependencies (kfsIO kfsCommon)
add_dependencies (kfsIO-shared kfsCommon-shared)
Index: src/cc/tests/CMakeLists.txt
===================================================================
--- src/cc/tests/CMakeLists.txt (revision 54)
+++ src/cc/tests/CMakeLists.txt (working copy)
@@ -11,6 +11,7 @@
KfsWriter
)
+add_definitions (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
#
# Every executable depends on its namesake source with _main.cc
#
Index: src/cc/tests/KfsSeekWrite_main.cc
===================================================================
--- src/cc/tests/KfsSeekWrite_main.cc (revision 54)
+++ src/cc/tests/KfsSeekWrite_main.cc (working copy)
@@ -318,7 +318,7 @@
toCompare = min(KFS_DATA_BUF_SIZE - (start % KFS_DATA_BUF_SIZE),
(long long) (numBytes - bytesCompared));
#else
- toCompare = min(KFS_DATA_BUF_SIZE - (start % KFS_DATA_BUF_SIZE),
+ toCompare = min((long) (KFS_DATA_BUF_SIZE - (start %
KFS_DATA_BUF_SIZE)),
(long) (numBytes - bytesCompared));
#endif
if (!compareData(kfsBuf1 + bytesCompared, src + (start %
KFS_DATA_BUF_SIZE),
Index: src/cc/chunk/ChunkServer_main.cc
===================================================================
--- src/cc/chunk/ChunkServer_main.cc (revision 54)
+++ src/cc/chunk/ChunkServer_main.cc (working copy)
@@ -58,7 +58,7 @@
vector<string> gChunkDirs;
ServerLocation gMetaServerLoc;
-size_t gTotalSpace; // max. storage space to use
+int64_t gTotalSpace; // max. storage space to use
int gChunkServerClientPort; // Port at which kfs clients connect to us
Properties gProp;
Index: src/cc/chunk/ChunkManager.cc
===================================================================
--- src/cc/chunk/ChunkManager.cc (revision 54)
+++ src/cc/chunk/ChunkManager.cc (working copy)
@@ -95,7 +95,7 @@
}
void
-ChunkManager::Init(const vector<string> &chunkDirs, size_t totalSpace)
+ChunkManager::Init(const vector<string> &chunkDirs, int64_t totalSpace)
{
mTotalSpace = totalSpace;
mChunkDirs = chunkDirs;
@@ -1039,7 +1039,7 @@
void
ChunkManager::ReplayWriteDone(kfsChunkId_t chunkId, size_t chunkSize,
- uint32_t offset, vector<uint32_t> checksums)
+ off_t offset, vector<uint32_t> checksums)
{
ChunkInfoHandle_t *cih;
int res;
@@ -1069,7 +1069,7 @@
{
ChunkInfoHandle_t *cih;
int res;
- uint32_t lastChecksumBlock;
+ off_t lastChecksumBlock;
res = GetChunkInfoHandle(chunkId, &cih);
if (res < 0)
@@ -1296,22 +1296,26 @@
return partition + "/lost+found/";
}
-size_t
+int64_t
ChunkManager::GetTotalSpace() const
{
+ int64_t availableSpace;
+
if (mChunkDirs.size() > 1) {
return mTotalSpace;
}
- struct statvfs result;
+ struct statvfs64 result;
// report the space based on availability
- if (statvfs(mChunkDirs[0].c_str(), &result) < 0) {
+ if (statvfs64(mChunkDirs[0].c_str(), &result) < 0) {
KFS_LOG_VA_DEBUG("statvfs failed...returning %ld", mTotalSpace);
return mTotalSpace;
}
if (result.f_frsize == 0)
return mTotalSpace;
+ availableSpace = result.f_bavail * result.f_frsize;
+
// we got all the info...so report true value
- return min(result.f_bavail * result.f_frsize, mTotalSpace);
+ return (availableSpace < mTotalSpace) ? availableSpace : mTotalSpace;
}
Index: src/cc/chunk/ChunkManager.h
===================================================================
--- src/cc/chunk/ChunkManager.h (revision 54)
+++ src/cc/chunk/ChunkManager.h (working copy)
@@ -75,7 +75,7 @@
~ChunkManager();
/// Init function to configure the chunk manager object.
- void Init(const std::vector<std::string> &chunkDirs, size_t
totalSpace);
+ void Init(const std::vector<std::string> &chunkDirs, int64_t
totalSpace);
/// Allocate a file to hold a chunk on disk. The filename is the
/// chunk id itself.
@@ -205,7 +205,7 @@
/// completion of a write.
/// @param[in] chunkSize The new size of the chunk
void ReplayWriteDone(kfsChunkId_t chunkId, size_t chunkSize,
- uint32_t offset, std::vector<uint32_t> checksum);
+ off_t offset, std::vector<uint32_t> checksum);
/// Replay a truncation done on a chunk.
/// @param[in] chunkId Update the size of chunk to reflect the
@@ -222,8 +222,8 @@
/// chunks are stored in a single directory, we use statvfs to
/// determine the total space avail; we report the min of statvfs
/// value and the configured mTotalSpace.
- size_t GetTotalSpace() const;
- size_t GetUsedSpace() const { return mUsedSpace; };
+ int64_t GetTotalSpace() const;
+ int64_t GetUsedSpace() const { return mUsedSpace; };
/// For a write, the client has pushed data to us. This is queued
/// for a commit later on.
@@ -263,9 +263,9 @@
static const int MAX_PENDING_WRITE_LRU_SECS = 300;
/// space available for allocation
- size_t mTotalSpace;
+ int64_t mTotalSpace;
/// how much is used up by chunks
- size_t mUsedSpace;
+ int64_t mUsedSpace;
/// directories for storing the chunks
std::vector<std::string> mChunkDirs;
Index: src/cc/chunk/KfsOps.h
===================================================================
--- src/cc/chunk/KfsOps.h (revision 54)
+++ src/cc/chunk/KfsOps.h (working copy)
@@ -232,8 +232,8 @@
};
struct HeartbeatOp : public KfsOp {
- ssize_t totalSpace;
- ssize_t usedSpace;
+ int64_t totalSpace;
+ int64_t usedSpace;
HeartbeatOp(kfsSeq_t s) :
KfsOp(CMD_HEARTBEAT, s)
{
@@ -540,8 +540,8 @@
// used for pinging the server and checking liveness
struct PingOp : public KfsOp {
- size_t totalSpace;
- size_t usedSpace;
+ int64_t totalSpace;
+ int64_t usedSpace;
PingOp(kfsSeq_t s) :
KfsOp(CMD_PING, s) { }
void Response(std::ostringstream &os);
@@ -607,8 +607,8 @@
struct HelloMetaOp : public KfsOp {
ServerLocation myLocation;
std::string clusterKey;
- size_t totalSpace;
- size_t usedSpace;
+ int64_t totalSpace;
+ int64_t usedSpace;
std::vector<ChunkInfo_t> chunks;
HelloMetaOp(kfsSeq_t s, ServerLocation &l, std::string &k) :
KfsOp(CMD_META_HELLO, s), myLocation(l), clusterKey(k) {
Index: src/cc/chunk/CMakeLists.txt
===================================================================
--- src/cc/chunk/CMakeLists.txt (revision 54)
+++ src/cc/chunk/CMakeLists.txt (working copy)
@@ -26,6 +26,8 @@
set_target_properties (chunk PROPERTIES CLEAN_DIRECT_OUTPUT 1)
set_target_properties (chunk-shared PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+add_definitions (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
+
add_executable (chunkserver ChunkServer_main.cc)
if (USE_STATIC_LIB_LINKAGE)
Index: src/cc/common/cxxutil.h
===================================================================
--- src/cc/common/cxxutil.h (revision 54)
+++ src/cc/common/cxxutil.h (working copy)
@@ -27,7 +27,7 @@
#ifndef COMMON_CXXUTIL_H
#define COMMON_CXXUTIL_H
-#if defined (__APPLE__)
+#if defined (__APPLE__) || defined (__i386__)
#include <tr1/functional>
namespace std
{
Index: src/cc/libkfsClient/CMakeLists.txt
===================================================================
--- src/cc/libkfsClient/CMakeLists.txt (revision 54)
+++ src/cc/libkfsClient/CMakeLists.txt (working copy)
@@ -10,6 +10,8 @@
add_library (kfsClient-shared SHARED ${sources})
set_target_properties (kfsClient-shared PROPERTIES OUTPUT_NAME "kfsClient")
+add_definitions (-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES)
+
#
# Since the objects have to be built twice, set this up so they don't
# clobber each other.
|