All-
I'm having a problem where files written to a PVFS volume overwrite the
beginning of the file after some output has already been generated, as
if lseek() had been called mid-write. The overwriting behavior does not
show up on a regular ext3 volume. Sample code is attached. I'd like to
know if anyone can duplicate this behavior, because it looks like a bug.
Essentially what happens is this: given a large (1024+ character)
string, I write some portion of the string using a C++ ostream, then
write another line:
out << st.substr(0, N);
out << "done";
If N < 1024, everything is fine. If N >= 1024, "done" is written at the
beginning of the file, overwriting what was there before.
I'd love to figure this out!
Cheers,
-crispy
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
// write len chars of text to filename
void writechars(string filename, string text, int len);
int main() {
// make a long string to print
string line = "0xxxxxxxxx1xxxxxxxxx2xxxxxxxxx3xxxxxxxxx4xxxxxxxxx5xxxxxxxxx\n"; // 60 chars plus linefeed
string t;
// make a long string for testing
for (int i = 0; i < 100; i++)
t = t + line;
// this will make a file with a bunch of xs, then the "should be the last line" message
writechars("test1.txt", t, 1023);
// on non-PVFS filesystem, produces same as above with one more x at end of series of xs
// on PVFS filesystem, makes a file where the second line output overwrites the start of the first
writechars("test2.txt", t, 1024);
return 0;
}
void writechars(string filename, string text, int len) {
filebuf fb;
fb.open(filename.c_str(), ios::out);
ostream os(&fb);
os << text.substr(0, len);
os << "\n" << "--- should be the last line ---" << "\n";
fb.close();
}
_______________________________________________
Pvfs2-users mailing list
[email protected]
http://www.beowulf-underground.org/mailman/listinfo/pvfs2-users