From: agk@sourceware.org <agk@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/device/dev-md.c
Date: 24 Oct 2007 00:51:05 -0000 [thread overview]
Message-ID: <20071024005105.25327.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2007-10-24 00:51:05
Modified files:
. : WHATS_NEW
lib/device : dev-md.c
Log message:
Detect md superblocks version 1.0, 1.1 and 1.2.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.721&r2=1.722
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7
--- LVM2/WHATS_NEW 2007/10/12 18:37:19 1.721
+++ LVM2/WHATS_NEW 2007/10/24 00:51:05 1.722
@@ -1,5 +1,6 @@
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 pv_dev_name() to access PV device name.
Add const attributes to pv accessor functions.
--- LVM2/lib/device/dev-md.c 2007/10/24 00:30:30 1.6
+++ LVM2/lib/device/dev-md.c 2007/10/24 00:51:05 1.7
@@ -40,15 +40,35 @@
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
*/
int dev_is_md(struct device *dev, uint64_t *sb)
{
- int ret = 0;
-
+ int ret = 1;
+ unsigned minor = 0;
uint64_t size, sb_offset;
- uint32_t md_magic;
if (!dev_get_size(dev, &size)) {
stack;
@@ -63,24 +83,35 @@
return -1;
}
+ /* Check if it is an md component device. */
+ /* Version 0.90.0 */
sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT;
+ if (_dev_has_md_magic(dev, sb_offset))
+ goto out;
- /* Check if it is an md component device. */
- if (_dev_has_md_magic(dev, sb_offset)) {
- if (sb)
- *sb = sb_offset;
- ret = 1;
- }
+ /* 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))
stack;
+ if (ret && sb)
+ *sb = sb_offset;
+
return ret;
}
#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;
}
next reply other threads:[~2007-10-24 0:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-24 0:51 agk [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-07-08 15:54 LVM2 ./WHATS_NEW lib/device/dev-md.c mbroz
2008-06-23 19:26 wysochanski
2008-06-23 14:54 wysochanski
2007-01-26 17:15 agk
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=20071024005105.25327.qmail@sourceware.org \
--to=agk@sourceware.org \
--cc=lvm-devel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.