Skip to contentSkip to conversation

About Chunk Tree recover

DISCUSSION Miao Xie 2 participants 2 messages Jan 29, 2013 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

Hi, everyone.

About 1 years ago, we implemented the chunk tree recover function, but it has not been applied till now because that implementation need change the disk format.
(http://marc.info/?l=linux-btrfs&m=129914269932543&w=2
http://marc.info/?l=linux-btrfs&m=130976668006281&w=2
http://marc.info/?l=linux-btrfs&m=129914269932543&w=2)

Recently, I reconsidered the implementation of this function, and found a new approach that needn't change the disk format. That is the external chunk tree backup, just like external journal device of ext4. The basic idea is:

- specify a external file or device which is used to backup the chunk tree when mount.
- When mount, compare the super block in the external file/device with the super block of the btrfs, if the checksum of the super block in the externel file/device is right, and the FS UUID and generation are the same as the fs, it means the chunk tree in the external file/device is valid, needn't rebuild it. Otherwise, we will rebuild the chunk tree in the external file/device according to the chunk tree of the fs.
- When we allocate a new chunk, we will log the new chunk information into the external file/device
- sync the external file/device when committing the transaction
- If the chunk tree of the fs is corrupted, we use the information in the external file/device to recover it.

By this way, we needn't change disk format and also needn't do a block device scan which need lots of time, and is very hard to find the start address and length of a chunk.

Any comment for this idea?

Thanks
Miao

#1 lore raw
Quoted 9 lines · Miao Xie

Hi, everyone.

About 1 years ago, we implemented the chunk tree recover function, but it has not been applied till now because that implementation need change the disk format.
(http://marc.info/?l=linux-btrfs&m=129914269932543&w=2
http://marc.info/?l=linux-btrfs&m=130976668006281&w=2
http://marc.info/?l=linux-btrfs&m=129914269932543&w=2)

Quoted 4 lines

Recently, I reconsidered the implementation of this function, and found a new approach that needn't change the disk format. That is the external chunk tree backup, just like external journal device of ext4. The basic idea is:

I do like the idea of a dedicated chunk backup area, outside the filesystem. But, I think we need to be able to fall back to the scanning operation.

The chunk tree backup actually fits well into the log area I'm setting up for raid5/6. The log area is really just a dedicated chunk where I'm stuffing blocks to avoid read/modify/write and to make sub stripe writes power cut safe.

-chris