Mercurial > nomad
changeset 761:44f88c8abb28
objstore: move create transaction op setup into a separate function
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Mon, 30 Mar 2020 10:07:37 -0400 |
parents | 2d794f76bd06 |
children | 16b4a319401c |
files | src/objstore/obj_dir_create.c src/objstore/obj_txn.c src/objstore/objstore_impl.h |
diffstat | 3 files changed, 23 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/objstore/obj_dir_create.c Mon Mar 30 09:58:22 2020 -0400 +++ b/src/objstore/obj_dir_create.c Mon Mar 30 10:07:37 2020 -0400 @@ -40,21 +40,8 @@ .owner = 0, .group = 0, }; - struct txn_entry *entry; - int ret; - ret = txn->clone->ops->allocoid(txn->clone, oid); - if (ret) - return ret; - - entry = txn_alloc_entry(txn); - entry->op = OP_CREATE; - entry->create.oid = *oid; - nvclock_reset(&entry->create.clock); - VERIFY0(nvclock_inc(&entry->create.clock)); - entry->create.attrs = attrs; - - return 0; + return obj_create(txn, &attrs, oid); } static int __dir_create_child_contents(struct txn *txn,
--- a/src/objstore/obj_txn.c Mon Mar 30 09:58:22 2020 -0400 +++ b/src/objstore/obj_txn.c Mon Mar 30 10:07:37 2020 -0400 @@ -24,6 +24,26 @@ #include "objstore_impl.h" +int obj_create(struct txn *txn, const struct nattr *attrs, + struct noid *oid) +{ + struct txn_entry *entry; + int ret; + + ret = txn->clone->ops->allocoid(txn->clone, oid); + if (ret) + return ret; + + entry = txn_alloc_entry(txn); + entry->op = OP_CREATE; + entry->create.oid = *oid; + nvclock_reset(&entry->create.clock); + VERIFY0(nvclock_inc(&entry->create.clock)); + entry->create.attrs = *attrs; + + return 0; +} + void obj_setattr(struct txn *txn, struct objver *ver, const struct nattr *attrs, unsigned valid) {
--- a/src/objstore/objstore_impl.h Mon Mar 30 09:58:22 2020 -0400 +++ b/src/objstore/objstore_impl.h Mon Mar 30 10:07:37 2020 -0400 @@ -65,6 +65,8 @@ const struct nvclock *clock); extern int obj_cow(struct objstore_open_obj_info *open, struct txn *txn); +extern int obj_create(struct txn *txn, const struct nattr *attrs, + struct noid *oid); extern void obj_setattr(struct txn *txn, struct objver *ver, const struct nattr *attrs, unsigned valid); extern void obj_write(struct txn *txn, struct objver *ver, struct buffer *buf,