From owner-freebsd-scsi@FreeBSD.ORG Wed Jun 16 23:20:14 2010 Return-Path: Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 65DCF106564A for ; Wed, 16 Jun 2010 23:20:14 +0000 (UTC) (envelope-from djmitche@gmail.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 17B298FC14 for ; Wed, 16 Jun 2010 23:20:13 +0000 (UTC) Received: by gwj20 with SMTP id 20so5777321gwj.13 for ; Wed, 16 Jun 2010 16:20:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=9G4ogzdzoFdExIWKYs7y2jQWL25X8CFf2SsA/Z4LwNI=; b=mtoTD34474wrYGGhX8OF5uvMYnHzoHBW85lb+fte7e9q9mdp8u8kOdawicKqbNGFPc bSIuLWB7YYX+kKrWDj1MK68tMhdJy51hC74JDtA9/ol8FJI0NkYR+HrtlyhnTjD5Wse1 IqIKA3xfKE27Lk0lGWECgn4vBxMlT9oSxh8Q8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; b=nX74XU9Q8rGFqjitQoBI0z22T5ZN9I/wF1GxGkQ2JlBhQytTkIdqbbbAr9E0fWPGXv fi/Jljtj+cCIlJje8BM8ZBZ/+K/FEvLpgWD3JNWsAyG3ouTahOVnUZOxhxV77brH2aQY UxKAlSph4XISMIBXwDJBau1h5odk4CsqxZcjE= MIME-Version: 1.0 Received: by 10.151.72.5 with SMTP id z5mr10701116ybk.235.1276728766403; Wed, 16 Jun 2010 15:52:46 -0700 (PDT) Sender: djmitche@gmail.com Received: by 10.150.144.4 with HTTP; Wed, 16 Jun 2010 15:52:46 -0700 (PDT) Date: Wed, 16 Jun 2010 17:52:46 -0500 X-Google-Sender-Auth: -4m3N1CGQ0YvXDjedlxBeJyuIJ8 Message-ID: From: "Dustin J. Mitchell" To: freebsd-scsi@freebsd.org Content-Type: text/plain; charset=UTF-8 Cc: Jean-Louis Martineau Subject: sa: write returns 0 = LEOM? 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: Wed, 16 Jun 2010 23:20:14 -0000 I'm investigating a user bug report in Amanda: http://forums.zmanda.com/showthread.php?t=2832 The problem boils down to a write(2) call for a SCSI tape device (/dev/nsa0) returning 0 after quite a bit of data and a number of filemarks have been written. Jean-Louis suspected that this was an early warning EOM indication, and that a subsequent write() would succeed, with Amanda having been duly warned that a physical EOM is coming up. But looking at scsi_sa.c, this doesn't seem to be the case. It looks like an early warning would result in a successful write instead, because resid is set to zero. cam/scsi/scsi_sa.c: 2418 /* 2419 * Handle filemark, end of tape, mismatched record sizes.... 2420 * From this point out, we're only handling read/write cases. 2421 * Handle writes && reads differently. 2422 */ 2423 2424 if (csio->cdb_io.cdb_bytes[0] == SA_WRITE) { 2425 if (sense_key == SSD_KEY_VOLUME_OVERFLOW) { 2426 csio->resid = resid; 2427 error = ENOSPC; 2428 } else if (sense->flags & SSD_EOM) { 2429 softc->flags |= SA_FLAG_EOM_PENDING; 2430 /* 2431 * Grotesque as it seems, the few times 2432 * I've actually seen a non-zero resid, 2433 * the tape drive actually lied and had 2434 * written all the data!. 2435 */ 2436 csio->resid = 0; 2437 } That said, I don't know my way around the kernel source, so I'm probably missing something obvious. So: 1. What could cause a write syscall to return 0? 2. Since we will be using early warning in the next version of Amanda, hints as to the best way to handle early warning from userspace would be appreciated. Thanks for any pointers! Dustin -- Open Source Storage Engineer http://www.zmanda.com