summaryrefslogtreecommitdiff
path: root/ctree.h
Commit message (Collapse)AuthorAge
* btrfs-progs: Rename OPEN_CTREE_FS_PARTIAL to OPEN_CTREE_TEMPORARY_SUPERQu Wenruo2018-04-24
| | | | | | | | | | | | | | | | | | | | | | | | The old flag OPEN_CTREE_FS_PARTIAL is in fact quite easy to be confused with OPEN_CTREE_PARTIAL, which allow btrfs-progs to open damaged filesystem (like corrupted extent/csum tree). However OPEN_CTREE_FS_PARTIAL, unlike its name, is just allowing btrfs-progs to open fs with temporary superblocks (which only has 6 basic trees on SINGLE meta/sys chunks). The usage of FS_PARTIAL is really confusing here. So rename OPEN_CTREE_FS_PARTIAL to OPEN_CTREE_TEMPORARY_SUPER, and add extra comment for its behavior. Also rename BTRFS_MAGIC_PARTIAL to BTRFS_MAGIC_TEMPORARY to keep the naming consistent. And with above comment, the usage of FS_PARTIAL in dump-tree is obviously incorrect, fix it. Fixes: 8698a2b9ba89 ("btrfs-progs: Allow inspect dump-tree to show specified tree block even some tree roots are corrupted") Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Unify btrfs_leaf_free_space() parameter with kernelQu Wenruo2018-04-24
| | | | | | | | | | Instead of struct btrfs_root, use struct btrfs_fs_info, since nodesize is now a per-fs setting, and with the need to pass a @root, caller don't need to wonder which root should be passed. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove BTRFS_CRC32_SIZE definitionMisono, Tomohiro2018-03-30
| | | | | | | | | | The kernel code no longer has BTRFS_CRC32_SIZE and only uses btrfs_csum_sizes[]. So, update the progs code as well. Suggested-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Introduce btrfs_raid_array and related infrastructuresQu Wenruo2018-02-24
| | | | | | | | | | | As part of the effort to unify code and behavior between btrfs-progs and kernel, copy the btrfs_raid_array from kernel to btrfs-progs. So later we can use the btrfs_raid_array[] to get needed raid info other than manually do if-else branches. Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Cleanup use of root in leaf_data_endGu Jinxiang2018-02-02
| | | | | | | | | | | | | In function leaf_data_end, root is just used to get fs_info, so change the parameter of this function from btrfs_root to btrfs_fs_info. And also make it consistent with kernel. Add const to parameter leaf of function btrfs_item_offset_nr to keep type consistent with leaf_data_end. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove no longer used btrfs_alloc_extentGu Jinxiang2018-02-02
| | | | | | | | Function btrfs_alloc_extent is no longer be used. So let's remove it. Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use fs_info instead of root for BTRFS_MAX_XATTR_SIZEGu Jinxiang2018-02-02
| | | | | | | | | | | | Do a cleanup. Also make it consistent with kernel. Use fs_info instead of root for BTRFS_MAX_XATTR_SIZE, since maybe in some situation we do not know root, but just know fs_info. To be consistent with kernel, change macro to inline function. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Sync code with kernel for BTRFS_MAX_INLINE_DATA_SIZEGu Jinxiang2018-02-02
| | | | | | | | | | | | | Do a cleanup. Also make it consistent with kernel. Use fs_info instead of root for BTRFS_MAX_INLINE_DATA_SIZE, since maybe in some situation we do not know root, but just know fs_info. Change macro to inline function to be consistent with kernel. And change the function body to match kernel. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use fs_info instead of root for BTRFS_NODEPTRS_PER_BLOCKGu Jinxiang2018-02-02
| | | | | | | | | | | | Do a cleanup. Also make it consistent with kernel. Use fs_info instead of root for BTRFS_NODEPTRS_PER_BLOCK, since maybe in some situation we do not know root, but just know fs_info. To be consistent with kernel, change macro to inline function. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use fs_info instead of root for BTRFS_LEAF_DATA_SIZEGu Jinxiang2018-02-02
| | | | | | | | | | Do a cleanup. Also make it consistent with kernel. Use fs_info instead of root for BTRFS_LEAF_DATA_SIZE, since maybe in some situation we do not know root, but just know fs_info. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove unnecessary parameter for btrfs_add_block_groupQu Wenruo2018-01-31
| | | | | | | | | | @chunk_objectid of btrfs_make_block_group() function is always fixed to BTRFS_FIRST_FREE_OBJECTID, so there is no need to pass it as parameter explicitly. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Use bool parameter to determine if we're allocating data extentQu Wenruo2018-01-31
| | | | | | | | | | | | | | | btrfs_reserve_extent() uses int @data to determine if we're allocating data extent, while reuse the parameter later to pass it as profile (data/meta/sys). It's a little confusing, this patch will follow kernel parameter to use bool @is_data to replace it. And in btrfs_reserve_extent(), use dedicated u64 @profile. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Remove unused parameter transGu Jinxiang2018-01-08
| | | | | | | | Some parameter of trans is not used indeed. Let's remove them. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: dump-tree: print c/o/s/r time of ROOT_ITEMMisono, Tomohiro2018-01-03
| | | | | | | | | | Currently ctime/otime/stime/rtime of ROOT_ITEM are not printed in print_root_item(). Fix this and print them if the values are not zero. The function print_timespec() is moved forward to reuse. Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: adjustments for further repairSu Yue2017-10-16
| | | | | | | | | | | For code reuse, btrfs_insert_dir_item() now calls inserts_with_overflow() even if the dir_item existed. Add a parameter @ignore_existed to btrfs_add_link(). If @ignore_existed is not zero, btrfs_add_link() continues to do link. Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add a parameter to btrfs_mksubvolYingyi Luo2017-10-06
| | | | | | | | A convert parameter is added as a flag to indicate if btrfs_mksubvol() is used for btrfs-convert. The change cascades down to the callchain. Signed-off-by: Yingyi Luo <yingyil@google.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: move link_subvol out of mainYingyi Luo2017-10-06
| | | | | | | | link_subvol() is moved to inode.c and renamed as btrfs_mksubvol(). The change cascades down to the callchain. Signed-off-by: Yingyi Luo <yingyil@google.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Add zstd supportNick Terrell2017-09-25
| | | | | | | | | | | | | | | | Adds zstd support to the btrfs program. An optional dependency on libzstd >= 1.0.0 is added. Autoconf accepts `--enable-zstd' or `--disable-zstd' and defaults to detecting if libzstd is present using `pkg-config'. The patch is also available in my fork of btrfs-progs [1], which passes Travis-CI with the new tests. The prebuilt binary is available there. I haven't updated Android.mk. [1] https://github.com/terrelln/btrfs-progs/tree/devel Signed-off-by: Nick Terrell <terrelln@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fi du: don't call lookup_path_rootid for ↵Goffredo Baroncelli2017-09-08
| | | | | | | | | | | | | | | | | | | | | | | BTRFS_EMPTY_SUBVOL_DIR_OBJECTID When ino is BTRFS_EMPTY_SUBVOL_DIR_OBJECTID, the item is not referred to any file-tree. So lookup_path_rootid() doesn't return any meaningful value. As was reported, this can be triggered by $ btrfs sub create test1 $ btrfs sub create test1/test2 $ btrfs sub snap test1 test1.snap $ btrfs fi du -s test1 Total Exclusive Set shared Filename 0.00B 0.00B 0.00B test1 $ btrfs fi du -s test1.snap Total Exclusive Set shared Filename ERROR: cannot check space of 'test1.snap': Inappropriate ioctl for device Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: start framework for transaction abortDavid Sterba2017-09-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: switch fs_info::system_allocs to bitDavid Sterba2017-09-08
| | | | | | | The value really is 0 or 1, the test in btrfs_reserve_extent can be simplified. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: add support for converting reiserfsJeff Mahoney2017-09-08
| | | | | | | | | | | | | This patch adds support to convert reiserfs file systems in-place to btrfs. It will convert extended attribute files to btrfs extended attributes, translate ACLs, coalesce tails that consist of multiple items into one item, and convert tails that are too big into indirect files. This requires that libreiserfscore 3.6.27 be available. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Refactor chunk creation functions to use btrfs_fs_infoQu Wenruo2017-07-12
| | | | | | | | 4 functions are involved in this refactor: btrfs_make_block_group() btrfs_make_block_groups(), btrfs_alloc_chunk, btrfs_alloc_data_chunk(). Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Refactor read_node_slot function to get rid of btrfs_rootQu Wenruo2017-07-03
| | | | | | parameter Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Remove block size members in btrfs_rootQu Wenruo2017-07-03
| | | | | | Finally, we can get rid of per tree block size members now. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Refactor block sizes users in ctree.c and ctree.hQu Wenruo2017-07-03
| | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Introduce sectorsize nodesize and stripesize members forQu Wenruo2017-07-03
| | | | | | | | | | | | | btrfs_fs_info Just like what we do in kernel, since we will not support different leaf/node/stripe size per tree, there is no need to store these block sizes in btrfs_root. This patch will introduce these block size members into btrfs_fs_info structure, allowing us to convert such usage in later patches. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: Remove deprecated leafsize usageQu Wenruo2017-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | Leafsize is deprecated for a long time, and kernel has already updated ctree.h to rename sb->leafsize to sb->__unused_leafsize. This patch will remove normal users of leafsize: 1) Remove leafsize member from btrfs_root structure Now only root->nodesize and root->sectorisze. No longer root->leafsize. 2) Remove @leafsize parameter from btrfs_setup_root() function Since no root->leafsize, no need for @leafsize parameter. The remaining user of leafsize will be: 1) btrfs inspect-internal dump-super Reformat the "leafsize" output to "leafsize (deprecated)" and use le32_to_cpu() to do the cast manually. 2) mkfs We still need to set sb->__unused_leafsize to nodesize. Do the manual cast too. 3) convert Same as mkfs, these two superblock setup should be merged later Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
* btrfs-progs: library: distribute sizes.h, fix buildDavid Sterba2017-03-16
| | | | | | | | | | | | | The patch "btrfs-progs: Introduce kernel sizes to cleanup large intermediate number" (a2203246ae483d09) was taken from kernel but not properly ported so the build breaks because the header linux/sizes.h is not exported. The build tests of library do not cover the case when the macro BTRFS_FLAT_INCLUDES is not defined (ie. an external build). Reported-by: Holger Hoffstätte <holger@applied-asynchrony.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Rework rollbackQu Wenruo2017-03-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework rollback to a more easy to understand way. New convert behavior makes us to have a more flex chunk layout, which only data chunk containing old fs data will be at the same physical location, while new chunks (data/meta/sys) can be mapped anywhere else. This behavior makes old rollback behavior can't handle it. As old behavior assumes all data/meta is mapped in a large chunk, which is mapped 1:1 on disk. So rework rollback to handle new convert behavior, enhance the check by only checking all file extents of convert image, only to check if these file extents and therir chunks are mapped 1:1. This new rollback check behavior can handle both new and old convert behavior, as the new behavior is a superset of old behavior. Further more, introduce a simple rollback mechanisim: 1) Read reserved data (offset = file offset) from convert image 2) Write reserved data into disk (offset = physical offset) Since old fs image is a valid fs, and we only need to rollback superblocks (btrfs reserved ranges), then we just read out data in reserved range, and write it back. Due to the fact that all other file extents of converted image is mapped 1:1 on disk, we put the missing piece back, then the fs is as good as old one. Then what we do in btrfs is just another dream. With this new rollback mechanisim, we can open btrfs read-only, so we won't cause any damage to current btrfs, until the final piece (0~1M, containing 1st super block) is put back. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [ port to v4.10 ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: file: Introduce function to read out file contentQu Wenruo2017-03-16
| | | | | | | | | | | | | Introduce a new function, btrfs_read_file(), to read out data of a file inode. This function will iterate through EXTENT_DATA items and handle inline/prealloc/hole file extents. Compression is not supported yet. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused argument from btrfs_lookup_inode_refDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: remove unused helpers from ctree.hDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop unused argument from btrfs_del_ptrDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop unused argument from btrfs_extend_itemDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: drop unused argument from btrfs_truncate_itemDavid Sterba2017-03-08
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Introduce kernel sizes to cleanup large intermediate numberQu Wenruo2017-03-08
| | | | | | | | | | | Large numbers like (1024 * 1024 * 1024) may cost reader/reviewer to waste one second to convert to 1G. Introduce kernel include/linux/sizes.h to replace any intermediate number larger than 4096 (not including 4096) to SZ_*. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: check: get the highest inode for lost+foundGoldwyn Rodrigues2017-01-25
| | | | | | | | | | | | | root->highest_inode is not accurate at the time of creating a lost+found and it fails because the highest_inode+1 is already present. This could be because of fixes after highest_inode is set. Instead, search for the highest inode in the tree and use it for lost+found. This makes root->highest_inode unnecessary and hence deleted. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: make incompat bit wrappers more compactDavid Sterba2016-12-14
| | | | | | Use the same macro tricks as in kernel code. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add btrfs_clear_free_space_tree() from the kernelOmar Sandoval2016-11-23
| | | | | | Reviewed-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add the FREE_SPACE_TREE_VALID compat_ro bit definitionOmar Sandoval2016-11-23
| | | | | | | This is just the definition; we don't support it yet. Signed-off-by: Omar Sandoval <osandov@fb.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert bitfield to separate variables in btrfs_pathDavid Sterba2016-11-09
| | | | | | We don't have that many bitfields that would save space. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: reduce size of btrfs_path::lowest_levelDavid Sterba2016-11-09
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: reduce size of btrfs_path::readaDavid Sterba2016-11-09
| | | | | | | We use only a few values, reada accessed not in performance critical contexts. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: reduce size of btrfs_path, locks are not usedDavid Sterba2016-11-09
| | | | | | | Size of btrfs_path can be reduced by 32 bytes as we don't use the locks array, down to 112 from 144 bytes. Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add dev stats on-disk structureDavid Sterba2016-11-09
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: add balance status structuresDavid Sterba2016-11-09
| | | | Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: switch dev stats item to the permanent item keyDavid Sterba2016-11-09
| | | | | [ kernel patch 242e2956e4afde7727fffe21adc0a7b198b77f96 ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: introduce key type for persistent permanent itemsDavid Sterba2016-11-09
| | | | | | | | | | | | | | The number of distinct key types is not that big that we could waste one for something new we want to store in the tree. Similar to the temporary items, we'll introduce a new name for an existing key value and use the objectid for further extension. The victim is the BTRFS_DEV_STATS_KEY (248). The device stats are an example of a permanent item. [ kernel patch 50c2d5abe64c1726b48d292a2ab04f60e8238933 ] Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: introduce key type for persistent temporary itemsDavid Sterba2016-11-09
| | | | | | | | | | | | | | The number of distinct key types is not that big that we could waste one for something new we want to store in the tree. We'll introduce a new name for an existing key value and use the objectid for further extension. The victim is the BTRFS_BALANCE_ITEM_KEY (248). The nature of the balance status item is a good example of the temporary item. It exists from beginning of the balance, keeps the status until it finishes. [ kernel patch 0bbbccb17fea86818e1a058faf5903aefd20b31a ] Signed-off-by: David Sterba <dsterba@suse.com>