Skip to content

Commit

Permalink
sheep: Only ledger and inode objects keep sparse when "dog node md plug"
Browse files Browse the repository at this point in the history
From the commit 2e3e1ee, atomic_create_and_write have required the sparse
parameter and md_move_object have called this with sparse=true. Because of
this, *all* the objects moving across the disks become sparse when
"dog node md plug," including the ones which should not become sparse
such as pre-allocated fully-zeroed data objects.

This commit fixes the problem described above. To be specific, before
calling atomic_create_and_write, md_move_object calls is_sparse_object
to check whether the given object can be sparse i.e. is either ledger or
inode object.

Signed-off-by: Takashi Menjo <menjo.takashi@lab.ntt.co.jp>
  • Loading branch information
tmenjo committed Aug 29, 2016
1 parent ba1f39a commit 44a7268
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sheep/store/md.c
Expand Up @@ -651,6 +651,7 @@ static int md_move_object(uint64_t oid, const char *old, const char *new)
struct strbuf buf = STRBUF_INIT;
int fd, ret = -1;
size_t sz = get_store_objsize(oid);
const bool sparse = is_sparse_object(oid);

fd = open(old, O_RDONLY);
if (fd < 0) {
Expand All @@ -665,7 +666,7 @@ static int md_move_object(uint64_t oid, const char *old, const char *new)
goto out_close;
}

if (atomic_create_and_write(new, buf.buf, buf.len, false, true) < 0) {
if (atomic_create_and_write(new, buf.buf, buf.len, false, sparse) < 0) {
if (errno != EEXIST) {
sd_err("failed to create %s", new);
ret = -1;
Expand Down

0 comments on commit 44a7268

Please sign in to comment.