summaryrefslogtreecommitdiff
path: root/mkfs.c
Commit message (Collapse)AuthorAge
* btrfs-progs: Improvement for making btrfs image from source directory.Zhong, Xin2011-10-25
| | | | | | | | | | | | * Initialize ret in btrfs_csum_file_block * Do not abort when xattr is not supported in the source directory * Remove size limitation of 256M * Alloc data chunk in a smaller size (8M) to make btrfs image smaller * Let user specify the btrfs image name Depends on below patch from samsung guys: http://marc.info/?l=linux-btrfs&m=127858068226025&w=2 Signed-off-by: Zhong, Xin <xin.zhong@intel.com>
* Btrfs-progs: specify label length larger than 255 bytes cause mkfs.btrfs ↵Jeff Liu2011-10-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | buffer overflow Hello, While going through the mkfs.c, I noticed there is an issue for label length checking, mkfs.btrfs will crashed if the label length exceeding 255 bytes, it's easy to triggered that out as below: jeff@pibroch:~/opensource/btrfs-progs$ sudo ./mkfs.btrfs -L `perl -e 'print "A"x256'` /usr/src/linux-3.0/img0 WARNING! - Btrfs v0.19-35-g1b444cd IS EXPERIMENTAL WARNING! - see http://btrfs.wiki.kernel.org before using *** buffer overflow detected ***: ./mkfs.btrfs terminated ======= Backtrace: ========= /lib/i386-linux-gnu/libc.so.6(__fortify_fail+0x50)[0xb7774df0] /lib/i386-linux-gnu/libc.so.6(+0xe4cca)[0xb7773cca] /lib/i386-linux-gnu/libc.so.6(__strcpy_chk+0x3f)[0xb777305f] ./mkfs.btrfs[0x805acc4] ./mkfs.btrfs[0x805def6] /lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xe7)[0xb76a5e37] ./mkfs.btrfs[0x8048ef1] ======= Memory map: ======== ...... a tiny patch could fix it. Signed-off-by: Jie Liu <jeff.liu@oracle.com>
* remove unused variablesHubert Kario2011-10-25
| | | | | | | fixes compilation warnings with gcc 4.6.0 20110429 Signed-off-by: Hubert Kario <kario@wit.edu.pl> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs.btrfs: Fix compilation errors with gcc 4.6Hugo Mills2011-10-25
| | | | | | | | | gcc 4.6 complains about several possible use-before-initialise cases in mkfs, and stops. Fix these by initialising one of the variables in question, and using the correct error-handling paths for the remainder. Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs.btrfs: fix error text in '-r' modeSergei Trofimovich2011-10-25
| | | | | | | | | | Smart gcc noticed use of uninitialized warning when compiled with -O0 flags: mkfs.c:1291: error: 'file' may be used uninitialized in this function Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs.btrfs: fix memory leak caused by 'scandir()' callsSergei Trofimovich2011-10-25
| | | | | Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs.btrfs: free buffers allocated by pretty_sizesSergei Trofimovich2011-10-25
| | | | | | | | | | | found by valgrind: ==2559== 16 bytes in 1 blocks are definitely lost in loss record 3 of 19 ==2559== at 0x4C2720E: malloc (vg_replace_malloc.c:236) ==2559== by 0x412F7E: pretty_sizes (utils.c:1054) ==2559== by 0x4179E9: main (mkfs.c:1395) Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs.btrfs: write zeroes instead on uninitialized data.Sergei Trofimovich2011-10-25
| | | | | | | | | | | | | | | | | | | | | | | | | Found by valgrind: ==8968== Use of uninitialised value of size 8 ==8968== at 0x41CE7D: crc32c_le (crc32c.c:98) ==8968== by 0x40A1D0: csum_tree_block_size (disk-io.c:82) ==8968== by 0x40A2D4: csum_tree_block (disk-io.c:105) ==8968== by 0x40A7D6: write_tree_block (disk-io.c:241) ==8968== by 0x40ACEE: __commit_transaction (disk-io.c:354) ==8968== by 0x40AE9E: btrfs_commit_transaction (disk-io.c:385) ==8968== by 0x42CF66: make_image (mkfs.c:1061) ==8968== by 0x42DE63: main (mkfs.c:1410) ==8968== Uninitialised value was created by a stack allocation ==8968== at 0x42B5FB: add_inode_items (mkfs.c:493) 1. On-disk inode format has reserved (and thus, random at alloc time) fields: btrfs_inode_item: __le64 reserved[4] 2. Sometimes extents are created on disk without writing data there. (Or at least not all data is written there). Kernel code always had it kzalloc'ed. Zero them all. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs.btrfs: fix symlink names writingSergei Trofimovich2011-10-25
| | | | | | | | | | | | | | | | | | | | Found by valgrind: ==8968== Use of uninitialised value of size 8 ==8968== at 0x41CE7D: crc32c_le (crc32c.c:98) ==8968== by 0x40A1D0: csum_tree_block_size (disk-io.c:82) ==8968== by 0x40A2D4: csum_tree_block (disk-io.c:105) ==8968== by 0x40A7D6: write_tree_block (disk-io.c:241) ==8968== by 0x40ACEE: __commit_transaction (disk-io.c:354) ==8968== by 0x40AE9E: btrfs_commit_transaction (disk-io.c:385) ==8968== by 0x42CF66: make_image (mkfs.c:1061) ==8968== by 0x42DE63: main (mkfs.c:1410) ==8968== Uninitialised value was created by a stack allocation ==8968== at 0x42B5FB: add_inode_items (mkfs.c:493) readlink(2) does not write '\0' for us, so make it manually. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs.btrfs: fail on scandir error (-r mode)Sergei Trofimovich2011-10-25
| | | | | | | | | | | | | | | | | | | | | | mkfs.btrfs does not handle relative pathnames for now. When they are passed to it it creates empty image. So first time I thought it does not work at all. This patch adds error handling for scandir(). With patch it behaves this way: $ mkfs.btrfs -r ./root ... fs created label (null) on output.img nodesize 4096 leafsize 4096 sectorsize 4096 size 256.00MB Btrfs v0.19-52-g438c5ff-dirty scandir for ./root failed: No such file or directory unable to traverse_directory Making image is aborted. mkfs.btrfs: mkfs.c:1402: main: Assertion `!(ret)' failed. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> 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>
* btrfs-progs: Add new feature to mkfs.btrfs to make file system image file ↵Donggeun Kim2011-10-25
| | | | | | | | | | | | | | | | | | from source directory Changes from V1 to V2: - support extended attributes - move btrfs_alloc_data_chunk function to volumes.c - fix an execution error when additional useless parameters are specified - fix traverse_directory function so that the insertion functions for the common items are invoked in a single point The extended attributes is implemented through llistxattr and getxattr function calls. Thanks Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs-progs: add support for mixed data+metadata block groupsJosef Bacik2011-10-25
| | | | | | | | | | | | So alot of crazy people (I'm looking at you Meego) want to use btrfs on phones and such with small devices. Unfortunately the way we split out metadata/data chunks it makes space usage inefficient for volumes that are smaller than 1gigabyte. So add a -M option for mixing metadata+data, and default to this mixed mode if the filesystem is less than or equal to 1 gigabyte. I've tested this with xfstests on a 100mb filesystem and everything is a-ok. Signed-off-by: Josef Bacik <josef@redhat.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 -V|--version to mkfs.btrfs argument parserLuca Bruno2009-06-03
| | | | | | | | | | | | | | | mkfs.btrfs now prints its version when invoked with -V|--version and exits without error. All other mkfs.* tools provide this feature and follow this implicit argument naming convention, as it is commonly used to check for helper tools presence. The corrisponding manual already mentions this option, no need to touch it. Signed-off-by: Luca Bruno <lucab@debian.org> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Fix mispatch of the experimental warningsChris Mason2009-01-11
| | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Fix mkfs.btrfs usage help to match the current argsShen Feng2009-01-07
| | | | | Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
* Make the minimum filesystem size error message more clearShen Feng2009-01-07
| | | | | Signed-off-by: Shen Feng <shen@cn.fujitsu.com>
* Btrfs: update converter for the new disk formatYan Zheng2008-12-17
| | | | | | | | | | | This patch updates the ext3 to btrfs converter for the new disk format. This mainly involves changing the convert's data relocation and free space management code. This patch also ports some functions from kernel module to btrfs-progs. Thank you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* superblock duplicationYan Zheng2008-12-05
| | | | | | | | | | This patch updates btrfs-progs for superblock duplication. Note: I didn't make this patch as complete as the one for kernel since updating the converter requires changing the code again. Thank you, Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* Btrfs: move data checksumming into a dedicated treeChris Mason2008-12-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Btrfs stores checksums for each data block. Until now, they have been stored in the subvolume trees, indexed by the inode that is referencing the data block. This means that when we read the inode, we've probably read in at least some checksums as well. But, this has a few problems: * The checksums are indexed by logical offset in the file. When compression is on, this means we have to do the expensive checksumming on the uncompressed data. It would be faster if we could checksum the compressed data instead. * If we implement encryption, we'll be checksumming the plain text and storing that on disk. This is significantly less secure. * For either compression or encryption, we have to get the plain text back before we can verify the checksum as correct. This makes the raid layer balancing and extent moving much more expensive. * It makes the front end caching code more complex, as we have touch the subvolume and inodes as we cache extents. * There is potentitally one copy of the checksum in each subvolume referencing an extent. The solution used here is to store the extent checksums in a dedicated tree. This allows us to index the checksums by phyiscal extent start and length. It means: * The checksum is against the data stored on disk, after any compression or encryption is done. * The checksum is stored in a central location, and can be verified without following back references, or reading inodes. This makes compression significantly faster by reducing the amount of data that needs to be checksummed. It will also allow much faster raid management code in general. The checksums are indexed by a key with a fixed objectid (a magic value in ctree.h) and offset set to the starting byte of the extent. This allows us to copy the checksum items into the fsync log tree directly (or any other tree), without having to invent a second format for them. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Add root tree pointer transaction idsYan Zheng2008-10-29
| | | | | | | | | | This patch adds transaction IDs to root tree pointers. Transaction IDs in tree pointers are compared with the generation numbers in block headers when reading root blocks of trees. This can detect some types of IO errors. Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
* update mkfs.btrfs for the new space balancing codeZheng Yan2008-09-26
| | | | | | | The new space balancing code needs a subvol to store the temporary inode for data extent relocation. Signed-off-by: Chris Mason <chris.mason@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.
* btrfs-progs new dir index supportJosef Bacik2008-07-24
|
* Print the version string in a few programsChris Mason2008-07-24
|
* Add a readonly flag open_ctree to force RO opensChris Mason2008-05-05
|
* Fix uninitialized variables, and use -O so gcc starts checking for themChris Mason2008-05-01
| | | | | | | | Gcc only sends warnings for uninitialized variables when you compile with -O, and there were a couple of bugs sprinkled in the code. The biggest was the alloc_start variable for mkfs, which can cause strange things to happen. (thanks to Gabor Micsko for helping to find this)
* Add btrfs-vol command to balance, add and (eventually) remove devicesChris Mason2008-04-28
|
* Add mkfs.btrfs -A offset to control allocation start on devicesChris Mason2008-04-25
| | | | | | This is a utility option for the resizer, it makes sure to allocate at offset bytes in the disk or higher. It ensures the resizer will have something to move when testing it.
* Update the Ext3 converterChris Mason2008-04-22
| | | | | | | | | | | The main changes in this patch are adding chunk handing and data relocation ability. In the last step of conversion, the converter relocates data in system chunk and move chunk tree into system chunk. In the rollback process, the converter remove chunk tree from system chunk and copy data back. Regards YZ ---
* Add a command to show all of the btrfs filesystems on the box (btrfs-show)Chris Mason2008-04-22
|
* Add checks to avoid adding the same device twice during mkfsChris Mason2008-04-18
|
* Use better chunk sizes for small and large filesystemsChris Mason2008-04-18
|
* Add support for filesystem labels via mkfs.btrfs -LChris Mason2008-04-18
|
* Add raid10 supportChris Mason2008-04-16
|
* Add chunk uuids and update multi-device back referencesChris Mason2008-04-15
| | | | | | | | | | | | | | | | | | Block headers now store the chunk tree uuid Chunk items records the device uuid for each stripes Device extent items record better back refs to the chunk tree Block groups record better back refs to the chunk tree The chunk tree format has also changed. The objectid of BTRFS_CHUNK_ITEM_KEY used to be the logical offset of the chunk. Now it is a chunk tree id, with the logical offset being stored in the offset field of the key. This allows a single chunk tree to record multiple logical address spaces, upping the number of bytes indexed by a chunk tree from 2^64 to 2^128.
* Use leafsize and nodesize == pagesize for nowChris Mason2008-04-09
|
* Recow all roots at the end of mkfsChris Mason2008-04-04
| | | | | | The mkfs code bootstraps the filesystem on a single device. Once the raid block groups are setup, it needs to recow all of the blocks so that each tree is properly allocated.
* Add mkfs options for data and metadata mirroring modesChris Mason2008-04-03
| | | | | | | | | | | | | | mkfs.btrfs --data {raid0,raid1,single} mkfs.btrfs --metadata {raid0,raid1,single} In single mode, no extra duplication or striping is done. In raid0 mode, blocks are spread across all of the available devices In raid1 mode, blocks are mirrored across two devices. For metadata, if raid1 is used and there is only one device, the metadata is duplicated on that single spindle. The defaults are raid0 for data and raid1 for metadata
* Add support for single single duplication of metadataChris Mason2008-04-03
|
* Add mirroring support across multiple drivesChris Mason2008-04-03
|
* Use getopt_long and introduce long mkfs options. -s now means --sectorsizeChris Mason2008-04-01
|
* check if partition is mounted before mkfsGoldwyn Rodrigues2008-04-01
| | | | | | | | This saves from the blunder of formatting a live mounted filesystem. This can be extended to get the mount flags of the filesystem mounted. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@gmail.com>
* Walk all block devices looking for btrfsChris Mason2008-03-24
|
* ioctls to scan for btrfs filesystemsChris Mason2008-03-24
|
* Add support for multiple devices per filesystemChris Mason2008-03-24
|
* mkfs: Zero 2MB at the start and end of the deviceChris Mason2008-02-15
| | | | But, on sparc, don't zero the first 1k.
* Update btrfs-progs to match kernel sourcesYan2008-01-04
|