Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Aug 2012 05:11:53 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org
Subject:   svn commit: r239707 - releng/9.1/sys/geom
Message-ID:  <201208260511.q7Q5Brgh065872@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sun Aug 26 05:11:52 2012
New Revision: 239707
URL: http://svn.freebsd.org/changeset/base/239707

Log:
  MFS: r239148
  
      r239148 | imp | 2012-08-08 14:21:33 -0600 (Wed, 08 Aug 2012) | 8 lines
  
      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
  
  This change fixes the binary compatibility problems with additions to
  the disk(9) API.  Disk drivers compiled against 9.0 will not work on
  9.1-RC1, but should start working after this change or in 9.1-RC2 and
  later.  Disk drivers should not be linked against 9.1-RC1 for
  distribution, except specifically for testing on RC1.  This was
  planned for RC1, but it was delayed due to circumstancs beyond my
  control.
  
  Approved by: re@ (kensmith)

Modified:
  releng/9.1/sys/geom/geom_disk.c
  releng/9.1/sys/geom/geom_disk.h
Directory Properties:
  releng/9.1/sys/   (props changed)

Modified: releng/9.1/sys/geom/geom_disk.c
==============================================================================
--- releng/9.1/sys/geom/geom_disk.c	Sun Aug 26 04:39:20 2012	(r239706)
+++ releng/9.1/sys/geom/geom_disk.c	Sun Aug 26 05:11:52 2012	(r239707)
@@ -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: releng/9.1/sys/geom/geom_disk.h
==============================================================================
--- releng/9.1/sys/geom/geom_disk.h	Sun Aug 26 04:39:20 2012	(r239706)
+++ releng/9.1/sys/geom/geom_disk.h	Sun Aug 26 05:11:52 2012	(r239707)
@@ -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?201208260511.q7Q5Brgh065872>