Deleted Added
full compact
zio.c (316849) zio.c (321529)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

633
634 mutex_init(&zio->io_lock, NULL, MUTEX_DEFAULT, NULL);
635 cv_init(&zio->io_cv, NULL, CV_DEFAULT, NULL);
636
637 list_create(&zio->io_parent_list, sizeof (zio_link_t),
638 offsetof(zio_link_t, zl_parent_node));
639 list_create(&zio->io_child_list, sizeof (zio_link_t),
640 offsetof(zio_link_t, zl_child_node));
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

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

633
634 mutex_init(&zio->io_lock, NULL, MUTEX_DEFAULT, NULL);
635 cv_init(&zio->io_cv, NULL, CV_DEFAULT, NULL);
636
637 list_create(&zio->io_parent_list, sizeof (zio_link_t),
638 offsetof(zio_link_t, zl_parent_node));
639 list_create(&zio->io_child_list, sizeof (zio_link_t),
640 offsetof(zio_link_t, zl_child_node));
641 metaslab_trace_init(&zio->io_alloc_list);
641
642 if (vd != NULL)
643 zio->io_child_type = ZIO_CHILD_VDEV;
644 else if (flags & ZIO_FLAG_GANG_CHILD)
645 zio->io_child_type = ZIO_CHILD_GANG;
646 else if (flags & ZIO_FLAG_DDT_CHILD)
647 zio->io_child_type = ZIO_CHILD_DDT;
648 else

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

691 }
692
693 return (zio);
694}
695
696static void
697zio_destroy(zio_t *zio)
698{
642
643 if (vd != NULL)
644 zio->io_child_type = ZIO_CHILD_VDEV;
645 else if (flags & ZIO_FLAG_GANG_CHILD)
646 zio->io_child_type = ZIO_CHILD_GANG;
647 else if (flags & ZIO_FLAG_DDT_CHILD)
648 zio->io_child_type = ZIO_CHILD_DDT;
649 else

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

692 }
693
694 return (zio);
695}
696
697static void
698zio_destroy(zio_t *zio)
699{
700 metaslab_trace_fini(&zio->io_alloc_list);
699 list_destroy(&zio->io_parent_list);
700 list_destroy(&zio->io_child_list);
701 mutex_destroy(&zio->io_lock);
702 cv_destroy(&zio->io_cv);
703 kmem_cache_free(zio_cache, zio);
704}
705
706zio_t *

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

2219 * since metaslab_class_throttle_reserve() always allows
2220 * additional reservations for gang blocks.
2221 */
2222 VERIFY(metaslab_class_throttle_reserve(mc, gbh_copies - copies,
2223 pio, flags));
2224 }
2225
2226 error = metaslab_alloc(spa, mc, SPA_GANGBLOCKSIZE,
701 list_destroy(&zio->io_parent_list);
702 list_destroy(&zio->io_child_list);
703 mutex_destroy(&zio->io_lock);
704 cv_destroy(&zio->io_cv);
705 kmem_cache_free(zio_cache, zio);
706}
707
708zio_t *

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

