super.c (8d29c4426b9f8afaccf28de414fde8a722b35fdf) super.c (2831231d4c3f999d2d062b23dfbc8b0faa4bc6e0)
1/*
2 * bcache setup/teardown code, and some metadata io - read a superblock and
3 * figure out what to do with it.
4 *
5 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com>
6 * Copyright 2012 Google, Inc.
7 */
8

--- 707 unchanged lines hidden (view full) ---

716
717static void bcache_device_attach(struct bcache_device *d, struct cache_set *c,
718 unsigned id)
719{
720 d->id = id;
721 d->c = c;
722 c->devices[id] = d;
723
1/*
2 * bcache setup/teardown code, and some metadata io - read a superblock and
3 * figure out what to do with it.
4 *
5 * Copyright 2010, 2011 Kent Overstreet <kent.overstreet@gmail.com>
6 * Copyright 2012 Google, Inc.
7 */
8

--- 707 unchanged lines hidden (view full) ---

716
717static void bcache_device_attach(struct bcache_device *d, struct cache_set *c,
718 unsigned id)
719{
720 d->id = id;
721 d->c = c;
722 c->devices[id] = d;
723
724 if (id >= c->devices_max_used)
725 c->devices_max_used = id + 1;
726
724 closure_get(&c->caching);
725}
726
727static inline int first_minor_to_idx(int first_minor)
728{
729 return (first_minor/BCACHE_MINORS);
730}
731

--- 530 unchanged lines hidden (view full) ---

1262}
1263
1264static int flash_devs_run(struct cache_set *c)
1265{
1266 int ret = 0;
1267 struct uuid_entry *u;
1268
1269 for (u = c->uuids;
727 closure_get(&c->caching);
728}
729
730static inline int first_minor_to_idx(int first_minor)
731{
732 return (first_minor/BCACHE_MINORS);
733}
734

--- 530 unchanged lines hidden (view full) ---

1265}
1266
1267static int flash_devs_run(struct cache_set *c)
1268{
1269 int ret = 0;
1270 struct uuid_entry *u;
1271
1272 for (u = c->uuids;
1270 u < c->uuids + c->nr_uuids && !ret;
1273 u < c->uuids + c->devices_max_used && !ret;
1271 u++)
1272 if (UUID_FLASH_ONLY(u))
1273 ret = flash_dev_run(c, u);
1274
1275 return ret;
1276}
1277
1278int bch_flash_dev_create(struct cache_set *c, uint64_t size)

--- 149 unchanged lines hidden (view full) ---

1428static void __cache_set_unregister(struct closure *cl)
1429{
1430 struct cache_set *c = container_of(cl, struct cache_set, caching);
1431 struct cached_dev *dc;
1432 size_t i;
1433
1434 mutex_lock(&bch_register_lock);
1435
1274 u++)
1275 if (UUID_FLASH_ONLY(u))
1276 ret = flash_dev_run(c, u);
1277
1278 return ret;
1279}
1280
1281int bch_flash_dev_create(struct cache_set *c, uint64_t size)

--- 149 unchanged lines hidden (view full) ---

1431static void __cache_set_unregister(struct closure *cl)
1432{
1433 struct cache_set *c = container_of(cl, struct cache_set, caching);
1434 struct cached_dev *dc;
1435 size_t i;
1436
1437 mutex_lock(&bch_register_lock);
1438
1436 for (i = 0; i < c->nr_uuids; i++)
1439 for (i = 0; i < c->devices_max_used; i++)
1437 if (c->devices[i]) {
1438 if (!UUID_FLASH_ONLY(&c->uuids[i]) &&
1439 test_bit(CACHE_SET_UNREGISTERING, &c->flags)) {
1440 dc = container_of(c->devices[i],
1441 struct cached_dev, disk);
1442 bch_cached_dev_detach(dc);
1443 } else {
1444 bcache_device_stop(c->devices[i]);

--- 46 unchanged lines hidden (view full) ---

1491 memcpy(c->sb.set_uuid, sb->set_uuid, 16);
1492 c->sb.block_size = sb->block_size;
1493 c->sb.bucket_size = sb->bucket_size;
1494 c->sb.nr_in_set = sb->nr_in_set;
1495 c->sb.last_mount = sb->last_mount;
1496 c->bucket_bits = ilog2(sb->bucket_size);
1497 c->block_bits = ilog2(sb->block_size);
1498 c->nr_uuids = bucket_bytes(c) / sizeof(struct uuid_entry);
1440 if (c->devices[i]) {
1441 if (!UUID_FLASH_ONLY(&c->uuids[i]) &&
1442 test_bit(CACHE_SET_UNREGISTERING, &c->flags)) {
1443 dc = container_of(c->devices[i],
1444 struct cached_dev, disk);
1445 bch_cached_dev_detach(dc);
1446 } else {
1447 bcache_device_stop(c->devices[i]);

--- 46 unchanged lines hidden (view full) ---

1494 memcpy(c->sb.set_uuid, sb->set_uuid, 16);
1495 c->sb.block_size = sb->block_size;
1496 c->sb.bucket_size = sb->bucket_size;
1497 c->sb.nr_in_set = sb->nr_in_set;
1498 c->sb.last_mount = sb->last_mount;
1499 c->bucket_bits = ilog2(sb->bucket_size);
1500 c->block_bits = ilog2(sb->block_size);
1501 c->nr_uuids = bucket_bytes(c) / sizeof(struct uuid_entry);
1499
1502 c->devices_max_used = 0;
1500 c->btree_pages = bucket_pages(c);
1501 if (c->btree_pages > BTREE_MAX_PAGES)
1502 c->btree_pages = max_t(int, c->btree_pages / 4,
1503 BTREE_MAX_PAGES);
1504
1505 sema_init(&c->sb_write_mutex, 1);
1506 mutex_init(&c->bucket_lock);
1507 init_waitqueue_head(&c->btree_cache_wait);

--- 634 unchanged lines hidden ---
1503 c->btree_pages = bucket_pages(c);
1504 if (c->btree_pages > BTREE_MAX_PAGES)
1505 c->btree_pages = max_t(int, c->btree_pages / 4,
1506 BTREE_MAX_PAGES);
1507
1508 sema_init(&c->sb_write_mutex, 1);
1509 mutex_init(&c->bucket_lock);
1510 init_waitqueue_head(&c->btree_cache_wait);

--- 634 unchanged lines hidden ---