>From 4a8615747d96efc5067932936c1330e17edfbd16 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Thu, 6 Aug 2009 21:35:30 +0200 Subject: [PATCH 1/2] Cleanup flags handling in per-bdi flusher threads patches. Signed-off-by: Jan Kara --- fs/fs-writeback.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index dfb4767..fc7e4a3 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -53,21 +53,24 @@ struct bdi_work { unsigned long seen; atomic_t pending; - unsigned long sb_data; + struct super_block *sb; unsigned long nr_pages; enum writeback_sync_modes sync_mode; unsigned long state; }; -static struct super_block *bdi_work_sb(struct bdi_work *work) -{ - return (struct super_block *) (work->sb_data & ~1UL); -} +enum { + WS_USED_B = 0, + WS_ONSTACK_B, +}; + +#define WS_USED (1 << WS_USED_B) +#define WS_ONSTACK (1 << WS_ONSTACK_B) static inline bool bdi_work_on_stack(struct bdi_work *work) { - return work->sb_data & 1UL; + return test_bit(WS_ONSTACK_B, &work->state); } static inline void bdi_work_init(struct bdi_work *work, struct super_block *sb, @@ -75,10 +78,10 @@ static inline void bdi_work_init(struct bdi_work *work, struct super_block *sb, enum writeback_sync_modes sync_mode) { INIT_RCU_HEAD(&work->rcu_head); - work->sb_data = (unsigned long) sb; + work->sb = sb; work->nr_pages = nr_pages; work->sync_mode = sync_mode; - work->state = 1; + work->state = WS_USED; } static inline void bdi_work_init_on_stack(struct bdi_work *work, @@ -87,7 +90,7 @@ static inline void bdi_work_init_on_stack(struct bdi_work *work, enum writeback_sync_modes sync_mode) { bdi_work_init(work, sb, nr_pages, sync_mode); - work->sb_data |= 1UL; + work->state |= WS_ONSTACK; } /** @@ -104,9 +107,9 @@ int writeback_in_progress(struct backing_dev_info *bdi) static void bdi_work_clear(struct bdi_work *work) { - clear_bit(0, &work->state); + clear_bit(WS_USED_B, &work->state); smp_mb__after_clear_bit(); - wake_up_bit(&work->state, 0); + wake_up_bit(&work->state, WS_USED_B); } static void bdi_work_free(struct rcu_head *head) @@ -215,7 +218,8 @@ static void bdi_queue_work(struct backing_dev_info *bdi, struct bdi_work *work) */ static void bdi_wait_on_work_clear(struct bdi_work *work) { - wait_on_bit(&work->state, 0, bdi_sched_wait, TASK_UNINTERRUPTIBLE); + wait_on_bit(&work->state, WS_USED_B, bdi_sched_wait, + TASK_UNINTERRUPTIBLE); } static struct bdi_work *bdi_alloc_work(struct super_block *sb, long nr_pages, @@ -376,7 +380,6 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) long nr_pages, wrote = 0; while ((work = get_next_work_item(bdi, wb)) != NULL) { - struct super_block *sb = bdi_work_sb(work); enum writeback_sync_modes sync_mode; nr_pages = work->nr_pages; @@ -396,7 +399,7 @@ long wb_do_writeback(struct bdi_writeback *wb, int force_wait) if (sync_mode == WB_SYNC_NONE) wb_clear_pending(wb, work); - wrote += wb_writeback(wb, nr_pages, sb, sync_mode, 0); + wrote += wb_writeback(wb, nr_pages, work->sb, sync_mode, 0); /* * This is a data integrity writeback, so only do the -- 1.6.0.2