linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: "Andi Kleen" <ak@suse.de>
To: Andreas Dilger <adilger@turbolinux.com>
Cc: Linux LVM mailing list <linux-lvm@msede.com>, idsfa@visi.com
Subject: Re: [linux-lvm] LVM support for LILO
Date: Thu, 7 Sep 2000 23:43:01 +0200	[thread overview]
Message-ID: <20000907234301.B21294@gruyere.muc.suse.de> (raw)
In-Reply-To: <200009071825.MAA08578@lynx.turbolabs.com>; from adilger@turbolinux.com on Thu, Sep 07, 2000 at 12:25:07PM -0600

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

  reply	other threads:[~2000-09-07 21:43 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-07 18:25 [linux-lvm] LVM support for LILO Andreas Dilger
2000-09-07 21:43 ` Andi Kleen [this message]
2000-09-07 22:39   ` Andreas Dilger
2000-09-07 22:46     ` Andi Kleen
2000-09-07 23:44       ` Andreas Dilger
2000-09-08 14:25         ` Andi Kleen
2000-09-08  0:11   ` Heinz J. Mauelshagen
2000-09-07 22:14     ` Andi Kleen
2000-09-07 23:00     ` Andi Kleen
2000-09-08  0:02 ` Heinz J. Mauelshagen
2000-09-07 23:29   ` Andreas Dilger
2000-09-08 13:02     ` Heinz J. Mauelshagen
2000-09-08 13:47       ` Luca Berra
2000-09-08 19:09         ` Heinz J. Mauelshagen
2000-09-08 14:03     ` Michael J Kellen
2001-02-27  0:30       ` Ralph Jennings
  -- strict thread matches above, loose matches on Subject: below --
2000-09-08 19:39 Andreas Dilger
2000-09-08 19:50 Andreas Dilger
2000-09-09  7:44 ` Luca Berra
2000-09-09 10:07 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20000907234301.B21294@gruyere.muc.suse.de \
    --to=ak@suse.de \
    --cc=adilger@turbolinux.com \
    --cc=idsfa@visi.com \
    --cc=linux-lvm@msede.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).