scoutfs: convert fs callers to forest

Convert fs callers to work with the btree forest calls instead of the
lsm item cache calls.  This is mostly a mechanical syntax conversion.
The inode dirtying path does now update the item rather than simply
dirtying it.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2019-09-29 22:19:57 -07:00
committed by Zach Brown
parent 858dad1d51
commit 48448d3926
6 changed files with 68 additions and 71 deletions

View File

@@ -32,7 +32,7 @@
#include "trans.h"
#include "counters.h"
#include "scoutfs_trace.h"
#include "item.h"
#include "forest.h"
#include "ioctl.h"
#include "client.h"
#include "lock.h"
@@ -218,19 +218,19 @@ static int data_extent_io(struct super_block *sb, int op,
expected = val.iov_len;
if (op == SEI_NEXT)
ret = scoutfs_item_next(sb, &key, &last, &val, lock);
ret = scoutfs_forest_next(sb, &key, &last, &val, lock);
else
ret = scoutfs_item_prev(sb, &key, &first, &val, lock);
ret = scoutfs_forest_prev(sb, &key, &first, &val, lock);
if (ret >= 0 && ret != expected)
ret = -EIO;
if (ret == expected)
ret = init_extent_from_item(ext, &key, &fex);
} else if (op == SEI_INSERT) {
ret = scoutfs_item_create(sb, &key, &val, lock);
ret = scoutfs_forest_create(sb, &key, &val, lock);
} else if (op == SEI_DELETE) {
ret = scoutfs_item_delete(sb, &key, lock);
ret = scoutfs_forest_delete(sb, &key, lock);
} else {
ret = WARN_ON_ONCE(-EINVAL);

View File

@@ -29,7 +29,7 @@
#include "trans.h"
#include "xattr.h"
#include "kvec.h"
#include "item.h"
#include "forest.h"
#include "lock.h"
#include "counters.h"
#include "scoutfs_trace.h"
@@ -253,7 +253,7 @@ static int lookup_dirent(struct super_block *sb, u64 dir_ino, const char *name,
kvec_init(&val, dent, dirent_bytes(SCOUTFS_NAME_LEN));
for (;;) {
ret = scoutfs_item_next(sb, &key, &last_key, &val, lock);
ret = scoutfs_forest_next(sb, &key, &last_key, &val, lock);
if (ret < 0)
break;
@@ -478,7 +478,7 @@ static int KC_DECLARE_READDIR(scoutfs_readdir, struct file *file,
init_dirent_key(&key, SCOUTFS_READDIR_TYPE, scoutfs_ino(inode),
kc_readdir_pos(file, ctx), 0);
ret = scoutfs_item_next(sb, &key, &last_key, &val, dir_lock);
ret = scoutfs_forest_next(sb, &key, &last_key, &val, dir_lock);
if (ret < 0) {
if (ret == -ENOENT)
ret = 0;
@@ -556,23 +556,23 @@ static int add_entry_items(struct super_block *sb, u64 dir_ino, u64 hash,
init_dirent_key(&lb_key, SCOUTFS_LINK_BACKREF_TYPE, ino, dir_ino, pos);
kvec_init(&val, dent, dirent_bytes(name_len));
ret = scoutfs_item_create(sb, &ent_key, &val, dir_lock);
ret = scoutfs_forest_create(sb, &ent_key, &val, dir_lock);
if (ret)
goto out;
del_ent = true;
ret = scoutfs_item_create(sb, &rdir_key, &val, dir_lock);
ret = scoutfs_forest_create(sb, &rdir_key, &val, dir_lock);
if (ret)
goto out;
del_rdir = true;
ret = scoutfs_item_create(sb, &lb_key, &val, inode_lock);
ret = scoutfs_forest_create(sb, &lb_key, &val, inode_lock);
out:
if (ret < 0) {
if (del_ent)
scoutfs_item_delete_dirty(sb, &ent_key);
scoutfs_forest_delete_dirty(sb, &ent_key);
if (del_rdir)
scoutfs_item_delete_dirty(sb, &rdir_key);
scoutfs_forest_delete_dirty(sb, &rdir_key);
}
kfree(dent);
@@ -602,15 +602,15 @@ static int del_entry_items(struct super_block *sb, u64 dir_ino, u64 hash,
init_dirent_key(&rdir_key, SCOUTFS_READDIR_TYPE, dir_ino, pos, 0);
init_dirent_key(&lb_key, SCOUTFS_LINK_BACKREF_TYPE, ino, dir_ino, pos);
ret = scoutfs_item_delete_save(sb, &ent_key, &dir_saved, dir_lock) ?:
scoutfs_item_delete_save(sb, &rdir_key, &dir_saved, dir_lock) ?:
scoutfs_item_delete_save(sb, &lb_key, &inode_saved, inode_lock);
ret = scoutfs_forest_delete_save(sb, &ent_key, &dir_saved, dir_lock) ?:
scoutfs_forest_delete_save(sb, &rdir_key, &dir_saved, dir_lock) ?:
scoutfs_forest_delete_save(sb, &lb_key, &inode_saved, inode_lock);
if (ret < 0) {
scoutfs_item_restore(sb, &dir_saved, dir_lock);
scoutfs_item_restore(sb, &inode_saved, inode_lock);
scoutfs_forest_restore(sb, &dir_saved, dir_lock);
scoutfs_forest_restore(sb, &inode_saved, inode_lock);
} else {
scoutfs_item_free_batch(sb, &dir_saved);
scoutfs_item_free_batch(sb, &inode_saved);
scoutfs_forest_free_batch(sb, &dir_saved);
scoutfs_forest_free_batch(sb, &inode_saved);
}
return ret;
@@ -988,11 +988,11 @@ static int symlink_item_ops(struct super_block *sb, int op, u64 ino,
kvec_init(&val, (void *)target, bytes);
if (op == SYM_CREATE)
ret = scoutfs_item_create(sb, &key, &val, lock);
ret = scoutfs_forest_create(sb, &key, &val, lock);
else if (op == SYM_LOOKUP)
ret = scoutfs_item_lookup_exact(sb, &key, &val, lock);
ret = scoutfs_forest_lookup_exact(sb, &key, &val, lock);
else if (op == SYM_DELETE)
ret = scoutfs_item_delete(sb, &key, lock);
ret = scoutfs_forest_delete(sb, &key, lock);
if (ret)
break;
@@ -1229,7 +1229,7 @@ int scoutfs_dir_add_next_linkref(struct super_block *sb, u64 ino,
if (ret)
goto out;
ret = scoutfs_item_next(sb, &key, &last_key, &val, lock);
ret = scoutfs_forest_next(sb, &key, &last_key, &val, lock);
scoutfs_unlock(sb, lock, SCOUTFS_LOCK_READ);
lock = NULL;
if (ret < 0)

View File

@@ -31,7 +31,7 @@
#include "trans.h"
#include "msg.h"
#include "kvec.h"
#include "item.h"
#include "forest.h"
#include "client.h"
#include "cmp.h"
@@ -296,7 +296,7 @@ int scoutfs_inode_refresh(struct inode *inode, struct scoutfs_lock *lock,
mutex_lock(&si->item_mutex);
if (atomic64_read(&si->last_refreshed) < refresh_gen) {
ret = scoutfs_item_lookup_exact(sb, &key, &val, lock);
ret = scoutfs_forest_lookup_exact(sb, &key, &val, lock);
if (ret == 0) {
load_inode(inode, &sinode);
atomic64_set(&si->last_refreshed, refresh_gen);
@@ -741,9 +741,7 @@ static void store_inode(struct scoutfs_inode *cinode, struct inode *inode)
* have to update it now with the current inode contents.
*
* Callers don't delete these dirty items on errors. They're still
* valid and will be merged with the current item eventually. They can
* be found in the dirty block to avoid future dirtying (say repeated
* creations in a directory).
* valid and will be merged with the current item eventually.
*
* The caller has to prevent sync between dirtying and updating the
* inodes.
@@ -753,15 +751,17 @@ static void store_inode(struct scoutfs_inode *cinode, struct inode *inode)
int scoutfs_dirty_inode_item(struct inode *inode, struct scoutfs_lock *lock)
{
struct super_block *sb = inode->i_sb;
struct scoutfs_key key;
struct scoutfs_inode sinode;
struct scoutfs_key key;
struct kvec val;
int ret;
store_inode(&sinode, inode);
kvec_init(&val, &sinode, sizeof(sinode));
init_inode_key(&key, scoutfs_ino(inode));
ret = scoutfs_item_dirty(sb, &key, lock);
ret = scoutfs_forest_update(sb, &key, &val, lock);
if (!ret)
trace_scoutfs_dirty_inode(inode);
return ret;
@@ -893,7 +893,7 @@ static int update_index_items(struct super_block *sb,
scoutfs_inode_init_index_key(&ins, type, major, minor, ino);
ins_lock = find_index_lock(lock_list, type, major, minor, ino);
ret = scoutfs_item_create_force(sb, &ins, NULL, ins_lock);
ret = scoutfs_forest_create_force(sb, &ins, NULL, ins_lock);
if (ret || !will_del_index(si, type, major, minor))
return ret;
@@ -905,9 +905,9 @@ static int update_index_items(struct super_block *sb,
del_lock = find_index_lock(lock_list, type, si->item_majors[type],
si->item_minors[type], ino);
ret = scoutfs_item_delete_force(sb, &del, del_lock);
ret = scoutfs_forest_delete_force(sb, &del, del_lock);
if (ret) {
err = scoutfs_item_delete(sb, &ins, ins_lock);
err = scoutfs_forest_delete(sb, &ins, ins_lock);
BUG_ON(err);
}
@@ -984,7 +984,7 @@ void scoutfs_update_inode_item(struct inode *inode, struct scoutfs_lock *lock,
init_inode_key(&key, ino);
kvec_init(&val, &sinode, sizeof(sinode));
err = scoutfs_item_update(sb, &key, &val, lock);
err = scoutfs_forest_update(sb, &key, &val, lock);
if (err) {
scoutfs_err(sb, "inode %llu update err %d", ino, err);
BUG_ON(err);
@@ -1259,7 +1259,7 @@ static int remove_index(struct super_block *sb, u64 ino, u8 type, u64 major,
scoutfs_inode_init_index_key(&key, type, major, minor, ino);
lock = find_index_lock(ind_locks, type, major, minor, ino);
ret = scoutfs_item_delete_force(sb, &key, lock);
ret = scoutfs_forest_delete_force(sb, &key, lock);
if (ret == -ENOENT)
ret = 0;
return ret;
@@ -1401,7 +1401,7 @@ struct inode *scoutfs_new_inode(struct super_block *sb, struct inode *dir,
init_inode_key(&key, scoutfs_ino(inode));
kvec_init(&val, &sinode, sizeof(sinode));
ret = scoutfs_item_create(sb, &key, &val, lock);
ret = scoutfs_forest_create(sb, &key, &val, lock);
if (ret) {
iput(inode);
return ERR_PTR(ret);
@@ -1429,7 +1429,7 @@ static int remove_orphan_item(struct super_block *sb, u64 ino)
init_orphan_key(&key, sbi->rid, ino);
ret = scoutfs_item_delete(sb, &key, lock);
ret = scoutfs_forest_delete(sb, &key, lock);
if (ret == -ENOENT)
ret = 0;
@@ -1464,7 +1464,7 @@ static int delete_inode_items(struct super_block *sb, u64 ino)
init_inode_key(&key, ino);
kvec_init(&val, &sinode, sizeof(sinode));
ret = scoutfs_item_lookup_exact(sb, &key, &val, lock);
ret = scoutfs_forest_lookup_exact(sb, &key, &val, lock);
if (ret < 0) {
if (ret == -ENOENT)
ret = 0;
@@ -1517,7 +1517,7 @@ retry:
goto out;
}
ret = scoutfs_item_delete(sb, &key, lock);
ret = scoutfs_forest_delete(sb, &key, lock);
if (ret)
goto out;
@@ -1586,7 +1586,7 @@ int scoutfs_scan_orphans(struct super_block *sb)
init_orphan_key(&last, sbi->rid, ~0ULL);
while (1) {
ret = scoutfs_item_next(sb, &key, &last, NULL, lock);
ret = scoutfs_forest_next(sb, &key, &last, NULL, lock);
if (ret == -ENOENT) /* No more orphan items */
break;
if (ret < 0)
@@ -1620,7 +1620,7 @@ int scoutfs_orphan_inode(struct inode *inode)
init_orphan_key(&key, sbi->rid, scoutfs_ino(inode));
ret = scoutfs_item_create(sb, &key, NULL, lock);
ret = scoutfs_forest_create(sb, &key, NULL, lock);
return ret;
}

View File

@@ -27,6 +27,7 @@
#include "ioctl.h"
#include "super.h"
#include "inode.h"
#include "forest.h"
#include "item.h"
#include "data.h"
#include "client.h"
@@ -110,7 +111,7 @@ static long scoutfs_ioc_walk_inodes(struct file *file, unsigned long arg)
for (nr = 0; nr < walk.nr_entries; ) {
ret = scoutfs_item_next(sb, &key, &last_key, NULL, lock);
ret = scoutfs_forest_next(sb, &key, &last_key, NULL, lock);
if (ret < 0 && ret != -ENOENT)
break;
@@ -128,14 +129,7 @@ static long scoutfs_ioc_walk_inodes(struct file *file, unsigned long arg)
scoutfs_unlock(sb, lock, SCOUTFS_LOCK_READ);
/*
* XXX This will miss dirty items. We'd need to
* force writeouts of dirty items in our
* zone|type and get the manifest root for that.
* It'd mean adding a lock to the inode index
* items which isn't quite there yet.
*/
ret = scoutfs_manifest_next_key(sb, &key, &next_key);
ret = scoutfs_forest_next_hint(sb, &key, &next_key);
if (ret < 0 && ret != -ENOENT)
goto out;
@@ -816,7 +810,7 @@ static long scoutfs_ioc_find_xattrs(struct file *file, unsigned long arg)
while (fx.nr_inodes) {
ret = scoutfs_item_next(sb, &key, &last, NULL, lock);
ret = scoutfs_forest_next(sb, &key, &last, NULL, lock);
if (ret < 0) {
if (ret == -ENOENT)
ret = 0;

View File

@@ -45,6 +45,7 @@
#include "options.h"
#include "sysfs.h"
#include "quorum.h"
#include "forest.h"
#include "scoutfs_trace.h"
static struct dentry *scoutfs_debugfs_root;
@@ -189,6 +190,7 @@ static void scoutfs_put_super(struct super_block *sb)
scoutfs_shutdown_trans(sb);
scoutfs_client_destroy(sb);
scoutfs_inode_destroy(sb);
scoutfs_forest_destroy(sb);
/* the server locks the listen address and compacts */
scoutfs_lock_shutdown(sb);
@@ -423,6 +425,7 @@ static int scoutfs_fill_super(struct super_block *sb, void *data, int silent)
scoutfs_seg_setup(sb) ?:
scoutfs_item_setup(sb) ?:
scoutfs_block_setup(sb) ?:
scoutfs_forest_setup(sb) ?:
scoutfs_inode_setup(sb) ?:
scoutfs_data_setup(sb) ?:
scoutfs_setup_trans(sb) ?:

View File

@@ -21,7 +21,7 @@
#include "key.h"
#include "super.h"
#include "kvec.h"
#include "item.h"
#include "forest.h"
#include "trans.h"
#include "xattr.h"
#include "lock.h"
@@ -195,7 +195,7 @@ static int get_next_xattr(struct inode *inode, struct scoutfs_key *key,
for (;;) {
key->skx_part = part;
kvec_init(&val, (void *)xat + total, bytes - total);
ret = scoutfs_item_next(sb, key, &last, &val, lock);
ret = scoutfs_forest_next(sb, key, &last, &val, lock);
if (ret < 0) {
/* XXX corruption, ran out of parts */
if (ret == -ENOENT && part > 0)
@@ -283,10 +283,10 @@ static int create_xattr_items(struct inode *inode, u64 id,
part_bytes = min(bytes - total, SCOUTFS_XATTR_MAX_PART_SIZE);
kvec_init(&val, (void *)xat + total, part_bytes);
ret = scoutfs_item_create(sb, &key, &val, lock);
ret = scoutfs_forest_create(sb, &key, &val, lock);
if (ret) {
while (key.skx_part-- > 0)
scoutfs_item_delete_dirty(sb, &key);
scoutfs_forest_delete_dirty(sb, &key);
break;
}
@@ -313,7 +313,7 @@ static int delete_xattr_items(struct inode *inode, u32 name_hash, u64 id,
init_xattr_key(&key, scoutfs_ino(inode), name_hash, id);
do {
ret = scoutfs_item_delete_save(sb, &key, list, lock);
ret = scoutfs_forest_delete_save(sb, &key, list, lock);
} while (ret == 0 && ++key.skx_part < nr_parts);
return ret;
@@ -528,11 +528,11 @@ retry:
hash = scoutfs_hash64(name, name_len);
scoutfs_xattr_index_key(&indx_key, hash, ino, id);
if (value)
ret = scoutfs_item_create_force(sb, &indx_key, NULL,
indx_lock);
ret = scoutfs_forest_create_force(sb, &indx_key, NULL,
indx_lock);
else
ret = scoutfs_item_delete_force(sb, &indx_key,
indx_lock);
ret = scoutfs_forest_delete_force(sb, &indx_key,
indx_lock);
if (ret < 0)
goto release;
undo_indx = true;
@@ -546,10 +546,10 @@ retry:
if (value && ret == 0)
ret = create_xattr_items(inode, id, xat, bytes, lck);
if (ret < 0) {
scoutfs_item_restore(sb, &saved, lck);
scoutfs_forest_restore(sb, &saved, lck);
goto release;
}
scoutfs_item_free_batch(sb, &saved);
scoutfs_forest_free_batch(sb, &saved);
/* XXX do these want i_mutex or anything? */
inode_inc_iversion(inode);
@@ -560,11 +560,11 @@ retry:
release:
if (ret < 0 && undo_indx) {
if (value)
err = scoutfs_item_delete_force(sb, &indx_key,
indx_lock);
err = scoutfs_forest_delete_force(sb, &indx_key,
indx_lock);
else
err = scoutfs_item_create_force(sb, &indx_key, NULL,
indx_lock);
err = scoutfs_forest_create_force(sb, &indx_key, NULL,
indx_lock);
BUG_ON(err);
}
@@ -717,7 +717,7 @@ int scoutfs_xattr_drop(struct super_block *sb, u64 ino,
for (;;) {
kvec_init(&val, (void *)xat, bytes);
ret = scoutfs_item_next(sb, &key, &last, &val, lock);
ret = scoutfs_forest_next(sb, &key, &last, &val, lock);
if (ret < 0) {
if (ret == -ENOENT)
ret = 0;
@@ -744,13 +744,13 @@ int scoutfs_xattr_drop(struct super_block *sb, u64 ino,
break;
release = true;
ret = scoutfs_item_delete(sb, &key, lock);
ret = scoutfs_forest_delete(sb, &key, lock);
if (ret < 0)
break;
if (tgs.indx) {
ret = scoutfs_item_delete_force(sb, &indx_key,
indx_lock);
ret = scoutfs_forest_delete_force(sb, &indx_key,
indx_lock);
if (ret < 0)
break;
}