[linux-lvm] LVM support for LILO

Andi Kleen ak at suse.de
Thu Sep 7 21:43:01 UTC 2000


On Thu, Sep 07, 2000 at 12:25:07PM -0600, Andreas Dilger wrote:
> Heinz,
> Michael Kellen and I have been working to add LILO support for booting
> from a LV (i.e. have /boot be an LV, and then not have ANY DOS partitions).

[...]

I did some similar work. I implemented an LVM_BMAP ioctl for LVM that
simply translates a given block to a (dev_t, blocknr in dev). lilo 
simply does a normal FIOBMAP and then calls LVM_BMAP for every block
it gets. When the dev_t ever changes it complains loudly. Then it does
its normal work with the resulting blocks.

It works ok. The only problem is that a standard PV cannot be used for
booting, because it does leave any space for a MBR (it probably needs 
a PV format revision that simply leaves 4K free) 

> However, the main problem that we are having is that you cannot use
> an LV device major/minor to do anything with liblvm.  All of the liblvm
> functions use an LV name, it would be good to add an ioctl which takes
> a dev_t (e.g. 0x3a01) and returns an LV name, or maybe an lv_t which
> we can use with liblvm.  Along the same lines, it may be good to have
> an ioctl which takes a dev_t and returns a vg_t of the VG which this LV
> is a part of.  Finally, it would be good to take the code out of lvm_map()
> which only does block/dev remapping (which lvm_map() will call), but
> which also be called by an ioctl like FIBMAP.

I'm just calling lvm_bmap from my ioctl. It is easy enough (patch against
2.2 appended) 


--- include/linux/lvm.h.LVMBMAP	Wed Aug  2 18:44:26 2000
+++ include/linux/lvm.h	Thu Aug 10 01:29:14 2000
@@ -355,6 +355,10 @@
 
 /* lock the logical volume manager */
 #define	LVM_LOCK_LVM            _IO ( 0xfe, 0x100)
+
+/* bmap, argument lv_bmap_t */
+#define LV_BMAP		_IOWR ( 0xfe, 0x51, 1)
+
 /* END ioctls */
 
 
@@ -534,7 +538,10 @@
    ulong    new_pe;
 } le_remap_req_t;
 
-
+typedef struct lv_bmap {
+    ulong lv_block;
+    dev_t lv_dev;	    
+} lv_bmap_t;
 
 /*
  * Structure Logical Volume (LV) Version 1
--- drivers/block/lvm.c.LVMBMAP	Sun Jul 30 01:55:16 2000
+++ drivers/block/lvm.c	Thu Aug 10 04:53:17 2000
@@ -1076,6 +1076,28 @@
  *
  ********************************************************************/
 
+static int lvm_user_bmap(struct inode *inode, struct lv_bmap *user_result) 
+{ 
+	struct buffer_head bh; 
+	unsigned long block; 
+	int err;
+
+	if (get_user(block, &user_result->lv_block)) 
+		return -EFAULT; 	
+
+	memset(&bh,0,sizeof bh); 
+	bh.b_size = 512; /* XXX */ 
+	bh.b_rsector = block;
+	bh.b_dev = bh.b_rdev = inode->i_dev;
+	if ((err=lvm_map(&bh, READ)) < 0)  {
+		printk("lvm map failed: %d\n", err); 
+		return -EINVAL; 
+	}	
+
+	return put_user(  kdev_t_to_nr(bh.b_rdev), &user_result->lv_dev) ||
+		put_user(bh.b_rsector, &user_result->lv_block) ? -EFAULT : 0;
+} 
+
 /*
  * block device open routine
  */
@@ -1259,6 +1281,10 @@
          vg[VG_BLK(minor)]->lv[LV_BLK(minor)]->lv_status = ( ulong) arg;
          break;
 
+	case LV_BMAP:
+		/* turn logical block into (dev_t, block). non privileged. */ 
+		return lvm_user_bmap(inode, (struct lv_bmap *) arg);  		
+		break; 
 
       /* set allocation flags of a logical volume */
       case LV_SET_ALLOCATION:




-Andi



More information about the linux-lvm mailing list