writeback.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * background writeback - scan btree for dirty data and write it to the backing
  4. * device
  5. *
  6. * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com>
  7. * Copyright 2012 Google, Inc.
  8. */
  9. #include "bcache.h"
  10. #include "btree.h"
  11. #include "debug.h"
  12. #include "writeback.h"
  13. #include <linux/delay.h>
  14. #include <linux/kthread.h>
  15. #include <linux/sched/clock.h>
  16. #include <trace/events/bcache.h>
  17. /* Rate limiting */
  18. static uint64_t __calc_target_rate(struct cached_dev *dc)
  19. {
  20. struct cache_set *c = dc->disk.c;
  21. /*
  22. * This is the size of the cache, minus the amount used for
  23. * flash-only devices
  24. */
  25. uint64_t cache_sectors = c->nbuckets * c->sb.bucket_size -
  26. bcache_flash_devs_sectors_dirty(c);
  27. /*
  28. * Unfortunately there is no control of global dirty data. If the
  29. * user states that they want 10% dirty data in the cache, and has,
  30. * e.g., 5 backing volumes of equal size, we try and ensure each
  31. * backing volume uses about 2% of the cache for dirty data.
  32. */
  33. uint32_t bdev_share =
  34. div64_u64(bdev_sectors(dc->bdev) << WRITEBACK_SHARE_SHIFT,
  35. c->cached_dev_sectors);
  36. uint64_t cache_dirty_target =
  37. div_u64(cache_sectors * dc->writeback_percent, 100);
  38. /* Ensure each backing dev gets at least one dirty share */
  39. if (bdev_share < 1)
  40. bdev_share = 1;
  41. return (cache_dirty_target * bdev_share) >> WRITEBACK_SHARE_SHIFT;
  42. }
  43. static void __update_writeback_rate(struct cached_dev *dc)
  44. {
  45. /*
  46. * PI controller:
  47. * Figures out the amount that should be written per second.
  48. *
  49. * First, the error (number of sectors that are dirty beyond our
  50. * target) is calculated. The error is accumulated (numerically
  51. * integrated).
  52. *
  53. * Then, the proportional value and integral value are scaled
  54. * based on configured values. These are stored as inverses to
  55. * avoid fixed point math and to make configuration easy-- e.g.
  56. * the default value of 40 for writeback_rate_p_term_inverse
  57. * attempts to write at a rate that would retire all the dirty
  58. * blocks in 40 seconds.
  59. *
  60. * The writeback_rate_i_inverse value of 10000 means that 1/10000th
  61. * of the error is accumulated in the integral term per second.
  62. * This acts as a slow, long-term average that is not subject to
  63. * variations in usage like the p term.
  64. */
  65. int64_t target = __calc_target_rate(dc);
  66. int64_t dirty = bcache_dev_sectors_dirty(&dc->disk);
  67. int64_t error = dirty - target;
  68. int64_t proportional_scaled =
  69. div_s64(error, dc->writeback_rate_p_term_inverse);
  70. int64_t integral_scaled;
  71. uint32_t new_rate;
  72. if ((error < 0 && dc->writeback_rate_integral > 0) ||
  73. (error > 0 && time_before64(local_clock(),
  74. dc->writeback_rate.next + NSEC_PER_MSEC))) {
  75. /*
  76. * Only decrease the integral term if it's more than
  77. * zero. Only increase the integral term if the device
  78. * is keeping up. (Don't wind up the integral
  79. * ineffectively in either case).
  80. *
  81. * It's necessary to scale this by
  82. * writeback_rate_update_seconds to keep the integral
  83. * term dimensioned properly.
  84. */
  85. dc->writeback_rate_integral += error *
  86. dc->writeback_rate_update_seconds;
  87. }
  88. integral_scaled = div_s64(dc->writeback_rate_integral,
  89. dc->writeback_rate_i_term_inverse);
  90. new_rate = clamp_t(int32_t, (proportional_scaled + integral_scaled),
  91. dc->writeback_rate_minimum, NSEC_PER_SEC);
  92. dc->writeback_rate_proportional = proportional_scaled;
  93. dc->writeback_rate_integral_scaled = integral_scaled;
  94. dc->writeback_rate_change = new_rate - dc->writeback_rate.rate;
  95. dc->writeback_rate.rate = new_rate;
  96. dc->writeback_rate_target = target;
  97. }
  98. static void update_writeback_rate(struct work_struct *work)
  99. {
  100. struct cached_dev *dc = container_of(to_delayed_work(work),
  101. struct cached_dev,
  102. writeback_rate_update);
  103. down_read(&dc->writeback_lock);
  104. if (atomic_read(&dc->has_dirty) &&
  105. dc->writeback_percent)
  106. __update_writeback_rate(dc);
  107. up_read(&dc->writeback_lock);
  108. schedule_delayed_work(&dc->writeback_rate_update,
  109. dc->writeback_rate_update_seconds * HZ);
  110. }
  111. static unsigned writeback_delay(struct cached_dev *dc, unsigned sectors)
  112. {
  113. if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) ||
  114. !dc->writeback_percent)
  115. return 0;
  116. return bch_next_delay(&dc->writeback_rate, sectors);
  117. }
  118. struct dirty_io {
  119. struct closure cl;
  120. struct cached_dev *dc;
  121. uint16_t sequence;
  122. struct bio bio;
  123. };
  124. static void dirty_init(struct keybuf_key *w)
  125. {
  126. struct dirty_io *io = w->private;
  127. struct bio *bio = &io->bio;
  128. bio_init(bio, bio->bi_inline_vecs,
  129. DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS));
  130. if (!io->dc->writeback_percent)
  131. bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));
  132. bio->bi_iter.bi_size = KEY_SIZE(&w->key) << 9;
  133. bio->bi_private = w;
  134. bch_bio_map(bio, NULL);
  135. }
  136. static void dirty_io_destructor(struct closure *cl)
  137. {
  138. struct dirty_io *io = container_of(cl, struct dirty_io, cl);
  139. kfree(io);
  140. }
  141. static void write_dirty_finish(struct closure *cl)
  142. {
  143. struct dirty_io *io = container_of(cl, struct dirty_io, cl);
  144. struct keybuf_key *w = io->bio.bi_private;
  145. struct cached_dev *dc = io->dc;
  146. bio_free_pages(&io->bio);
  147. /* This is kind of a dumb way of signalling errors. */
  148. if (KEY_DIRTY(&w->key)) {
  149. int ret;
  150. unsigned i;
  151. struct keylist keys;
  152. bch_keylist_init(&keys);
  153. bkey_copy(keys.top, &w->key);
  154. SET_KEY_DIRTY(keys.top, false);
  155. bch_keylist_push(&keys);
  156. for (i = 0; i < KEY_PTRS(&w->key); i++)
  157. atomic_inc(&PTR_BUCKET(dc->disk.c, &w->key, i)->pin);
  158. ret = bch_btree_insert(dc->disk.c, &keys, NULL, &w->key);
  159. if (ret)
  160. trace_bcache_writeback_collision(&w->key);
  161. atomic_long_inc(ret
  162. ? &dc->disk.c->writeback_keys_failed
  163. : &dc->disk.c->writeback_keys_done);
  164. }
  165. bch_keybuf_del(&dc->writeback_keys, w);
  166. up(&dc->in_flight);
  167. closure_return_with_destructor(cl, dirty_io_destructor);
  168. }
  169. static void dirty_endio(struct bio *bio)
  170. {
  171. struct keybuf_key *w = bio->bi_private;
  172. struct dirty_io *io = w->private;
  173. if (bio->bi_status)
  174. SET_KEY_DIRTY(&w->key, false);
  175. closure_put(&io->cl);
  176. }
  177. static void write_dirty(struct closure *cl)
  178. {
  179. struct dirty_io *io = container_of(cl, struct dirty_io, cl);
  180. struct keybuf_key *w = io->bio.bi_private;
  181. struct cached_dev *dc = io->dc;
  182. uint16_t next_sequence;
  183. if (atomic_read(&dc->writeback_sequence_next) != io->sequence) {
  184. /* Not our turn to write; wait for a write to complete */
  185. closure_wait(&dc->writeback_ordering_wait, cl);
  186. if (atomic_read(&dc->writeback_sequence_next) == io->sequence) {
  187. /*
  188. * Edge case-- it happened in indeterminate order
  189. * relative to when we were added to wait list..
  190. */
  191. closure_wake_up(&dc->writeback_ordering_wait);
  192. }
  193. continue_at(cl, write_dirty, io->dc->writeback_write_wq);
  194. return;
  195. }
  196. next_sequence = io->sequence + 1;
  197. /*
  198. * IO errors are signalled using the dirty bit on the key.
  199. * If we failed to read, we should not attempt to write to the
  200. * backing device. Instead, immediately go to write_dirty_finish
  201. * to clean up.
  202. */
  203. if (KEY_DIRTY(&w->key)) {
  204. dirty_init(w);
  205. bio_set_op_attrs(&io->bio, REQ_OP_WRITE, 0);
  206. io->bio.bi_iter.bi_sector = KEY_START(&w->key);
  207. bio_set_dev(&io->bio, io->dc->bdev);
  208. io->bio.bi_end_io = dirty_endio;
  209. closure_bio_submit(&io->bio, cl);
  210. }
  211. atomic_set(&dc->writeback_sequence_next, next_sequence);
  212. closure_wake_up(&dc->writeback_ordering_wait);
  213. continue_at(cl, write_dirty_finish, io->dc->writeback_write_wq);
  214. }
  215. static void read_dirty_endio(struct bio *bio)
  216. {
  217. struct keybuf_key *w = bio->bi_private;
  218. struct dirty_io *io = w->private;
  219. /* is_read = 1 */
  220. bch_count_io_errors(PTR_CACHE(io->dc->disk.c, &w->key, 0),
  221. bio->bi_status, 1,
  222. "reading dirty data from cache");
  223. dirty_endio(bio);
  224. }
  225. static void read_dirty_submit(struct closure *cl)
  226. {
  227. struct dirty_io *io = container_of(cl, struct dirty_io, cl);
  228. closure_bio_submit(&io->bio, cl);
  229. continue_at(cl, write_dirty, io->dc->writeback_write_wq);
  230. }
  231. static void read_dirty(struct cached_dev *dc)
  232. {
  233. unsigned delay = 0;
  234. struct keybuf_key *next, *keys[MAX_WRITEBACKS_IN_PASS], *w;
  235. size_t size;
  236. int nk, i;
  237. struct dirty_io *io;
  238. struct closure cl;
  239. uint16_t sequence = 0;
  240. BUG_ON(!llist_empty(&dc->writeback_ordering_wait.list));
  241. atomic_set(&dc->writeback_sequence_next, sequence);
  242. closure_init_stack(&cl);
  243. /*
  244. * XXX: if we error, background writeback just spins. Should use some
  245. * mempools.
  246. */
  247. next = bch_keybuf_next(&dc->writeback_keys);
  248. while (!kthread_should_stop() && next) {
  249. size = 0;
  250. nk = 0;
  251. do {
  252. BUG_ON(ptr_stale(dc->disk.c, &next->key, 0));
  253. /*
  254. * Don't combine too many operations, even if they
  255. * are all small.
  256. */
  257. if (nk >= MAX_WRITEBACKS_IN_PASS)
  258. break;
  259. /*
  260. * If the current operation is very large, don't
  261. * further combine operations.
  262. */
  263. if (size >= MAX_WRITESIZE_IN_PASS)
  264. break;
  265. /*
  266. * Operations are only eligible to be combined
  267. * if they are contiguous.
  268. *
  269. * TODO: add a heuristic willing to fire a
  270. * certain amount of non-contiguous IO per pass,
  271. * so that we can benefit from backing device
  272. * command queueing.
  273. */
  274. if ((nk != 0) && bkey_cmp(&keys[nk-1]->key,
  275. &START_KEY(&next->key)))
  276. break;
  277. size += KEY_SIZE(&next->key);
  278. keys[nk++] = next;
  279. } while ((next = bch_keybuf_next(&dc->writeback_keys)));
  280. /* Now we have gathered a set of 1..5 keys to write back. */
  281. for (i = 0; i < nk; i++) {
  282. w = keys[i];
  283. io = kzalloc(sizeof(struct dirty_io) +
  284. sizeof(struct bio_vec) *
  285. DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS),
  286. GFP_KERNEL);
  287. if (!io)
  288. goto err;
  289. w->private = io;
  290. io->dc = dc;
  291. io->sequence = sequence++;
  292. dirty_init(w);
  293. bio_set_op_attrs(&io->bio, REQ_OP_READ, 0);
  294. io->bio.bi_iter.bi_sector = PTR_OFFSET(&w->key, 0);
  295. bio_set_dev(&io->bio,
  296. PTR_CACHE(dc->disk.c, &w->key, 0)->bdev);
  297. io->bio.bi_end_io = read_dirty_endio;
  298. if (bch_bio_alloc_pages(&io->bio, GFP_KERNEL))
  299. goto err_free;
  300. trace_bcache_writeback(&w->key);
  301. down(&dc->in_flight);
  302. /* We've acquired a semaphore for the maximum
  303. * simultaneous number of writebacks; from here
  304. * everything happens asynchronously.
  305. */
  306. closure_call(&io->cl, read_dirty_submit, NULL, &cl);
  307. }
  308. delay = writeback_delay(dc, size);
  309. /* If the control system would wait for at least half a
  310. * second, and there's been no reqs hitting the backing disk
  311. * for awhile: use an alternate mode where we have at most
  312. * one contiguous set of writebacks in flight at a time. If
  313. * someone wants to do IO it will be quick, as it will only
  314. * have to contend with one operation in flight, and we'll
  315. * be round-tripping data to the backing disk as quickly as
  316. * it can accept it.
  317. */
  318. if (delay >= HZ / 2) {
  319. /* 3 means at least 1.5 seconds, up to 7.5 if we
  320. * have slowed way down.
  321. */
  322. if (atomic_inc_return(&dc->backing_idle) >= 3) {
  323. /* Wait for current I/Os to finish */
  324. closure_sync(&cl);
  325. /* And immediately launch a new set. */
  326. delay = 0;
  327. }
  328. }
  329. while (!kthread_should_stop() && delay) {
  330. schedule_timeout_interruptible(delay);
  331. delay = writeback_delay(dc, 0);
  332. }
  333. }
  334. if (0) {
  335. err_free:
  336. kfree(w->private);
  337. err:
  338. bch_keybuf_del(&dc->writeback_keys, w);
  339. }
  340. /*
  341. * Wait for outstanding writeback IOs to finish (and keybuf slots to be
  342. * freed) before refilling again
  343. */
  344. closure_sync(&cl);
  345. }
  346. /* Scan for dirty data */
  347. void bcache_dev_sectors_dirty_add(struct cache_set *c, unsigned inode,
  348. uint64_t offset, int nr_sectors)
  349. {
  350. struct bcache_device *d = c->devices[inode];
  351. unsigned stripe_offset, stripe, sectors_dirty;
  352. if (!d)
  353. return;
  354. stripe = offset_to_stripe(d, offset);
  355. stripe_offset = offset & (d->stripe_size - 1);
  356. while (nr_sectors) {
  357. int s = min_t(unsigned, abs(nr_sectors),
  358. d->stripe_size - stripe_offset);
  359. if (nr_sectors < 0)
  360. s = -s;
  361. if (stripe >= d->nr_stripes)
  362. return;
  363. sectors_dirty = atomic_add_return(s,
  364. d->stripe_sectors_dirty + stripe);
  365. if (sectors_dirty == d->stripe_size)
  366. set_bit(stripe, d->full_dirty_stripes);
  367. else
  368. clear_bit(stripe, d->full_dirty_stripes);
  369. nr_sectors -= s;
  370. stripe_offset = 0;
  371. stripe++;
  372. }
  373. }
  374. static bool dirty_pred(struct keybuf *buf, struct bkey *k)
  375. {
  376. struct cached_dev *dc = container_of(buf, struct cached_dev, writeback_keys);
  377. BUG_ON(KEY_INODE(k) != dc->disk.id);
  378. return KEY_DIRTY(k);
  379. }
  380. static void refill_full_stripes(struct cached_dev *dc)
  381. {
  382. struct keybuf *buf = &dc->writeback_keys;
  383. unsigned start_stripe, stripe, next_stripe;
  384. bool wrapped = false;
  385. stripe = offset_to_stripe(&dc->disk, KEY_OFFSET(&buf->last_scanned));
  386. if (stripe >= dc->disk.nr_stripes)
  387. stripe = 0;
  388. start_stripe = stripe;
  389. while (1) {
  390. stripe = find_next_bit(dc->disk.full_dirty_stripes,
  391. dc->disk.nr_stripes, stripe);
  392. if (stripe == dc->disk.nr_stripes)
  393. goto next;
  394. next_stripe = find_next_zero_bit(dc->disk.full_dirty_stripes,
  395. dc->disk.nr_stripes, stripe);
  396. buf->last_scanned = KEY(dc->disk.id,
  397. stripe * dc->disk.stripe_size, 0);
  398. bch_refill_keybuf(dc->disk.c, buf,
  399. &KEY(dc->disk.id,
  400. next_stripe * dc->disk.stripe_size, 0),
  401. dirty_pred);
  402. if (array_freelist_empty(&buf->freelist))
  403. return;
  404. stripe = next_stripe;
  405. next:
  406. if (wrapped && stripe > start_stripe)
  407. return;
  408. if (stripe == dc->disk.nr_stripes) {
  409. stripe = 0;
  410. wrapped = true;
  411. }
  412. }
  413. }
  414. /*
  415. * Returns true if we scanned the entire disk
  416. */
  417. static bool refill_dirty(struct cached_dev *dc)
  418. {
  419. struct keybuf *buf = &dc->writeback_keys;
  420. struct bkey start = KEY(dc->disk.id, 0, 0);
  421. struct bkey end = KEY(dc->disk.id, MAX_KEY_OFFSET, 0);
  422. struct bkey start_pos;
  423. /*
  424. * make sure keybuf pos is inside the range for this disk - at bringup
  425. * we might not be attached yet so this disk's inode nr isn't
  426. * initialized then
  427. */
  428. if (bkey_cmp(&buf->last_scanned, &start) < 0 ||
  429. bkey_cmp(&buf->last_scanned, &end) > 0)
  430. buf->last_scanned = start;
  431. if (dc->partial_stripes_expensive) {
  432. refill_full_stripes(dc);
  433. if (array_freelist_empty(&buf->freelist))
  434. return false;
  435. }
  436. start_pos = buf->last_scanned;
  437. bch_refill_keybuf(dc->disk.c, buf, &end, dirty_pred);
  438. if (bkey_cmp(&buf->last_scanned, &end) < 0)
  439. return false;
  440. /*
  441. * If we get to the end start scanning again from the beginning, and
  442. * only scan up to where we initially started scanning from:
  443. */
  444. buf->last_scanned = start;
  445. bch_refill_keybuf(dc->disk.c, buf, &start_pos, dirty_pred);
  446. return bkey_cmp(&buf->last_scanned, &start_pos) >= 0;
  447. }
  448. static int bch_writeback_thread(void *arg)
  449. {
  450. struct cached_dev *dc = arg;
  451. bool searched_full_index;
  452. bch_ratelimit_reset(&dc->writeback_rate);
  453. while (!kthread_should_stop()) {
  454. down_write(&dc->writeback_lock);
  455. if (!atomic_read(&dc->has_dirty) ||
  456. (!test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags) &&
  457. !dc->writeback_running)) {
  458. up_write(&dc->writeback_lock);
  459. set_current_state(TASK_INTERRUPTIBLE);
  460. if (kthread_should_stop())
  461. return 0;
  462. schedule();
  463. continue;
  464. }
  465. searched_full_index = refill_dirty(dc);
  466. if (searched_full_index &&
  467. RB_EMPTY_ROOT(&dc->writeback_keys.keys)) {
  468. atomic_set(&dc->has_dirty, 0);
  469. cached_dev_put(dc);
  470. SET_BDEV_STATE(&dc->sb, BDEV_STATE_CLEAN);
  471. bch_write_bdev_super(dc, NULL);
  472. }
  473. up_write(&dc->writeback_lock);
  474. read_dirty(dc);
  475. if (searched_full_index) {
  476. unsigned delay = dc->writeback_delay * HZ;
  477. while (delay &&
  478. !kthread_should_stop() &&
  479. !test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags))
  480. delay = schedule_timeout_interruptible(delay);
  481. bch_ratelimit_reset(&dc->writeback_rate);
  482. }
  483. }
  484. return 0;
  485. }
  486. /* Init */
  487. struct sectors_dirty_init {
  488. struct btree_op op;
  489. unsigned inode;
  490. };
  491. static int sectors_dirty_init_fn(struct btree_op *_op, struct btree *b,
  492. struct bkey *k)
  493. {
  494. struct sectors_dirty_init *op = container_of(_op,
  495. struct sectors_dirty_init, op);
  496. if (KEY_INODE(k) > op->inode)
  497. return MAP_DONE;
  498. if (KEY_DIRTY(k))
  499. bcache_dev_sectors_dirty_add(b->c, KEY_INODE(k),
  500. KEY_START(k), KEY_SIZE(k));
  501. return MAP_CONTINUE;
  502. }
  503. void bch_sectors_dirty_init(struct bcache_device *d)
  504. {
  505. struct sectors_dirty_init op;
  506. bch_btree_op_init(&op.op, -1);
  507. op.inode = d->id;
  508. bch_btree_map_keys(&op.op, d->c, &KEY(op.inode, 0, 0),
  509. sectors_dirty_init_fn, 0);
  510. }
  511. void bch_cached_dev_writeback_init(struct cached_dev *dc)
  512. {
  513. sema_init(&dc->in_flight, 64);
  514. init_rwsem(&dc->writeback_lock);
  515. bch_keybuf_init(&dc->writeback_keys);
  516. dc->writeback_metadata = true;
  517. dc->writeback_running = true;
  518. dc->writeback_percent = 10;
  519. dc->writeback_delay = 30;
  520. dc->writeback_rate.rate = 1024;
  521. dc->writeback_rate_minimum = 8;
  522. dc->writeback_rate_update_seconds = 5;
  523. dc->writeback_rate_p_term_inverse = 40;
  524. dc->writeback_rate_i_term_inverse = 10000;
  525. INIT_DELAYED_WORK(&dc->writeback_rate_update, update_writeback_rate);
  526. }
  527. int bch_cached_dev_writeback_start(struct cached_dev *dc)
  528. {
  529. dc->writeback_write_wq = alloc_workqueue("bcache_writeback_wq",
  530. WQ_MEM_RECLAIM, 0);
  531. if (!dc->writeback_write_wq)
  532. return -ENOMEM;
  533. dc->writeback_thread = kthread_create(bch_writeback_thread, dc,
  534. "bcache_writeback");
  535. if (IS_ERR(dc->writeback_thread))
  536. return PTR_ERR(dc->writeback_thread);
  537. schedule_delayed_work(&dc->writeback_rate_update,
  538. dc->writeback_rate_update_seconds * HZ);
  539. bch_writeback_queue(dc);
  540. return 0;
  541. }