Lines Matching defs:dev
29 #include "dev-replace.h"
222 static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev);
414 struct btrfs_device *dev;
416 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
417 if (!dev)
424 dev->flush_bio = bio_alloc_bioset(GFP_KERNEL, 0, NULL);
425 if (!dev->flush_bio) {
426 kfree(dev);
430 INIT_LIST_HEAD(&dev->dev_list);
431 INIT_LIST_HEAD(&dev->dev_alloc_list);
432 INIT_LIST_HEAD(&dev->post_commit_list);
434 atomic_set(&dev->reada_in_flight, 0);
435 atomic_set(&dev->dev_stats_ccnt, 0);
436 btrfs_device_data_ordered_init(dev);
437 INIT_RADIX_TREE(&dev->reada_zones, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
438 INIT_RADIX_TREE(&dev->reada_extents, GFP_NOFS & ~__GFP_DIRECT_RECLAIM);
439 extent_io_tree_init(fs_info, &dev->alloc_state,
442 return dev;
953 * btrfs dev scan cli after FS has been mounted. We're still
1558 * check to ensure dev extents are not double allocated.
1559 * This makes the function safe to allocate dev extents but may not report
1677 * allocated dev extents, and when shrinking the device,
1766 "Failed to remove dev extent item");
2290 * to fs_devices of fs_info. However when the dev being replaced is
2291 * a seed dev it will point to the seed's local fs_devices. In short
3041 * with map stripes (dev-replace.c:btrfs_dev_replace_finishing()).
3045 struct btrfs_device *device = map->stripes[i].dev;
3114 * Make sure to acquire this mutex before doing a tree search (dev
3117 * we release the path used to search the chunk/dev tree and before
5061 devices_info[ndevs].dev = device;
5173 map->stripes[s].dev = devices_info[i].dev;
5214 struct btrfs_device *dev = map->stripes[i].dev;
5216 btrfs_device_set_bytes_used(dev,
5217 dev->bytes_used + ctl->stripe_size);
5218 if (list_empty(&dev->post_commit_list))
5219 list_add_tail(&dev->post_commit_list,
5340 * (dev-replace.c:btrfs_dev_replace_finishing()).
5344 device = map->stripes[i].dev;
5362 device = map->stripes[i].dev;
5439 &map->stripes[i].dev->dev_state)) {
5444 &map->stripes[i].dev->dev_state)) {
5590 * dev-replace procedure, only choose it if no other non-missing
5594 if (map->stripes[preferred_mirror].dev->bdev &&
5595 (tolerance || map->stripes[preferred_mirror].dev != srcdev))
5598 if (map->stripes[i].dev->bdev &&
5599 (tolerance || map->stripes[i].dev != srcdev))
5636 /* plus the variable array for the tgt dev */
5639 * plus the raid_map, which includes both the tgt dev
5772 bbio->stripes[i].dev = map->stripes[stripe_index].dev;
5823 * In dev-replace case, for repair case (that's the only case where the mirror
5832 * can happen because btrfs_num_copies() returns one more in the dev-replace
5872 if (bbio->stripes[i].dev->devid != srcdev_devid)
5915 * duplicate the write operations while the dev replace
5927 if (bbio->stripes[i].dev->devid == srcdev_devid) {
5936 new->dev = dev_replace->tgtdev;
5950 * During the dev-replace procedure, the target drive can also
5957 if (bbio->stripes[i].dev->devid == srcdev_devid) {
5979 tgtdev_stripe->dev = dev_replace->tgtdev;
6277 bbio->stripes[i].dev = map->stripes[stripe_index].dev;
6326 bbio->stripes[0].dev = dev_replace->tgtdev;
6378 struct btrfs_device *dev = btrfs_io_bio(bio)->device;
6380 ASSERT(dev->bdev);
6382 btrfs_dev_stat_inc_and_print(dev,
6385 btrfs_dev_stat_inc_and_print(dev,
6388 btrfs_dev_stat_inc_and_print(dev,
6425 u64 physical, struct btrfs_device *dev)
6430 btrfs_io_bio(bio)->device = dev;
6434 "btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu (%s id %llu), size=%u",
6436 (unsigned long)dev->bdev->bd_dev, rcu_str_deref(dev->name),
6437 dev->devid, bio->bi_iter.bi_size);
6438 bio_set_dev(bio, dev->bdev);
6465 struct btrfs_device *dev;
6517 dev = bbio->stripes[dev_nr].dev;
6518 if (!dev || !dev->bdev || test_bit(BTRFS_DEV_STATE_MISSING,
6519 &dev->dev_state) ||
6521 !test_bit(BTRFS_DEV_STATE_WRITEABLE, &dev->dev_state))) {
6531 submit_stripe_bio(bbio, bio, bbio->stripes[dev_nr].physical, dev);
6623 struct btrfs_device *dev;
6629 dev = __alloc_device(fs_info);
6630 if (IS_ERR(dev))
6631 return dev;
6640 btrfs_free_device(dev);
6644 dev->devid = tmp;
6647 memcpy(dev->uuid, uuid, BTRFS_UUID_SIZE);
6649 generate_random_uuid(dev->uuid);
6651 return dev;
6754 map->stripes[i].dev = btrfs_find_device(fs_info->fs_devices,
6756 if (!map->stripes[i].dev &&
6762 if (!map->stripes[i].dev) {
6763 map->stripes[i].dev =
6766 if (IS_ERR(map->stripes[i].dev)) {
6769 "failed to init missing dev %llu: %ld",
6770 devid, PTR_ERR(map->stripes[i].dev));
6771 return PTR_ERR(map->stripes[i].dev);
6776 &(map->stripes[i].dev->dev_state));
6905 "failed to add missing dev %llu: %ld",
7124 struct btrfs_device *dev = map->stripes[i].dev;
7126 if (!dev || !dev->bdev ||
7127 test_bit(BTRFS_DEV_STATE_MISSING, &dev->dev_state) ||
7128 dev->last_flush_error)
7130 else if (failing_dev && failing_dev == dev)
7503 void btrfs_dev_stat_inc_and_print(struct btrfs_device *dev, int index)
7505 btrfs_dev_stat_inc(dev, index);
7506 btrfs_dev_stat_print_on_error(dev);
7509 static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev)
7511 if (!dev->dev_stats_valid)
7513 btrfs_err_rl_in_rcu(dev->fs_info,
7515 rcu_str_deref(dev->name),
7516 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS),
7517 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_READ_ERRS),
7518 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_FLUSH_ERRS),
7519 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_CORRUPTION_ERRS),
7520 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_GENERATION_ERRS));
7523 static void btrfs_dev_stat_print_on_load(struct btrfs_device *dev)
7528 if (btrfs_dev_stat_read(dev, i) != 0)
7533 btrfs_info_in_rcu(dev->fs_info,
7535 rcu_str_deref(dev->name),
7536 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_WRITE_ERRS),
7537 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_READ_ERRS),
7538 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_FLUSH_ERRS),
7539 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_CORRUPTION_ERRS),
7540 btrfs_dev_stat_read(dev, BTRFS_DEV_STAT_GENERATION_ERRS));
7546 struct btrfs_device *dev;
7551 dev = btrfs_find_device(fs_info->fs_devices, stats->devid, NULL, NULL,
7555 if (!dev) {
7558 } else if (!dev->dev_stats_valid) {
7565 btrfs_dev_stat_read_and_reset(dev, i);
7567 btrfs_dev_stat_set(dev, i, 0);
7574 stats->values[i] = btrfs_dev_stat_read(dev, i);
7631 struct btrfs_device *dev;
7643 "dev extent physical offset %llu on devid %llu doesn't have corresponding chunk",
7653 "dev extent physical offset %llu on devid %llu length doesn't match chunk %llu, have %llu expect %llu",
7661 if (map->stripes[i].dev->devid == devid &&
7666 "too many dev extents for chunk %llu found",
7677 "dev extent physical offset %llu devid %llu has no corresponding chunk",
7682 /* Make sure no dev extent is beyond device bondary */
7683 dev = btrfs_find_device(fs_info->fs_devices, devid, NULL, NULL, true);
7684 if (!dev) {
7691 if (dev->disk_total_bytes == 0) {
7696 dev = btrfs_find_device(devs, devid, NULL, NULL, false);
7697 if (!dev) {
7705 if (physical_offset + physical_len > dev->disk_total_bytes) {
7707 "dev extent devid %llu physical offset %llu len %llu is beyond device boundary %llu",
7709 dev->disk_total_bytes);
7731 "chunk %llu has missing dev extent, have %d expect %d",
7744 * Ensure that all dev extents are mapped to correct chunk, otherwise
7776 /* No dev extents at all? Not good */
7801 /* Check if this dev extent overlaps with the previous one */
7804 "dev extent devid %llu physical offset %llu overlap with previous dev extent end %llu",
7826 /* Ensure all chunks have corresponding dev extents */