Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Jun 2009 11:45:42 +1200
From:      Andrew Turner <andrew@fubar.geek.nz>
To:        freebsd-geom@FreeBSD.org
Subject:   Sending BIO_GETATTR to disks
Message-ID:  <20090601114542.4cb80938@fubar.geek.nz>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
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
[-- Attachment #2 --]
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);

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090601114542.4cb80938>