Skip to contentSkip to conversation

How Can I modify the mapping PE to LE??

linux-lvm 조완근 3 participants 3 messages Jun 7, 2006 – Jun 9, 2006

lore
Share & tools
lore

조완근

author
#0 lore raw

Hello, I'm at the beginning to use LVM in my machine.

 

Could you give any information on the implementation details of LVM and device mapper?? More specifically, I want to change the "mapping between PE and LE" for some purposes, however I'm just finished to read the manual of LVM-HowTO. This means that I'm totally a newbie in LVM and device-mapper. I just read some codes on data structures in LVM2/lib/metadata/metadata.h, but I can't get more information anymore on how they are mapped.

 

I was hanging around the codes in LVM2 source to find the part related with the "mapping", I just got to know the mapping information is stored in device mapper, not in the LVM.

 

I'll use LVM for this purpose - I would like to make a program to change the mapping relationship between PE and LE in my own. In fact, the program's goal is to move an extent in a bad disk to a disk with good performance. The movement is done by the extent. In order to do it, I definitely, have to know how I can modify the mapping and maybe, the entire structure of LVM and device mapper.

 

Could you give me some information on LVM & device-mapper details that help me??

- exactly all about the mapping between LE & PE..

I'm totally at the beginning, I'm well prepared to dig in the codes from now on, does anyone can help me to run faster??

#1 lore raw
Quoted 5 lines · 조완근

Hello, I'm at the beginning to use LVM in my machine.

Could you give any information on the implementation details of LVM and device mapper?? More specifically, I want to change the "mapping between PE and LE" for some purposes, however I'm just finished to read the manual of LVM-HowTO. This means that I'm totally a newbie in LVM and device-mapper. I just read some codes on data ... I'll use LVM for this purpose - I would like to make a program to change the mapping relationship between PE and LE in my own. In fact, the program's goal
is to move an extent in a bad disk to a disk with good performance. The movement is done by the extent. In order to do it, I definitely, have to know how I can modify the mapping and maybe, the entire structure of LVM and device mapper.

Hmm, are you realy finished to read the manual :-)

Sounds to me like you reinvent the "pvmove" command. This is not "some purpose" but a central task LVM performs for you on demand!

regards, Dieter.

#2 lore raw
In reply to 조완근
Quoted 1 line · 조완근

Hello, I'm at the beginning to use LVM in my machine.

Congrats!

Quoted 7 lines

Could you give any information on the implementation details of LVM and device mapper?? More specifically, I want to change the "mapping between PE and LE" for some purposes, however I'm just finished to read the manual of LVM-HowTO. This means that I'm totally a newbie in LVM and device-mapper. I just read some codes on data structures in LVM2/lib/metadata/metadata.h, but I can't get more information anymore on how they are mapped.

Well really it's down to basic concepts here. A physical volume is created using some backing store (block device). The pv is then put into a volume group where it is split into PEs (Physical Extents) that are then used to create logical volumes. Logical volumes are split up into LE (Logical Extents) which are the same size as the volume groups PE size. The idea is that any LE can be on a PE from any pv in the volume group. (make sense?)

Now if you wish to discover which LEs map to which PEs (and in turn what disks) you need to use lvdisplay -m vg/lv and this will give you each set of extent ranges and what PE/PVs they map to. Here is an example:
ath600 sbin # lvdisplay -m main/var
--- Logical volume ---

  LV Name                /dev/main/var
  VG Name                main
  LV UUID                Qq9ywx-zPNR-mbhn-LcZ4-7ZEV-AJhF-42wDk1
  LV Write Access        read/write
  LV Status              available
  # open                 2
  LV Size                8.00 GB
  Current LE             2048
  Segments               3
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:2

--- Segments ---
Logical extent 0 to 511:

    Type                linear
    Physical volume     /dev/sda3
    Physical extents    30976 to 31487

Logical extent 512 to 1279:

    Type                linear
    Physical volume     /dev/sdb
    Physical extents    25725 to 26492

Logical extent 1280 to 2047:

    Type                linear
    Physical volume     /dev/sda3
    Physical extents    45056 to 45823

So you can clearly see that both /dev/sda3 and sdb are spanned for this logical volume. You can see which LEs map to which PEs.

Quoted 6 lines

I'll use LVM for this purpose - I would like to make a program to change the mapping relationship between PE and LE in my own. In fact, the program's goal is to move an extent in a bad disk to a disk with good performance. The movement is done by the extent. In order to do it, I definitely, have to know how I can modify the mapping and maybe, the entire structure of LVM and device mapper.

Okay this is actually already done. You are looking for pvmove. Check its man page. If you want to move all allocated extents from a slow drive to a faster one it's quite easy, just do pvmove /dev/slowdisk /dev/fastdisk. However if you just want to move extents from some LVs then you'll need the much more advanced, pvmove /dev/slowdisk:beginextent-endextent /dev/fastdisk, version of the command. Use the output of lvdisplay -m to guide you in the extents.

Quoted 2 lines

Could you give me some information on LVM & device-mapper details that help me??

Not sure you need these details, just more fundamental knowledge of the concepts and of what the userland tools can do for you.

Quoted 2 lines

I'm totally at the beginning, I'm well prepared to dig in the codes from now on, does anyone can help me to run faster??

No need to read the code unless you really really really get stuck and this list can't help you. And if you've made it that far then someone on this list will surely be of good service as a starting point.

If you really want to run faster you can move data that is touched often onto faster disks with pvmove. Also making volumes contiguously helps and you can use pvmove to make existing logical volumes contiguous as well. I'll leave that as an excercise for the reader.

Hope That helps!

Signature · 3 lines
Zac Slade
[email protected]
ICQ:1415282 YM:krakrjak AIM:ttyp99