From aad5a34290a19be56474c5f02f118cae4f08c61c Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 12 Jan 2017 11:17:46 -0800 Subject: [PATCH] Don't prematurely write dirty super A previous refactoring messed up and had scoutfs_trans_write_func() always write the dirty super even when nothing was dirty and there was nothing for the sync attempt to do. This was very confusing and made it look like the segment and treap writes were being lost when in fact it was the super write that shouldn't have happened. Signed-off-by: Zach Brown --- kmod/src/trans.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/kmod/src/trans.c b/kmod/src/trans.c index 6ea4b5f8..5987646c 100644 --- a/kmod/src/trans.c +++ b/kmod/src/trans.c @@ -84,7 +84,6 @@ void scoutfs_trans_write_func(struct work_struct *work) struct scoutfs_segment *seg; bool advance = false; int ret = 0; - int err; scoutfs_bio_init_comp(&comp); sbi->trans_task = current; @@ -101,7 +100,6 @@ void scoutfs_trans_write_func(struct work_struct *work) * XXX this needs serious work to handle errors. */ while (scoutfs_item_dirty_bytes(sb)) { - advance = true; seg = NULL; ret = scoutfs_seg_alloc(sb, &seg) ?: scoutfs_item_dirty_seg(sb, seg) ?: @@ -115,26 +113,21 @@ void scoutfs_trans_write_func(struct work_struct *work) } if (scoutfs_manifest_has_dirty(sb) || scoutfs_alloc_has_dirty(sb)) { - advance = true; ret = scoutfs_manifest_dirty_ring(sb) ?: scoutfs_alloc_dirty_ring(sb) ?: - scoutfs_treap_submit_write(sb, &comp); + scoutfs_treap_submit_write(sb, &comp) ?: + scoutfs_bio_wait_comp(sb, &comp) ?: + scoutfs_write_dirty_super(sb); if (ret) goto out; + + advance = true; } out: - err = scoutfs_bio_wait_comp(sb, &comp) ?: - scoutfs_write_dirty_super(sb); - if (err && !ret) - ret = err; - /* XXX this all needs serious work for dealing with errors */ WARN_ON_ONCE(ret); - if (advance && ret) - advance = false; - spin_lock(&sbi->trans_write_lock); if (advance) scoutfs_advance_dirty_super(sb);