From be98c4dfd889eff1f30ba3a902dc2276501d67f6 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Wed, 7 Dec 2016 10:33:05 -0800 Subject: [PATCH] Fix up manifest key use The manifest entries were changed to be a single contiguous allocation. The calculation of the vec that points to the last key vec was adding the key length in units of the add manifest struct. Adding the manifest wasn't setting the key lengths nor copying the keys into their position in the entry alloc. Signed-off-by: Zach Brown --- kmod/src/manifest.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kmod/src/manifest.c b/kmod/src/manifest.c index 15c22fd5..2901c724 100644 --- a/kmod/src/manifest.c +++ b/kmod/src/manifest.c @@ -67,7 +67,7 @@ static void init_ment_keys(struct manifest_entry *ment, struct kvec *first, { scoutfs_kvec_init(first, &ment->am + 1, le16_to_cpu(ment->am.first_key_len)); - scoutfs_kvec_init(last, &ment->am + 1 + + scoutfs_kvec_init(last, (void *)(&ment->am + 1) + le16_to_cpu(ment->am.first_key_len), le16_to_cpu(ment->am.last_key_len)); } @@ -209,6 +209,8 @@ int scoutfs_manifest_add(struct super_block *sb, struct kvec *first, { DECLARE_MANIFEST(sb, mani); struct manifest_entry *ment; + SCOUTFS_DECLARE_KVEC(ment_first); + SCOUTFS_DECLARE_KVEC(ment_last); unsigned long flags; int bytes; int ret; @@ -229,8 +231,14 @@ int scoutfs_manifest_add(struct super_block *sb, struct kvec *first, ment->am.eh.len = cpu_to_le16(bytes); ment->am.segno = cpu_to_le64(segno); ment->am.seq = cpu_to_le64(seq); + ment->am.first_key_len = cpu_to_le16(scoutfs_kvec_length(first)); + ment->am.last_key_len = cpu_to_le16(scoutfs_kvec_length(last)); ment->am.level = level; + init_ment_keys(ment, ment_first, ment_last); + scoutfs_kvec_memcpy(ment_first, first); + scoutfs_kvec_memcpy(ment_last, last); + /* XXX think about where to insert level 0 */ spin_lock_irqsave(&mani->lock, flags); ret = add_ment(mani, ment, dirty);