View | Details | Raw Unified | Return to bug 234576
Collapse All | Expand All

(-)primary.c (-4 / +18 lines)
Lines 73-78 Link Here
73
/* The is only one remote component for now. */
73
/* The is only one remote component for now. */
74
#define	ISREMOTE(no)	((no) == 1)
74
#define	ISREMOTE(no)	((no) == 1)
75
75
76
/* There appears to be an issue with ZFS where you get MAXPHYS + 0x200 back in geom_gate
77
   on occasion - usually when using raidz2.  This causes a lot of issues; so we "fix" this
78
   by allowing an additional 0x800 bytes before croaking.                                  */
79
80
/* Upgrading to 12.0 leads to a request for 0x100000 bytes.  This makes this fix even more
81
   fragile but as a workaround, allow ggate_recv to receive this much data.                */ 
82
#define GGRMAXLEN 0x100000 
83
76
struct hio {
84
struct hio {
77
	/*
85
	/*
78
	 * Number of components we are still waiting for.
86
	 * Number of components we are still waiting for.
Lines 490-502 Link Here
490
			    sizeof(hio->hio_next[0]) * ncomps);
498
			    sizeof(hio->hio_next[0]) * ncomps);
491
		}
499
		}
492
		hio->hio_ggio.gctl_version = G_GATE_VERSION;
500
		hio->hio_ggio.gctl_version = G_GATE_VERSION;
493
		hio->hio_ggio.gctl_data = malloc(MAXPHYS);
501
		hio->hio_ggio.gctl_data = malloc(GGRMAXLEN);
494
		if (hio->hio_ggio.gctl_data == NULL) {
502
		if (hio->hio_ggio.gctl_data == NULL) {
495
			primary_exitx(EX_TEMPFAIL,
503
			primary_exitx(EX_TEMPFAIL,
496
			    "Unable to allocate %zu bytes of memory for gctl_data.",
504
			    "Unable to allocate %zu bytes of memory for gctl_data.",
497
			    MAXPHYS);
505
			    GGRMAXLEN);
498
		}
506
		}
499
		hio->hio_ggio.gctl_length = MAXPHYS;
507
		hio->hio_ggio.gctl_length = GGRMAXLEN;
500
		hio->hio_ggio.gctl_error = 0;
508
		hio->hio_ggio.gctl_error = 0;
501
		TAILQ_INSERT_HEAD(&hio_free_list, hio, hio_free_next);
509
		TAILQ_INSERT_HEAD(&hio_free_list, hio, hio_free_next);
502
		hio_free_list_size++;
510
		hio_free_list_size++;
Lines 1236-1242 Link Here
1236
		pjdlog_debug(2, "ggate_recv: (%p) Got free request.", hio);
1244
		pjdlog_debug(2, "ggate_recv: (%p) Got free request.", hio);
1237
		ggio = &hio->hio_ggio;
1245
		ggio = &hio->hio_ggio;
1238
		ggio->gctl_unit = res->hr_ggateunit;
1246
		ggio->gctl_unit = res->hr_ggateunit;
1239
		ggio->gctl_length = MAXPHYS;
1247
		ggio->gctl_length = GGRMAXLEN;
1240
		ggio->gctl_error = 0;
1248
		ggio->gctl_error = 0;
1241
		hio->hio_done = false;
1249
		hio->hio_done = false;
1242
		hio->hio_replication = res->hr_replication;
1250
		hio->hio_replication = res->hr_replication;
Lines 1266-1271 Link Here
1266
			 * Buffer too small? Impossible, we allocate MAXPHYS
1274
			 * Buffer too small? Impossible, we allocate MAXPHYS
1267
			 * bytes - request can't be bigger than that.
1275
			 * bytes - request can't be bigger than that.
1268
			 */
1276
			 */
1277
			primary_exitx(EX_OSERR, "G_GATE_CMD_START failed: %s.  This is in the source as being 'impossible' and appears to have happened.  allocated=%x length=%x maxphys=%x", strerror(error), GGRMAXLEN, ggio->gctl_length, MAXPHYS);
1278
1269
			/* FALLTHROUGH */
1279
			/* FALLTHROUGH */
1270
		case ENXIO:
1280
		case ENXIO:
1271
		default:
1281
		default:
Lines 1273-1278 Link Here
1273
			    strerror(error));
1283
			    strerror(error));
