From owner-freebsd-drivers@FreeBSD.ORG Sat Sep 22 04:59:55 2012 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7C6771065675; Sat, 22 Sep 2012 04:59:55 +0000 (UTC) (envelope-from jacks.1785@gmail.com) Received: from mail-ie0-f182.google.com (mail-ie0-f182.google.com [209.85.223.182]) by mx1.freebsd.org (Postfix) with ESMTP id 3538A8FC1C; Sat, 22 Sep 2012 04:59:54 +0000 (UTC) Received: by ieak10 with SMTP id k10so5713448iea.13 for ; Fri, 21 Sep 2012 21:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ChPh2UYrmjAmLRz8Q/22WJ4vy7LHJ0U9cDOZLanCL9w=; b=kfMsLYEyHsQI2T7yL6OkYBsCOt+GZxykDCeXaw4IDZjA7DC6fx/kYGRDQUbnE4THJk 02d0Tc7PdZo16lRri0m8+dJK6w/iyzwtbdSPbgw5LbSJMSnPpI7EtO3HDPVv20w4dCQ8 TLhUCGGctziqRDEn/4YEUKcOkc3fTtgrGkP7U0u75n6LGE4R2ieEk6zILJTmZItO3c1t 8Cn0ujYxmiuab2wFHQLdb8m/8lT4RwHf9Faqer5+g3RJKPiNivNgKJA1oRSIQ/c9ipt5 TRGE+do03TZRz9MmSZMhZ3J8sA913ZdOVvME4JmVin+FeHQMMsIMQpRWAt/K3iRjxAop oGDw== MIME-Version: 1.0 Received: by 10.43.16.67 with SMTP id px3mr5456092icb.17.1348289993527; Fri, 21 Sep 2012 21:59:53 -0700 (PDT) Received: by 10.64.44.105 with HTTP; Fri, 21 Sep 2012 21:59:53 -0700 (PDT) In-Reply-To: References: <201209190825.07384.jhb@freebsd.org> <5059CC56.8040705@FreeBSD.org> <505B6D1B.7070506@FreeBSD.org> Date: Sat, 22 Sep 2012 10:29:53 +0530 Message-ID: From: Jack To: Alexander Motin Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-drivers Subject: Re: Exclusive access of SCSI/ATA devices from user space X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Sep 2012 04:59:55 -0000 On 9/21/12, Jack wrote: > > Thanks Alexander. So, I only need to modify da/ada/sa drivers such > that they do not attach themselves to the selected device. Then I will > access the device via CAM pass driver. > > Is it possible that 2 different processes can access the same device > via cam pass through driver? > > Actually there are 2 perspectives here, I'm talking about: > ( Assume we have modified da/ada/sa drivers such that they do not > attach themselves to the selected device, and utility is loaded in > main memory. ) > > a) While one processes is accessing the selected device via cam pass > driver, is it possible for another process to access this same > selected device via cam pass driver(it can't access through da/ada/sa > drivers as they are not attached to the selected device rightnow). I'm > trying to deactivate/disable simultaneous access to the selected > device. > > b) Assume that none of the process is currently accessing the selected > device. Is it possible that except my utility, none of the other > userland processes be able to access the selected device via cam pass > driver(again, it can't access through da/ada/sa drivers), even if my > utility is not accessing the device at this time. I mean, is there > some kind of automatic or forced locking so that only utility process > can access the selected device via CAM passthrough driver. > > -- > Jack > It seems that I misunderstood your first post. I'm quoting it for reference. > > ... CAM does not restrict simultaneous access to the devices, so the same device can be > accessed through both pass and da/ada drivers (or any other if they happen) at the same > time. Usually it is not a problem because pass interface is used only by short list of tools, > like ones for CD/DVD recording. > So, two or more processes can access the same device simultaneously, via cam pass driver, or one via cam pass driver and other one via block access, but two or more processes simultaneously can't access same device via block interface - GEOM does controls concurrent device access. Now is it possible that we can restrict access to a pass device solely to a particular process(ie my utility), so that no other process(neither simultaneously, nor at time when no other process is accessing the selected device), would ever be able to access the selected device via cam pass driver - e.g. some sort of lock on pass device or something like that. Assuming that da/ada/sa drivers are not attached to the selected device, if it is possible to put the above mentioned restriction on pass device, then the only process, that can access the selected device will be the utility's process, and none else. -- Jack