FreeBSD Bugzilla – Attachment 235084 Details for
Bug 237269
panic in glabel (g_label_destroy) stop after resizing GPT partition
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch against stable/12
diff (text/plain), 11.44 KB, created by
Mark Johnston
on 2022-07-05 14:41:43 UTC
(
hide
)
Description:
patch against stable/12
Filename:
MIME Type:
Creator:
Mark Johnston
Created:
2022-07-05 14:41:43 UTC
Size:
11.44 KB
patch
obsolete
>diff --git a/share/man/man9/g_attach.9 b/share/man/man9/g_attach.9 >index c5cdf5a8e959..afacc90eb932 100644 >--- a/share/man/man9/g_attach.9 >+++ b/share/man/man9/g_attach.9 >@@ -24,7 +24,7 @@ > .\" > .\" $FreeBSD$ > .\" >-.Dd January 16, 2004 >+.Dd October 10, 2020 > .Dt G_ATTACH 9 > .Os > .Sh NAME >@@ -122,6 +122,8 @@ Possible errors: > .Bl -tag -width Er > .It Bq Er ELOOP > The operation creates a topology loop. >+.It Bq Er ENXIO >+Provider got orphaned. > .El > .Sh SEE ALSO > .Xr geom 4 , >diff --git a/sys/geom/bde/g_bde.c b/sys/geom/bde/g_bde.c >index 948f7fa6de75..18ebb9605153 100644 >--- a/sys/geom/bde/g_bde.c >+++ b/sys/geom/bde/g_bde.c >@@ -132,7 +132,13 @@ g_bde_create_geom(struct gctl_req *req, struct g_class *mp, struct g_provider *p > > gp = g_new_geomf(mp, "%s.bde", pp->name); > cp = g_new_consumer(gp); >- g_attach(cp, pp); >+ error = g_attach(cp, pp); >+ if (error != 0) { >+ g_destroy_consumer(cp); >+ g_destroy_geom(gp); >+ gctl_error(req, "could not attach consumer"); >+ return; >+ } > error = g_access(cp, 1, 1, 1); > if (error) { > g_detach(cp); >diff --git a/sys/geom/cache/g_cache.c b/sys/geom/cache/g_cache.c >index 6ea9606721c6..1eecc49c38ab 100644 >--- a/sys/geom/cache/g_cache.c >+++ b/sys/geom/cache/g_cache.c >@@ -670,9 +670,11 @@ g_cache_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > gp->orphan = g_cache_orphan; > gp->access = g_cache_access; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_cache_read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_cache_read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/concat/g_concat.c b/sys/geom/concat/g_concat.c >index e686ffc51285..bfda52dceb2e 100644 >--- a/sys/geom/concat/g_concat.c >+++ b/sys/geom/concat/g_concat.c >@@ -714,9 +714,11 @@ g_concat_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > gp->access = g_concat_access; > gp->orphan = g_concat_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_concat_read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_concat_read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/geom_dev.c b/sys/geom/geom_dev.c >index 1d20e4e0bf0e..60888b8aa632 100644 >--- a/sys/geom/geom_dev.c >+++ b/sys/geom/geom_dev.c >@@ -337,7 +337,7 @@ g_dev_taste(struct g_class *mp, struct g_provider *pp, int insist __unused) > cp->private = sc; > cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; > error = g_attach(cp, pp); >- KASSERT(error == 0, >+ KASSERT(error == 0 || error == ENXIO, > ("g_dev_taste(%s) failed to g_attach, err=%d", pp->name, error)); > > make_dev_args_init(&args); >diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c >index ccc048fe865d..a95a21812b79 100644 >--- a/sys/geom/geom_subr.c >+++ b/sys/geom/geom_subr.c >@@ -832,6 +832,8 @@ g_attach(struct g_consumer *cp, struct g_provider *pp) > G_VALID_PROVIDER(pp); > g_trace(G_T_TOPOLOGY, "g_attach(%p, %p)", cp, pp); > KASSERT(cp->provider == NULL, ("attach but attached")); >+ if ((pp->flags & (G_PF_ORPHAN | G_PF_WITHER)) != 0) >+ return (ENXIO); > cp->provider = pp; > cp->flags &= ~G_CF_ORPHAN; > LIST_INSERT_HEAD(&pp->consumers, cp, consumers); >diff --git a/sys/geom/geom_vfs.c b/sys/geom/geom_vfs.c >index 7448ed3cea65..f7ba1ce8f3ed 100644 >--- a/sys/geom/geom_vfs.c >+++ b/sys/geom/geom_vfs.c >@@ -253,7 +253,11 @@ g_vfs_open(struct vnode *vp, struct g_consumer **cpp, const char *fsname, int wr > sc->sc_bo = bo; > gp->softc = sc; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >+ error = g_attach(cp, pp); >+ if (error) { >+ g_wither_geom(gp, ENXIO); >+ return (error); >+ } > error = g_access(cp, 1, wr, wr); > if (error) { > g_wither_geom(gp, ENXIO); >diff --git a/sys/geom/journal/g_journal.c b/sys/geom/journal/g_journal.c >index 6532c2cd03e6..43df1580da01 100644 >--- a/sys/geom/journal/g_journal.c >+++ b/sys/geom/journal/g_journal.c >@@ -2475,9 +2475,11 @@ g_journal_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > /* This orphan function should be never called. */ > gp->orphan = g_journal_taste_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_journal_metadata_read(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_journal_metadata_read(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/label/g_label.c b/sys/geom/label/g_label.c >index a61a39ae094c..df2434a73099 100644 >--- a/sys/geom/label/g_label.c >+++ b/sys/geom/label/g_label.c >@@ -346,7 +346,8 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > gp->access = g_label_access_taste; > gp->orphan = g_label_orphan_taste; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >+ if (g_attach(cp, pp) != 0) >+ goto end2; > if (g_access(cp, 1, 0, 0) != 0) > goto end; > do { >@@ -393,6 +394,7 @@ g_label_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > g_access(cp, -1, 0, 0); > end: > g_detach(cp); >+end2: > g_destroy_consumer(cp); > g_destroy_geom(gp); > return (NULL); >diff --git a/sys/geom/linux_lvm/g_linux_lvm.c b/sys/geom/linux_lvm/g_linux_lvm.c >index 06fdfbcf7878..43f8db0a510f 100644 >--- a/sys/geom/linux_lvm/g_linux_lvm.c >+++ b/sys/geom/linux_lvm/g_linux_lvm.c >@@ -538,11 +538,13 @@ g_llvm_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > /* This orphan function should be never called. */ > gp->orphan = g_llvm_taste_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_llvm_read_label(cp, &ll); >- if (!error) >- error = g_llvm_read_md(cp, &md, &ll); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_llvm_read_label(cp, &ll); >+ if (error == 0) >+ error = g_llvm_read_md(cp, &md, &ll); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c >index 5633a7c5f5ce..960fd41d7832 100644 >--- a/sys/geom/mirror/g_mirror.c >+++ b/sys/geom/mirror/g_mirror.c >@@ -3204,9 +3204,11 @@ g_mirror_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > */ > gp->orphan = g_mirror_taste_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_mirror_read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_mirror_read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/mirror/g_mirror_ctl.c b/sys/geom/mirror/g_mirror_ctl.c >index 74663179ab4b..56a929518695 100644 >--- a/sys/geom/mirror/g_mirror_ctl.c >+++ b/sys/geom/mirror/g_mirror_ctl.c >@@ -400,7 +400,11 @@ g_mirror_ctl_create(struct gctl_req *req, struct g_class *mp) > gctl_error(req, "Disk %s is invalid.", name); > goto err; > } >- g_attach(cp, pp); >+ if (g_attach(cp, pp) != 0) { >+ G_MIRROR_DEBUG(1, "Can't attach disk %s.", pp->name); >+ gctl_error(req, "Can't attach disk %s.", pp->name); >+ goto err; >+ } > if (g_access(cp, 1, 0, 0) != 0) { > G_MIRROR_DEBUG(1, "Can't open disk %s.", name); > gctl_error(req, "Can't open disk %s.", name); >diff --git a/sys/geom/mountver/g_mountver.c b/sys/geom/mountver/g_mountver.c >index 1088c98b179d..1dba99d202d6 100644 >--- a/sys/geom/mountver/g_mountver.c >+++ b/sys/geom/mountver/g_mountver.c >@@ -594,7 +594,12 @@ g_mountver_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > return (NULL); > > cp = LIST_FIRST(&gp->consumer); >- g_attach(cp, pp); >+ error = g_attach(cp, pp); >+ if (error != 0) { >+ G_MOUNTVER_DEBUG(0, "Cannot attach to %s; error = %d.", pp->name, error); >+ return (NULL); >+ } >+ > error = g_mountver_ident_matches(gp); > if (error != 0) { > g_detach(cp); >diff --git a/sys/geom/multipath/g_multipath.c b/sys/geom/multipath/g_multipath.c >index 7a8c88ab61fc..b67337cb5dcd 100644 >--- a/sys/geom/multipath/g_multipath.c >+++ b/sys/geom/multipath/g_multipath.c >@@ -829,9 +829,11 @@ g_multipath_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > gp->access = g_multipath_access; > gp->orphan = g_multipath_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_multipath_read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_multipath_read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c >index e6b93fc08c62..8ffcaa296ec9 100644 >--- a/sys/geom/raid/g_raid.c >+++ b/sys/geom/raid/g_raid.c >@@ -2225,7 +2225,8 @@ g_raid_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > gp->orphan = g_raid_taste_orphan; > cp = g_new_consumer(gp); > cp->flags |= G_CF_DIRECT_RECEIVE; >- g_attach(cp, pp); >+ if (g_attach(cp, pp) != 0) >+ goto ofail2; > if (g_access(cp, 1, 0, 0) != 0) > goto ofail; > >@@ -2248,6 +2249,7 @@ g_raid_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > (void)g_access(cp, -1, 0, 0); > ofail: > g_detach(cp); >+ofail2: > g_destroy_consumer(cp); > g_destroy_geom(gp); > G_RAID_DEBUG(2, "Tasting provider %s done.", pp->name); >diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c >index 02ec5b45c694..ae39c759afc6 100644 >--- a/sys/geom/raid3/g_raid3.c >+++ b/sys/geom/raid3/g_raid3.c >@@ -3314,9 +3314,11 @@ g_raid3_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > /* This orphan function should be never called. */ > gp->orphan = g_raid3_taste_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_raid3_read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_raid3_read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/shsec/g_shsec.c b/sys/geom/shsec/g_shsec.c >index 5775b4af2ec8..85f884acccf4 100644 >--- a/sys/geom/shsec/g_shsec.c >+++ b/sys/geom/shsec/g_shsec.c >@@ -644,9 +644,11 @@ g_shsec_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > gp->access = g_shsec_access; > gp->orphan = g_shsec_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_shsec_read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_shsec_read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c >index 3fc311f74bbb..7d70c9759d0c 100644 >--- a/sys/geom/stripe/g_stripe.c >+++ b/sys/geom/stripe/g_stripe.c >@@ -956,9 +956,11 @@ g_stripe_taste(struct g_class *mp, struct g_provider *pp, int flags __unused) > gp->access = g_stripe_access; > gp->orphan = g_stripe_orphan; > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = g_stripe_read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = g_stripe_read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); > if (error != 0) >diff --git a/sys/geom/virstor/g_virstor.c b/sys/geom/virstor/g_virstor.c >index 8110629085c9..86b3a542a28e 100644 >--- a/sys/geom/virstor/g_virstor.c >+++ b/sys/geom/virstor/g_virstor.c >@@ -792,9 +792,11 @@ g_virstor_taste(struct g_class *mp, struct g_provider *pp, int flags) > gp->orphan = (void *)invalid_call; /* I really want these to fail. */ > > cp = g_new_consumer(gp); >- g_attach(cp, pp); >- error = read_metadata(cp, &md); >- g_detach(cp); >+ error = g_attach(cp, pp); >+ if (error == 0) { >+ error = read_metadata(cp, &md); >+ g_detach(cp); >+ } > g_destroy_consumer(cp); > g_destroy_geom(gp); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 237269
: 235084