Lines Matching refs:ca
221 for_each_member_device_rcu(c, ca, NULL) in bch2_dev_to_fs()
222 if (ca->disk_sb.bdev && ca->disk_sb.bdev->bd_dev == dev) { in bch2_dev_to_fs()
315 for_each_member_device(c, ca) { in __bch2_fs_read_only()
316 bch2_dev_io_ref_stop(ca, WRITE); in __bch2_fs_read_only()
317 bch2_dev_allocator_remove(c, ca); in __bch2_fs_read_only()
499 for_each_online_member_rcu(c, ca) in __bch2_fs_read_write()
500 if (ca->mi.state == BCH_MEMBER_STATE_rw) { in __bch2_fs_read_write()
501 bch2_dev_allocator_add(c, ca); in __bch2_fs_read_write()
502 enumerated_ref_start(&ca->io_ref[WRITE]); in __bch2_fs_read_write()
681 struct bch_dev *ca = rcu_dereference_protected(c->devs[i], true); in __bch2_fs_stop() local
682 if (ca) in __bch2_fs_stop()
683 bch2_dev_io_ref_stop(ca, READ); in __bch2_fs_stop()
686 for_each_member_device(c, ca) in __bch2_fs_stop()
687 bch2_dev_unlink(ca); in __bch2_fs_stop()
706 for_each_member_device(c, ca) in __bch2_fs_stop()
707 cancel_work_sync(&ca->io_error_work); in __bch2_fs_stop()
722 struct bch_dev *ca = rcu_dereference_protected(c->devs[i], true); in bch2_fs_free() local
724 if (ca) { in bch2_fs_free()
725 EBUG_ON(atomic_long_read(&ca->ref) != 1); in bch2_fs_free()
726 bch2_dev_io_ref_stop(ca, READ); in bch2_fs_free()
727 bch2_free_super(&ca->disk_sb); in bch2_fs_free()
728 bch2_dev_free(ca); in bch2_fs_free()
780 for_each_member_device(c, ca) { in bch2_fs_online()
781 ret = bch2_dev_sysfs_online(c, ca); in bch2_fs_online()
784 bch2_dev_put(ca); in bch2_fs_online()
1115 for_each_online_member(c, ca, BCH_DEV_READ_REF_bch2_online_devs) { in print_mount_opts()
1117 prt_str(&p, ca->name); in print_mount_opts()
1126 struct bch_dev *ca; in bch2_fs_may_start() local
1142 ca = bch2_dev_locked(c, i); in bch2_fs_may_start()
1144 if (!bch2_dev_is_online(ca) && in bch2_fs_may_start()
1145 (ca->mi.state == BCH_MEMBER_STATE_rw || in bch2_fs_may_start()
1146 ca->mi.state == BCH_MEMBER_STATE_ro)) { in bch2_fs_may_start()
1195 for_each_online_member_rcu(c, ca) in bch2_fs_start()
1196 bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx)->last_mount = in bch2_fs_start()
1205 for_each_online_member_rcu(c, ca) in bch2_fs_start()
1206 if (ca->mi.state == BCH_MEMBER_STATE_rw) in bch2_fs_start()
1207 bch2_dev_allocator_add(c, ca); in bch2_fs_start()
1352 static void bch2_dev_io_ref_stop(struct bch_dev *ca, int rw) in bch2_dev_io_ref_stop() argument
1355 clear_bit(ca->dev_idx, ca->fs->online_devs.d); in bch2_dev_io_ref_stop()
1357 if (!enumerated_ref_is_zero(&ca->io_ref[rw])) in bch2_dev_io_ref_stop()
1358 enumerated_ref_stop(&ca->io_ref[rw], in bch2_dev_io_ref_stop()
1366 struct bch_dev *ca = container_of(kobj, struct bch_dev, kobj); in bch2_dev_release() local
1368 kfree(ca); in bch2_dev_release()
1371 static void bch2_dev_free(struct bch_dev *ca) in bch2_dev_free() argument
1373 WARN_ON(!enumerated_ref_is_zero(&ca->io_ref[WRITE])); in bch2_dev_free()
1374 WARN_ON(!enumerated_ref_is_zero(&ca->io_ref[READ])); in bch2_dev_free()
1376 cancel_work_sync(&ca->io_error_work); in bch2_dev_free()
1378 bch2_dev_unlink(ca); in bch2_dev_free()
1380 if (ca->kobj.state_in_sysfs) in bch2_dev_free()
1381 kobject_del(&ca->kobj); in bch2_dev_free()
1383 bch2_bucket_bitmap_free(&ca->bucket_backpointer_mismatch); in bch2_dev_free()
1384 bch2_bucket_bitmap_free(&ca->bucket_backpointer_empty); in bch2_dev_free()
1386 bch2_free_super(&ca->disk_sb); in bch2_dev_free()
1387 bch2_dev_allocator_background_exit(ca); in bch2_dev_free()
1388 bch2_dev_journal_exit(ca); in bch2_dev_free()
1390 free_percpu(ca->io_done); in bch2_dev_free()
1391 bch2_dev_buckets_free(ca); in bch2_dev_free()
1392 kfree(ca->sb_read_scratch); in bch2_dev_free()
1394 bch2_time_stats_quantiles_exit(&ca->io_latency[WRITE]); in bch2_dev_free()
1395 bch2_time_stats_quantiles_exit(&ca->io_latency[READ]); in bch2_dev_free()
1397 enumerated_ref_exit(&ca->io_ref[WRITE]); in bch2_dev_free()
1398 enumerated_ref_exit(&ca->io_ref[READ]); in bch2_dev_free()
1400 percpu_ref_exit(&ca->ref); in bch2_dev_free()
1402 kobject_put(&ca->kobj); in bch2_dev_free()
1405 static void __bch2_dev_offline(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_offline() argument
1410 if (enumerated_ref_is_zero(&ca->io_ref[READ])) in __bch2_dev_offline()
1413 __bch2_dev_read_only(c, ca); in __bch2_dev_offline()
1415 bch2_dev_io_ref_stop(ca, READ); in __bch2_dev_offline()
1417 bch2_dev_unlink(ca); in __bch2_dev_offline()
1419 bch2_free_super(&ca->disk_sb); in __bch2_dev_offline()
1420 bch2_dev_journal_exit(ca); in __bch2_dev_offline()
1426 struct bch_dev *ca = container_of(ref, struct bch_dev, ref); in bch2_dev_ref_complete() local
1428 complete(&ca->ref_completion); in bch2_dev_ref_complete()
1432 static void bch2_dev_unlink(struct bch_dev *ca) in bch2_dev_unlink() argument
1444 if (ca->kobj.state_in_sysfs && in bch2_dev_unlink()
1445 ca->disk_sb.bdev && in bch2_dev_unlink()
1446 (b = bdev_kobj(ca->disk_sb.bdev))->state_in_sysfs) { in bch2_dev_unlink()
1448 sysfs_remove_link(&ca->kobj, "block"); in bch2_dev_unlink()
1452 static int bch2_dev_sysfs_online(struct bch_fs *c, struct bch_dev *ca) in bch2_dev_sysfs_online() argument
1459 if (!ca->kobj.state_in_sysfs) { in bch2_dev_sysfs_online()
1460 ret = kobject_add(&ca->kobj, &c->kobj, "dev-%u", ca->dev_idx) ?: in bch2_dev_sysfs_online()
1461 bch2_opts_create_sysfs_files(&ca->kobj, OPT_DEVICE); in bch2_dev_sysfs_online()
1466 if (ca->disk_sb.bdev) { in bch2_dev_sysfs_online()
1467 struct kobject *block = bdev_kobj(ca->disk_sb.bdev); in bch2_dev_sysfs_online()
1469 ret = sysfs_create_link(block, &ca->kobj, "bcachefs"); in bch2_dev_sysfs_online()
1473 ret = sysfs_create_link(&ca->kobj, block, "block"); in bch2_dev_sysfs_online()
1484 struct bch_dev *ca; in __bch2_dev_alloc() local
1487 ca = kzalloc(sizeof(*ca), GFP_KERNEL); in __bch2_dev_alloc()
1488 if (!ca) in __bch2_dev_alloc()
1491 kobject_init(&ca->kobj, &bch2_dev_ktype); in __bch2_dev_alloc()
1492 init_completion(&ca->ref_completion); in __bch2_dev_alloc()
1494 INIT_WORK(&ca->io_error_work, bch2_io_error_work); in __bch2_dev_alloc()
1496 bch2_time_stats_quantiles_init(&ca->io_latency[READ]); in __bch2_dev_alloc()
1497 bch2_time_stats_quantiles_init(&ca->io_latency[WRITE]); in __bch2_dev_alloc()
1499 ca->mi = bch2_mi_to_cpu(member); in __bch2_dev_alloc()
1502 atomic64_set(&ca->errors[i], le64_to_cpu(member->errors[i])); in __bch2_dev_alloc()
1504 ca->uuid = member->uuid; in __bch2_dev_alloc()
1506 ca->nr_btree_reserve = DIV_ROUND_UP(BTREE_NODE_RESERVE, in __bch2_dev_alloc()
1507 ca->mi.bucket_size / btree_sectors(c)); in __bch2_dev_alloc()
1510 if (percpu_ref_init(&ca->ref, bch2_dev_ref_complete, 0, GFP_KERNEL)) in __bch2_dev_alloc()
1513 atomic_long_set(&ca->ref, 1); in __bch2_dev_alloc()
1516 mutex_init(&ca->bucket_backpointer_mismatch.lock); in __bch2_dev_alloc()
1517 mutex_init(&ca->bucket_backpointer_empty.lock); in __bch2_dev_alloc()
1519 bch2_dev_allocator_background_init(ca); in __bch2_dev_alloc()
1521 if (enumerated_ref_init(&ca->io_ref[READ], BCH_DEV_READ_REF_NR, NULL) || in __bch2_dev_alloc()
1522 enumerated_ref_init(&ca->io_ref[WRITE], BCH_DEV_WRITE_REF_NR, NULL) || in __bch2_dev_alloc()
1523 !(ca->sb_read_scratch = kmalloc(BCH_SB_READ_SCRATCH_BUF_SIZE, GFP_KERNEL)) || in __bch2_dev_alloc()
1524 bch2_dev_buckets_alloc(c, ca) || in __bch2_dev_alloc()
1525 !(ca->io_done = alloc_percpu(*ca->io_done))) in __bch2_dev_alloc()
1528 return ca; in __bch2_dev_alloc()
1530 bch2_dev_free(ca); in __bch2_dev_alloc()
1534 static void bch2_dev_attach(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_attach() argument
1537 ca->dev_idx = dev_idx; in bch2_dev_attach()
1538 __set_bit(ca->dev_idx, ca->self.d); in bch2_dev_attach()
1540 if (!ca->name[0]) in bch2_dev_attach()
1541 scnprintf(ca->name, sizeof(ca->name), "dev-%u", dev_idx); in bch2_dev_attach()
1543 ca->fs = c; in bch2_dev_attach()
1544 rcu_assign_pointer(c->devs[ca->dev_idx], ca); in bch2_dev_attach()
1546 if (bch2_dev_sysfs_online(c, ca)) in bch2_dev_attach()
1553 struct bch_dev *ca = NULL; in bch2_dev_alloc() local
1558 ca = __bch2_dev_alloc(c, &member); in bch2_dev_alloc()
1559 if (!ca) in bch2_dev_alloc()
1562 ca->fs = c; in bch2_dev_alloc()
1564 bch2_dev_attach(c, ca, dev_idx); in bch2_dev_alloc()
1570 static int __bch2_dev_attach_bdev(struct bch_dev *ca, struct bch_sb_handle *sb) in __bch2_dev_attach_bdev() argument
1574 if (bch2_dev_is_online(ca)) { in __bch2_dev_attach_bdev()
1575 bch_err(ca, "already have device online in slot %u", in __bch2_dev_attach_bdev()
1577 return bch_err_throw(ca->fs, device_already_online); in __bch2_dev_attach_bdev()
1581 ca->mi.bucket_size * ca->mi.nbuckets) { in __bch2_dev_attach_bdev()
1582 bch_err(ca, "cannot online: device too small"); in __bch2_dev_attach_bdev()
1583 return bch_err_throw(ca->fs, device_size_too_small); in __bch2_dev_attach_bdev()
1586 BUG_ON(!enumerated_ref_is_zero(&ca->io_ref[READ])); in __bch2_dev_attach_bdev()
1587 BUG_ON(!enumerated_ref_is_zero(&ca->io_ref[WRITE])); in __bch2_dev_attach_bdev()
1589 ret = bch2_dev_journal_init(ca, sb->sb); in __bch2_dev_attach_bdev()
1595 strscpy(ca->name, name.buf, sizeof(ca->name)); in __bch2_dev_attach_bdev()
1599 ca->disk_sb = *sb; in __bch2_dev_attach_bdev()
1607 ca->disk_sb.holder->c = ca->fs; in __bch2_dev_attach_bdev()
1609 ca->dev = ca->disk_sb.bdev->bd_dev; in __bch2_dev_attach_bdev()
1611 enumerated_ref_start(&ca->io_ref[READ]); in __bch2_dev_attach_bdev()
1618 struct bch_dev *ca; in bch2_dev_attach_bdev() local
1629 ca = bch2_dev_locked(c, sb->sb->dev_idx); in bch2_dev_attach_bdev()
1631 ret = __bch2_dev_attach_bdev(ca, sb); in bch2_dev_attach_bdev()
1635 set_bit(ca->dev_idx, c->online_devs.d); in bch2_dev_attach_bdev()
1637 bch2_dev_sysfs_online(c, ca); in bch2_dev_attach_bdev()
1654 bool bch2_dev_state_allowed(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_state_allowed() argument
1666 if (ca->mi.state != BCH_MEMBER_STATE_rw) in bch2_dev_state_allowed()
1671 if (ca2 != ca) in bch2_dev_state_allowed()
1684 if (ca->mi.state != BCH_MEMBER_STATE_rw && in bch2_dev_state_allowed()
1685 ca->mi.state != BCH_MEMBER_STATE_ro) in bch2_dev_state_allowed()
1690 __clear_bit(ca->dev_idx, new_online_devs.d); in bch2_dev_state_allowed()
1698 static void __bch2_dev_read_only(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_read_only() argument
1700 bch2_dev_io_ref_stop(ca, WRITE); in __bch2_dev_read_only()
1705 bch2_dev_allocator_remove(c, ca); in __bch2_dev_read_only()
1707 bch2_dev_journal_stop(&c->journal, ca); in __bch2_dev_read_only()
1710 static void __bch2_dev_read_write(struct bch_fs *c, struct bch_dev *ca) in __bch2_dev_read_write() argument
1714 BUG_ON(ca->mi.state != BCH_MEMBER_STATE_rw); in __bch2_dev_read_write()
1716 bch2_dev_allocator_add(c, ca); in __bch2_dev_read_write()
1719 if (enumerated_ref_is_zero(&ca->io_ref[WRITE])) in __bch2_dev_read_write()
1720 enumerated_ref_start(&ca->io_ref[WRITE]); in __bch2_dev_read_write()
1722 bch2_dev_do_discards(ca); in __bch2_dev_read_write()
1725 int __bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca, in __bch2_dev_set_state() argument
1731 if (ca->mi.state == new_state) in __bch2_dev_set_state()
1734 if (!bch2_dev_state_allowed(c, ca, new_state, flags)) in __bch2_dev_set_state()
1738 __bch2_dev_read_only(c, ca); in __bch2_dev_set_state()
1740 bch_notice(ca, "%s", bch2_member_states[new_state]); in __bch2_dev_set_state()
1743 m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); in __bch2_dev_set_state()
1749 __bch2_dev_read_write(c, ca); in __bch2_dev_set_state()
1756 int bch2_dev_set_state(struct bch_fs *c, struct bch_dev *ca, in bch2_dev_set_state() argument
1762 ret = __bch2_dev_set_state(c, ca, new_state, flags); in bch2_dev_set_state()
1770 int bch2_dev_remove(struct bch_fs *c, struct bch_dev *ca, int flags) in bch2_dev_remove() argument
1773 unsigned dev_idx = ca->dev_idx, data; in bch2_dev_remove()
1784 bch2_dev_put(ca); in bch2_dev_remove()
1786 if (!bch2_dev_state_allowed(c, ca, BCH_MEMBER_STATE_failed, flags)) { in bch2_dev_remove()
1787 bch_err(ca, "Cannot remove without losing data"); in bch2_dev_remove()
1792 __bch2_dev_read_only(c, ca); in bch2_dev_remove()
1795 ? bch2_dev_data_drop_by_backpointers(c, ca->dev_idx, flags) in bch2_dev_remove()
1796 : (bch2_dev_data_drop(c, ca->dev_idx, flags) ?: in bch2_dev_remove()
1797 bch2_dev_remove_stripes(c, ca->dev_idx, flags)); in bch2_dev_remove()
1802 struct bch_dev_usage usage = bch2_dev_usage_read(ca); in bch2_dev_remove()
1807 bch_err(ca, "Remove failed: still has data (%s, %llu buckets)", in bch2_dev_remove()
1813 ret = bch2_dev_remove_alloc(c, ca); in bch2_dev_remove()
1814 bch_err_msg(ca, ret, "bch2_dev_remove_alloc()"); in bch2_dev_remove()
1828 ret = bch2_journal_flush_device_pins(&c->journal, ca->dev_idx); in bch2_dev_remove()
1829 bch_err_msg(ca, ret, "bch2_journal_flush_device_pins()"); in bch2_dev_remove()
1834 bch_err_msg(ca, ret, "bch2_journal_flush()"); in bch2_dev_remove()
1839 bch_err_msg(ca, ret, "bch2_replicas_gc2()"); in bch2_dev_remove()
1843 data = bch2_dev_has_data(c, ca); in bch2_dev_remove()
1848 bch_err(ca, "Remove failed, still has data (%s)", data_has.buf); in bch2_dev_remove()
1854 __bch2_dev_offline(c, ca); in bch2_dev_remove()
1857 rcu_assign_pointer(c->devs[ca->dev_idx], NULL); in bch2_dev_remove()
1861 percpu_ref_kill(&ca->ref); in bch2_dev_remove()
1863 ca->dying = true; in bch2_dev_remove()
1864 bch2_dev_put(ca); in bch2_dev_remove()
1866 wait_for_completion(&ca->ref_completion); in bch2_dev_remove()
1868 bch2_dev_free(ca); in bch2_dev_remove()
1889 ca->mi.state == BCH_MEMBER_STATE_rw && in bch2_dev_remove()
1890 !enumerated_ref_is_zero(&ca->io_ref[READ])) in bch2_dev_remove()
1891 __bch2_dev_read_write(c, ca); in bch2_dev_remove()
1901 struct bch_dev *ca = NULL; in bch2_dev_add() local
1939 ca = __bch2_dev_alloc(c, &dev_mi); in bch2_dev_add()
1940 if (!ca) { in bch2_dev_add()
1945 ret = __bch2_dev_attach_bdev(ca, &sb); in bch2_dev_add()
1953 ret = bch2_sb_from_fs(c, ca); in bch2_dev_add()
1974 ca->disk_sb.sb->dev_idx = dev_idx; in bch2_dev_add()
1975 bch2_dev_attach(c, ca, dev_idx); in bch2_dev_add()
1978 ret = __bch2_dev_group_set(c, ca, label.buf); in bch2_dev_add()
1988 ret = bch2_dev_usage_init(ca, false); in bch2_dev_add()
1992 ret = bch2_trans_mark_dev_sb(c, ca, BTREE_TRIGGER_transactional); in bch2_dev_add()
1993 bch_err_msg(ca, ret, "marking new superblock"); in bch2_dev_add()
1998 bch_err_msg(ca, ret, "initializing free space"); in bch2_dev_add()
2002 if (ca->mi.state == BCH_MEMBER_STATE_rw) in bch2_dev_add()
2003 __bch2_dev_read_write(c, ca); in bch2_dev_add()
2005 ret = bch2_dev_journal_alloc(ca, false); in bch2_dev_add()
2015 invalidate_bdev(ca->disk_sb.bdev); in bch2_dev_add()
2025 kobject_uevent_env(&ca->disk_sb.bdev->bd_device.kobj, KOBJ_CHANGE, envp); in bch2_dev_add()
2038 if (ca) in bch2_dev_add()
2039 bch2_dev_free(ca); in bch2_dev_add()
2044 ca = NULL; in bch2_dev_add()
2053 struct bch_dev *ca; in bch2_dev_online() local
2076 ca = bch2_dev_locked(c, dev_idx); in bch2_dev_online()
2078 ret = bch2_trans_mark_dev_sb(c, ca, BTREE_TRIGGER_transactional); in bch2_dev_online()
2083 if (ca->mi.state == BCH_MEMBER_STATE_rw) in bch2_dev_online()
2084 __bch2_dev_read_write(c, ca); in bch2_dev_online()
2086 if (!ca->mi.freespace_initialized) { in bch2_dev_online()
2087 ret = bch2_dev_freespace_init(c, ca, 0, ca->mi.nbuckets); in bch2_dev_online()
2088 bch_err_msg(ca, ret, "initializing free space"); in bch2_dev_online()
2093 if (!ca->journal.nr) { in bch2_dev_online()
2094 ret = bch2_dev_journal_alloc(ca, false); in bch2_dev_online()
2095 bch_err_msg(ca, ret, "allocating journal"); in bch2_dev_online()
2101 bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx)->last_mount = in bch2_dev_online()
2114 int bch2_dev_offline(struct bch_fs *c, struct bch_dev *ca, int flags) in bch2_dev_offline() argument
2118 if (!bch2_dev_is_online(ca)) { in bch2_dev_offline()
2119 bch_err(ca, "Already offline"); in bch2_dev_offline()
2124 if (!bch2_dev_state_allowed(c, ca, BCH_MEMBER_STATE_failed, flags)) { in bch2_dev_offline()
2125 bch_err(ca, "Cannot offline required disk"); in bch2_dev_offline()
2130 __bch2_dev_offline(c, ca); in bch2_dev_offline()
2136 static int __bch2_dev_resize_alloc(struct bch_dev *ca, u64 old_nbuckets, u64 new_nbuckets) in __bch2_dev_resize_alloc() argument
2138 struct bch_fs *c = ca->fs; in __bch2_dev_resize_alloc()
2141 return bch2_trans_commit_do(ca->fs, NULL, NULL, 0, in __bch2_dev_resize_alloc()
2143 .dev = ca->dev_idx, in __bch2_dev_resize_alloc()
2145 bch2_dev_freespace_init(c, ca, old_nbuckets, new_nbuckets); in __bch2_dev_resize_alloc()
2148 int bch2_dev_resize(struct bch_fs *c, struct bch_dev *ca, u64 nbuckets) in bch2_dev_resize() argument
2155 old_nbuckets = ca->mi.nbuckets; in bch2_dev_resize()
2157 if (nbuckets < ca->mi.nbuckets) { in bch2_dev_resize()
2158 bch_err(ca, "Cannot shrink yet"); in bch2_dev_resize()
2164 bch_err(ca, "New device size too big (%llu greater than max %u)", in bch2_dev_resize()
2170 if (bch2_dev_is_online(ca) && in bch2_dev_resize()
2171 get_capacity(ca->disk_sb.bdev->bd_disk) < in bch2_dev_resize()
2172 ca->mi.bucket_size * nbuckets) { in bch2_dev_resize()
2173 bch_err(ca, "New size larger than device"); in bch2_dev_resize()
2178 ret = bch2_dev_buckets_resize(c, ca, nbuckets); in bch2_dev_resize()
2179 bch_err_msg(ca, ret, "resizing buckets"); in bch2_dev_resize()
2183 ret = bch2_trans_mark_dev_sb(c, ca, BTREE_TRIGGER_transactional); in bch2_dev_resize()
2188 m = bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); in bch2_dev_resize()
2194 if (ca->mi.freespace_initialized) { in bch2_dev_resize()
2195 ret = __bch2_dev_resize_alloc(ca, old_nbuckets, nbuckets); in bch2_dev_resize()
2208 for_each_online_member(c, ca, BCH_DEV_READ_REF_fs_resize_on_mount) { in bch2_fs_resize_on_mount()
2209 u64 old_nbuckets = ca->mi.nbuckets; in bch2_fs_resize_on_mount()
2210 u64 new_nbuckets = div64_u64(get_capacity(ca->disk_sb.bdev->bd_disk), in bch2_fs_resize_on_mount()
2211 ca->mi.bucket_size); in bch2_fs_resize_on_mount()
2213 if (ca->mi.resize_on_mount && in bch2_fs_resize_on_mount()
2214 new_nbuckets > ca->mi.nbuckets) { in bch2_fs_resize_on_mount()
2215 bch_info(ca, "resizing to size %llu", new_nbuckets * ca->mi.bucket_size); in bch2_fs_resize_on_mount()
2216 int ret = bch2_dev_buckets_resize(c, ca, new_nbuckets); in bch2_fs_resize_on_mount()
2217 bch_err_fn(ca, ret); in bch2_fs_resize_on_mount()
2219 enumerated_ref_put(&ca->io_ref[READ], in bch2_fs_resize_on_mount()
2227 bch2_members_v2_get_mut(c->disk_sb.sb, ca->dev_idx); in bch2_fs_resize_on_mount()
2235 if (ca->mi.freespace_initialized) { in bch2_fs_resize_on_mount()
2236 ret = __bch2_dev_resize_alloc(ca, old_nbuckets, new_nbuckets); in bch2_fs_resize_on_mount()
2238 enumerated_ref_put(&ca->io_ref[READ], in bch2_fs_resize_on_mount()
2255 for_each_member_device(c, ca) in bch2_dev_lookup()
2256 if (!strcmp(name, ca->name)) in bch2_dev_lookup()
2257 return ca; in bch2_dev_lookup()
2282 for_each_member_device(c, ca) in bdev_to_bch_dev()
2283 if (ca->disk_sb.bdev == bdev) in bdev_to_bch_dev()
2284 return ca; in bdev_to_bch_dev()
2305 struct bch_dev *ca = bdev_to_bch_dev(c, bdev); in bch2_fs_bdev_mark_dead() local
2306 if (!ca) in bch2_fs_bdev_mark_dead()
2309 bool dev = bch2_dev_state_allowed(c, ca, in bch2_fs_bdev_mark_dead()
2321 __bch2_log_msg_start(ca->name, &buf); in bch2_fs_bdev_mark_dead()
2326 __bch2_dev_offline(c, ca); in bch2_fs_bdev_mark_dead()
2335 bch2_dev_put(ca); in bch2_fs_bdev_mark_dead()