linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: liubo <liubo2009@cn.fujitsu.com>
To: Linux Btrfs <linux-btrfs@vger.kernel.org>
Cc: Josef Bacik <josef@redhat.com>,
	Tsutomu Itoh <t-itoh@jp.fujitsu.com>,
	"Yan, Zheng" <zheng.yan@oracle.com>,
	Wenyi Liu <qingshenlwy@gmail.com>,
	Mike Fedyk <mfedyk@mikefedyk.com>
Subject: [RFC PATCH 0/5 v3] Btrfs: Add readonly support to replace BUG_ON phrase
Date: Fri, 03 Dec 2010 16:15:56 +0800	[thread overview]
Message-ID: <4CF8A73C.1060504@cn.fujitsu.com> (raw)

Btrfs has a number of BUG_ON()s, which may lead btrfs to unpleasant panic.
Meanwhile, they are very ugly and should be handled more propriately.

There are mainly two ways to deal with these BUG_ON()s.

1. For those errors which can be handled well by callers, we just return their
error number to callers.

2. For others, We can force the filesystem readonly when it hits errors, which
 is what this patchset has done. Replaced BUG_ON() with the interface provided
 in this patchset, we will get error infomation via dmesg. Since btrfs is now 
readonly, we can save our data safely and umount it, then a btrfsck is 
recommended.

By these ways, we can protect our filesystem from panic caused by those 
BUG_ONs.

We still need a incompat flag to make old kernels happy.

This patchset needs more test.

v2->v3:
- since btrfs may do log replay after crash, even it is mounted as readonly,
  and we have add a readonly check at start transaction time, it needs to set
  and to restore readonly flags around log replay.

v1->v2:
- in order to avoid deadlock thing, move write super stuff from error handle
  path to unmount time.
- remove BTRFS_SUPER_FLAG_VALID, just use BTRFS_SUPER_FLAG_ERROR to make it
  simple.
- add MS_RDONLY check at start of a transaction instead of commit transaction.
---
 fs/btrfs/ctree.h       |   19 ++++++++++
 fs/btrfs/disk-io.c     |   56 +++++++++++++++++++++++++++++-
 fs/btrfs/super.c       |   88 ++++++++++++++++++++++++++++++++++++++++++++++++
 fs/btrfs/transaction.c |    3 ++
 4 files changed, 164 insertions(+), 2 deletions(-)

             reply	other threads:[~2010-12-03  8:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-03  8:15 liubo [this message]
2010-12-15  8:38 ` [RFC PATCH 0/5 v3] Btrfs: Add readonly support to replace BUG_ON phrase liubo

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=4CF8A73C.1060504@cn.fujitsu.com \
    --to=liubo2009@cn.fujitsu.com \
    --cc=josef@redhat.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=mfedyk@mikefedyk.com \
    --cc=qingshenlwy@gmail.com \
    --cc=t-itoh@jp.fujitsu.com \
    --cc=zheng.yan@oracle.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 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).