From 6db1b32e894791b87937d831c528ed8ecc34ac05 Mon Sep 17 00:00:00 2001 From: imp Date: Sun, 26 Aug 2012 05:11:52 +0000 Subject: [PATCH] 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) git-svn-id: svn://svn.freebsd.org/base/releng/9.1@239707 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/geom/geom_disk.c | 13 +++++++++++-- sys/geom/geom_disk.h | 5 ++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c index 17cc7d2e..f9b5f0df 100644 --- a/sys/geom/geom_disk.c +++ b/sys/geom/geom_disk.c @@ -509,7 +509,14 @@ g_disk_providergone(struct g_provider *pp) 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")); diff --git a/sys/geom/geom_disk.h b/sys/geom/geom_disk.h index e8007ab8..4479bc91 100644 --- a/sys/geom/geom_disk.h +++ b/sys/geom/geom_disk.h @@ -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); -- 2.42.0