Mercurial > nomad
changeset 817:af90ba985ab9
objstore: rely on createobj vol op initializing empty dirs for us
Instead of writing out the empty directory contents using obj_write, we rely
on the backends calling obj_make_dir_buffer and writing the result to the
newly allocated directory object.
It is unfortunate that we have to force backends to duplicate this logic,
but this is simpler than any of the currently possible ways of passing a
buffer from the generic code to the backend. The difficulty stems from the
fact that obj_write requires an objver structure, but we don't have one
because it was this transaction that created the object (and its first
version) in an earlier entry. Instead of implementing some sort of "result
forwarding" between transaction entries, it is simpler (for now) to just
force the backends to construct the directory contents themselves.
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 06 Apr 2020 22:17:21 -0400 |
parents | 7938320113fb |
children | facc1b5299a8 |
files | src/objstore/obj_dir_create.c |
diffstat | 1 files changed, 0 insertions(+), 34 deletions(-) [+] |
line wrap: on
line diff
--- a/src/objstore/obj_dir_create.c Mon Apr 06 22:11:12 2020 -0400 +++ b/src/objstore/obj_dir_create.c Mon Apr 06 22:17:21 2020 -0400 @@ -45,33 +45,6 @@ return obj_create(txn, &attrs, oid, parent); } -static int __dir_create_child_contents(struct txn *txn, - const struct noid *parent, - const struct noid *child) -{ - struct buffer buf; - int ret; - - ret = buffer_init_heap(&buf, DIR_BLOCK_SIZE); - if (ret) - return ret; - - ret = obj_make_dir_buffer(noid_get_allocator(parent), - noid_get_uniq(parent), - noid_get_allocator(child), - noid_get_uniq(child), - &buf); - if (ret) { - buffer_free(&buf); - return ret; - } - - FIXME("child dir write op has NULL objver"); - obj_write(txn, NULL /* FIXME */, &buf, 0); - - return 0; -} - static int __dir_create_add_dirent(struct txn *txn, struct objver *dirver, const char *name, uint16_t mode, const struct noid *child) @@ -251,13 +224,6 @@ ASSERT(!noid_is_null(child)); - /* write out empty child dir contents */ - if (NATTR_ISDIR(mode)) { - ret = __dir_create_child_contents(txn, &dirver->obj->oid, child); - if (ret) - return ret; - } - /* add dirent to parent dir */ if (!update_existing) { ret = __dir_create_add_dirent(txn, dirver, name, mode, child);