Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Nov 2018 15:38:27 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r341237 - stable/12/sys/geom/concat
Message-ID:  <201811291538.wATFcRTY098611@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Thu Nov 29 15:38:27 2018
New Revision: 341237
URL: https://svnweb.freebsd.org/changeset/base/341237

Log:
  MFC r339900:
  Have gconcat advertise delete support if one of its disks does.
  
  PR:	232676

Modified:
  stable/12/sys/geom/concat/g_concat.c
  stable/12/sys/geom/concat/g_concat.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/geom/concat/g_concat.c
==============================================================================
--- stable/12/sys/geom/concat/g_concat.c	Thu Nov 29 15:26:07 2018	(r341236)
+++ stable/12/sys/geom/concat/g_concat.c	Thu Nov 29 15:38:27 2018	(r341237)
@@ -206,6 +206,27 @@ fail:
 }
 
 static void
+g_concat_candelete(struct bio *bp)
+{
+	struct g_concat_softc *sc;
+	struct g_concat_disk *disk;
+	int i, *val;
+
+	val = (int *)bp->bio_data;
+	*val = 0;
+
+	sc = bp->bio_to->geom->softc;
+	for (i = 0; i < sc->sc_ndisks; i++) {
+		disk = &sc->sc_disks[i];
+		if (!disk->d_removed && disk->d_candelete) {
+			*val = 1;
+			break;
+		}
+	}
+	g_io_deliver(bp, 0);
+}
+
+static void
 g_concat_kernel_dump(struct bio *bp)
 {
 	struct g_concat_softc *sc;
@@ -327,6 +348,9 @@ g_concat_start(struct bio *bp)
 		if (strcmp("GEOM::kerneldump", bp->bio_attribute) == 0) {
 			g_concat_kernel_dump(bp);
 			return;
+		} else if (strcmp("GEOM::candelete", bp->bio_attribute) == 0) {
+			g_concat_candelete(bp);
+			return;
 		}
 		/* To which provider it should be delivered? */
 		/* FALLTHROUGH */
@@ -408,6 +432,7 @@ g_concat_check_and_run(struct g_concat_softc *sc)
 	struct g_provider *dp, *pp;
 	u_int no, sectorsize = 0;
 	off_t start;
+	int error;
 
 	g_topology_assert();
 	if (g_concat_nvalid(sc) != sc->sc_ndisks)
@@ -425,6 +450,16 @@ g_concat_check_and_run(struct g_concat_softc *sc)
 		if (sc->sc_type == G_CONCAT_TYPE_AUTOMATIC)
 			disk->d_end -= dp->sectorsize;
 		start = disk->d_end;
+		error = g_access(disk->d_consumer, 1, 0, 0);
+		if (error == 0) {
+			error = g_getattr("GEOM::candelete", disk->d_consumer,
+			    &disk->d_candelete);
+			if (error != 0)
+				disk->d_candelete = 0;
+			(void)g_access(disk->d_consumer, -1, 0, 0);
+		} else
+			G_CONCAT_DEBUG(1, "Failed to access disk %s, error %d.",
+			    dp->name, error);
 		if (no == 0)
 			sectorsize = dp->sectorsize;
 		else

Modified: stable/12/sys/geom/concat/g_concat.h
==============================================================================
--- stable/12/sys/geom/concat/g_concat.h	Thu Nov 29 15:26:07 2018	(r341236)
+++ stable/12/sys/geom/concat/g_concat.h	Thu Nov 29 15:38:27 2018	(r341237)
@@ -74,6 +74,7 @@ struct g_concat_disk {
 	struct g_concat_softc	*d_softc;
 	off_t			 d_start;
 	off_t			 d_end;
+	int			 d_candelete;
 	int			 d_removed;
 };
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811291538.wATFcRTY098611>