Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 8 Aug 2012 20:21:34 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r239148 - stable/9/sys/geom
Message-ID:  <201208082021.q78KLYii023749@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Wed Aug  8 20:21:33 2012
New Revision: 239148
URL: http://svn.freebsd.org/changeset/base/239148

Log:
  Make the addition of the d_gone binary compatible.  This allows
  storage drivers compiled for 9.0 to work on 9.1 and preserves the ABI
  for disks.
  
  Reviewed by:	scottl, ken
  Approved by:	re@ (kensmith)
  MFS after:	releng/9.1 gets sorted

Modified:
  stable/9/sys/geom/geom_disk.c
  stable/9/sys/geom/geom_disk.h

Modified: stable/9/sys/geom/geom_disk.c
==============================================================================
--- stable/9/sys/geom/geom_disk.c	Wed Aug  8 20:08:45 2012	(r239147)
+++ stable/9/sys/geom/geom_disk.c	Wed Aug  8 20:21:33 2012	(r239148)
@@ -509,7 +509,14 @@ g_disk_providergone(struct g_provider *p
 
 	dp = sc->dp;
 
-	if (dp->d_gone != NULL)
+	/*
+	 * FreeBSD 9 started with VERSION_01 of the struct disk structure.
+	 * However, g_gone was added in the middle of the branch.  To
+	 * cope with version being missing from struct disk, we set a flag
+	 * in g_disk_create for VERSION_01 and avoid touching the d_gone
+	 * field for old consumers.
+	 */
+	if (!(dp->d_flags & DISKFLAG_LACKS_GONE) && dp->d_gone != NULL)
 		dp->d_gone(dp);
 }
 
@@ -577,7 +584,7 @@ disk_alloc()
 void
 disk_create(struct disk *dp, int version)
 {
-	if (version != DISK_VERSION_02) {
+	if (version != DISK_VERSION_02 && version != DISK_VERSION_01) {
 		printf("WARNING: Attempt to add disk %s%d %s",
 		    dp->d_name, dp->d_unit,
 		    " using incompatible ABI version of disk(9)\n");
@@ -585,6 +592,8 @@ disk_create(struct disk *dp, int version
 		    dp->d_name, dp->d_unit);
 		return;
 	}
+	if (version == DISK_VERSION_01)
+		dp->d_flags |= DISKFLAG_LACKS_GONE;
 	KASSERT(dp->d_strategy != NULL, ("disk_create need d_strategy"));
 	KASSERT(dp->d_name != NULL, ("disk_create need d_name"));
 	KASSERT(*dp->d_name != 0, ("disk_create need d_name"));

Modified: stable/9/sys/geom/geom_disk.h
==============================================================================
--- stable/9/sys/geom/geom_disk.h	Wed Aug  8 20:08:45 2012	(r239147)
+++ stable/9/sys/geom/geom_disk.h	Wed Aug  8 20:21:33 2012	(r239148)
@@ -78,7 +78,6 @@ struct disk {
 	disk_ioctl_t		*d_ioctl;
 	dumper_t		*d_dump;
 	disk_getattr_t		*d_getattr;
-	disk_gone_t		*d_gone;
 
 	/* Info fields from driver to geom_disk.c. Valid when open */
 	u_int			d_sectorsize;
@@ -97,12 +96,16 @@ struct disk {
 
 	/* Fields private to the driver */
 	void			*d_drv1;
+
+	/* new fields in stable - don't use if DISKFLAG_LACKS_GONE is set */
+	disk_gone_t		*d_gone;
 };
 
 #define DISKFLAG_NEEDSGIANT	0x1
 #define DISKFLAG_OPEN		0x2
 #define DISKFLAG_CANDELETE	0x4
 #define DISKFLAG_CANFLUSHCACHE	0x8
+#define DISKFLAG_LACKS_GONE	0x10
 
 struct disk *disk_alloc(void);
 void disk_create(struct disk *disk, int version);



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