diff options
| author | Jaegeuk Kim <jaegeuk@kernel.org> | 2016-01-26 11:55:35 -0800 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-04-13 12:32:54 +0200 |
| commit | ba3738edf92559a86cec401ddd85b6fd52caca41 (patch) | |
| tree | 043cf37fd4ecdc9bd7b1a052cda3cd1a80cd53dc /fs | |
| parent | f233152fd9ceedaef5bb27d16f1e5b86376f5365 (diff) | |
| download | android_kernel_m2note-ba3738edf92559a86cec401ddd85b6fd52caca41.tar.gz | |
f2fs: use wq_has_sleeper for cp_wait wait_queue
We need to use wq_has_sleeper including smp_mb to consider cp_wait concurrency.
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/f2fs/data.c | 3 | ||||
| -rw-r--r-- | fs/f2fs/f2fs.h | 21 |
2 files changed, 22 insertions, 2 deletions
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index cf6d098c7..3f4dc962f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -75,8 +75,7 @@ static void f2fs_write_end_io(struct bio *bio, int err) dec_page_count(sbi, F2FS_WRITEBACK); } - if (!get_pages(sbi, F2FS_WRITEBACK) && - !list_empty(&sbi->cp_wait.task_list)) + if (!get_pages(sbi, F2FS_WRITEBACK) && wq_has_sleeper(&sbi->cp_wait)) wake_up(&sbi->cp_wait); bio_put(bio); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index b0a2bff4a..6c7c8d833 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -105,6 +105,27 @@ static inline bool f2fs_crc_valid(__u32 blk_crc, void *buf, size_t buf_size) return f2fs_crc32(buf, buf_size) == blk_crc; } +/** + * wq_has_sleeper - check if there are any waiting processes + * @wq: wait queue head + * + * Returns true if wq has waiting processes + * + * Please refer to the comment for waitqueue_active. + */ +static inline bool wq_has_sleeper(wait_queue_head_t *wq) +{ + /* + * We need to be sure we are in sync with the + * add_wait_queue modifications to the wait queue. + * + * This memory barrier should be paired with one on the + * waiting side. + */ + smp_mb(); + return waitqueue_active(wq); +} + /* * For checkpoint manager */ |
