From wollman@hergotha.csail.mit.edu  Mon Sep  6 04:14:52 2010
Return-Path: <wollman@hergotha.csail.mit.edu>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 99D9F10656DE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  6 Sep 2010 04:14:52 +0000 (UTC)
	(envelope-from wollman@hergotha.csail.mit.edu)
Received: from hergotha.csail.mit.edu (hergotha.csail.mit.edu [66.92.79.170])
	by mx1.freebsd.org (Postfix) with ESMTP id 4EC338FC1A
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  6 Sep 2010 04:14:51 +0000 (UTC)
Received: from hergotha.csail.mit.edu (localhost [127.0.0.1])
	by hergotha.csail.mit.edu (8.14.4/8.14.4) with ESMTP id o864EopC046618
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 6 Sep 2010 00:14:50 -0400 (EDT)
	(envelope-from wollman@hergotha.csail.mit.edu)
Received: (from wollman@localhost)
	by hergotha.csail.mit.edu (8.14.4/8.14.4/Submit) id o864EoNx046617;
	Mon, 6 Sep 2010 00:14:50 -0400 (EDT)
	(envelope-from wollman)
Message-Id: <201009060414.o864EoNx046617@hergotha.csail.mit.edu>
Date: Mon, 6 Sep 2010 00:14:50 -0400 (EDT)
From: Garrett Wollman <wollman@freebsd.org>
Reply-To: Garrett Wollman <wollman@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: sizeof(union ccb) changed between 7.x and 8.x
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         150315
>Category:       kern
>Synopsis:       [ata] sizeof(union ccb) changed between 7.x and 8.x
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 06 04:20:04 UTC 2010
>Closed-Date:    
>Last-Modified:  Mon Jul 18 11:10:10 UTC 2011
>Originator:     Garrett Wollman
>Release:        FreeBSD 8.1-RELEASE amd64
>Organization:
FreeBSD Project
>Environment:
System: FreeBSD hergotha.csail.mit.edu 8.1-RELEASE FreeBSD 8.1-RELEASE #0 r212140M: Sat Sep 4 00:16:21 EDT 2010 wollman@hergotha.csail.mit.edu:/usr/obj/usr/src/sys/HERGOTHA amd64

>Description:

sizeof(union ccb) changed when ATA support was added to the CAM
framework in the 8.x branch.  However, the CAMIOCOMMAND ioctl request,
used by many userland utilities that send direct SCSI commands, takes
a "union ccb" as its argument; this encodes sizeof(union ccb) into the
ioctl number and breaks binary compatibility between 7.x and 8.x for
these tools, even when COMPAT_FREEBSD7 is defined in the kernel
configuration.

This may be the same problem was originally reported in misc/138622,
which does not appear to have garnered any responses.

>How-To-Repeat:

Try to run any 7.x program which uses CAMIOCOMMAND to send SCSI
commands directly to devices (e.g., smartctl) and watch it fail
mysteriously when ioctl returns [ENOTTY].

>Fix:

It's not clear to me whether there's a good fix here.  The best fix
would be to define a (private) "union occb" and OCAMIOCOMMAND ioctl
which is compatible with 7.x, but I'm not sure if that's actually safe
to do when there are ATA devices actually in use.  Possibly just
recognizing the generic form of CAMIOCOMMAND and logging a
"CAMIOCOMMAND used with wrong size CCB" to the console would be a
stopgap if it's not practical to implement full compatability.
>Release-Note:
>Audit-Trail:

From: Alexander Motin <mav@FreeBSD.org>
To: bug-followup@FreeBSD.org, wollman@freebsd.org
Cc:  
Subject: Re: kern/150315: [ata] sizeof(union ccb) changed between 7.x and
 8.x
Date: Mon, 18 Jul 2011 13:43:08 +0300

 The main problem is not just in union ccb size change. Problem is that
 elements newly added to several structures were added not to the ends,
 and in some places there are arrays of structures used. As result
 providing compatibility layer would required to repack all requests and
 responses, reordering their fields.
 
 I am not sure that supporting it now (1.5 years after 8.0 release) worth
 polluting code. Speaking about smartctl -- the best way is to rebuild
 it, as new version also supports CAM ATA.
 
 -- 
 Alexander Motin
>Unformatted:
