Bug 719760 - pvcreate with "linear" md device causes "sysfs attr level not in expected format: linear"
Summary: pvcreate with "linear" md device causes "sysfs attr level not in expected for...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: lvm2
Version: 5.6
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Milan Broz
QA Contact: Corey Marthaler
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-07 21:51 UTC by Dave Wysochanski
Modified: 2018-11-27 21:32 UTC (History)
10 users (show)

Fixed In Version: lvm2-2.02.88-1.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-02-21 06:04:50 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0161 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2012-02-20 15:07:59 UTC

Description Dave Wysochanski 2011-07-07 21:51:39 UTC
Description of problem:
[root@PG803 ~]# mdadm --create /dev/md0 -c 32 -l linear -f -n1 /dev/sddlmaa1
mdadm: array /dev/md0 started.
[root@PG803 ~]# pvcreate /dev/md0
  /dev/md0 sysfs attr level not in expected format: linear

  Physical volume "/dev/md0" successfully created

Version-Release number of selected component (if applicable):
all

Additional info:

This is an easy fix.

Net-net:
1. For this customer, we need to figure out if the md chunksize is relevant for a linear md.
If not, the message can be safely ignored.
2. We could submit a patch to lvm code to fix the error.


Analysis


static int _md_sysfs_attribute_scanf(const char *sysfs_dir,
                                     struct device *dev,
                                     const char *attribute_name,
                                     const char *attribute_fmt,
                                     void *attribute_value)
{
...
        int ret = 0;
...
        if ((ret = sscanf(buffer, attribute_fmt, attribute_value)) != 1) {
                log_error("%s sysfs attr %s not in expected format: %s",
                          dev_name(dev), attribute_name, buffer);
                goto out;
        }

out:

        return ret;
}


/*
 * Retrieve level from md device using sysfs.
 */
static int dev_md_level(const char *sysfs_dir, struct device *dev)
{
        const char *attribute = "level";
        int level = -1;

        if (_md_sysfs_attribute_scanf(sysfs_dir, dev, attribute,
                                      "raid%d", &level) != 1)
                return -1;

...
}


/*
 * Calculate stripe width of md device using its sysfs files.
 */
unsigned long dev_md_stripe_width(const char *sysfs_dir, struct device *dev)
{
...
        level = dev_md_level(sysfs_dir, dev);
        if (level < 0)
                return 0;

...
}


The only caller of dev_md_stripe_width() is:
unsigned long set_pe_align(struct physical_volume *pv, unsigned long data_alignment)
{
        if (pv->pe_align)
                goto out;

        if (data_alignment)
                pv->pe_align = data_alignment;
        else
                pv->pe_align = MAX(65536UL, lvm_getpagesize()) >> SECTOR_SHIFT;

        if (!pv->dev)
                goto out;

        /*
         * Align to stripe-width of underlying md device if present
         */
        if (find_config_tree_bool(pv->fmt->cmd, "devices/md_chunk_alignment",
                                  DEFAULT_MD_CHUNK_ALIGNMENT))
                pv->pe_align = MAX(pv->pe_align,
                                   dev_md_stripe_width(pv->fmt->cmd->sysfs_dir,
                                                       pv->dev));

...
}

So we're setting the pv->pe_align value based on the MAX value of any calculated md_stripe
width.

But when we get the above error, we'll get the following call chain:
-->dev_md_stripe_width() returns 0
  -->dev_md_level() returns -1
    -->_md_sysfs_attribute_scanf() returns != 1, sscanf fail, ("linear" does not match "raid%d")

So our equation becomes: 
MAX(pv->pe_align, 0) == pv->pe_align

No adjustment is made for the md stripe width if it is "linear".

Comment 1 Milan Broz 2011-07-08 10:48:53 UTC
Well, I would really like to know why you want to using LVM over linear MD - some very special case?

