Deleted Added
sdiff udiff text old ( 339104 ) new ( 339106 )
full compact
1/*
2 * CDDL HEADER START
3 *
4 * This file and its contents are supplied under the terms of the
5 * Common Development and Distribution License ("CDDL"), version 1.0.
6 * You may only use this file in accordance with the terms of version
7 * 1.0 of the CDDL.
8 *

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

18 */
19
20#include <sys/zfs_context.h>
21#include <sys/spa.h>
22#include <sys/spa_impl.h>
23#include <sys/vdev_impl.h>
24#include <sys/fs/zfs.h>
25#include <sys/zio.h>
26#include <sys/metaslab.h>
27#include <sys/refcount.h>
28#include <sys/dmu.h>
29#include <sys/vdev_indirect_mapping.h>
30#include <sys/dmu_tx.h>
31#include <sys/dsl_synctask.h>
32#include <sys/zap.h>
33#include <sys/abd.h>

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

41 * to access the DVA. Unfortunately, this mapping did not respect
42 * logical block boundaries when it was first created, and so a DVA on
43 * this indirect vdev may be "split" into multiple sections that each
44 * map to a different location. As a consequence, not all DVAs can be
45 * translated to an equivalent new DVA. Instead we must provide a
46 * "vdev_remap" operation that executes a callback on each contiguous
47 * segment of the new location. This function is used in multiple ways:
48 *
49 * - reads and repair writes to this device use the callback to create
50 * a child io for each mapped segment.
51 *
52 * - frees and claims to this device use the callback to free or claim
53 * each mapped segment. (Note that we don't actually need to claim
54 * log blocks on indirect vdevs, because we don't allocate to
55 * removing vdevs. However, zdb uses zio_claim() for its leak
56 * detection.)
57 */
58
59/*
60 * "Big theory statement" for how we mark blocks obsolete.

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

199 * This is used by the test suite so that it can ensure that certain
200 * actions happen while in the middle of a condense (which might otherwise
201 * complete too quickly). If used to reduce the performance impact of
202 * condensing in production, a maximum value of 1 should be sufficient.
203 */
204int zfs_condense_indirect_commit_entry_delay_ticks = 0;
205
206/*
207 * Mark the given offset and size as being obsolete.
208 */
209void
210vdev_indirect_mark_obsolete(vdev_t *vd, uint64_t offset, uint64_t size)
211{
212 spa_t *spa = vd->vdev_spa;
213
214 ASSERT3U(vd->vdev_indirect_config.vic_mapping_object, !=, 0);

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

813
814/* ARGSUSED */
815static void
816vdev_indirect_close(vdev_t *vd)
817{
818}
819
820/* ARGSUSED */
821static void
822vdev_indirect_io_done(zio_t *zio)
823{
824}
825
826/* ARGSUSED */
827static int
828vdev_indirect_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
829 uint64_t *logical_ashift, uint64_t *physical_ashift)
830{
831 *psize = *max_psize = vd->vdev_asize +
832 VDEV_LABEL_START_SIZE + VDEV_LABEL_END_SIZE;
833 *logical_ashift = vd->vdev_ashift;
834 *physical_ashift = vd->vdev_physical_ashift;

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

1062
1063 mutex_enter(&pio->io_lock);
1064 pio->io_error = zio_worst_error(pio->io_error, zio->io_error);
1065 mutex_exit(&pio->io_lock);
1066
1067 abd_put(zio->io_abd);
1068}
1069
1070static void
1071vdev_indirect_io_start_cb(uint64_t split_offset, vdev_t *vd, uint64_t offset,
1072 uint64_t size, void *arg)
1073{
1074 zio_t *zio = arg;
1075
1076 ASSERT3P(vd, !=, NULL);
1077
1078 if (vd->vdev_ops == &vdev_indirect_ops)
1079 return;
1080
1081 zio_nowait(zio_vdev_child_io(zio, NULL, vd, offset,
1082 abd_get_offset(zio->io_abd, split_offset),
1083 size, zio->io_type, zio->io_priority,
1084 0, vdev_indirect_child_io_done, zio));
1085}
1086
1087static void
1088vdev_indirect_io_start(zio_t *zio)
1089{
1090 spa_t *spa = zio->io_spa;
1091
1092 ASSERT(spa_config_held(spa, SCL_ALL, RW_READER) != 0);
1093 if (zio->io_type != ZIO_TYPE_READ) {
1094 ASSERT3U(zio->io_type, ==, ZIO_TYPE_WRITE);
1095 ASSERT((zio->io_flags &
1096 (ZIO_FLAG_SELF_HEAL | ZIO_FLAG_INDUCE_DAMAGE)) != 0);
1097 }
1098
1099 vdev_indirect_remap(zio->io_vd, zio->io_offset, zio->io_size,
1100 vdev_indirect_io_start_cb, zio);
1101
1102 zio_execute(zio);
1103}
1104
1105vdev_ops_t vdev_indirect_ops = {
1106 vdev_indirect_open,
1107 vdev_indirect_close,
1108 vdev_default_asize,
1109 vdev_indirect_io_start,
1110 vdev_indirect_io_done,
1111 NULL,
1112 NULL,
1113 NULL,
1114 NULL,
1115 vdev_indirect_remap,
1116 VDEV_TYPE_INDIRECT, /* name of this vdev type */
1117 B_FALSE /* leaf vdev */
1118};