mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Detect md superblocks version 1.0, 1.1 and 1.2.
This commit is contained in:
parent
951e1064c9
commit
47c06763b7
@ -1,5 +1,6 @@
|
|||||||
Version 2.02.29 -
|
Version 2.02.29 -
|
||||||
==================================
|
==================================
|
||||||
|
Detect md superblocks version 1.0, 1.1 and 1.2.
|
||||||
Add _alloc_pv() and _free_pv() from _pv_create() code and fix error paths.
|
Add _alloc_pv() and _free_pv() from _pv_create() code and fix error paths.
|
||||||
Add pv_dev_name() to access PV device name.
|
Add pv_dev_name() to access PV device name.
|
||||||
Add const attributes to pv accessor functions.
|
Add const attributes to pv accessor functions.
|
||||||
|
@ -40,15 +40,35 @@ static int _dev_has_md_magic(struct device *dev, uint64_t sb_offset)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME Explain this algorithm */
|
||||||
|
static uint64_t _v1_sb_offset(uint64_t size, int minor_version)
|
||||||
|
{
|
||||||
|
uint64_t sb_offset;
|
||||||
|
|
||||||
|
switch(minor_version) {
|
||||||
|
case 0:
|
||||||
|
sb_offset = (size - 8 * 2) & ~(4 * 2 - 1);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
sb_offset = 0;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sb_offset = 4 * 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sb_offset <<= SECTOR_SHIFT;
|
||||||
|
|
||||||
|
return sb_offset;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns -1 on error
|
* Returns -1 on error
|
||||||
*/
|
*/
|
||||||
int dev_is_md(struct device *dev, uint64_t *sb)
|
int dev_is_md(struct device *dev, uint64_t *sb)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 1;
|
||||||
|
unsigned minor = 0;
|
||||||
uint64_t size, sb_offset;
|
uint64_t size, sb_offset;
|
||||||
uint32_t md_magic;
|
|
||||||
|
|
||||||
if (!dev_get_size(dev, &size)) {
|
if (!dev_get_size(dev, &size)) {
|
||||||
stack;
|
stack;
|
||||||
@ -63,24 +83,35 @@ int dev_is_md(struct device *dev, uint64_t *sb)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
|
|
||||||
|
|
||||||
/* Check if it is an md component device. */
|
/* Check if it is an md component device. */
|
||||||
if (_dev_has_md_magic(dev, sb_offset)) {
|
/* Version 0.90.0 */
|
||||||
if (sb)
|
sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
|
||||||
*sb = sb_offset;
|
if (_dev_has_md_magic(dev, sb_offset))
|
||||||
ret = 1;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
|
/* Version 1, try v1.0 -> v1.2 */
|
||||||
|
do {
|
||||||
|
sb_offset = _v1_sb_offset(size, minor);
|
||||||
|
if (_dev_has_md_magic(dev, sb_offset))
|
||||||
|
goto out;
|
||||||
|
} while (++minor <= 2);
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
if (!dev_close(dev))
|
if (!dev_close(dev))
|
||||||
stack;
|
stack;
|
||||||
|
|
||||||
|
if (ret && sb)
|
||||||
|
*sb = sb_offset;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int dev_is_md(struct device *dev __attribute((unused)), uint64_t *sb __attribute((unused)))
|
int dev_is_md(struct device *dev __attribute((unused)),
|
||||||
|
uint64_t *sb __attribute((unused)))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user