2221 * since metaslab_class_throttle_reserve() always allows
2222 * additional reservations for gang blocks.
2223 */
2224 VERIFY(metaslab_class_throttle_reserve(mc, gbh_copies - copies,
2225 pio, flags));
2226 }
2227
2228 error = metaslab_alloc(spa, mc, SPA_GANGBLOCKSIZE,
2227 bp, gbh_copies, txg, pio == gio ? NULL : gio->io_bp, flags, pio);
2229 bp, gbh_copies, txg, pio == gio ? NULL : gio->io_bp, flags,
2230 &pio->io_alloc_list, pio);
2228 if (error) {
2229 if (pio->io_flags & ZIO_FLAG_IO_ALLOCATING) {
2230 ASSERT(pio->io_priority == ZIO_PRIORITY_ASYNC_WRITE);
2231 ASSERT(!(pio->io_flags & ZIO_FLAG_NODATA));
2232
2233 /*
2234 * If we failed to allocate the gang block header then
2235 * we remove any additional allocation reservations that

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

2872 if (zio->io_flags & ZIO_FLAG_GANG_CHILD) {
2873 flags |= METASLAB_GANG_CHILD;
2874 }
2875 if (zio->io_priority == ZIO_PRIORITY_ASYNC_WRITE) {
2876 flags |= METASLAB_ASYNC_ALLOC;
2877 }
2878
2879 error = metaslab_alloc(spa, mc, zio->io_size, bp,
2231 if (error) {
2232 if (pio->io_flags & ZIO_FLAG_IO_ALLOCATING) {
2233 ASSERT(pio->io_priority == ZIO_PRIORITY_ASYNC_WRITE);
2234 ASSERT(!(pio->io_flags & ZIO_FLAG_NODATA));
2235
2236 /*
2237 * If we failed to allocate the gang block header then
2238 * we remove any additional allocation reservations that

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

2875 if (zio->io_flags & ZIO_FLAG_GANG_CHILD) {
2876 flags |= METASLAB_GANG_CHILD;
2877 }
2878 if (zio->io_priority == ZIO_PRIORITY_ASYNC_WRITE) {
2879 flags |= METASLAB_ASYNC_ALLOC;
2880 }
2881
2882 error = metaslab_alloc(spa, mc, zio->io_size, bp,
2880 zio->io_prop.zp_copies, zio->io_txg, NULL, flags, zio);
2883 zio->io_prop.zp_copies, zio->io_txg, NULL, flags,
2884 &zio->io_alloc_list, zio);
2881
2882 if (error != 0) {
2883 spa_dbgmsg(spa, "%s: metaslab allocation failure: zio %p, "
2884 "size %llu, error %d", spa_name(spa), zio, zio->io_size,
2885 error);
2886 if (error == ENOSPC && zio->io_size > SPA_MINBLOCKSIZE)
2887 return (zio_write_gang_block(zio));
2888 zio->io_error = error;

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

2936/*
2937 * Try to allocate an intent log block. Return 0 on success, errno on failure.
2938 */
2939int
2940zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp, blkptr_t *old_bp,
2941 uint64_t size, boolean_t *slog)
2942{
2943 int error = 1;
2885
2886 if (error != 0) {
2887 spa_dbgmsg(spa, "%s: metaslab allocation failure: zio %p, "
2888 "size %llu, error %d", spa_name(spa), zio, zio->io_size,
2889 error);
2890 if (error == ENOSPC && zio->io_size > SPA_MINBLOCKSIZE)
2891 return (zio_write_gang_block(zio));
2892 zio->io_error = error;

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

2940/*
2941 * Try to allocate an intent log block. Return 0 on success, errno on failure.
2942 */
2943int
2944zio_alloc_zil(spa_t *spa, uint64_t txg, blkptr_t *new_bp, blkptr_t *old_bp,
2945 uint64_t size, boolean_t *slog)
2946{
2947 int error = 1;
2948 zio_alloc_list_t io_alloc_list;
2944
2945 ASSERT(txg > spa_syncing_txg(spa));
2946
2949
2950 ASSERT(txg > spa_syncing_txg(spa));
2951
2947 error = metaslab_alloc(spa, spa_log_class(spa), size,
2948 new_bp, 1, txg, old_bp, METASLAB_HINTBP_AVOID, NULL);
2952 metaslab_trace_init(&io_alloc_list);
2953 error = metaslab_alloc(spa, spa_log_class(spa), size, new_bp, 1,
2954 txg, old_bp, METASLAB_HINTBP_AVOID, &io_alloc_list, NULL);
2949 if (error == 0) {
2950 *slog = TRUE;
2951 } else {
2952 error = metaslab_alloc(spa, spa_normal_class(spa), size,
2955 if (error == 0) {
2956 *slog = TRUE;
2957 } else {
2958 error = metaslab_alloc(spa, spa_normal_class(spa), size,
2953 new_bp, 1, txg, old_bp, METASLAB_HINTBP_AVOID, NULL);
2959 new_bp, 1, txg, old_bp, METASLAB_HINTBP_AVOID,
2960 &io_alloc_list, NULL);
2954 if (error == 0)
2955 *slog = FALSE;
2956 }
2961 if (error == 0)
2962 *slog = FALSE;
2963 }
2964 metaslab_trace_fini(&io_alloc_list);
2957
2958 if (error == 0) {
2959 BP_SET_LSIZE(new_bp, size);
2960 BP_SET_PSIZE(new_bp, size);
2961 BP_SET_COMPRESS(new_bp, ZIO_COMPRESS_OFF);
2962 BP_SET_CHECKSUM(new_bp,
2963 spa_version(spa) >= SPA_VERSION_SLIM_ZIL
2964 ? ZIO_CHECKSUM_ZILOG2 : ZIO_CHECKSUM_ZILOG);

--- 1077 unchanged lines hidden ---
2965
2966 if (error == 0) {
2967 BP_SET_LSIZE(new_bp, size);
2968 BP_SET_PSIZE(new_bp, size);
2969 BP_SET_COMPRESS(new_bp, ZIO_COMPRESS_OFF);
2970 BP_SET_CHECKSUM(new_bp,
2971 spa_version(spa) >= SPA_VERSION_SLIM_ZIL
2972 ? ZIO_CHECKSUM_ZILOG2 : ZIO_CHECKSUM_ZILOG);

--- 1077 unchanged lines hidden ---