From 1f933016f09aa35419b616a1dae1c327c6053820 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 23 May 2017 12:58:09 -0700 Subject: [PATCH] scoutfs: remove ephemeral items Ephemeral items were only used by the page cache which tracked page contents in items whose values pointed to the pages. Remove their special case. Signed-off-by: Zach Brown --- kmod/src/counters.h | 2 -- kmod/src/item.c | 76 ++------------------------------------------- kmod/src/item.h | 6 ---- 3 files changed, 3 insertions(+), 81 deletions(-) diff --git a/kmod/src/counters.h b/kmod/src/counters.h index c9d081a6..3e35a1be 100644 --- a/kmod/src/counters.h +++ b/kmod/src/counters.h @@ -29,8 +29,6 @@ EXPAND_COUNTER(data_writepage) \ EXPAND_COUNTER(data_end_writeback_page) \ EXPAND_COUNTER(item_create) \ - EXPAND_COUNTER(item_create_ephemeral) \ - EXPAND_COUNTER(item_update_ephemeral) \ EXPAND_COUNTER(item_lookup_hit) \ EXPAND_COUNTER(item_lookup_miss) \ EXPAND_COUNTER(item_delete) \ diff --git a/kmod/src/item.c b/kmod/src/item.c index ba213f8c..440912fe 100644 --- a/kmod/src/item.c +++ b/kmod/src/item.c @@ -70,8 +70,7 @@ struct cached_item { }; long dirty; - unsigned deletion:1, - ephemeral:1; + unsigned deletion:1; struct scoutfs_key_buf *key; @@ -94,8 +93,7 @@ static void free_item(struct super_block *sb, struct cached_item *item) { if (!IS_ERR_OR_NULL(item)) { scoutfs_key_free(sb, item->key); - if (!item->ephemeral) - scoutfs_kvec_kfree(item->val); + scoutfs_kvec_kfree(item->val); kfree(item); } } @@ -921,74 +919,6 @@ int scoutfs_item_create(struct super_block *sb, struct scoutfs_key_buf *key, return ret; } -/* - * Ephemeral items are slightly magical and used to track file contents - * without copying the data into an allocated value. - * - * Their value kvec clones the callers which means they reference - * external data. They're freed after items are copied into segments so - * that callers can know that no items reference their structures after - * a commit finishes. - * - * They forcefully clobber any existing item at their key without - * reading the existing item. - */ -int scoutfs_item_create_ephemeral(struct super_block *sb, - struct scoutfs_key_buf *key, - struct kvec *val) -{ - struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); - struct item_cache *cac = sbi->item_cache; - struct cached_item *item; - unsigned long flags; - int ret; - - item = alloc_item(sb, key, NULL); - if (!item) - return -ENOMEM; - - scoutfs_kvec_clone(item->val, val); - item->ephemeral = 1; - - spin_lock_irqsave(&cac->lock, flags); - - ret = insert_item(sb, cac, item, true); - BUG_ON(ret); - - scoutfs_inc_counter(sb, item_create_ephemeral); - mark_item_dirty(sb, cac, item); - - spin_unlock_irqrestore(&cac->lock, flags); - - return ret; -} - -/* - * Update the value for an ephemeral item if it exists. - */ -void scoutfs_item_update_ephemeral(struct super_block *sb, - struct scoutfs_key_buf *key, - struct kvec *val) -{ - struct scoutfs_sb_info *sbi = SCOUTFS_SB(sb); - struct item_cache *cac = sbi->item_cache; - struct cached_item *item; - unsigned long flags; - - spin_lock_irqsave(&cac->lock, flags); - - item = find_item(sb, &cac->items, key); - if (item && item->ephemeral) { - trace_printk("updating ephemeral item %p\n", item); - scoutfs_inc_counter(sb, item_update_ephemeral); - clear_item_dirty(sb, cac, item); - scoutfs_kvec_clone(item->val, val); - mark_item_dirty(sb, cac, item); - } - - spin_unlock_irqrestore(&cac->lock, flags); -} - /* * Allocate an item with the key and value and add it to the list of * items to be inserted as a batch later. The caller adds in sort order @@ -1623,7 +1553,7 @@ int scoutfs_item_dirty_seg(struct super_block *sb, struct scoutfs_segment *seg) del = item; item = next_dirty(item); - if (del->deletion || del->ephemeral) + if (del->deletion) erase_item(sb, cac, del); nr_items--; diff --git a/kmod/src/item.h b/kmod/src/item.h index 868aeeb6..97ef8bc1 100644 --- a/kmod/src/item.h +++ b/kmod/src/item.h @@ -27,15 +27,9 @@ int scoutfs_item_next_same(struct super_block *sb, struct scoutfs_key_buf *key, struct scoutfs_key_buf *last, struct kvec *val); int scoutfs_item_create(struct super_block *sb, struct scoutfs_key_buf *key, struct kvec *val); -int scoutfs_item_create_ephemeral(struct super_block *sb, - struct scoutfs_key_buf *key, - struct kvec *val); int scoutfs_item_dirty(struct super_block *sb, struct scoutfs_key_buf *key); int scoutfs_item_update(struct super_block *sb, struct scoutfs_key_buf *key, struct kvec *val); -void scoutfs_item_update_ephemeral(struct super_block *sb, - struct scoutfs_key_buf *key, - struct kvec *val); void scoutfs_item_delete_dirty(struct super_block *sb, struct scoutfs_key_buf *key); int scoutfs_item_delete_many(struct super_block *sb,