summaryrefslogtreecommitdiff
path: root/ctree.h
Commit message (Collapse)AuthorAge
* btrfs-progs: Avoid uninitialized data in output of btrfs-convertZhao Lei2015-09-09
| | | | | | | | The sequence, transid and reserved fields of inode were writen to disk with uninitizlized value, this patch fixes it. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: fix typo in set/get of btrfs_inode_item::sequenceZhao Lei2015-09-09
| | | | | | | | s/generation/sequence/ for BTRFS_SETGET_STACK_FUNCS(stack_inode_sequence, ...) Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: convert: Avoid allocating metadata extent crossing stripe boundaryQu Wenruo2015-08-31
| | | | | | | | | | | As convert implement its own alloc extent, avoid such metadata problem too. Reported-by: Chris Murphy <lists@colorremedies.com> Reported-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> 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: 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: Remove non-exist csum size.Qu Wenruo2015-05-14
| | | | | | | | | | | Current btrfs only support CRC32 as checksum algorithm. But in btrfs_csum_sizes array, we have an extra 0 at tail, causing csum_type 1 can still be considered as supported csum type. Fix it by removing the tailing 0. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Introduce change_header_uuid functionQu Wenruo2015-05-14
| | | | | | | | | | This function is used to change fsid and chunk_tree_uuid of a node/leaf. The function does it without transaction protection. This is the basis of offline uuid change. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add open_ctree check for uuid changingQu Wenruo2015-05-14
| | | | | | | | | | | Now open_ctree will exit if it found the superblock is marked CHANGING_FSID, except given IGNORE_FSID open ctree flags. Kernel will do the same thing later. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [removed the chunk tree flag, reworded the error message] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add CHANGING_FSID super flagQu Wenruo2015-05-14
| | | | | | | | | Add the super flag to inform kernel not to mount a filesystem wich fsid change is in progress. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [removed the chunk tree flag] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: check for matching free space in cacheJosef Bacik2015-04-24
| | | | | | | | | | | We have this check in the kernel but not in userspace, which makes fsck fail when we wouldn't have a problem in the kernel. This was meant to catch this case because it really isn't good, unfortunately it will require a design change to fix in the kernel so in the meantime add this check so we can be sure our tests only catch real problems. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add stack get/set functions for btrfs_qgroup_status_itemQu Wenruo2015-03-24
| | | | | | | This provides the basis for later qgroup related changes. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Update qgroup status flags and replace qgroup level/subvid ↵Qu Wenruo2015-03-24
| | | | | | | | | | | | | | calculation with inline function Ctree.h of btrfs-progs contains wrong flags for btrfs_qgroup_status. Update it with the one in kernel. Also, introduce the inline function btrfs_qgroup_(level/subvid) to get the level/subvolid of qgroup, to replace the old open-coded bit operations. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add support to suppress tree block csum error outputQu Wenruo2015-02-11
| | | | | | | | | | | | Add new open ctree flag OPEN_CTREE_SUPPRESS_CHECK_BLOCK_ERRORS to suppress tree block csum error output. Provides the basis for new btrfs-find-root and other enhancement on btrfs offline tools output. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> [renamed vars and funcs, added comments] Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: remove global transaction from fsckJosef Bacik2015-02-09
| | | | | | | | | | | We hold a transaction open for the entirety of fixing extent refs. This works out ok most of the time but we can be tight on space and run out of space when fixing things. To get around this just push down the transaction starting dance into the functions that actually fix things. This keeps us from ending up with ENOSPC because we pinned everything and allows the code to be a bit simpler. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com>
* Btrfs-progs: Introduce metadump_v2Josef Bacik2015-02-09
| | | | | | | | | | The METADUMP super flag makes us skip doing the chunk tree reading which isn't helpful for the new restore since we have a valid chunk tree. But we still want to have a way for the kernel to know that this is a metadump restore so it doesn't do things like verify data checksums. We also want to skip some of the device extent checks in fsck since those will obviously not match. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com>
* btrfs-progs: Add btrfs_get_extent() and btrfs_punch_hole().Qu Wenruo2015-02-02
| | | | | | | | | | | | | | | | | | | Add btrfs_get_extent() and btrfs_punch_hole() for btrfs-progs. Btrfs_get_extent() will act much like kernel one, return the first extent that covers the given range. The difference will be that progs btrfs_get_extent() can't handle no-holes feature, which means caller should handle it carefully. Btrfs_punch_hole() will punch a hole in given range of given inode, however it differs from kernel one since it won't zero any page or drop any extents if there is any extent in the hole range. These functions are mainly used for later I_ERR_FILE_EXTENT_DISCOUNT repair function. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Record orphan data extent ref to corresponding root.Qu Wenruo2015-02-02
| | | | | | | | | | | | | | | | | | | | | | Before this patch, when a extent's data ref points to a invalid key in fs tree, this happens if a leaf/node of fs tree is corrupted, btrfsck can't do any repair and just exit. In fact, such problem can be handled in fs tree repair routines, rebuild the inode item(if missing) and add back the extent data (with some assumption). So this patch records such data extent refs for later fs tree recovery routine. TODO: Restore orphan data extent refs into btrfs_root is not the best method. It's best to directly restore it into inode_record, however current extent tree and fs tree can't cooperate together, so use btrfs_root as a temporary storage until inode_cache is built. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: unify header file inclusion protectionsDavid Sterba2015-01-21
| | | | | | There are missing ifdefs or defines with very generic names. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add inode item rebuild function.Qu Wenruo2014-12-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add a basic inode item rebuild function for I_ERR_NO_INODE_ITEM. The main use case is to repair btrfs which fs root has corrupted leaf, but it is already working for case if the corrupteed fs root leaf/node contains no inode extent_data. The repair needs 3 elements for inode rebuild: 1. inode number This is quite easy, existing inode_record codes will detect it quite well. 2. inode type This is the trick part. The only reliable method is to recovery it from parent's dir_index/item. The remaining method will search for regular file extent for FILE type or child's backref for DIR(todo). Fallback will be FILE. Inode name(inode_ref) will be recoverd by nlink repair function. This is just a fundamental implement, some advanced recovery can be improved later with btrfs-progs infrastructure change. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add btrfs_mkdir() function for the incoming 'lost+found' fsck ↵Qu Wenruo2014-12-10
| | | | | | | | | | | | | mechanism. With the previous btrfs inode operations patches, now we can use btrfs_mkdir() to create the 'lost+found' dir to do some data salvage in btrfsck. This patch along with previous ones will make data salvage easier. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Add btrfs_unlink() and btrfs_add_link() functions.Qu Wenruo2014-12-10
| | | | | | | | Add btrfs_unlink() and btrfs_add_link() functions in inode.c, for the incoming btrfs_mkdir() and later inode operations functions. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Import lookup/del_inode_ref() function.Qu Wenruo2014-12-10
| | | | | | | | | | | Import lookup/del_inode_ref() function in inode-item.c, as base functions for the incoming btrfs_add_link() and btrfs_unlink() functions. Also modify btrfs_insert_inode_ref() and split_leaf() making them able to deal with EXTENT_IREF incompat flag. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Import btrfs_insert/del/lookup_extref() functions.Qu Wenruo2014-12-10
| | | | | | | | Import btrfs_insert/del/lookup_extref() functions form kernel for the incoming btrfs_add_link() and btrfs_unlink() functions. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Enhance the command btrfs filesystem dfGoffredo Baroncelli2014-12-04
| | | | | | | | | | Enhance the command "btrfs filesystem df" to show space usage information for a mount point(s). It shows also an estimation of the space available, on the basis of the current one used. Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it> [code moved under #if 0 instead of deletion] Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: delete bogus dir indexesJosef Bacik2014-10-14
| | | | | | | | | | | | | | We may run across dir indexes that are corrupt in such a way that it makes them useless, such as having a bad location key or a bad name. In this case we can just delete dir indexes that don't show up properly and then re-create what we need. When we delete dir indexes however we need to restart scanning the fs tree as we could have greated bogus inode recs if the location key was bad, so set it up so that if we had to delete an dir index we go ahead and free up our inode recs and return -EAGAIN to check_fs_roots so it knows to restart the loop. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: pull back backref.c and fix it upJosef Bacik2014-10-14
| | | | | | | | | This patch pulls back backref.c, adds a couple of helpers everywhere that it needs, and cleans up backref.c to fit in btrfs-progs. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> [removed free_some_buffers after "do not reclaim extent buffer"] Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: read global reserve size from space infosDavid Sterba2014-08-28
| | | | | | | | Kernels >= 3.15 export the global block reserve as a space info presented by 'btrfs fi df' but would display 'unknown' instead of some meaningful string. Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: remove unused flags for btrfs_pathGui Hecheng2014-08-28
| | | | | | | | | | | | | | | The three flags of @btrfs_path: btrfs_path { unsigned int keep_locks:1; unsigned int skip_locking:1; unsigned int leave_spinning:1; } have little meaning, because the userspace @btrfs_search_slot() is free of locking and no other routines will decide their behavior on these. So just remove them. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: replace BTRFS_NUM_MIRRORS with BTRFS_MAX_MIRRORSGui Hecheng2014-08-22
| | | | | | | | | | | | | | | The chunk-recover.c/BTRFS_NUM_MIRRORS in the userspace means the same thing as ctree.h/BTRFS_MAX_MIRRORS in the kernelspace, so to stay consistent with the kernelspace, just make this movement in the userspace: chunk-recover.c/BTRFS_NUM_MIRRORS ===> ctree.h/BTRFS_MAX_MIRRORS This provides convenience for future use. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: add quota group verify codeMark Fasheh2014-08-22
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds functionality (in qgroup-verify.c) to compute bytecounts in subvolume quota groups. The original groups are read in and stored in memory so that after we compute our own bytecounts, we can compare them with those on disk. A print function is provided to do this comparison and show the results on the console. A 'qgroup check' pass is added to btrfsck. If any subvolume quota groups differ from what we compute, the differences for them are printed. We also provide an option '--qgroup-report' which will run only the quota check code and print a report on all quota groups. Other than making it possible to verify that our qgroup changes work correctly, this mode can also be used in xfstests for automated checking after qgroup tests. This patch does not address the following: - compressed counts are identical to non compressed, because kernel doesn't make the distinction yet. Adding the code to verify compressed counts shouldn't be hard at all though once kernel can do this. - It is only concerned with subvolume quota groups (like most of btrfs-progs). Signed-off-by: Mark Fasheh <mfasheh@suse.de> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: update btrfs_file_extent_inline_len to match kernel versionFilipe David Borba Manana2014-04-11
| | | | | | | | | | | | | | | | | | | | | | | The following kernel commit changed the definition of the inline function btrfs_file_extent_inline_len(): commit 514ac8ad8793a097c0c9d89202c642479d6dfa34 Author: Chris Mason <clm@fb.com> Date: Fri Jan 3 21:07:00 2014 -0800 Btrfs: don't use ram_bytes for uncompressed inline items If we truncate an uncompressed inline item, ram_bytes isn't updated to reflect the new size. The fixe uses the size directly from the item header when reading uncompressed inlines, and also fixes truncate to update the size as it goes. Not having this new definition implies that the restore tool might misbehave when restoring files with an inline extent that got truncated on a kernel older than release 3.14. Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
* btrfs-progs: Constify gettersKusanagi Kouichi2014-04-11
| | | | | Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp> Signed-off-by: David Sterba <dsterba@suse.cz>
* Btrfs-progs: use bitfield instead of integer for some variants in fs_infoWang Shilong2014-03-21
| | | | | | Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: add support for the no holes incompat flagJosef Bacik2014-01-31
| | | | | | | | | | This adds the flag to ctree.h, adds the feature option to mkfs to turn it on and fixes fsck so it doesn't complain about missing hole extents in files when this flag is set. Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: deal with invalid key orderings and bad orphan items V2Josef Bacik2014-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A user had a fs where the objectid of an orphan item was not the actual orphan item objectid. This screwed up fsck because the block has keys in the wrong order, also the fs scanning stuff will freak out because we have an inode with nlink 0 and no orphan item. So this patch is pretty big but is all related. 1) Deal with bad key ordering. We can easily fix this up, so fix the checking stuff to tell us exactly what it found when it said there was a problem. Then if it's bad key ordering we can reorder the keys and restart the scan. 2) Deal with bad keys. If we find an orphan item with the wrong objectid it's likely to screw with stuff, so keep track of these sort of things with a bad_item list and just run through and delete any objects that don't make sense. So far we just do this for orphan items but we could extend this as new stuff pops up. 3) Deal with missing orphan items. This is easy, if we have a file with i_nlink set to 0 and no orphan item we can just add an orphan item. 4) Add the infrastructure to corrupt actual key values. Needed this to create a test image to verify I was fixing things properly. This patch fixes the corrupt image I'm adding and passes the other make test tests. Thanks, Signed-off-by: Josef Bacik <jbacik@fb.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* Btrfs-progs: chunk-recover: add new flag to prepare recovering for ordered ↵Wang Shilong2014-01-31
| | | | | | | | | | | | data chunk When reading block groups we will searching it's corresponding chunk, however, at this time, some chunks has not been built(data chunks raid0/raid10/raid56), don't bug_on here, we will try to rebuild these chunks later. Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* btrfs-progs: Make btrfs_header_chunk_tree_uuid() return unsigned longRoss Kirk2014-01-31
| | | | | | | | | | | | Internally, btrfs_header_chunk_tree_uuid() calculates an unsigned long, but casts it to a pointer, while all callers cast it to unsigned long again. From btrfs commit b308bc2f05a86e728bd035e21a4974acd05f4d1e Signed-off-by: Ross Kirk <ross.kirk@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
* mkfs: fix mkfs -r to properly allocate spaceChris Mason2013-10-16
| | | | | | | | | | | | | | | | mkfs -r wasn't creating chunks properly, making it very difficult to allocate space for anything except tiny filesystems. This changes it around to use more of the generic infrastructure, and to do actual logical->physical block number translation. It also allocates space to the files in smaller extents (max 1MB), which keeps the allocator from trying to allocate an extent bigger than a single chunk. It doesn't quite support multi-device mkfs -r yet, but is much closer. Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: restructure show_qgroupsWang Shilong2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current show_qgroups() just shows a little information, and it is hard to add some functions which the users need in the future, so i restructure it, make it easy to add new functions. In order to improve the scalability of show_qgroups(), i add some important structures: struct qgroup_lookup { struct rb_root root; } /* *store qgroup's information */ struct btrfs_qgroup { struct rb_node rb_node; u64 qgroupid; u64 generation; u64 rfer; u64 rfer_cmpr; u64 excl_cmpr; u64 flags; u64 max_rfer; u64 max_excl; u64 rsv_rfer; u64 rsv_excl; struct list_head qgroups; struct list_head members; } /* *glue structure to represent the relations *between qgroups */ struct btrfs_qgroup_list { struct list_head next_qgroups; struct list_head next_member; struct btrfs_qgroup *qgroup; struct btrfs_qgroup *member; } The above 3 structures are used to manage all the information of qgroups. struct { char *name; char *column_name; int need_print; } btrfs_qgroup_columns[] We define a arrary to manage all the columns that can be outputed, and use a member variant(->need_print) to control the output of the relative column. Some columns are outputed by default. But we can change it according to the requirement of the users. For example: if outputing max referenced size of qgroup is needed,the function 'btrfs_qgroup_setup_column()' will be called, and the parameter 'BTRFS_QGROUP_MAX_RFER' (extend in the future) will be passsed to the function. After the function is done, when showing qgroups, max referenced size of qgroup will be output. Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com> Signed-off-by: Miao Xie <miaox@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* Btrfs-progs: keep track of transid failures and fix them if possibleJosef Bacik2013-10-16
| | | | | | | | | | | | | A user was reporting an issue with bad transid errors on his blocks. The thing is that btrfs-progs will ignore transid failures for things like restore and fsck so we can do a best effort to fix a users file system. So fsck can put together a coherent view of the file system with stale blocks. So if everything else is ok in the mind of fsck then we can recow these blocks to fix the generation and the user can get their file system back. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: move out print in cmd_df to another functionAnand Jain2013-10-16
| | | | | | | | | This is a prepatory work for the btrfs fi show command fixes. So that we have a function get_df to get the fs sizes Signed-off-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: Make btrfs_header_fsid() return unsigned longRoss Kirk2013-10-16
| | | | | | | | | | | | | Internally, btrfs_header_fsid() calculates an unsigned long, but casts it to a pointer, while all callers cast it to unsigned long again. Committed to btrfs as fba6aa75654394fccf2530041e9451414c28084f Fix line length issues and match changes to kernelspace Signed-off-by: Ross Kirk <ross.kirk@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: remove unused parameter from btrfs_header_fsidRoss Kirk2013-10-16
| | | | | | | | | | Remove unused parameter, 'eb'. Unused since introduction in 7777e63b425f1444d2472ea05a6b2b9cf865f35b Signed-off-by: Ross Kirk <ross.kirk@gmail.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: drop unused parameter from btrfs_item_nrRoss Kirk2013-10-16
| | | | | | | | | | Remove unused eb parameter from btrfs_item_nr, unused since introduced in 7777e63b425f1444d2472ea05a6b2b9cf865f35b Signed-off-by: Ross Kirk <ross.kirk@gmail.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: calculate available blocks on device properlyHidetoshi Seto2013-10-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I found that mkfs.btrfs aborts when assigned multi volumes contain a small volume: # parted /dev/sdf p Model: LSI MegaRAID SAS RMB (scsi) Disk /dev/sdf: 72.8GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 72.4GB 72.4GB primary 2 72.4GB 72.8GB 461MB primary # ./mkfs.btrfs -f /dev/sdf1 /dev/sdf2 : SMALL VOLUME: forcing mixed metadata/data groups adding device /dev/sdf2 id 2 mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed. Aborted (core dumped) This failure of btrfs_alloc_chunk was caused by following steps: 1) since there is only small space in the small device, mkfs was going to allocate a chunk from free space as much as available. So mkfs called btrfs_alloc_chunk with size = device->total_bytes - device->used_bytes. 2) (According to the comment in source code, to avoid overwriting superblock,) btrfs_alloc_chunk starts taking chunks at an offset of 1MB. It means that the layout of a disk will be like: [[1MB at beginning for sb][allocated chunks]* ... free space ... ] and you can see that the available free space for allocation is: avail = device->total_bytes - device->used_bytes - 1MB. 3) Therefore there is only free space 1MB less than requested. damn. >From further investigations I also found that this issue is easily reproduced by using -A, --alloc-start option: # truncate --size=1G testfile # ./mkfs.btrfs -A900M -f testfile : mkfs.btrfs: volumes.c:852: btrfs_alloc_chunk: Assertion `!(ret)' failed. Aborted (core dumped) In this case there is only 100MB for allocation but btrfs_alloc_chunk was going to allocate more than the 100MB. The root cause of both of above troubles is a same simple bug: btrfs_chunk_alloc does not calculate available bytes properly even though it researches how many devices have enough room to have a chunk to be allocated. So this patch introduces new function btrfs_device_avail_bytes() which returns available bytes for allocation in specified device. Signed-off-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: add ULL to u64 constantZach Brown2013-09-03
| | | | | | | | | | | | | | | | | | | | This silences a sparse warning: warning: constant 0x4D5F53665248425F is so big it is long from commit 52162700bb59663add809a6465ce2769d80b3664 Author: Zach Brown <zab@redhat.com> Date: Thu Jan 17 11:54:47 2013 -0800 btrfs-progs: treat super.magic as an le64 High fives, past me! Signed-off-by: Zach Brown <zab@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: mark static & remove unused from shared kernel codeEric Sandeen2013-09-03
| | | | | | | | | | | In files copied from the kernel, mark many functions as static, and remove any resulting dead code. Some functions are left unmarked if they aren't static in the kernel tree. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: make set/get functions for the super compat_ro flags use compat_roEric Sandeen2013-09-03
| | | | | | | | | | | | | | | | | | | | Port of commit 12534832 to userspace: commit 12534832cb7b0abc7369298246e8b7af03b863ca Author: Josef Bacik <josef@redhat.com> Date: Thu Dec 17 21:32:27 2009 +0000 Btrfs: make set/get functions for the super compat_ro flags use compat_ro Our set/get functions for compat_ro_flags actually look at compat_flags. This will mess any attempt to use compat flags up. The fix is obvious. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: fix definition of struct btrfs_extent_inline_refEric Sandeen2013-09-03
| | | | | | | | | | Port kernel commit 1bec1aed to userspace. use __le64 instead of u64 in on-disk structure definition. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
* btrfs-progs: drop unused parameter from btrfs_release_pathEric Sandeen2013-09-03
| | | | | | | | | | | | | | | Port of commit b3b4aa7 to userspace. parameter tree root it's not used since commit 5f39d397dfbe140a14edecd4e73c34ce23c4f9ee ("Btrfs: Create extent_buffer interface for large blocksizes") This gets userspace a tad closer to kernelspace by removing this unused parameter that was all over the codebase... Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>