From owner-svn-src-head@FreeBSD.ORG Fri May 3 11:53:07 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 182CE35A; Fri, 3 May 2013 11:53:07 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EED7F1B76; Fri, 3 May 2013 11:53:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r43Br66B039156; Fri, 3 May 2013 11:53:06 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r43Br6ET039155; Fri, 3 May 2013 11:53:06 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201305031153.r43Br6ET039155@svn.freebsd.org> From: Alexander Motin Date: Fri, 3 May 2013 11:53:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250208 - head/sys/cam/scsi X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 May 2013 11:53:07 -0000 Author: mav Date: Fri May 3 11:53:06 2013 New Revision: 250208 URL: http://svnweb.freebsd.org/changeset/base/250208 Log: Tune support for removable media in da driver: - remove DA_FLAG_SAW_MEDIA flag, almost opposite to DA_FLAG_PACK_INVALID, using the last instead. - allow opening device with no media present, reporting zero media size and non-zero sector size, as geom/notes suggests. That allow to read device attributes and potentially do other things, not related to media. Modified: head/sys/cam/scsi/scsi_da.c Modified: head/sys/cam/scsi/scsi_da.c ============================================================================== --- head/sys/cam/scsi/scsi_da.c Fri May 3 11:10:04 2013 (r250207) +++ head/sys/cam/scsi/scsi_da.c Fri May 3 11:53:06 2013 (r250208) @@ -82,7 +82,6 @@ typedef enum { DA_FLAG_NEW_PACK = 0x002, DA_FLAG_PACK_LOCKED = 0x004, DA_FLAG_PACK_REMOVABLE = 0x008, - DA_FLAG_SAW_MEDIA = 0x010, DA_FLAG_NEED_OTAG = 0x020, DA_FLAG_WENT_IDLE = 0x040, DA_FLAG_RETRY_UA = 0x080, @@ -1026,9 +1025,6 @@ daopen(struct disk *dp) ("daopen\n")); softc = (struct da_softc *)periph->softc; - softc->flags |= DA_FLAG_OPEN; - softc->flags &= ~DA_FLAG_PACK_INVALID; - dareprobe(periph); /* Wait for the disk size update. */ @@ -1037,25 +1033,23 @@ daopen(struct disk *dp) if (error != 0) xpt_print(periph->path, "unable to retrieve capacity data"); - if (periph->flags & CAM_PERIPH_INVALID || - softc->disk->d_sectorsize == 0 || - softc->disk->d_mediasize == 0) + if (periph->flags & CAM_PERIPH_INVALID) error = ENXIO; if (error == 0 && (softc->flags & DA_FLAG_PACK_REMOVABLE) != 0 && (softc->quirks & DA_Q_NO_PREVENT) == 0) daprevent(periph, PR_PREVENT); - if (error == 0) - softc->flags |= DA_FLAG_SAW_MEDIA; + if (error == 0) { + softc->flags &= ~DA_FLAG_PACK_INVALID; + softc->flags |= DA_FLAG_OPEN; + } cam_periph_unhold(periph); cam_periph_unlock(periph); - if (error != 0) { - softc->flags &= ~DA_FLAG_OPEN; + if (error != 0) cam_periph_release(periph); - } return (error); } @@ -2818,9 +2812,10 @@ dadone(struct cam_periph *periph, union * here. */ if (block_size == 0 && maxsector == 0) { - snprintf(announce_buf, sizeof(announce_buf), - "0MB (no media?)"); - } else if (block_size >= MAXPHYS || block_size == 0) { + block_size = 512; + maxsector = -1; + } + if (block_size >= MAXPHYS || block_size == 0) { xpt_print(periph->path, "unsupportable block size %ju\n", (uintmax_t) block_size); @@ -2920,6 +2915,7 @@ dadone(struct cam_periph *periph, union const char *sense_key_desc; const char *asc_desc; + dasetgeom(periph, 512, -1, NULL, 0); scsi_sense_desc(sense_key, asc, ascq, &cgd.inq_data, &sense_key_desc, @@ -3297,8 +3293,8 @@ daerror(union ccb *ccb, u_int32_t cam_fl asc == 0x28 && ascq == 0x00) disk_media_changed(softc->disk, M_NOWAIT); else if (sense_key == SSD_KEY_NOT_READY && - asc == 0x3a && (softc->flags & DA_FLAG_SAW_MEDIA)) { - softc->flags &= ~DA_FLAG_SAW_MEDIA; + asc == 0x3a && (softc->flags & DA_FLAG_PACK_INVALID) == 0) { + softc->flags |= DA_FLAG_PACK_INVALID; disk_media_gone(softc->disk, M_NOWAIT); } }