From owner-freebsd-scsi@FreeBSD.ORG Mon Dec 19 09:34:52 2005 Return-Path: X-Original-To: freebsd-scsi@freebsd.org Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 66A4716A42C for ; Mon, 19 Dec 2005 09:34:52 +0000 (GMT) (envelope-from kern@sibbald.com) Received: from matou.sibbald.com (matou.sibbald.com [194.158.240.20]) by mx1.FreeBSD.org (Postfix) with ESMTP id 17C3F43D60 for ; Mon, 19 Dec 2005 09:34:50 +0000 (GMT) (envelope-from kern@sibbald.com) Received: from rufus (rufus [192.168.68.112]) by matou.sibbald.com (8.13.4/8.13.4) with ESMTP id jBJ9YmtC001830; Mon, 19 Dec 2005 10:34:49 +0100 From: Kern Sibbald To: Matthew Jacob Date: Mon, 19 Dec 2005 10:34:52 +0100 User-Agent: KMail/1.8.2 References: <200512151122.34949.kern@sibbald.com> <7579f7fb0512181448x1dc4b3f4m9d5112cc6bc9fc1a@mail.gmail.com> In-Reply-To: <7579f7fb0512181448x1dc4b3f4m9d5112cc6bc9fc1a@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200512191034.52756.kern@sibbald.com> Cc: freebsd-scsi@freebsd.org Subject: Re: Tape drive handling on FreeBSD X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Dec 2005 09:34:52 -0000 On Sunday 18 December 2005 23:48, Matthew Jacob wrote: > The first paragraph of mtio(4) describes the usage of a control device. Yes, thanks. I've already read that and other sections of the man pages, and it is true that the .ctl device allows one to figure out if a tape drive really exists or not. The problem is: 1. It is system dependent -- I would like to see some standardization of the Unix API from system to system where it is reasonable, practical, and doesn't break everything. 2. The errno that is currently returned by an empt tape drive during an open() is "incorrect" or at the least misleading. 3. The API that you currently have doesn't work correctly with Bacula, which was originally designed on Linux and Solaris -- it penalizes FreeBSD Bacula users. Since the FreeBSD way of doing things is the minority in my little Unix world, it is unlikely (though possible) that I will rewrite my code. 4. There are other shortcomings of the SCSI driver that penalize FreeBSD users compared to Solaris and Linux that I would like to discuss as well (ability to have the driver efficiently space to the end of the medium and keep track of the file position). Actually, I am really shocked how poor the "Unix" tape interface is (this has nothing to do with FreeBSD in particular). There is no standard way to set tape drive options, there is no standard way to figure out if a tape drive exists and what options it has set for it (blocking, two eof, density, compression, ...). Probably most annoying, there is no standard way to know if a tape is mounted or not. My main interest is to try to discuss what possibilities exist for changing (unifying) the API (or there is also a small chance that I am missing something ...). If no possibility of discussion/changes exists, so be it. > > On 12/15/05, Kern Sibbald wrote: > > Hello, > > > > We correponded a couple of years ago when Bacula was experiencing data > > loss > > at the end of tapes -- it turned out to be a pthreads bug that suppressed > > the early end of tape warning. > > > > I have a new problem, and if you cannot help, please > > direct me in the right direction. > > > > Basically Bacula (network backup program) needs to open() the tape drive > > so > > that it can read/write it. On both Linux and Solaris, it is possible to > > open > > the drive with O_NONBLOCK and get a descriptor that can be used for > > ioctl() > > calls and providing there is a tape in the drive, it can be used for > > read() > > and write(). > > > > On FreeBSD, if there is no tape in the drive, the OS always immediately > > returns errno=ENXIO "Device not configured". This means that on FreeBSD, > > if > > there is no tape in the drive, that drive is totally unusable by > > Bacula. Now > > it seems to me that there are two solutions: > > > > 1. Modify Bacula and system dependent code that opens the control device > > to > > see if a tape drive is really there or not, and then rewrite the tape > > driver > > code to deal with the fact that if you cannot open a device, it may > > really be > > there, and you should continue trying to open it between asking the user > > to > > mount it. This is clearly possible. > > > > 2. Consider implementing something in FreeBSD as exists on at least Linux > > and > > Solaris -- i.e. a means to open the drive and get a valid file > > descriptor. If you read/write/rewind/... a drive opened and there is no > > tape, it should > > either return EIO or better ENOMEDIUM. > > > > Comments? > > > > -- > > Best regards, > > > > Kern > > > > ("> > > /\ > > V_V > > > > ------------------------------------------------------- > > > > -- > > Best regards, > > > > Kern > > > > ("> > > /\ > > V_V > > _______________________________________________ > > freebsd-scsi@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-scsi > > To unsubscribe, send any mail to "freebsd-scsi-unsubscribe@freebsd.org" -- Best regards, Kern ("> /\ V_V