From owner-freebsd-scsi@FreeBSD.ORG Sun Jun 1 15:39:23 2003 Return-Path: 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 9E9E437B401 for ; Sun, 1 Jun 2003 15:39:23 -0700 (PDT) Received: from aslan.scsiguy.com (mail.scsiguy.com [63.229.232.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A7E543F3F for ; Sun, 1 Jun 2003 15:39:22 -0700 (PDT) (envelope-from gibbs@scsiguy.com) Received: from aslan.scsiguy.com (aslan.scsiguy.com [63.229.232.106]) by aslan.scsiguy.com (8.12.8/8.12.8) with ESMTP id h51MdMIh025446; Sun, 1 Jun 2003 16:39:22 -0600 (MDT) (envelope-from gibbs@scsiguy.com) Date: Sun, 01 Jun 2003 16:39:22 -0600 From: "Justin T. Gibbs" To: Kern Sibbald Message-ID: <2897610000.1054507162@aslan.scsiguy.com> In-Reply-To: <1054503429.1578.1715.camel@rufus> References: <1054490081.1582.1685.camel@rufus> <2846020000.1054498114@aslan.scsiguy.com> <1054503429.1578.1715.camel@rufus> X-Mailer: Mulberry/3.0.3 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline cc: scsi@FreeBSD.org Subject: Re: SCSI tape data loss X-BeenThere: freebsd-scsi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: SCSI subsystem List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Jun 2003 22:39:24 -0000 >> Perhaps both Linux and Solaris force the tape drives to run in >> unbuffered mode? > > Both of these systems run in synchronous write (unbuffered) > mode by default. It is possible to run with asynchronous > writes (buffered mode), but I am not aware of any > program that does so. The mt program can be used to set > synchronous/asynchronous writes, or other modes such > as Sys V compatibility rather than BSD style. Does Solaris have the drvbuffer command that is in Linux? >> > 2. The SCSI driver is doing asynchronous writes (very bad) and >> > the End of Medium is not sent to Bacula until many writes after >> > the end of the tape. >> >> Disabling the tape drive's write buffer kills performance. All >> of the information required to handle buffered writes should be >> available to you. > > My personal preference is for data security before performance. There is no potential for lost data if you handle the status that is presented to you. > If you are in fact doing asynchronous writes (buffered mode), then > Bacula will not support FreeBSD without essentially duplicating the > driver's buffering code inside Bacula -- something I don't plan > to do in the near future, if for not other reason than doing so > would mean a different driver for every operating system. The tape driver doesn't have any buffering code (unlike Linux which does). The tape drive has a buffer. We are just enabling the use of that buffer. If you really want to do this simply, just do a write filemarks of 0 marks everytime you are about to switch input files. The write marks flushes the device's buffer an guarantees that any residual will be within the fd that you are currently using. This would imply that you only need to explicitly buffer if you support backups from stdin. > I'm not convinced that there is really much loss in performance, > and even if I am wrong (quite possibly) > it can be easily compensated by having Bacula > buffer itself and using a separate thread dedicated to writing > and using synchronous (non-buffered) writes in the OS driver. You can never recover the round trip time on the SCSI bus unless you either have a device that allows you to queue more than one command at a time or that buffers. I believe that only FC tape devices support queuing more than one command at a time, but few programs support this anyway (unless you lie and say that a previous write has completed). > How do you support tar? Tar knows nothing about buffering -- > at least not GNU tar to the best of my knowledge. I think few people use tar for multi-volume backups unless they specify a specific tape length, but I really don't know. >> Perhaps we should also implement the MTCACHE/MTNOCACHE opcodes so >> that userland apps can control this. It's not clear if this is >> exactly what they were created for, but it may be better to use >> these than to add some other opcodes. > >> From my experience with Solaris/Linux (absolutely no problems in > 3 years), I'd recommend implementing a non-buffered mode (your > MTNOCACHE I assume), and it should be the default. In fact, > though it is certainly possible and possibly worth the effort, > I've never heard of any standard Unix program handling a > buffered tape drive. If you know one, I would certainly like to > know about it. Standard program? I don't know about that, but the commercial apps have always supported buffered mode. > Exactly what ioctl() does what is not critical for me as I can > always code it -- what counts is that it is well documented. > Of course, the more things are standard across systems, the > easier it is to program. It's not clear to me that there is a standard. > Maybe I missed it, but I didn't see anything that indicated that > the FreeBSD does asynchronous writes. >From looking at the sa driver, it appears that it always tries to do buffered writes unless there is a device quirk indicating that mode select doesn't work. -- Justin