stackpop
unread,Jul 6, 2011, 8:29:41 PM7/6/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to KFS User
Dear all,
I wanna do some special coding on the data before the data being
stored in the chunkserver.
Because the project have special requirements, we can't coding in
the user client.
As far as I am concerned , all the data are stored in a vector
writeVec of Class IOBuffer.
I tried to do some changes of the data before them written to the
disk.
int IOBuffer::Write(int fd)
{
DebugVerify();
const int kMaxWritevBufs = 32;
const int maxWriteBufs = std::min(IOV_MAX,
kMaxWritevBufs);
const int kPreferredWriteSize = 64 << 10;
struct iovec writeVec[kMaxWritevBufs];
ssize_t totWr = 0;
while (! mBuf.empty()) {
BList::iterator it;
int nVec;
ssize_t toWr;
for (it = mBuf.begin(), nVec = 0, toWr = 0;
it != mBuf.end() && nVec < maxWriteBufs &&
toWr < kPreferredWriteSize;
) {
const int nBytes = it->BytesConsumable();
if (nBytes <= 0) {
it = mBuf.erase(it);
continue;
}
/*Here I did some changes and the following is the
original codes*/
/*
writeVec[nVec].iov_base = it->Consumer();
writeVec[nVec].iov_len = (size_t)nBytes;
*/
/*the following are my modified codes*/
char * tmp = it->Consumer;
writeVec[nVec].iov_base = tmp;
writeVec[nVec].iov_len = (size_t)nBytes;
//add 1 to the data of each byte
if(nVec >= 1){
for(int i = 0; i != nBytes; ++i)
*(tmp+i) = *(tmp+i) +1;
}
/* end of my codes*/
toWr += nBytes;
nVec++;
++it;
}
if (nVec <= 0) {
assert(it == mBuf.end());
mBuf.clear();
break;
}
//I think here the kfs chunkmanager write the data to the disk
//And I can see no checksum step before data written to disk
//My question is why the client told me that checksum
mismatch,Thank you ~
const ssize_t nWr = writev(fd, writeVec, nVec);