Lines Matching refs:d
92 sb->d[i] = le64_to_cpu(s->d[i]); in read_super()
174 if (sb->d[i] != sb->first_bucket + i) in read_super()
234 out->d[i] = cpu_to_le64(sb->d[i]); in __write_super()
542 struct bucket_disk *d = p->data; in bch_prio_write() local
543 struct bucket_disk *end = d + prios_per_bucket(ca); in bch_prio_write()
546 b < ca->buckets + ca->sb.nbuckets && d < end; in bch_prio_write()
547 b++, d++) { in bch_prio_write()
548 d->prio = cpu_to_le16(b->prio); in bch_prio_write()
549 d->gen = b->gen; in bch_prio_write()
590 struct bucket_disk *d = p->data + prios_per_bucket(ca), *end = d; in prio_read() local
596 b++, d++) { in prio_read()
597 if (d == end) { in prio_read()
611 d = p->data; in prio_read()
614 b->prio = le16_to_cpu(d->prio); in prio_read()
615 b->gen = b->last_gc = d->gen; in prio_read()
623 struct bcache_device *d = b->bd_disk->private_data; in open_dev() local
624 if (test_bit(BCACHE_DEV_CLOSING, &d->flags)) in open_dev()
627 closure_get(&d->cl); in open_dev()
633 struct bcache_device *d = b->private_data; in release_dev() local
634 closure_put(&d->cl); in release_dev()
640 struct bcache_device *d = b->bd_disk->private_data; in ioctl_dev() local
641 return d->ioctl(d, mode, cmd, arg); in ioctl_dev()
651 void bcache_device_stop(struct bcache_device *d) in bcache_device_stop() argument
653 if (!test_and_set_bit(BCACHE_DEV_CLOSING, &d->flags)) in bcache_device_stop()
654 closure_queue(&d->cl); in bcache_device_stop()
657 static void bcache_device_unlink(struct bcache_device *d) in bcache_device_unlink() argument
661 if (d->c && !test_and_set_bit(BCACHE_DEV_UNLINK_DONE, &d->flags)) { in bcache_device_unlink()
665 sysfs_remove_link(&d->c->kobj, d->name); in bcache_device_unlink()
666 sysfs_remove_link(&d->kobj, "cache"); in bcache_device_unlink()
668 for_each_cache(ca, d->c, i) in bcache_device_unlink()
669 bd_unlink_disk_holder(ca->bdev, d->disk); in bcache_device_unlink()
673 static void bcache_device_link(struct bcache_device *d, struct cache_set *c, in bcache_device_link() argument
679 for_each_cache(ca, d->c, i) in bcache_device_link()
680 bd_link_disk_holder(ca->bdev, d->disk); in bcache_device_link()
682 snprintf(d->name, BCACHEDEVNAME_SIZE, in bcache_device_link()
683 "%s%u", name, d->id); in bcache_device_link()
685 WARN(sysfs_create_link(&d->kobj, &c->kobj, "cache") || in bcache_device_link()
686 sysfs_create_link(&c->kobj, &d->kobj, d->name), in bcache_device_link()
689 clear_bit(BCACHE_DEV_UNLINK_DONE, &d->flags); in bcache_device_link()
692 static void bcache_device_detach(struct bcache_device *d) in bcache_device_detach() argument
696 if (test_bit(BCACHE_DEV_DETACHING, &d->flags)) { in bcache_device_detach()
697 struct uuid_entry *u = d->c->uuids + d->id; in bcache_device_detach()
702 bch_uuid_write(d->c); in bcache_device_detach()
705 bcache_device_unlink(d); in bcache_device_detach()
707 d->c->devices[d->id] = NULL; in bcache_device_detach()
708 closure_put(&d->c->caching); in bcache_device_detach()
709 d->c = NULL; in bcache_device_detach()
712 static void bcache_device_attach(struct bcache_device *d, struct cache_set *c, in bcache_device_attach() argument
715 d->id = id; in bcache_device_attach()
716 d->c = c; in bcache_device_attach()
717 c->devices[id] = d; in bcache_device_attach()
722 static void bcache_device_free(struct bcache_device *d) in bcache_device_free() argument
726 pr_info("%s stopped", d->disk->disk_name); in bcache_device_free()
728 if (d->c) in bcache_device_free()
729 bcache_device_detach(d); in bcache_device_free()
730 if (d->disk && d->disk->flags & GENHD_FL_UP) in bcache_device_free()
731 del_gendisk(d->disk); in bcache_device_free()
732 if (d->disk && d->disk->queue) in bcache_device_free()
733 blk_cleanup_queue(d->disk->queue); in bcache_device_free()
734 if (d->disk) { in bcache_device_free()
735 ida_simple_remove(&bcache_minor, d->disk->first_minor); in bcache_device_free()
736 put_disk(d->disk); in bcache_device_free()
739 if (d->bio_split) in bcache_device_free()
740 bioset_free(d->bio_split); in bcache_device_free()
741 kvfree(d->full_dirty_stripes); in bcache_device_free()
742 kvfree(d->stripe_sectors_dirty); in bcache_device_free()
744 closure_debug_destroy(&d->cl); in bcache_device_free()
747 static int bcache_device_init(struct bcache_device *d, unsigned block_size, in bcache_device_init() argument
754 if (!d->stripe_size) in bcache_device_init()
755 d->stripe_size = 1 << 31; in bcache_device_init()
757 d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size); in bcache_device_init()
759 if (!d->nr_stripes || in bcache_device_init()
760 d->nr_stripes > INT_MAX || in bcache_device_init()
761 d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { in bcache_device_init()
766 n = d->nr_stripes * sizeof(atomic_t); in bcache_device_init()
767 d->stripe_sectors_dirty = n < PAGE_SIZE << 6 in bcache_device_init()
770 if (!d->stripe_sectors_dirty) in bcache_device_init()
773 n = BITS_TO_LONGS(d->nr_stripes) * sizeof(unsigned long); in bcache_device_init()
774 d->full_dirty_stripes = n < PAGE_SIZE << 6 in bcache_device_init()
777 if (!d->full_dirty_stripes) in bcache_device_init()
784 if (!(d->bio_split = bioset_create(4, offsetof(struct bbio, bio))) || in bcache_device_init()
785 !(d->disk = alloc_disk(1))) { in bcache_device_init()
790 set_capacity(d->disk, sectors); in bcache_device_init()
791 snprintf(d->disk->disk_name, DISK_NAME_LEN, "bcache%i", minor); in bcache_device_init()
793 d->disk->major = bcache_major; in bcache_device_init()
794 d->disk->first_minor = minor; in bcache_device_init()
795 d->disk->fops = &bcache_ops; in bcache_device_init()
796 d->disk->private_data = d; in bcache_device_init()
803 d->disk->queue = q; in bcache_device_init()
804 q->queuedata = d; in bcache_device_init()
805 q->backing_dev_info.congested_data = d; in bcache_device_init()
815 set_bit(QUEUE_FLAG_NONROT, &d->disk->queue->queue_flags); in bcache_device_init()
816 clear_bit(QUEUE_FLAG_ADD_RANDOM, &d->disk->queue->queue_flags); in bcache_device_init()
817 set_bit(QUEUE_FLAG_DISCARD, &d->disk->queue->queue_flags); in bcache_device_init()
839 struct bcache_device *d = &dc->disk; in bch_cached_dev_run() local
858 if (!d->c && in bch_cached_dev_run()
868 add_disk(d->disk); in bch_cached_dev_run()
872 kobject_uevent_env(&disk_to_dev(d->disk)->kobj, KOBJ_CHANGE, env); in bch_cached_dev_run()
876 if (sysfs_create_link(&d->kobj, &disk_to_dev(d->disk)->kobj, "dev") || in bch_cached_dev_run()
877 sysfs_create_link(&disk_to_dev(d->disk)->kobj, &d->kobj, "bcache")) in bch_cached_dev_run()
1080 struct bcache_device *d = &dc->disk; in cached_dev_flush() local
1083 bcache_device_unlink(d); in cached_dev_flush()
1087 kobject_del(&d->kobj); in cached_dev_flush()
1189 struct bcache_device *d = container_of(kobj, struct bcache_device, in bch_flash_dev_release() local
1191 kfree(d); in bch_flash_dev_release()
1196 struct bcache_device *d = container_of(cl, struct bcache_device, cl); in flash_dev_free() local
1198 bcache_device_free(d); in flash_dev_free()
1200 kobject_put(&d->kobj); in flash_dev_free()
1205 struct bcache_device *d = container_of(cl, struct bcache_device, cl); in flash_dev_flush() local
1208 bcache_device_unlink(d); in flash_dev_flush()
1210 kobject_del(&d->kobj); in flash_dev_flush()
1216 struct bcache_device *d = kzalloc(sizeof(struct bcache_device), in flash_dev_run() local
1218 if (!d) in flash_dev_run()
1221 closure_init(&d->cl, NULL); in flash_dev_run()
1222 set_closure_fn(&d->cl, flash_dev_flush, system_wq); in flash_dev_run()
1224 kobject_init(&d->kobj, &bch_flash_dev_ktype); in flash_dev_run()
1226 if (bcache_device_init(d, block_bytes(c), u->sectors)) in flash_dev_run()
1229 bcache_device_attach(d, c, u - c->uuids); in flash_dev_run()
1230 bch_flash_dev_request_init(d); in flash_dev_run()
1231 add_disk(d->disk); in flash_dev_run()
1233 if (kobject_add(&d->kobj, &disk_to_dev(d->disk)->kobj, "bcache")) in flash_dev_run()
1236 bcache_device_link(d, c, "volume"); in flash_dev_run()
1240 kobject_put(&d->kobj); in flash_dev_run()
1640 ca->sb.d[j] = ca->sb.first_bucket + j; in run_cache_set()