Lines Matching refs:d
115 sb->d[i] = le64_to_cpu(s->d[i]); in read_super()
197 if (sb->d[i] != sb->first_bucket + i) in read_super()
257 out->d[i] = cpu_to_le64(sb->d[i]); in __write_super()
565 struct bucket_disk *d = p->data; in bch_prio_write() local
566 struct bucket_disk *end = d + prios_per_bucket(ca); in bch_prio_write()
569 b < ca->buckets + ca->sb.nbuckets && d < end; in bch_prio_write()
570 b++, d++) { in bch_prio_write()
571 d->prio = cpu_to_le16(b->prio); in bch_prio_write()
572 d->gen = b->gen; in bch_prio_write()
613 struct bucket_disk *d = p->data + prios_per_bucket(ca), *end = d; in prio_read() local
619 b++, d++) { in prio_read()
620 if (d == end) { in prio_read()
634 d = p->data; in prio_read()
637 b->prio = le16_to_cpu(d->prio); in prio_read()
638 b->gen = b->last_gc = d->gen; in prio_read()
646 struct bcache_device *d = b->bd_disk->private_data; in open_dev() local
647 if (test_bit(BCACHE_DEV_CLOSING, &d->flags)) in open_dev()
650 closure_get(&d->cl); in open_dev()
656 struct bcache_device *d = b->private_data; in release_dev() local
657 closure_put(&d->cl); in release_dev()
663 struct bcache_device *d = b->bd_disk->private_data; in ioctl_dev() local
664 return d->ioctl(d, mode, cmd, arg); in ioctl_dev()
674 void bcache_device_stop(struct bcache_device *d) in bcache_device_stop() argument
676 if (!test_and_set_bit(BCACHE_DEV_CLOSING, &d->flags)) in bcache_device_stop()
677 closure_queue(&d->cl); in bcache_device_stop()
680 static void bcache_device_unlink(struct bcache_device *d) in bcache_device_unlink() argument
684 if (d->c && !test_and_set_bit(BCACHE_DEV_UNLINK_DONE, &d->flags)) { in bcache_device_unlink()
688 sysfs_remove_link(&d->c->kobj, d->name); in bcache_device_unlink()
689 sysfs_remove_link(&d->kobj, "cache"); in bcache_device_unlink()
691 for_each_cache(ca, d->c, i) in bcache_device_unlink()
692 bd_unlink_disk_holder(ca->bdev, d->disk); in bcache_device_unlink()
696 static void bcache_device_link(struct bcache_device *d, struct cache_set *c, in bcache_device_link() argument
702 for_each_cache(ca, d->c, i) in bcache_device_link()
703 bd_link_disk_holder(ca->bdev, d->disk); in bcache_device_link()
705 snprintf(d->name, BCACHEDEVNAME_SIZE, in bcache_device_link()
706 "%s%u", name, d->id); in bcache_device_link()
708 WARN(sysfs_create_link(&d->kobj, &c->kobj, "cache") || in bcache_device_link()
709 sysfs_create_link(&c->kobj, &d->kobj, d->name), in bcache_device_link()
712 clear_bit(BCACHE_DEV_UNLINK_DONE, &d->flags); in bcache_device_link()
715 static void bcache_device_detach(struct bcache_device *d) in bcache_device_detach() argument
719 if (test_bit(BCACHE_DEV_DETACHING, &d->flags)) { in bcache_device_detach()
720 struct uuid_entry *u = d->c->uuids + d->id; in bcache_device_detach()
725 bch_uuid_write(d->c); in bcache_device_detach()
728 bcache_device_unlink(d); in bcache_device_detach()
730 d->c->devices[d->id] = NULL; in bcache_device_detach()
731 closure_put(&d->c->caching); in bcache_device_detach()
732 d->c = NULL; in bcache_device_detach()
735 static void bcache_device_attach(struct bcache_device *d, struct cache_set *c, in bcache_device_attach() argument
738 d->id = id; in bcache_device_attach()
739 d->c = c; in bcache_device_attach()
740 c->devices[id] = d; in bcache_device_attach()
745 static void bcache_device_free(struct bcache_device *d) in bcache_device_free() argument
749 pr_info("%s stopped", d->disk->disk_name); in bcache_device_free()
751 if (d->c) in bcache_device_free()
752 bcache_device_detach(d); in bcache_device_free()
753 if (d->disk && d->disk->flags & GENHD_FL_UP) in bcache_device_free()
754 del_gendisk(d->disk); in bcache_device_free()
755 if (d->disk && d->disk->queue) in bcache_device_free()
756 blk_cleanup_queue(d->disk->queue); in bcache_device_free()
757 if (d->disk) { in bcache_device_free()
758 ida_simple_remove(&bcache_minor, d->disk->first_minor); in bcache_device_free()
759 put_disk(d->disk); in bcache_device_free()
762 bio_split_pool_free(&d->bio_split_hook); in bcache_device_free()
763 if (d->bio_split) in bcache_device_free()
764 bioset_free(d->bio_split); in bcache_device_free()
765 if (is_vmalloc_addr(d->full_dirty_stripes)) in bcache_device_free()
766 vfree(d->full_dirty_stripes); in bcache_device_free()
768 kfree(d->full_dirty_stripes); in bcache_device_free()
769 if (is_vmalloc_addr(d->stripe_sectors_dirty)) in bcache_device_free()
770 vfree(d->stripe_sectors_dirty); in bcache_device_free()
772 kfree(d->stripe_sectors_dirty); in bcache_device_free()
774 closure_debug_destroy(&d->cl); in bcache_device_free()
777 static int bcache_device_init(struct bcache_device *d, unsigned block_size, in bcache_device_init() argument
784 if (!d->stripe_size) in bcache_device_init()
785 d->stripe_size = 1 << 31; in bcache_device_init()
787 d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size); in bcache_device_init()
789 if (!d->nr_stripes || in bcache_device_init()
790 d->nr_stripes > INT_MAX || in bcache_device_init()
791 d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { in bcache_device_init()
796 n = d->nr_stripes * sizeof(atomic_t); in bcache_device_init()
797 d->stripe_sectors_dirty = n < PAGE_SIZE << 6 in bcache_device_init()
800 if (!d->stripe_sectors_dirty) in bcache_device_init()
803 n = BITS_TO_LONGS(d->nr_stripes) * sizeof(unsigned long); in bcache_device_init()
804 d->full_dirty_stripes = n < PAGE_SIZE << 6 in bcache_device_init()
807 if (!d->full_dirty_stripes) in bcache_device_init()
814 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) || in bcache_device_init()
815 bio_split_pool_init(&d->bio_split_hook) || in bcache_device_init()
816 !(d->disk = alloc_disk(1))) { in bcache_device_init()
821 set_capacity(d->disk, sectors); in bcache_device_init()
822 snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", minor); in bcache_device_init()
824 d->disk->major = bcache_major; in bcache_device_init()
825 d->disk->first_minor = minor; in bcache_device_init()
826 d->disk->fops = &bcache_ops; in bcache_device_init()
827 d->disk->private_data = d; in bcache_device_init()
834 d->disk->queue = q; in bcache_device_init()
835 q->queuedata = d; in bcache_device_init()
836 q->backing_dev_info.congested_data = d; in bcache_device_init()
846 set_bit(QUEUE_FLAG_NONROT, &d->disk->queue->queue_flags); in bcache_device_init()
847 clear_bit(QUEUE_FLAG_ADD_RANDOM, &d->disk->queue->queue_flags); in bcache_device_init()
848 set_bit(QUEUE_FLAG_DISCARD, &d->disk->queue->queue_flags); in bcache_device_init()
870 struct bcache_device *d = &dc->disk; in bch_cached_dev_run() local
889 if (!d->c && in bch_cached_dev_run()
899 add_disk(d->disk); in bch_cached_dev_run()
903 kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env); in bch_cached_dev_run()
907 if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") || in bch_cached_dev_run()
908 sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache")) in bch_cached_dev_run()
1111 struct bcache_device *d = &dc->disk; in cached_dev_flush() local
1114 bcache_device_unlink(d); in cached_dev_flush()
1118 kobject_del(&d->kobj); in cached_dev_flush()
1220 struct bcache_device *d = container_of(kobj, struct bcache_device, in bch_flash_dev_release() local
1222 kfree(d); in bch_flash_dev_release()
1227 struct bcache_device *d = container_of(cl, struct bcache_device, cl); in flash_dev_free() local
1229 bcache_device_free(d); in flash_dev_free()
1231 kobject_put(&d->kobj); in flash_dev_free()
1236 struct bcache_device *d = container_of(cl, struct bcache_device, cl); in flash_dev_flush() local
1239 bcache_device_unlink(d); in flash_dev_flush()
1241 kobject_del(&d->kobj); in flash_dev_flush()
1247 struct bcache_device *d = kzalloc(sizeof(struct bcache_device), in flash_dev_run() local
1249 if (!d) in flash_dev_run()
1252 closure_init(&d->cl, NULL); in flash_dev_run()
1253 set_closure_fn(&d->cl, flash_dev_flush, system_wq); in flash_dev_run()
1255 kobject_init(&d->kobj, &bch_flash_dev_ktype); in flash_dev_run()
1257 if (bcache_device_init(d, block_bytes(c), u->sectors)) in flash_dev_run()
1260 bcache_device_attach(d, c, u - c->uuids); in flash_dev_run()
1261 bch_flash_dev_request_init(d); in flash_dev_run()
1262 add_disk(d->disk); in flash_dev_run()
1264 if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache")) in flash_dev_run()
1267 bcache_device_link(d, c, "volume"); in flash_dev_run()
1271 kobject_put(&d->kobj); in flash_dev_run()
1671 ca->sb.d[j] = ca->sb.first_bucket + j; in run_cache_set()