linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo@cn.fujitsu.com>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: What about storing more crc32 in the unused csum size for metadata?
Date: Mon, 12 Jan 2015 10:32:30 +0800	[thread overview]
Message-ID: <54B3323E.3090100@cn.fujitsu.com> (raw)

[Old layout]
Btrfs csum size for tree block is 32 bytes, and currently, only the
first 4 bytes(sector 0) is used, storing the crc32 for the whole
leaf/node.

Takes 4K as example for leafsize.
Sectors:
|---0---|---1---|---2---|---3---|---4---|---5---|---6---|---7---|
Sector 0: Csum of the leaf/node (32 ~ 4K)
Sector 1~7: Not used

So, what about restoring more crc32 in other sectors in the following
backward-compatible way?

[New layout]
Take leafsize as 4K for example.

Sectors:
|---0---|---1---|---2---|---3---|---4---|---5---|---6---|---7---|
Sector 0: Csum of the leaf/node (32~4K)(not changed)
Sector 1: Csum of the first eighths of the leaf/node (32~512)
Sector 2: Csum of the second eighths of the leaf/node (512~1024)
....
Sector 7: Csum of the last eighths of the leaf/node (3584 ~ 4096)

And due to the fact
crc(sector 0 ~ sector 7) = crc(crc(sector 0), crc(sector 1), ...)

We won't waste too much CPU time, and since we keep the behavior of
sector 0, so it is completely backward compatible.

[Advantage]
The advantage usage of the new layout is more accuracy in scrub and
btrfsck.
For scrub, even all duplication is broken, there is still chance for
scrub to rebuild the block if corruptions occurs in different sector.

And for btrfsck --repair, if node is corrupted, we don't need to drop
all the nodes/leaves belong to the nodes, but only drops nodes/leaves
belong to the sector.

             reply	other threads:[~2015-01-12  2:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12  2:32 Qu Wenruo [this message]
2015-01-12  4:52 ` What about storing more crc32 in the unused csum size for metadata? Duncan
2015-01-12  4:56   ` Qu Wenruo
2015-01-12  5:23     ` Duncan

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=54B3323E.3090100@cn.fujitsu.com \
    --to=quwenruo@cn.fujitsu.com \
    --cc=linux-btrfs@vger.kernel.org \
    /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).