Skip to content

Commit

Permalink
Merge pull request #7957 from majianpeng/bluestore-read
Browse files Browse the repository at this point in the history
os/filestore: require offset == length == 0 for full object read; add test

Reviewed-by: Sage Weil <sage@redhat.com>
Reviewed-by: Igor Fedotov <ifedotov@mirantis.com>
  • Loading branch information
liewegas committed Mar 17, 2016
2 parents c021e1b + 1785f91 commit 6741606
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 6741606

Please sign in to comment.