Bug 458936 - write barriers not supported, ext3 does not complain
write barriers not supported, ext3 does not complain
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: kernel (Show other bugs)
5.2
All Linux
medium Severity medium
: rc
: ---
Assigned To: Milan Broz
Martin Jenner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-08-13 06:41 EDT by Lars Volker
Modified: 2013-02-28 23:06 EST (History)
18 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2009-01-20 15:16:16 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Lars Volker 2008-08-13 06:41:23 EDT
When mounting an ext3 fs with "-o barrier=1" which resides on a device-mapper-backed device, the barrier feature will obviously not work. Device-mapper does not support write barriers. However xfs reports the lack of a barrier to the user via dmesg. Ext3 just silently mounts the device, without mentioning the problem.

This should be changed. Ext3 should complain or at least issue a warning with a hint on where to find further information.
Comment 1 Milan Broz 2008-08-13 07:12:01 EDT
There is no generic check in RHEL5 for barrier IO, only some targets return NOTSUPPORTED.

So, barrier is sent to underlying device and in some configurations it should work.

Unfortunatelly, if the request need to be split, it will not behave correctly.
(IO will finish, but without barrier flag, so there is possible corruption if power is lost for example.)

I think we should disable barriers for all device-mapper mappings all in RHEL5 kernel... (the same like upstream). (Until we have proper barrie implementation in device-mapper.)
Comment 2 RHEL Product and Program Management 2008-08-13 07:24:13 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.
Comment 3 Eric Sandeen 2008-08-15 17:49:49 EDT
Milan - so, in RHEL5 we actually do pass barriers to the underlying devices, but, it will be incorrect/incomplete at times due to splits based on the underlying geometry?

But, if an LV is on a single physical device, it actually does pass the barrier correctly?  It sounds like on the one hand, current RHEL5 behavior gives a false sense of security, but it actually does  work in some cases.  If you reject all barriers as upstream does, then it will work in no cases?  Seems like a difficult trade-off.
Comment 6 Lars Volker 2008-08-16 11:56:50 EDT
After mkfs'ing it with the correct filesystem i mounted /dev/sdb several times, which was a iscsi-target backed by drbd backed by scsi.

xfs on /dev/sdb issued no warning
ext3 with barrier=0 issued no warning 
ext3 with barrier=1 issued no warning

Then i created a volume-group containing sdb as its only physical volume. I created a lv in it and retested:

xfs issued a warning
ext3 issued no warning for both settings of barrier

Then i obtained the kernel-source and wanted to see, where ext3 looses the track of the failed barrier requests. I found fs/jbd/commit.c (search for "ordered") where a barrier-protected commit-request for the journal is issued. However the warning issued for failed barrier requests is never issued to the kernel log. If you google for the expected error message you end up with lots of hits regarding suse.

So the question remains: does the device-mapper in RHEL support barriers? In most of the targets (of which i only use "linear") EOPNOTSUPP is returned for barrier-protected requests.
Comment 7 Eric Sandeen 2008-08-16 13:40:47 EDT
ext3 should be doing the right thing here; I was going to paste this earlier:

        /* is it possible for another commit to fail at roughly
         * the same time as this one?  If so, we don't want to
         * trust the barrier flag in the super, but instead want
         * to remember if we sent a barrier request
         */
        if (ret == -EOPNOTSUPP && barrier_done) {
                char b[BDEVNAME_SIZE];

                printk(KERN_WARNING
                        "JBD: barrier-based sync failed on %s - "
                        "disabling barriers\n",
                        bdevname(journal->j_dev, b));


so *if* the underlying storage rejects the barrier, jbd will do the right thing, warn, and turn barriers off, on the first attempted barrier IO issued from jbd.

But if lvm/dm is not issuing the EOPNOTSUPP, then there is no way for ext3 to know.

If you try this on an upstream (say, fedora) kernel you'll see the warning from jbd, because lvm rejects *all* barrier requests upstream.  :(

p.s. the difference with xfs is that xfs does more pedantic checks on mount, and first checks queue flags*, then attempts a single barrier IO, before mount even completes.  So any warning will come immediately.

*the flag check is removed in most recent kernels and xfs only relies on the barrier IO test.
Comment 8 Lars Volker 2008-08-16 13:56:09 EDT
xfs warns here and everything in drivers/md/dm-linear.c suggests, that EOPNOTSUPP is returned. However ext3/jbd does *not* complain. Of course I testet writing of a new file, so the commit-journal should have been called at least once and the warning should have been displayed, shouldn't it?

Eric: Does that mean jbd and xfs rely on the same occurance of EOPNOTSUPP in dm-linear.c for their check?
Comment 9 Eric Sandeen 2008-08-16 14:08:46 EDT
For xfs, look at xfs_mountfs_check_barriers(), it checks a few conditions & queue flags than actually tests a barrier IO.

You'll see ""Disabling barriers, not supported by the underlying device"" if the queue does not have flags that advertise the presence of barrier capability (this test has actually been removed upstream), and ""Disabling barriers, trial barrier write failed"" if the barrier IO test actually fails (upstream still does a trial IO).

upstream, dm does:

static int dm_request(struct request_queue *q, struct bio *bio)
{
        int r = -EIO;
        int rw = bio_data_dir(bio);
        struct mapped_device *md = q->queuedata;

        /*
         * There is no use in forwarding any barrier request since we can't
         * guarantee it is (or can be) handled by the targets correctly.
         */
        if (unlikely(bio_barrier(bio))) {
                bio_endio(bio, -EOPNOTSUPP);
                return 0;
        }

so pretty much any barrier request will get back EOPNOTSUPP; the RHEL5 kernel does not have this code.  I see no reference to EOPNOTSUPP in rhel5's dm-linear.c or upstream; how dm behaves is probably best left to Milan though.

In any case I would love to see lvm support barriers as well as it can in RHEL5, I agree.
Comment 10 Lars Volker 2008-08-17 05:28:12 EDT
Eric: Thanks for pointing that up. I was only looking in linear.c which does:

        if (unlikely(bio_barrier(bio))) {
                bio_endio(bio, bio->bi_size, -EOPNOTSUPP);
                return 0;
        }


Is this file used inside dm? Or is it only used for linear raid personalities?
Comment 11 Milan Broz 2008-08-17 05:46:51 EDT
linear.c is part of MD subsystem, not device-mapper.

Cuerrently, there is not such line in RHEL5 kernel, is doesn't return EOPNOTSUPP for dm linear mapping.

This is wrong for some situation (but not all). Situation is not so simple, because device-mapper can reload table during operation, so even if there is one PV (good, barrir should work) it can change (lvextend, pvmove, ...) and later configuration is not barrier safe (for example request which need split between two PVs...)

IOW see this upstream patch http://tinyurl.com/62blpl

In upstream device-mapper entry point (dm_request) will handle NOTSUPP barrier request, in RHEL only some targets return error.
(upstream == 2.6.25, currently 26 has some other problem so it not sending barriers now for JBD),

This bugzilla is exactly about adding patch above to rhel5 kernel.
Comment 13 Don Zickus 2008-09-11 15:43:54 EDT
in kernel-2.6.18-111.el5
You can download this test kernel from http://people.redhat.com/dzickus/el5
Comment 17 errata-xmlrpc 2009-01-20 15:16:16 EST
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2009-0225.html

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