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

(-)b/share/man/man9/g_attach.9 (-1 / +3 lines)
Lines 24-30 Link Here
24
.\"
24
.\"
25
.\" $FreeBSD$
25
.\" $FreeBSD$
26
.\"
26
.\"
27
.Dd January 16, 2004
27
.Dd October 10, 2020
28
.Dt G_ATTACH 9
28
.Dt G_ATTACH 9
29
.Os
29
.Os
30
.Sh NAME
30
.Sh NAME
Lines 122-127 Possible errors: Link Here
122
.Bl -tag -width Er
122
.Bl -tag -width Er
123
.It Bq Er ELOOP
123
.It Bq Er ELOOP
124
The operation creates a topology loop.
124
The operation creates a topology loop.
125
.It Bq Er ENXIO
126
Provider got orphaned.
125
.El
127
.El
126
.Sh SEE ALSO
128
.Sh SEE ALSO
127
.Xr geom 4 ,
129
.Xr geom 4 ,
(-)b/sys/geom/bde/g_bde.c (-1 / +7 lines)
Lines 132-138 g_bde_create_geom(struct gctl_req *req, struct g_class *mp, struct g_provider *p Link Here
132
132
133
	gp = g_new_geomf(mp, "%s.bde", pp->name);
133
	gp = g_new_geomf(mp, "%s.bde", pp->name);
134
	cp = g_new_consumer(gp);
134
	cp = g_new_consumer(gp);
135
	g_attach(cp, pp);
135
	error = g_attach(cp, pp);
136
	if (error != 0) {
137
		g_destroy_consumer(cp);
138
		g_destroy_geom(gp);
139
		gctl_error(req, "could not attach consumer");
140
		return;
141
	}
136
	error = g_access(cp, 1, 1, 1);
142
	error = g_access(cp, 1, 1, 1);
137
	if (error) {
143
	if (error) {
138
		g_detach(cp);
144
		g_detach(cp);
(-)b/sys/geom/cache/g_cache.c (-3 / +5 lines)
Lines 670-678 g_cache_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
670
	gp->orphan = g_cache_orphan;
670
	gp->orphan = g_cache_orphan;
671
	gp->access = g_cache_access;
671
	gp->access = g_cache_access;
672
	cp = g_new_consumer(gp);
672
	cp = g_new_consumer(gp);
673
	g_attach(cp, pp);
673
	error = g_attach(cp, pp);
674
	error = g_cache_read_metadata(cp, &md);
674
	if (error == 0) {
675
	g_detach(cp);
675
		error = g_cache_read_metadata(cp, &md);
676
		g_detach(cp);
677
	}
676
	g_destroy_consumer(cp);
678
	g_destroy_consumer(cp);
677
	g_destroy_geom(gp);
679
	g_destroy_geom(gp);
678
	if (error != 0)
680
	if (error != 0)
(-)b/sys/geom/concat/g_concat.c (-3 / +5 lines)
Lines 714-722 g_concat_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
714
	gp->access = g_concat_access;
714
	gp->access = g_concat_access;
715
	gp->orphan = g_concat_orphan;
715
	gp->orphan = g_concat_orphan;
716
	cp = g_new_consumer(gp);
716
	cp = g_new_consumer(gp);
717
	g_attach(cp, pp);
717
	error = g_attach(cp, pp);
718
	error = g_concat_read_metadata(cp, &md);
718
	if (error == 0) {
719
	g_detach(cp);
719
		error = g_concat_read_metadata(cp, &md);
720
		g_detach(cp);
721
	}
720
	g_destroy_consumer(cp);
722
	g_destroy_consumer(cp);
721
	g_destroy_geom(gp);
723
	g_destroy_geom(gp);
722
	if (error != 0)
724
	if (error != 0)
(-)b/sys/geom/geom_dev.c (-1 / +1 lines)
Lines 337-343 g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) Link Here
337
	cp->private = sc;
337
	cp->private = sc;
338
	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
338
	cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
339
	error = g_attach(cp, pp);
339
	error = g_attach(cp, pp);
340
	KASSERT(error == 0,
340
	KASSERT(error == 0 || error == ENXIO,
341
	    ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
341
	    ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error));
342
342
343
	make_dev_args_init(&args);
343
	make_dev_args_init(&args);
(-)b/sys/geom/geom_subr.c (+2 lines)
Lines 832-837 g_attach(struct g_consumer *cp, struct g_provider *pp) Link Here
832
	G_VALID_PROVIDER(pp);
832
	G_VALID_PROVIDER(pp);
833
	g_trace(G_T_TOPOLOGY, "g_attach(%p, %p)", cp, pp);
833
	g_trace(G_T_TOPOLOGY, "g_attach(%p, %p)", cp, pp);
834
	KASSERT(cp->provider == NULL, ("attach but attached"));
834
	KASSERT(cp->provider == NULL, ("attach but attached"));
835
	if ((pp->flags & (G_PF_ORPHAN | G_PF_WITHER)) != 0)
836
		return (ENXIO);
835
	cp->provider = pp;
837
	cp->provider = pp;
836
	cp->flags &= ~G_CF_ORPHAN;
838
	cp->flags &= ~G_CF_ORPHAN;
837
	LIST_INSERT_HEAD(&pp->consumers, cp, consumers);
839
	LIST_INSERT_HEAD(&pp->consumers, cp, consumers);
(-)b/sys/geom/geom_vfs.c (-1 / +5 lines)
Lines 253-259 g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr Link Here
253
	sc->sc_bo = bo;
253
	sc->sc_bo = bo;
254
	gp->softc = sc;
254
	gp->softc = sc;
255
	cp = g_new_consumer(gp);
255
	cp = g_new_consumer(gp);
256
	g_attach(cp, pp);
256
	error = g_attach(cp, pp);
257
	if (error) {
258
		g_wither_geom(gp, ENXIO);
259
		return (error);
260
	}
257
	error = g_access(cp, 1, wr, wr);
261
	error = g_access(cp, 1, wr, wr);
258
	if (error) {
262
	if (error) {
259
		g_wither_geom(gp, ENXIO);
263
		g_wither_geom(gp, ENXIO);
(-)b/sys/geom/journal/g_journal.c (-3 / +5 lines)
Lines 2475-2483 g_journal_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
2475
	/* This orphan function should be never called. */
2475
	/* This orphan function should be never called. */
2476
	gp->orphan = g_journal_taste_orphan;
2476
	gp->orphan = g_journal_taste_orphan;
2477
	cp = g_new_consumer(gp);
2477
	cp = g_new_consumer(gp);
2478
	g_attach(cp, pp);
2478
	error = g_attach(cp, pp);
2479
	error = g_journal_metadata_read(cp, &md);
2479
	if (error == 0) {
2480
	g_detach(cp);
2480
		error = g_journal_metadata_read(cp, &md);
2481
		g_detach(cp);
2482
	}
2481
	g_destroy_consumer(cp);
2483
	g_destroy_consumer(cp);
2482
	g_destroy_geom(gp);
2484
	g_destroy_geom(gp);
2483
	if (error != 0)
2485
	if (error != 0)
(-)b/sys/geom/label/g_label.c (-1 / +3 lines)
Lines 346-352 g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
346
	gp->access = g_label_access_taste;
346
	gp->access = g_label_access_taste;
347
	gp->orphan = g_label_orphan_taste;
347
	gp->orphan = g_label_orphan_taste;
348
	cp = g_new_consumer(gp);
348
	cp = g_new_consumer(gp);
349
	g_attach(cp, pp);
349
	if (g_attach(cp, pp) != 0)
350
		goto end2;
350
	if (g_access(cp, 1, 0, 0) != 0)
351
	if (g_access(cp, 1, 0, 0) != 0)
351
		goto end;
352
		goto end;
352
	do {
353
	do {
Lines 393-398 g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
393
	g_access(cp, -1, 0, 0);
394
	g_access(cp, -1, 0, 0);
394
end:
395
end:
395
	g_detach(cp);
396
	g_detach(cp);
397
end2:
396
	g_destroy_consumer(cp);
398
	g_destroy_consumer(cp);
397
	g_destroy_geom(gp);
399
	g_destroy_geom(gp);
398
	return (NULL);
400
	return (NULL);
(-)b/sys/geom/linux_lvm/g_linux_lvm.c (-5 / +7 lines)
Lines 538-548 g_llvm_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
538
	/* This orphan function should be never called. */
538
	/* This orphan function should be never called. */
539
	gp->orphan = g_llvm_taste_orphan;
539
	gp->orphan = g_llvm_taste_orphan;
540
	cp = g_new_consumer(gp);
540
	cp = g_new_consumer(gp);
541
	g_attach(cp, pp);
541
	error = g_attach(cp, pp);
542
	error = g_llvm_read_label(cp, &ll);
542
	if (error == 0) {
543
	if (!error)
543
		error = g_llvm_read_label(cp, &ll);
544
		error = g_llvm_read_md(cp, &md, &ll);
544
		if (error == 0)
545
	g_detach(cp);
545
			error = g_llvm_read_md(cp, &md, &ll);
546
		g_detach(cp);
547
	}
546
	g_destroy_consumer(cp);
548
	g_destroy_consumer(cp);
547
	g_destroy_geom(gp);
549
	g_destroy_geom(gp);
548
	if (error != 0)
550
	if (error != 0)
(-)b/sys/geom/mirror/g_mirror.c (-3 / +5 lines)
Lines 3204-3212 g_mirror_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
3204
	 */
3204
	 */
3205
	gp->orphan = g_mirror_taste_orphan;
3205
	gp->orphan = g_mirror_taste_orphan;
3206
	cp = g_new_consumer(gp);
3206
	cp = g_new_consumer(gp);
3207
	g_attach(cp, pp);
3207
	error = g_attach(cp, pp);
3208
	error = g_mirror_read_metadata(cp, &md);
3208
	if (error == 0) {
3209
	g_detach(cp);
3209
		error = g_mirror_read_metadata(cp, &md);
3210
		g_detach(cp);
3211
	}
3210
	g_destroy_consumer(cp);
3212
	g_destroy_consumer(cp);
3211
	g_destroy_geom(gp);
3213
	g_destroy_geom(gp);
3212
	if (error != 0)
3214
	if (error != 0)
(-)b/sys/geom/mirror/g_mirror_ctl.c (-1 / +5 lines)
Lines 400-406 g_mirror_ctl_create(struct gctl_req *req, struct g_class *mp) Link Here
400
			gctl_error(req, "Disk %s is invalid.", name);
400
			gctl_error(req, "Disk %s is invalid.", name);
401
			goto err;
401
			goto err;
402
		}
402
		}
403
		g_attach(cp, pp);
403
		if (g_attach(cp, pp) != 0) {
404
			G_MIRROR_DEBUG(1, "Can't attach disk %s.", pp->name);
405
			gctl_error(req, "Can't attach disk %s.", pp->name);
406
			goto err;
407
		}
404
		if (g_access(cp, 1, 0, 0) != 0) {
408
		if (g_access(cp, 1, 0, 0) != 0) {
405
			G_MIRROR_DEBUG(1, "Can't open disk %s.", name);
409
			G_MIRROR_DEBUG(1, "Can't open disk %s.", name);
406
			gctl_error(req, "Can't open disk %s.", name);
410
			gctl_error(req, "Can't open disk %s.", name);
(-)b/sys/geom/mountver/g_mountver.c (-1 / +6 lines)
Lines 594-600 g_mountver_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
594
		return (NULL);
594
		return (NULL);
595
595
596
	cp = LIST_FIRST(&gp->consumer);
596
	cp = LIST_FIRST(&gp->consumer);
597
	g_attach(cp, pp);
597
	error = g_attach(cp, pp);
598
	if (error != 0) {
599
		G_MOUNTVER_DEBUG(0, "Cannot attach to %s; error = %d.", pp->name, error);
600
		return (NULL);
601
	}
602
598
	error = g_mountver_ident_matches(gp);
603
	error = g_mountver_ident_matches(gp);
599
	if (error != 0) {
604
	if (error != 0) {
600
		g_detach(cp);
605
		g_detach(cp);
(-)b/sys/geom/multipath/g_multipath.c (-3 / +5 lines)
Lines 829-837 g_multipath_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
829
	gp->access = g_multipath_access;
829
	gp->access = g_multipath_access;
830
	gp->orphan = g_multipath_orphan;
830
	gp->orphan = g_multipath_orphan;
831
	cp = g_new_consumer(gp);
831
	cp = g_new_consumer(gp);
832
	g_attach(cp, pp);
832
	error = g_attach(cp, pp);
833
	error = g_multipath_read_metadata(cp, &md);
833
	if (error == 0) {
834
	g_detach(cp);
834
		error = g_multipath_read_metadata(cp, &md);
835
		g_detach(cp);
836
	}
835
	g_destroy_consumer(cp);
837
	g_destroy_consumer(cp);
836
	g_destroy_geom(gp);
838
	g_destroy_geom(gp);
837
	if (error != 0)
839
	if (error != 0)
(-)b/sys/geom/raid/g_raid.c (-1 / +3 lines)
Lines 2225-2231 g_raid_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
2225
	gp->orphan = g_raid_taste_orphan;
2225
	gp->orphan = g_raid_taste_orphan;
2226
	cp = g_new_consumer(gp);
2226
	cp = g_new_consumer(gp);
2227
	cp->flags |= G_CF_DIRECT_RECEIVE;
2227
	cp->flags |= G_CF_DIRECT_RECEIVE;
2228
	g_attach(cp, pp);
2228
	if (g_attach(cp, pp) != 0)
2229
		goto ofail2;
2229
	if (g_access(cp, 1, 0, 0) != 0)
2230
	if (g_access(cp, 1, 0, 0) != 0)
2230
		goto ofail;
2231
		goto ofail;
2231
2232
Lines 2248-2253 g_raid_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
2248
		(void)g_access(cp, -1, 0, 0);
2249
		(void)g_access(cp, -1, 0, 0);
2249
ofail:
2250
ofail:
2250
	g_detach(cp);
2251
	g_detach(cp);
2252
ofail2:
2251
	g_destroy_consumer(cp);
2253
	g_destroy_consumer(cp);
2252
	g_destroy_geom(gp);
2254
	g_destroy_geom(gp);
2253
	G_RAID_DEBUG(2, "Tasting provider %s done.", pp->name);
2255
	G_RAID_DEBUG(2, "Tasting provider %s done.", pp->name);
(-)b/sys/geom/raid3/g_raid3.c (-3 / +5 lines)
Lines 3314-3322 g_raid3_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
3314
	/* This orphan function should be never called. */
3314
	/* This orphan function should be never called. */
3315
	gp->orphan = g_raid3_taste_orphan;
3315
	gp->orphan = g_raid3_taste_orphan;
3316
	cp = g_new_consumer(gp);
3316
	cp = g_new_consumer(gp);
3317
	g_attach(cp, pp);
3317
	error = g_attach(cp, pp);
3318
	error = g_raid3_read_metadata(cp, &md);
3318
	if (error == 0) {
3319
	g_detach(cp);
3319
		error = g_raid3_read_metadata(cp, &md);
3320
		g_detach(cp);
3321
	}
3320
	g_destroy_consumer(cp);
3322
	g_destroy_consumer(cp);
3321
	g_destroy_geom(gp);
3323
	g_destroy_geom(gp);
3322
	if (error != 0)
3324
	if (error != 0)
(-)b/sys/geom/shsec/g_shsec.c (-3 / +5 lines)
Lines 644-652 g_shsec_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
644
	gp->access = g_shsec_access;
644
	gp->access = g_shsec_access;
645
	gp->orphan = g_shsec_orphan;
645
	gp->orphan = g_shsec_orphan;
646
	cp = g_new_consumer(gp);
646
	cp = g_new_consumer(gp);
647
	g_attach(cp, pp);
647
	error = g_attach(cp, pp);
648
	error = g_shsec_read_metadata(cp, &md);
648
	if (error == 0) {
649
	g_detach(cp);
649
		error = g_shsec_read_metadata(cp, &md);
650
		g_detach(cp);
651
	}
650
	g_destroy_consumer(cp);
652
	g_destroy_consumer(cp);
651
	g_destroy_geom(gp);
653
	g_destroy_geom(gp);
652
	if (error != 0)
654
	if (error != 0)
(-)b/sys/geom/stripe/g_stripe.c (-3 / +5 lines)
Lines 956-964 g_stripe_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) Link Here
956
	gp->access = g_stripe_access;
956
	gp->access = g_stripe_access;
957
	gp->orphan = g_stripe_orphan;
957
	gp->orphan = g_stripe_orphan;
958
	cp = g_new_consumer(gp);
958
	cp = g_new_consumer(gp);
959
	g_attach(cp, pp);
959
	error = g_attach(cp, pp);
960
	error = g_stripe_read_metadata(cp, &md);
960
	if (error == 0) {
961
	g_detach(cp);
961
		error = g_stripe_read_metadata(cp, &md);
962
		g_detach(cp);
963
	}
962
	g_destroy_consumer(cp);
964
	g_destroy_consumer(cp);
963
	g_destroy_geom(gp);
965
	g_destroy_geom(gp);
964
	if (error != 0)
966
	if (error != 0)
(-)b/sys/geom/virstor/g_virstor.c (-3 / +5 lines)
Lines 792-800 g_virstor_taste(struct g_class *mp, struct g_provider *pp, int flags) Link Here
792
	gp->orphan = (void *)invalid_call;	/* I really want these to fail. */
792
	gp->orphan = (void *)invalid_call;	/* I really want these to fail. */
793
793
794
	cp = g_new_consumer(gp);
794
	cp = g_new_consumer(gp);
795
	g_attach(cp, pp);
795
	error = g_attach(cp, pp);
796
	error = read_metadata(cp, &md);
796
	if (error == 0) {
797
	g_detach(cp);
797
		error = read_metadata(cp, &md);
798
		g_detach(cp);
799
	}
798
	g_destroy_consumer(cp);
800
	g_destroy_consumer(cp);
799
	g_destroy_geom(gp);
801
	g_destroy_geom(gp);
800
802

Return to bug 237269