Lines Matching +full:dc +full:- +full:dc
1 /* SPDX-License-Identifier: GPL-2.0 */
53 for (i = 0; i < d->nr_stripes; i++) in bcache_dev_sectors_dirty()
54 ret += atomic_read(d->stripe_sectors_dirty + i); in bcache_dev_sectors_dirty()
62 do_div(offset, d->stripe_size); in offset_to_stripe()
64 /* d->nr_stripes is in range [1, INT_MAX] */ in offset_to_stripe()
65 if (unlikely(offset >= d->nr_stripes)) { in offset_to_stripe()
67 offset, d->nr_stripes); in offset_to_stripe()
68 return -EINVAL; in offset_to_stripe()
78 static inline bool bcache_dev_stripe_dirty(struct cached_dev *dc, in bcache_dev_stripe_dirty() argument
82 int stripe = offset_to_stripe(&dc->disk, offset); in bcache_dev_stripe_dirty()
88 if (atomic_read(dc->disk.stripe_sectors_dirty + stripe)) in bcache_dev_stripe_dirty()
91 if (nr_sectors <= dc->disk.stripe_size) in bcache_dev_stripe_dirty()
94 nr_sectors -= dc->disk.stripe_size; in bcache_dev_stripe_dirty()
102 static inline bool should_writeback(struct cached_dev *dc, struct bio *bio, in should_writeback() argument
105 unsigned int in_use = dc->disk.c->gc_stats.in_use; in should_writeback()
108 test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) || in should_writeback()
115 if (dc->partial_stripes_expensive && in should_writeback()
116 bcache_dev_stripe_dirty(dc, bio->bi_iter.bi_sector, in should_writeback()
123 return (op_is_sync(bio->bi_opf) || in should_writeback()
124 bio->bi_opf & (REQ_META|REQ_PRIO) || in should_writeback()
128 static inline void bch_writeback_queue(struct cached_dev *dc) in bch_writeback_queue() argument
130 if (!IS_ERR_OR_NULL(dc->writeback_thread)) in bch_writeback_queue()
131 wake_up_process(dc->writeback_thread); in bch_writeback_queue()
134 static inline void bch_writeback_add(struct cached_dev *dc) in bch_writeback_add() argument
136 if (!atomic_read(&dc->has_dirty) && in bch_writeback_add()
137 !atomic_xchg(&dc->has_dirty, 1)) { in bch_writeback_add()
138 if (BDEV_STATE(&dc->sb) != BDEV_STATE_DIRTY) { in bch_writeback_add()
139 SET_BDEV_STATE(&dc->sb, BDEV_STATE_DIRTY); in bch_writeback_add()
141 bch_write_bdev_super(dc, NULL); in bch_writeback_add()
144 bch_writeback_queue(dc); in bch_writeback_add()
152 void bch_cached_dev_writeback_init(struct cached_dev *dc);
153 int bch_cached_dev_writeback_start(struct cached_dev *dc);