Anyway, detection shuould work here (linear has proper chunk_size 0 in sysfs),
so fix should be trivial.

Comment 2 Milan Broz 2011-07-08 11:33:02 UTC
Reading the code, I do not think there is a bug.

linear (and the same will be MD multipath) has chunk_size 0, code properly use that.

So what's the problem? MD linear is just JBOD, there is nothing like chuck size, why do you want to apply some value here?

Comment 3 Dave Wysochanski 2011-07-08 13:14:14 UTC
The bug is just the error message, which caused a customer call, and the fact it was not obvious without code inspection whether this was something to be concerned about.

Maybe it should be log_warn in this case, or not print anything?

Comment 4 Milan Broz 2011-07-08 13:55:13 UTC
# mdadm -C --rounding=32 -l linear -n 2 /dev/md0 /dev/sd[bc]
# pvcreate /dev/md0
  /dev/md0 sysfs attr level not in expected format: linear
  Physical volume "/dev/md0" successfully created

Note that --rounding is overloaded od "chunk" parameter, from mdadm
--rounding=
Specify rounding factor for a Linear array.  The size of each component will be rounded down to a multiple of this  size.
This  is  a  synonym  for  --chunk but highlights the different meaning for Linear as compared to other RAID levels.
The default is 64K if a kernel earlier than 2.6.16 is in use, and is 0K (i.e. no rounding) in later kernels.

So we should ignore chunk value for anything else than "raidX" MD personality.

Comment 5 Milan Broz 2011-07-08 14:31:20 UTC
Patch is here
https://www.redhat.com/archives/lvm-devel/2011-July/msg00029.html

Comment 6 Dave Wysochanski 2011-09-16 19:46:32 UTC
Committed upstream in 2.02.86, rebase for 5.8 should pick this up.

commit 566939185eb01ef0f88151720e2c6b0106370833
Author: Milan Broz <mbroz>
Date:   Fri Jul 8 15:53:59 2011 +0000

    Fix warning for pvcreate over MD linear.
    
    If MD linear device has set rounding (overload chunk size attribute),
    the pvcreate command prints this warning:
    
      /dev/md0 sysfs attr level not in expected format: linear

diff --git a/WHATS_NEW b/WHATS_NEW
index 9962fdf..18ed33e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.86 -  
 =================================
+  Fix warning in pvcreate for MD linear devices.

NOTE: whats new message was refactored as follows:

Version 2.02.86 - 8th July 2011
===============================
  Remove unnecessary warning in pvcreate for MD linear devices.

Comment 7 Milan Broz 2011-10-17 21:36:12 UTC
Fixed in lvm2-2.02.88-1.el5.

Comment 9 Corey Marthaler 2011-11-23 18:58:17 UTC
Fix verified in the latest rpms.


2.6.18-274.el5
lvm2-2.02.88-4.el5    BUILT: Wed Nov 16 09:40:55 CST 2011
lvm2-cluster-2.02.88-4.el5    BUILT: Wed Nov 16 09:46:51 CST 2011
device-mapper-1.02.67-2.el5    BUILT: Mon Oct 17 08:31:56 CDT 2011
device-mapper-event-1.02.67-2.el5    BUILT: Mon Oct 17 08:31:56 CDT 2011
cmirror-1.1.39-10.el5    BUILT: Wed Sep  8 16:32:05 CDT 2010
kmod-cmirror-0.1.22-3.el5    BUILT: Tue Dec 22 13:39:47 CST 2009



[root@grant-01 ~]# mdadm --create /dev/md0 -c 32 -l linear -f -n1 /dev/sdc1
mdadm: array /dev/md0 started.
[root@grant-01 ~]# pvcreate /dev/md0
  Writing physical volume data to disk "/dev/md0"
  Physical volume "/dev/md0" successfully created

Comment 10 errata-xmlrpc 2012-02-21 06:04:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0161.html


Note You need to log in before you can comment on or make changes to this bug.