From owner-freebsd-geom@FreeBSD.ORG Mon Jun 1 00:03:33 2009 Return-Path: Delivered-To: freebsd-geom@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DD2B106566C for ; Mon, 1 Jun 2009 00:03:33 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: from farnsworth.fubar.geek.nz (farnsworth.fubar.geek.nz [69.55.236.47]) by mx1.freebsd.org (Postfix) with ESMTP id 50F718FC19 for ; Mon, 1 Jun 2009 00:03:33 +0000 (UTC) (envelope-from andrew@fubar.geek.nz) Received: by farnsworth.fubar.geek.nz (Postfix, from userid 65534) id 4592833C26; Sun, 31 May 2009 16:45:59 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on farnsworth.fubar.geek.nz X-Spam-Level: * X-Spam-Status: No, score=1.6 required=5.0 tests=AWL,BAYES_00,HELO_LOCALHOST, RCVD_IN_PBL,RDNS_DYNAMIC autolearn=no version=3.2.5 Received: from localhost (125-238-22-134.broadband-telecom.global-gateway.net.nz [125.238.22.134]) by farnsworth.fubar.geek.nz (Postfix) with ESMTP id 4E00633C24 for ; Sun, 31 May 2009 16:45:56 -0700 (PDT) Date: Mon, 1 Jun 2009 11:45:42 +1200 From: Andrew Turner To: freebsd-geom@FreeBSD.org Message-ID: <20090601114542.4cb80938@fubar.geek.nz> X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.1; amd64-portbld-freebsd7.1) X-Pirate: Arrrr Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/tST7Qemc8Jc.V/jI_=KC=JS" Cc: Subject: Sending BIO_GETATTR to disks X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jun 2009 00:03:33 -0000 --MP_/tST7Qemc8Jc.V/jI_=KC=JS Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline While working on a NAND flash driver I noticed a BIO_GETATTR request will not make it to the disk. It would be useful to support attributes in a NAND layer, eg. to get the size of the OOB region. I've attached a patch to pass the disk driver BIO_GETATTR when the new DISKFLAG_CANGETATTR is set. When DISKFLAG_CANGETATTR is unset it will act the same as currently and deliver ENOIOCTL. Andrew --MP_/tST7Qemc8Jc.V/jI_=KC=JS Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=freebsd-geom_disk.diff Index: geom_disk.c =================================================================== --- geom_disk.c (revision 193190) +++ geom_disk.c (working copy) @@ -306,8 +306,22 @@ break; else if (!strcmp(bp->bio_attribute, "GEOM::kerneldump")) g_disk_kerneldump(bp, dp); - else + else if (!(dp->d_flags & DISKFLAG_CANGETATTR)) error = ENOIOCTL; + else { + bp2 = g_clone_bio(bp); + if (bp2 == NULL) { + g_io_deliver(bp, ENOMEM); + return; + } + bp2->bio_done = g_disk_done; + bp2->bio_disk = dp; + bp2->bio_to = bp->bio_to; + bp2->bio_from = bp->bio_from; + g_disk_lock_giant(dp); + dp->d_strategy(bp2); + g_disk_unlock_giant(dp); + } break; case BIO_FLUSH: g_trace(G_T_TOPOLOGY, "g_disk_flushcache(%s)", Index: geom_disk.h =================================================================== --- geom_disk.h (revision 193190) +++ geom_disk.h (working copy) @@ -90,10 +90,11 @@ void *d_drv1; }; -#define DISKFLAG_NEEDSGIANT 0x1 -#define DISKFLAG_OPEN 0x2 -#define DISKFLAG_CANDELETE 0x4 -#define DISKFLAG_CANFLUSHCACHE 0x8 +#define DISKFLAG_NEEDSGIANT 0x01 +#define DISKFLAG_OPEN 0x02 +#define DISKFLAG_CANDELETE 0x04 +#define DISKFLAG_CANFLUSHCACHE 0x08 +#define DISKFLAG_CANGETATTR 0x10 struct disk *disk_alloc(void); void disk_create(struct disk *disk, int version); --MP_/tST7Qemc8Jc.V/jI_=KC=JS--