linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fusionio.com>
To: Stefan Behrens <sbehrens@giantdisaster.de>
Cc: <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH] Btrfs: fail device statistic reset on read-only filesystem
Date: Fri, 11 Oct 2013 09:47:33 -0400	[thread overview]
Message-ID: <20131011134733.GA5095@localhost.localdomain> (raw)
In-Reply-To: <2a649d6a51055ac36352a73add403037acc537ef.1381493768.git.sbehrens@giantdisaster.de>

On Fri, Oct 11, 2013 at 02:18:23PM +0200, Stefan Behrens wrote:
> Currently the attempt to reset the device statistics with
> 'btrfs device stat -z ...' on read-only filesystems does not return an
> error. The statistics that are hold in main memory are reset but the
> statistics that are stored in the filesystem are not reset.
> 
> Fix it by returning EROFS in this case.
> 
> This is the reproducer:
> 
>  #!/bin/sh
> TEST_DEV1=/dev/sdzzzzz1
> TEST_DEV2=/dev/sdzzzzz2
> TEST_MNT=/mnt
> echo 0 25165824 linear $TEST_DEV1 0 | dmsetup create foom
> echo 0 25165824 linear $TEST_DEV2 0 | dmsetup create foon
> mkfs.btrfs -f -d raid1 -m raid1 /dev/mapper/foom /dev/mapper/foon
> mount /dev/mapper/foom $TEST_MNT
>  # switch to I/O error mode:
> echo 0 25165824 error | dmsetup reload foon
> dmsetup resume foon
>  # cause I/O errors:
> touch ${TEST_MNT}/foo
> sync
>  # switch dm back to I/O good mode:
> echo 0 25165824 linear $TEST_DEV1 0 | dmsetup reload foon
> dmsetup resume foon
> umount ${TEST_MNT}
> btrfs dev scan
> mount /dev/mapper/foom ${TEST_MNT} -o ro
>  # will report counters != 0, should fail with EROFS
> btrfs device stat -z ${TEST_MNT}
>  # will report counters == 0:
> btrfs device stat ${TEST_MNT}
> umount ${TEST_MNT}
> mount /dev/mapper/foom ${TEST_MNT} -o ro
>  # will report counters != 0, i.e., the 'btrfs device stat -z' failed to
>  # clear the counters on disk, only the counters in main memory had been
>  # cleared:
> btrfs device stat ${TEST_MNT}
> umount ${TEST_MNT}
> dmsetup remove foom; dmsetup remove foon
> 

Hey look something else that should go into xfstests,

Josef

  reply	other threads:[~2013-10-11 13:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-11 12:18 [PATCH] Btrfs: fail device statistic reset on read-only filesystem Stefan Behrens
2013-10-11 13:47 ` Josef Bacik [this message]
2013-10-11 14:07   ` Stefan Behrens
2013-10-11 14:22     ` Josef Bacik

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=20131011134733.GA5095@localhost.localdomain \
    --to=jbacik@fusionio.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=sbehrens@giantdisaster.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).