Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/filestore: require offset == length == 0 for full object read; add test #7957

Merged
merged 2 commits into from Mar 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/os/filestore/FileStore.cc
Expand Up @@ -2973,7 +2973,7 @@ int FileStore::read(
return r;
}

if (len == 0) {
if (offset == 0 && len == 0) {
struct stat st;
memset(&st, 0, sizeof(struct stat));
int r = ::fstat(**fd, &st);
Expand Down
11 changes: 11 additions & 0 deletions src/test/objectstore/store_test.cc
Expand Up @@ -525,6 +525,17 @@ TEST_P(StoreTest, SimpleObjectTest) {
in.hexdump(cout);
ASSERT_TRUE(in.contents_equal(bl));
}
{
bufferlist bl;
bl.append("abcde01234012340123401234abcde01234012340123401234abcde01234012340123401234abcde01234012340123401234");

//test: offset=len=0 mean read all data
bufferlist in;
r = store->read(cid, hoid, 0, 0, in);
ASSERT_EQ((int)bl.length(), r);
in.hexdump(cout);
ASSERT_TRUE(in.contents_equal(bl));
}
{
ObjectStore::Transaction t;
t.remove(cid, hoid);
Expand Down