From owner-svn-src-stable@FreeBSD.ORG Sat Sep 14 09:37:22 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id E6DEF55E; Sat, 14 Sep 2013 09:37:21 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id D45F92C1B; Sat, 14 Sep 2013 09:37:21 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8E9bLkU010887; Sat, 14 Sep 2013 09:37:21 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r8E9bLGQ010886; Sat, 14 Sep 2013 09:37:21 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201309140937.r8E9bLGQ010886@svn.freebsd.org> From: Alexander Motin Date: Sat, 14 Sep 2013 09:37:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r255553 - stable/9/sys/cam/scsi X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Sep 2013 09:37:22 -0000 Author: mav Date: Sat Sep 14 09:37:21 2013 New Revision: 255553 URL: http://svnweb.freebsd.org/changeset/base/255553 Log: MFC r250208: 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: stable/9/sys/cam/scsi/scsi_da.c Directory Properties: stable/9/sys/ (props changed) Modified: stable/9/sys/cam/scsi/scsi_da.c ============================================================================== --- stable/9/sys/cam/scsi/scsi_da.c Sat Sep 14 09:34:25 2013 (r255552) +++ stable/9/sys/cam/scsi/scsi_da.c Sat Sep 14 09:37:21 2013 (r255553) @@ -83,7 +83,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, @@ -1212,9 +1211,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. */ @@ -1223,25 +1219,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); } @@ -3045,9 +3039,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); @@ -3147,6 +3142,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, @@ -3525,8 +3521,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); } }