Deleted Added
full compact
zvol.c (289190) zvol.c (294329)
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

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

1109
1110 if (zv->zv_total_opens == 0)
1111 err = zvol_first_open(zv);
1112 if (err) {
1113 mutex_exit(&zfsdev_state_lock);
1114 return (err);
1115 }
1116#else /* !illumos */
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

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

1109
1110 if (zv->zv_total_opens == 0)
1111 err = zvol_first_open(zv);
1112 if (err) {
1113 mutex_exit(&zfsdev_state_lock);
1114 return (err);
1115 }
1116#else /* !illumos */
1117 boolean_t locked = B_FALSE;
1118
1119 /*
1120 * Protect against recursively entering spa_namespace_lock
1121 * when spa_open() is used for a pool on a (local) ZVOL(s).
1122 * This is needed since we replaced upstream zfsdev_state_lock
1123 * with spa_namespace_lock in the ZVOL code.
1124 * We are using the same trick as spa_open().
1125 * Note that calls in zvol_first_open which need to resolve
1126 * pool name to a spa object will enter spa_open()
1127 * recursively, but that function already has all the
1128 * necessary protection.
1129 */
1130 if (!MUTEX_HELD(&zfsdev_state_lock)) {
1131 mutex_enter(&zfsdev_state_lock);
1132 locked = B_TRUE;
1117 if (tsd_get(zfs_geom_probe_vdev_key) != NULL) {
1118 /*
1119 * if zfs_geom_probe_vdev_key is set, that means that zfs is
1120 * attempting to probe geom providers while looking for a
1121 * replacement for a missing VDEV. In this case, the
1122 * spa_namespace_lock will not be held, but it is still illegal
1123 * to use a zvol as a vdev. Deadlocks can result if another
1124 * thread has spa_namespace_lock
1125 */
1126 return (EOPNOTSUPP);
1133 }
1134
1127 }
1128
1129 mutex_enter(&zfsdev_state_lock);
1130
1135 zv = pp->private;
1136 if (zv == NULL) {
1131 zv = pp->private;
1132 if (zv == NULL) {
1137 if (locked)
1138 mutex_exit(&zfsdev_state_lock);
1133 mutex_exit(&zfsdev_state_lock);
1139 return (SET_ERROR(ENXIO));
1140 }
1141
1142 if (zv->zv_total_opens == 0) {
1143 err = zvol_first_open(zv);
1144 if (err) {
1134 return (SET_ERROR(ENXIO));
1135 }
1136
1137 if (zv->zv_total_opens == 0) {
1138 err = zvol_first_open(zv);
1139 if (err) {
1145 if (locked)
1146 mutex_exit(&zfsdev_state_lock);
1140 mutex_exit(&zfsdev_state_lock);
1147 return (err);
1148 }
1149 pp->mediasize = zv->zv_volsize;
1150 pp->stripeoffset = 0;
1151 pp->stripesize = zv->zv_volblocksize;
1152 }
1153#endif /* illumos */
1154 if ((flag & FWRITE) && (zv->zv_flags & ZVOL_RDONLY)) {

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

1172#ifdef illumos
1173 if (zv->zv_open_count[otyp] == 0 || otyp == OTYP_LYR) {
1174 zv->zv_open_count[otyp]++;
1175 zv->zv_total_opens++;
1176 }
1177 mutex_exit(&zfsdev_state_lock);
1178#else
1179 zv->zv_total_opens += count;
1141 return (err);
1142 }
1143 pp->mediasize = zv->zv_volsize;
1144 pp->stripeoffset = 0;
1145 pp->stripesize = zv->zv_volblocksize;
1146 }
1147#endif /* illumos */
1148 if ((flag & FWRITE) && (zv->zv_flags & ZVOL_RDONLY)) {

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

1166#ifdef illumos
1167 if (zv->zv_open_count[otyp] == 0 || otyp == OTYP_LYR) {
1168 zv->zv_open_count[otyp]++;
1169 zv->zv_total_opens++;
1170 }
1171 mutex_exit(&zfsdev_state_lock);
1172#else
1173 zv->zv_total_opens += count;
1180 if (locked)
1181 mutex_exit(&zfsdev_state_lock);
1174 mutex_exit(&zfsdev_state_lock);
1182#endif
1183
1184 return (err);
1185out:
1186 if (zv->zv_total_opens == 0)
1187 zvol_last_close(zv);
1188#ifdef illumos
1189 mutex_exit(&zfsdev_state_lock);
1190#else
1175#endif
1176
1177 return (err);
1178out:
1179 if (zv->zv_total_opens == 0)
1180 zvol_last_close(zv);
1181#ifdef illumos
1182 mutex_exit(&zfsdev_state_lock);
1183#else
1191 if (locked)
1192 mutex_exit(&zfsdev_state_lock);
1184 mutex_exit(&zfsdev_state_lock);
1193#endif
1194 return (err);
1195}
1196
1197/*ARGSUSED*/
1198#ifdef illumos
1199int
1200zvol_close(dev_t dev, int flag, int otyp, cred_t *cr)

--- 1995 unchanged lines hidden ---
1185#endif
1186 return (err);
1187}
1188
1189/*ARGSUSED*/
1190#ifdef illumos
1191int
1192zvol_close(dev_t dev, int flag, int otyp, cred_t *cr)

--- 1995 unchanged lines hidden ---