summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* btrfs-progs: inspect: add command min-dev-sizeDavid Sterba2015-08-31
| | | | | | | | | | Previously in 'filesystem resize get_min_size', now 'inspect-internal min-dev-size'. We'd like to avoid cluttering the 'resize' syntax further. The test has been updated to exercise the new option. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move min-resize implementation to inspect-internalDavid Sterba2015-08-31
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs-progs: add feature to get mininum size for resizing a fs/deviceFilipe Manana2015-08-31
| | | | | | | | | | | | | | | | | | | Currently there is not way for a user to know what is the minimum size a device of a btrfs filesystem can be resized to. Sometimes the value of total allocated space (sum of all allocated chunks/device extents), which can be parsed from 'btrfs filesystem show' and 'btrfs filesystem usage', works as the minimum size, but sometimes it does not, namely when device extents have to relocated to holes (unallocated space) within the new size of the device (the total allocated space sum). This change adds the ability to reliably compute such minimum value and extents 'btrfs filesystem resize' with the following syntax to get such value: btrfs filesystem resize [devid:]get_min_size Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: utils: missing newline in error messages when checking dupDavid Sterba2015-07-14
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: Cleanup temporary chunk to avoid strange balance behavior.Qu Wenruo2015-07-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [BUG] # mkfs.btrfs /dev/sdb /dev/sdd -m raid0 -d raid0 # mount /dev/sdb /mnt/btrfs # btrfs balance start /mnt/btrfs # btrfs fi df /mnt/btrfs Data, single: total=1.00GiB, used=320.00KiB System, single: total=32.00MiB, used=16.00KiB Metadata, RAID0: total=256.00MiB, used=112.00KiB GlobalReserve, single: total=16.00MiB, used=0.00B Only metadata stay RAID0. Data and system goes from RAID0 to single. [REASON] The problem is caused by the temporary single chunk. In mkfs, it will always create single data/metadata/sys chunk and them add device into the temporary btrfs. When doing all chunk balance, for data and syschunk, they are almost empty, so balance will move them into the single chunk and remove the old RAID0 chunk. For metadata, it has more data and will kick the metadata chunk pre alloc, so new RAID0 chunk is allocated and the old metadata is move there. Old RAID0 and single chunks are removed. [FIX] Now we add a new function to cleanup the temporary chunks at the end of mkfs routine. It will cleanup the chunks which is empty and its profile differs from the mkfs profile. So in balance, btrfs will always alloc a new chunk to keep the profile, other than moving data into the single chunk. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Documentation: update btrfs-replace manual to support RAID5/6Wang Yanfeng2015-07-14
| | | | | | | | Man manual need to be updated since RAID5/6 has been supported by btrfs-replace. Signed-off-by: Wang Yanfeng <wangyf-fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.1.2David Sterba2015-07-14
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* Revert "btrfs-progs: mkfs: create only desired block groups for single device"Qu Wenruo2015-07-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5f8232e5c8f0b0de0ef426274911385b0e877392. This commit causes a regression: $ mkfs.btrfs -f /dev/sda6 $ btrfsck /dev/sda6 Checking filesystem on /dev/sda6 UUID: 2ebb483c-1986-4610-802a-c6f3e6ab4b76 checking extents Chunk[256, 228, 0]: length(4194304), offset(0), type(2) mismatch with block group[0, 192, 4194304]: offset(4194304), objectid(0), flags(34) Chunk[256, 228, 4194304]: length(8388608), offset(4194304), type(4) mismatch with block group[4194304, 192, 8388608]: offset(8388608), objectid(4194304), flags(36) Block group[0, 4194304] (flags = 34) didn't find the relative chunk. Block group[4194304, 8388608] (flags = 36) didn't find the relative chunk. ...... The commit has the following bug causing the problem. 1) Typo forgets to add meta/data_profile for alloc_chunk. Only meta/data_profile is added to allocate a block group, but not chunk. 2) Type for the first system chunk is impossible to modify yet. The type for the first chunk and its stripe is hard coded into make_btrfs() function. So even we try to modify the type of the block group, we are unable to change the type of the first chunk. Causing the chunk type mismatch problem. The 1st bug can be fixed quite easily but the second is not. The good news is, the last patch "btrfs-progs: mkfs: Cleanup temporary chunk to avoid strange balance behavior." from my patchset can handle it quite well alone. So just revert the patch. New bug fix for btrfsck(err is 0 even chunk/extent tree is corrupted) and new test cases for mkfs will follow soon. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* Btrfs progs v4.1.1David Sterba2015-07-10
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: extent-tree: Introduce btrfs_free_block_group functionQu Wenruo2015-07-10
| | | | | | | | | This function will be used to free a empty chunk. This provides the basis for later temp chunk cleanup. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: extent-tree: Introduce functions to free in-memory block group ↵Qu Wenruo2015-07-10
| | | | | | | | | | | | | cache Introduce two functions, free_space_info and free_block_group_cache. The former will free the space of a empty block group. The latter will free the in memory block group cache along with its space in space_info and device space. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: extent-tree: Introduce functions to free chunk itemsQu Wenruo2015-07-10
| | | | | | | | | | | Introduce two functions, free_chunk_item and free_system_chunk_item. First one will free chunk item in chunk tree. The latter one will free a system chunk in super block. They are used for later chunk/block group free function. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: extent-tree: Introduce functions to free dev extents in a chunkQu Wenruo2015-07-10
| | | | | | | | Introduce two functions, free_dev_extent_item and free_chunk_dev_extent_items, to free dev extent items in a chunk. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: extent-tree: Introduce free_block_group_item functionQu Wenruo2015-07-10
| | | | | | | | | | | This function is used to free a block group item. It must be called with all the space in the block group pinned. Or there is a possibility that tree blocks be allocated into the range. The function is used for later block group/chunk free function. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: disk-io: Support commit transaction on chunk treeQu Wenruo2015-07-10
| | | | | | | | | As chunk tree is only stored in super block, chunk tree commit doesn't need to go through tree root update. Or a BUG_ON will be triggered. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: let corrupt-block kill nbytesDavid Sterba2015-07-03
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: tests: Add test case for I_ERR_FILE_WRONG_NBYTES repairQu Wenruo2015-07-03
| | | | | | | | Add a new test case for I_ERR_FILE_WRONG_NBYTES. The new btrfs-image dump image contains a file in 12K size. But nbytes in its inode item is a random number. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: fsck: Add repair function for I_ERR_FILE_WRONG_NBYTESQu Wenruo2015-07-03
| | | | | | | | | | | | | | | Some unknown kernel bug makes inode nbytes modification out of sync with file extent update. But it's quite easy to fix in btrfs-progs anyway. So just fix it by adding a new function repair_inode_nbytes by using the found_size in inode_record. Reported-by: Christian <cdysthe@gmail.com> Reported-by: Chris Murphy <lists@colorremedies.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: mkfs: create only desired block groups for single deviceDavid Sterba2015-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The filesystem creation has to solve some chicken-egg problems and creates some temporary objects. In our case it's an extra single/single pair of block groups that's not used unless the user asks that explicitly. Example: Data, single: total=8.00MiB, used=64.00KiB System, DUP: total=8.00MiB, used=16.00KiB System, single: total=4.00MiB, used=0.00B Metadata, DUP: total=153.56MiB, used=112.00KiB Metadata, single: total=8.00MiB, used=0.00B GlobalReserve, single: total=16.00MiB, used=0.00B Even with a single device filesystem and defaults, there's single block group for metadata and system. The single device case is easy to fix, we'll simply create the right type from the beginning. Example: Data, single: total=8.00MiB, used=64.00KiB System, DUP: total=4.00MiB, used=16.00KiB Metadata, DUP: total=136.00MiB, used=112.00KiB GlobalReserve, single: total=16.00MiB, used=0.00B Filesystem on top of multiple devices still leaves the single/single groups behind. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop unused argument from create_raid_groupsDavid Sterba2015-07-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: split data block group creation out of make_root_dirDavid Sterba2015-07-02
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move transaction start/commit out of make_root_dirDavid Sterba2015-07-01
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: split metadata group creation out of make_root_dirDavid Sterba2015-07-01
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop unused parameter from make_btrfsDavid Sterba2015-07-01
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: move make_btrfs arguments to a structDavid Sterba2015-07-01
| | | | | | | No functional change, just introduce the structure and switch current users. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add 'device remove' alias to completionDavid Sterba2015-07-01
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: doc: fix short explanation of restore in btrfsTsutomu Itoh2015-07-01
| | | | | | | Short explanation of restore is wrong. Fix it. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check for item end outside of leafDavid Sterba2015-07-01
| | | | | | | | Enhance leaf check to verify item ends that looks otherwise fine but would exceed leaf. Same check is done in kernel. Reported-by: Robert Marklund <robbelibobban@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop argument from attribute deprecatedDavid Sterba2015-06-30
| | | | | | | | | | The optional argument to attribute 'deprecated' has been introduced in gcc 4.5, and does not build on 4.4 which is still in use. The recommended replacements are mentioned in the comment, not absolutely necessary to repeat it via the attribute. Reported-by: Amr El-Sharnoby <amr.elsharnoby@horizontechs.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add nbytes output for print-tree and reformat inode outputQu Wenruo2015-06-26
| | | | | | | | | | | The original implementation doesn't output the nbytes for an inode. Add the output and since the output is too long, reformat it to multi lines. This is very handy to debug related bugs. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: no extra newline between aliased commands in help textDavid Sterba2015-06-26
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: alias btrfs device delete to btrfs device removeOmar Sandoval2015-06-26
| | | | | | | | There's an awkward asymmetry between btrfs device add and btrfs device delete. Resolve this by aliasing delete to remove. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: replace struct cmd_group->hidden with flagsOmar Sandoval2015-06-26
| | | | | | | | We're also going to want to support aliases, so rather than adding another member, replace "hidden" with a "flags" member. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: inspect: Fix out of bounds string termination.Patrik Lundquist2015-06-26
| | | | | Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: doc: update defrag pageDavid Sterba2015-06-26
| | | | | | | - update wording for -t - add optional argument to -c Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: defrag, check target extent earlierDavid Sterba2015-06-25
| | | | | | Print a warning if the target extent size (option -t) is larger than 4G. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: fix defrag threshold overflowPatrik Lundquist2015-06-25
| | | | | | | | btrfs fi defrag -t 1T overflows the u32 thresh variable and default, instead of max, threshold is used. Signed-off-by: Patrik Lundquist <patrik.lundquist@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: doc: mkfs.btrfs: document -O^Adam Borowski2015-06-25
| | | | | Signed-off-by: Adam Borowski <kilobyte@angband.pl> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs progs v4.1David Sterba2015-06-22
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: docs: new size options for fi showQu Wenruo2015-06-22
| | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Allow "filesystem show" command to handle different unitsQu Wenruo2015-06-22
| | | | | | | | | | Now "filesystem show" command can handle different units now. This is handy for higher level programs to get accurate output from "fi show" command. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: INSTALL: fix typosDavid Sterba2015-06-22
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: configure: fix typo in summaryDavid Sterba2015-06-22
| | | | Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: print correct current uuid during rewriteDavid Sterba2015-06-18
| | | | | | | | uuid_unparse is supposed to take the ASCII representation of a UUID, so we have to pass the raw fsid buffer. Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: btrfstune: print lowercase uuid during uuid rewriteDavid Sterba2015-06-18
| | | | | | | We're using lowercase everywhere else. Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: tests: verify btrfstune output during uuid-rewriteDavid Sterba2015-06-18
| | | | | | | The 'Current fsid:' value does not match the real fsid. Reported-by: Mike Fleetwood <mike.fleetwood@googlemail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: map-logical: Rework map-logical logicsQu Wenruo2015-06-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [BUG] The original map-logical has the following problems: 1) Assert if we pass any tree root bytenr. The problem is easy to trigger, here the number 29622272 is the bytenr of tree root: # btrfs-map-logical -l 29622272 /dev/sda6 mirror 1 logical 29622272 physical 38010880 device /dev/sda6 mirror 2 logical 29622272 physical 1111752704 device /dev/sda6 extent_io.c:582: free_extent_buffer: Assertion `eb->refs < 0` failed. btrfs-map-logical[0x41c464] btrfs-map-logical(free_extent_buffer+0xc0)[0x41cf10] btrfs-map-logical(btrfs_release_all_roots+0x59)[0x40e649] btrfs-map-logical(close_ctree+0x1aa)[0x40f51a] btrfs-map-logical(main+0x387)[0x4077c7] /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f80a5562790] btrfs-map-logical(_start+0x29)[0x4078f9] The problem is that, btrfs-map-logical always use sectorsize as default block size to call alloc_extent_buffer. And when it failes to find the block with the same size, it will free the extent buffer in a incorrect method(Free and create a new one with refs == 1). 2) Will return map result for non-exist extent. # btrfs-map-logical -l 1 -b 123456 /dev/sda6 mirror 1 logical 1 physical 1 device /dev/sda6 mirror 1 logical 4097 physical 4097 device /dev/sda6 mirror 1 logical 8193 physical 8193 device /dev/sda6 ... Normally, before bytenr 12582912, there should be no extent as that's the mkfs time temp metadata/system chunk. But map-logical will still map them out. Not to mention the 1 offset among all results. [FIX] This patch will rework the whole map logical by the following methods: 1) Always do things inside a extent Even under the following case, map logical will only return covered range in existing extents. |<------ range given ------->| |<-Extent A->| |<-Extent B->| |<---Extent C->| Result: |<-->| |<---------->| |<-->| So with this patch, we will search extent tree to ensure all operation are inside a extent before we do some stupid things. 2) No direct call on alloc_extent_buffer function. That low-level function shouldn't be called at such high level. It's only designed for low-level tree operation. So in this patch we will only use safe high level functions avoid such problem. [RESULT] With this patch, no assert will be triggered and better handle on non-exist extents. # btrfs-map-logical -l 29622272 /dev/sda6 mirror 1 logical 29622272 physical 38010880 device /dev/sda6 mirror 2 logical 29622272 physical 1111752704 device /dev/sda6 # btrfs-map-logical -l 1 -b 123456 /dev/sda6 No extent found at range [1,123457) Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: map-logical: introduce write_extent_content functionQu Wenruo2015-06-17
| | | | | | | This function will write extent content info desired file. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: map-logical: introduce print_mapping_info functionQu Wenruo2015-06-17
| | | | | | | | | | | The new function will print the mapping info of given range [logical, logical+len). Note, caller must ensure the ranges are completely inside an extent. Or btrfs_map_block can return -ENOENT. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: map-logical: introduce map_one_extent functionQu Wenruo2015-06-17
| | | | | | | | Introduce the function to get accurate extent length based on extent tree search. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>