summaryrefslogtreecommitdiff
path: root/btrfsck.c
Commit message (Collapse)AuthorAge
* Btrfs-progs: fix wrong return value of check_owner_ref()Miao Xie2012-10-04
| | | | | | | If we find the block by seach corresponding fs tree, we should return 0, and tell the caller we pass the check. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
* Btrfs-progs: fix unresolved ref root messageMiao Xie2012-10-04
| | | | | | | | | | | | btrfsck misinformed "unresolved ref root" message when there were several snapshots in the file system. The patch(commit cfdd42686c70) tried to fix this bug, but didn't fix it completely. If the metadata was stored in a shared leaf of the tree, the problem would happen again. This patch fixes it by another way, we don't check the relationship of the trees when we traverse the fs/file tree, we just do the check when we merge the snapshot records to the root cache. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
* Btrfs-progs: fix wrong leaf when checking the trees relationshipMiao Xie2012-10-04
| | | | | | | | The variant named 'leaf' in is_child_root() still hold old result after we get the next leaf, it make btrfsck returns the wrong result, such as "unresolved ref root ..", fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
* btrfs-progs: fsck: understand the -s optionDavid Sterba2012-10-02
| | | | | | Short options have to be repeated at the getopt_long call. Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: fix btrfsck's snapshot wrong "unresolved refs"Miao Xie2012-07-03
| | | | | | | | | If the fs/file tree is not the parent of the snapshot, it is reasonable that we can not find the relative reference and back reference. But btrfsck doesn't consider this case, and reports "unresolved refs" message, it's wrong, fix it. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
* Btrfs-progs: make btrfsck aware of free space inodesJosef Bacik2012-06-05
| | | | | | | | | | | The new xfstests will run fsck against the volume to make sure we didn't introduce any inconsistencies, which is nice except we will error out immediately if we mount with inode_cache. We need to make btrfsck skip the special free space cache items and then just assume that we have a link for the free space cache inode item. This makes btrfsck pass with success on a fs with inode cache items. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com>
* btrfsck: add early code to handle corrupted block groupsChris Mason2012-02-22
| | | | | | | This is mostly disabled, but it is step one in handling corrupted block groups in the extent allocation tree. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfsck: add the ability to prune corrupt extent allocation tree blocksChris Mason2012-02-21
| | | | | | | When we discover bad blocks in the extent allocation tree, repair can now discard them and recreate the references from the rest of the trees. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* btrfsck: remove extents from the fsck reference tracker as they are freedChris Mason2012-02-10
| | | | | | | | | | | | | | | | | | | During btrfsck --repair, we make an index of extents that have incorrect reference counts. Once we've collect the whole index, we go through and modify the extent allocation tree to reflect the correct results. Changing the extent allocation tree may free blocks, and so it may end up removing a block that had a missing reference structure. The fsck code may then circle back around and add the reference back. The result is an extent that isn't actually used, but is recorded in the extent allocation tree. This commit adds a hook called as extents are freed. The hook searches the index of incorrect references and updates it to reflect the freeing of the extent. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* btrfsck: make sure we fix the block group accounting during repairChris Mason2012-02-09
| | | | | | | | The block group accounting is fixed after we check the extent back references. This makes sure the accounting is fixed unless we were not able to repair the backrefs. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* btrfsck: add --init-csum-tree to replace the csum root with an empty oneChris Mason2012-02-09
| | | | | | | This will effectively delete all of your crcs, but at least you'll be able to mount the FS with nodatasum. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* btrfsck: fix block group accounting during repairChris Mason2012-02-08
| | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* btrfsck: add code to rebuild extent recordsChris Mason2012-02-07
| | | | | | | This also includes a new --repair btrfsck option. For now it can only fix errors in the extent allocation tree. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* btrfsck: don't BUG on corrupted extent recordsChris Mason2012-02-06
|
* btrfsck: print some progressChris Mason2012-02-06
| | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Add open_ctree_fs_info for partial FS opensChris Mason2012-02-05
| | | | | | | | | | fsck needs to be able to open a damaged FS, which means open_ctree needs to be able to return a damaged FS. This adds a new open_ctree_fs_info which can be used to open any and all roots that are valid. btrfs-debug-tree is changed to use it. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* btrfsck: decode error properlySergei Trofimovich2011-10-25
| | | | | | | | | | | | | | | check_mounted() returns kernel-style negative errors. Patch drops sign for strerror(). Before the patch: check_mounted(): Could not open /dev/sdb2 Could not check mount status: Unknown error 18446744073709551603 After the patch: check_mounted(): Could not open /dev/sdb2 Could not check mount status: Permission denied Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
* gcc 4.6: fix potentially unused variableHugo Mills2011-10-25
| | | | | | | Fix a complaint by gcc 4.6 that "ret" may be unused in process_one_leaf of btrfsck. Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* Fix unused-but-set errors in gcc-4.6Chris Ball2011-10-25
| | | | | | | | | | | | | | | | gcc-4.6 (as shipped in Fedora) turns on -Wunused-but-set-variable by default, which breaks the build when combined with -Wall, e.g.: debug-tree.c: In function ‘print_extent_leaf’: debug-tree.c:45:13: error: variable ‘last_len’ set but not used [-Werror=unused-but-set-variable] debug-tree.c:44:13: error: variable ‘last’ set but not used [-Werror=unused-but-set-variable] debug-tree.c:41:21: error: variable ‘item’ set but not used [-Werror=unused-but-set-variable] cc1: all warnings being treated as errors This patch fixes the errors by removing the unused variables. Signed-off-by: Chris Ball <cjb@laptop.org> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* Add btrfsck option to select the super block copyChris Mason2010-10-04
| | | | | | btrfsck -s 0 uses the defult 0, -s 1 uses copy #1 etc. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Fix inode link count checks in btrfsckYan Zheng2010-09-23
| | | | Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Remove superfluous WARN_ON in btrfsckYan Zheng2010-09-23
| | | | Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* add missing include for btrfsck.cChristian Hesse2010-09-23
| | | | | | | | compiling btrfs-progs from current git I get an error in btrfsck.c about undefined references. The attached patch adds an include for sys/stat.h which fixes the problem for me. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* prevent btrfsck to run on mounted filesystemsAndi Drebes2010-09-23
| | | | | | | | | As recently discussed on the list, btrfsck should only be run on unmounted filesystems. This patch adds a short check for the mount status at the beginning of btrfsck. If the FS is mounted, the program aborts showing an error message. Signed-off-by: Andi Drebes <lists-receive@programmierforen.de>
* btrfsck: check root back/forward referencesYan, Zheng2009-09-21
| | | | | | | | This patch adds semantic checks for links to snapshot/subvolume and root back/forward references. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Mixed back reference (FORWARD ROLLING FORMAT CHANGE)Chris Mason2009-06-08
| | | | | | | | | | | | | | | | | This commit introduces a new kind of back reference for btrfs metadata. Once a filesystem has been mounted with this commit, IT WILL NO LONGER BE MOUNTABLE BY OLDER KERNELS. The new back ref provides information about pointer's key, level and in which tree the pointer lives. This information allow us to find the pointer by searching the tree. The shortcoming of the new back ref is that it only works for pointers in tree blocks referenced by their owner trees. This is mostly a problem for snapshots, where resolving one of these fuzzy back references would be O(number_of_snapshots) and quite slow. The solution used here is to use the fuzzy back references in the common case where a given tree block is only referenced by one root, and use the full back references when multiple roots have a reference
* Fix printf format casting errorsLuca Bruno2009-06-03
| | | | | | | | | | | | There are still some warnings of the form: format '%llu' expects type 'long long unsigned int' but argument has type 'u64' In conjunction with -Werror, this is causing some build failures. Now they're properly casted, avoiding compiler warnings. Signed-off-by: Luca Bruno <lucab@debian.org> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Add scan of the btrfs log tree to btrfs-debug-treeChris Mason2009-04-15
|
* btrfsck.c: bit-fields should be unsignedWang Cong2009-01-21
| | | | | Signed-off-by: WANG Cong <wangcong@zeuux.org>
* btrfsck: Exit and print error message when not able to open a deviceThadeu Lima de Souza Cascardo2009-01-21
| | | | | | If btrfsck is not able to open a device, it segfaults. This fixes it and prints an error message too.
* btrfs-progs: make several functions staticWang Cong2009-01-21
| | | | | | | Make several functions static, and make one argument const. Signed-off-by: WANG Cong <wangcong@zeuux.org>
* Fix an accessing freed memory bug in btrfsckYan Zheng2009-01-09
|
* Add semantic checks to btrfsck for files and directoriesYan Zheng2009-01-07
| | | | | | | | | | | | | | | | This patch makes btrfsck check more things, including directory items, file extents, checksumming, inode link counts etc. The code for these checks is similar to the code verifies extent back references. The main difference is that shared tree blocks are treated specially. The partial checking results(unresolved references and/or errors) of shared sub-trees are cached. This avoids scanning the shared blocks several times. Thank you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Add fallocate support v2Yan Zheng2008-10-31
| | | | | | | This patch updates btrfs-progs for fallocate support. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Remove offset field from struct btrfs_extent_refYan Zheng2008-10-09
| | | | | | | | | | | | | | The offset field in struct btrfs_extent_ref records the position inside file that file extent is referenced by. In the new back reference system, tree leaves holding reference to file extent are recorded explicitly. We can quickly scan these tree leaves, so the offset field is not required. This patch also makes the back reference system check the objectid when extents are being deleted Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Full back reference supportZheng Yan2008-09-23
| | | | | | | | This patch makes the back reference system to explicit record the location of parent node for all types of extents. The location of parent node is placed into the offset field of backref key. Every time a tree block is balanced, the back references for the affected lower level extents are updated.
* Print the version string in a few programsChris Mason2008-07-24
|
* Pass down the expected generation number when reading tree blocksChris Mason2008-05-12
|
* Add a readonly flag open_ctree to force RO opensChris Mason2008-05-05
|
* Fix compiler warning in volumes.cChris Mason2008-05-02
|
* Fix a few casts for 32 bit compileChris Mason2008-04-11
|
* Add mirroring support across multiple drivesChris Mason2008-04-03
|
* Btrfsck updates for multi-device filesystemsChris Mason2008-03-24
|
* Fix btrfsck args checkingKyle McMartin2008-01-22
| | | | | btrfsck fails to check if it actually received a dev argument though, so if you don't pass a device, we get a nice segfault.
* Update btrfs-progs to match kernel sourcesYan2008-01-04
|
* Verify extent back references in btrfsckChris Mason2007-12-14
|
* Add back pointers from extents to the file or btree referencing themChris Mason2007-12-11
|
* Create a slightly more generic extent-caching structureChris Mason2007-10-15
|
* Switch to byte granular allocationsChris Mason2007-10-15
|
* Allow large blocksChris Mason2007-10-15
|