1274
		}
1284
		}
1275
1285
1286
		if (ggio->gctl_length > MAXPHYS) {
1287
			pjdlog_warning("gctl_length is larger than MAXPHYS (%x) - would have been ENOMEM.", ggio->gctl_length);
1288
		}
1289
	
1276
		ncomp = 0;
1290
		ncomp = 0;
1277
		ncomps = HAST_NCOMPONENTS;
1291
		ncomps = HAST_NCOMPONENTS;
1278
1292
(-)secondary.c (-5 / +8 lines)
Lines 131-136 Link Here
131
	mtx_unlock(&hio_##name##_list_lock);				\
131
	mtx_unlock(&hio_##name##_list_lock);				\
132
} while (0)
132
} while (0)
133
133
134
/* See comments in primary.c about this.                 */
135
#define GGRMAXLEN 0x100000
136
134
static void
137
static void
135
output_status_aux(struct nv *nvout)
138
output_status_aux(struct nv *nvout)
136
{
139
{
Lines 196-206 Link Here
196
			    "Unable to allocate memory (%zu bytes) for hio request.",
199
			    "Unable to allocate memory (%zu bytes) for hio request.",
197
			    sizeof(*hio));
200
			    sizeof(*hio));
198
		}
201
		}
199
		hio->hio_data = malloc(MAXPHYS);
202
		hio->hio_data = malloc(GGRMAXLEN);
200
		if (hio->hio_data == NULL) {
203
		if (hio->hio_data == NULL) {
201
			pjdlog_exitx(EX_TEMPFAIL,
204
			pjdlog_exitx(EX_TEMPFAIL,
202
			    "Unable to allocate memory (%zu bytes) for gctl_data.",
205
			    "Unable to allocate memory (%zu bytes) for gctl_data.",
203
			    (size_t)MAXPHYS);
206
			    (size_t)GGRMAXLEN);
204
		}
207
		}
205
		hio_clear(hio);
208
		hio_clear(hio);
206
		TAILQ_INSERT_HEAD(&hio_free_list, hio, hio_next);
209
		TAILQ_INSERT_HEAD(&hio_free_list, hio, hio_next);
Lines 597-605 Link Here
597
			hio->hio_error = EINVAL;
600
			hio->hio_error = EINVAL;
598
			goto end;
601
			goto end;
599
		}
602
		}
600
		if (hio->hio_cmd != HIO_DELETE && hio->hio_length > MAXPHYS) {
603
		if (hio->hio_cmd != HIO_DELETE && hio->hio_length > GGRMAXLEN) {
601
			pjdlog_error("Data length is too large (%ju > %ju).",
604
			pjdlog_error("Data length is too large (%ju > %ju).",
602
			    (uintmax_t)hio->hio_length, (uintmax_t)MAXPHYS);
605
			    (uintmax_t)hio->hio_length, (uintmax_t)GGRMAXLEN);
603
			hio->hio_error = EINVAL;
606
			hio->hio_error = EINVAL;
604
			goto end;
607
			goto end;
605
		}
608
		}
Lines 705-711 Link Here
705
			continue;
708
			continue;
706
		} else if (hio->hio_cmd == HIO_WRITE) {
709
		} else if (hio->hio_cmd == HIO_WRITE) {
707
			if (hast_proto_recv_data(res, res->hr_remotein, nv,
710
			if (hast_proto_recv_data(res, res->hr_remotein, nv,
708
			    hio->hio_data, MAXPHYS) == -1) {
711
			    hio->hio_data, GGRMAXLEN) == -1) {
709
				secondary_exit(EX_TEMPFAIL,
712
				secondary_exit(EX_TEMPFAIL,
710
				    "Unable to receive request data");
713
				    "Unable to receive request data");
711
			}
714
			}

Return to bug 234576