mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-06 08:06:56 +00:00
scoutfs: lock around dirty item writing
Writing dirty items into a segment wasn't protected by locking. It's not racing with item dirtying, bit it's absolutely racing with reads while modifying the rbtree. And shrinking will be modifying the item cache at any old time in the future. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -1488,9 +1488,12 @@ int scoutfs_item_dirty_seg(struct super_block *sb, struct scoutfs_segment *seg)
|
||||
struct item_cache *cac = sbi->item_cache;
|
||||
struct cached_item *item = NULL;
|
||||
struct cached_item *del;
|
||||
unsigned long flags;
|
||||
u32 key_bytes;
|
||||
u32 nr_items;
|
||||
|
||||
spin_lock_irqsave(&cac->lock, flags);
|
||||
|
||||
count_seg_items(cac, &nr_items, &key_bytes);
|
||||
|
||||
/* remember nr_items is passed to _first_item */
|
||||
@@ -1522,6 +1525,8 @@ int scoutfs_item_dirty_seg(struct super_block *sb, struct scoutfs_segment *seg)
|
||||
nr_items--;
|
||||
}
|
||||
|
||||
spin_unlock_irqrestore(&cac->lock, flags);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user