Lines Matching refs:dev
172 struct ubiblock *dev; in find_dev_nolock() local
174 list_for_each_entry(dev, &ubiblock_devices, list) in find_dev_nolock()
175 if (dev->ubi_num == ubi_num && dev->vol_id == vol_id) in find_dev_nolock()
176 return dev; in find_dev_nolock()
183 struct ubiblock *dev = req->q->queuedata; in ubiblock_read() local
188 int offset = do_div(pos, dev->leb_size); in ubiblock_read()
209 if (offset + to_read > dev->leb_size) in ubiblock_read()
210 to_read = dev->leb_size - offset; in ubiblock_read()
212 ret = ubi_read_sg(dev->desc, leb, &pdu->usgl, offset, to_read); in ubiblock_read()
232 struct ubiblock *dev = disk->private_data; in ubiblock_open() local
235 mutex_lock(&dev->dev_mutex); in ubiblock_open()
236 if (dev->refcnt > 0) { in ubiblock_open()
253 dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY); in ubiblock_open()
254 if (IS_ERR(dev->desc)) { in ubiblock_open()
255 dev_err(disk_to_dev(dev->gd), "failed to open ubi volume %d_%d", in ubiblock_open()
256 dev->ubi_num, dev->vol_id); in ubiblock_open()
257 ret = PTR_ERR(dev->desc); in ubiblock_open()
258 dev->desc = NULL; in ubiblock_open()
263 dev->refcnt++; in ubiblock_open()
264 mutex_unlock(&dev->dev_mutex); in ubiblock_open()
268 mutex_unlock(&dev->dev_mutex); in ubiblock_open()
274 struct ubiblock *dev = gd->private_data; in ubiblock_release() local
276 mutex_lock(&dev->dev_mutex); in ubiblock_release()
277 dev->refcnt--; in ubiblock_release()
278 if (dev->refcnt == 0) { in ubiblock_release()
279 ubi_close_volume(dev->desc); in ubiblock_release()
280 dev->desc = NULL; in ubiblock_release()
282 mutex_unlock(&dev->dev_mutex); in ubiblock_release()
351 struct ubiblock *dev; in ubiblock_create() local
368 dev = kzalloc(sizeof(struct ubiblock), GFP_KERNEL); in ubiblock_create()
369 if (!dev) { in ubiblock_create()
374 mutex_init(&dev->dev_mutex); in ubiblock_create()
376 dev->ubi_num = vi->ubi_num; in ubiblock_create()
377 dev->vol_id = vi->vol_id; in ubiblock_create()
378 dev->leb_size = vi->usable_leb_size; in ubiblock_create()
380 dev->tag_set.ops = &ubiblock_mq_ops; in ubiblock_create()
381 dev->tag_set.queue_depth = 64; in ubiblock_create()
382 dev->tag_set.numa_node = NUMA_NO_NODE; in ubiblock_create()
383 dev->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING; in ubiblock_create()
384 dev->tag_set.cmd_size = sizeof(struct ubiblock_pdu); in ubiblock_create()
385 dev->tag_set.driver_data = dev; in ubiblock_create()
386 dev->tag_set.nr_hw_queues = 1; in ubiblock_create()
388 ret = blk_mq_alloc_tag_set(&dev->tag_set); in ubiblock_create()
390 dev_err(disk_to_dev(dev->gd), "blk_mq_alloc_tag_set failed"); in ubiblock_create()
396 gd = blk_mq_alloc_disk(&dev->tag_set, dev); in ubiblock_create()
405 gd->first_minor = idr_alloc(&ubiblock_minor_idr, dev, 0, 0, GFP_KERNEL); in ubiblock_create()
413 gd->private_data = dev; in ubiblock_create()
414 sprintf(gd->disk_name, "ubiblock%d_%d", dev->ubi_num, dev->vol_id); in ubiblock_create()
416 dev->gd = gd; in ubiblock_create()
418 dev->rq = gd->queue; in ubiblock_create()
419 blk_queue_max_segments(dev->rq, UBI_MAX_SG_COUNT); in ubiblock_create()
421 list_add_tail(&dev->list, &ubiblock_devices); in ubiblock_create()
424 ret = device_add_disk(vi->dev, dev->gd, NULL); in ubiblock_create()
428 dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)", in ubiblock_create()
429 dev->ubi_num, dev->vol_id, vi->name); in ubiblock_create()
434 list_del(&dev->list); in ubiblock_create()
437 put_disk(dev->gd); in ubiblock_create()
439 blk_mq_free_tag_set(&dev->tag_set); in ubiblock_create()
441 kfree(dev); in ubiblock_create()
448 static void ubiblock_cleanup(struct ubiblock *dev) in ubiblock_cleanup() argument
451 del_gendisk(dev->gd); in ubiblock_cleanup()
453 dev_info(disk_to_dev(dev->gd), "released"); in ubiblock_cleanup()
454 put_disk(dev->gd); in ubiblock_cleanup()
455 blk_mq_free_tag_set(&dev->tag_set); in ubiblock_cleanup()
456 idr_remove(&ubiblock_minor_idr, dev->gd->first_minor); in ubiblock_cleanup()
461 struct ubiblock *dev; in ubiblock_remove() local
465 dev = find_dev_nolock(vi->ubi_num, vi->vol_id); in ubiblock_remove()
466 if (!dev) { in ubiblock_remove()
472 mutex_lock(&dev->dev_mutex); in ubiblock_remove()
473 if (dev->refcnt > 0) { in ubiblock_remove()
479 list_del(&dev->list); in ubiblock_remove()
480 ubiblock_cleanup(dev); in ubiblock_remove()
481 mutex_unlock(&dev->dev_mutex); in ubiblock_remove()
484 kfree(dev); in ubiblock_remove()
488 mutex_unlock(&dev->dev_mutex); in ubiblock_remove()
496 struct ubiblock *dev; in ubiblock_resize() local
506 dev = find_dev_nolock(vi->ubi_num, vi->vol_id); in ubiblock_resize()
507 if (!dev) { in ubiblock_resize()
516 dev_warn(disk_to_dev(dev->gd), in ubiblock_resize()
523 mutex_lock(&dev->dev_mutex); in ubiblock_resize()
525 if (get_capacity(dev->gd) != disk_capacity) { in ubiblock_resize()
526 set_capacity(dev->gd, disk_capacity); in ubiblock_resize()
527 dev_info(disk_to_dev(dev->gd), "resized to %lld bytes", in ubiblock_resize()
530 mutex_unlock(&dev->dev_mutex); in ubiblock_resize()
624 struct ubiblock *dev; in ubiblock_remove_all() local
627 list_for_each_entry_safe(dev, next, &ubiblock_devices, list) { in ubiblock_remove_all()
629 WARN_ON(dev->desc); in ubiblock_remove_all()
631 list_del(&dev->list); in ubiblock_remove_all()
632 ubiblock_cleanup(dev); in ubiblock_remove_all()
633 kfree(dev); in ubiblock_remove_all()