summaryrefslogtreecommitdiff
path: root/utils.c
Commit message (Collapse)AuthorAge
* Scan the devices listed in /proc/partitionsGoffredo Baroncelli2011-10-25
| | | | | | | | | | | During the commands: - btrfs filesystem show - btrfs device scan the devices "scanned" are extracted from /proc/partitions. This should avoid to scan devices not suitable for a btrfs filesystem like cdrom and floppy or to scan not existant devices. The old behavior (scan all the block devices under /dev) may be forced passing the "--all-devices" switch.
* btrfs-progs: added check_mounted_whereJan Schmidt2011-10-25
| | | | | | | | | new version of check_mounted() returning more information gathered while searching. check_mounted() is now a wrapper for check_mounted_where(). the new version is needed by scrub.c Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* mkfs should initialize unused fields properlyJan Schmidt2011-10-25
| | | | | | | | | | | we discovered speed setting is (probably unintentionally) initialized to 1 in make_btrfs(), while being initialized to 0 in btrfs_add_to_fsid(). initialization in make_btrfs() is due to reuse of buf after pwrite() without clearing it. consequently, code like btrfs_set_extent_generation(buf, extent_item, 1); writes to the same location in buf where speed will be placed, later. It may be a good idea to clear buf after each pwrite(), though leaving the struct btrfs_header intact. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* btrfs-progs: setting of time to the root directoryTsutomu Itoh2011-10-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the setting of time to the root directory to the mkfs.btrfs command. As a result, the time of the mount point not correctly displayed comes to be displayed correctly. [before] # mkfs.btrfs /dev/sdd10 # mount /dev/sdd10 /test1 # ls -ld /test1 dr-xr-xr-x 1 root root 0 Jan 1 1970 /test1 [after] # date Tue Nov 16 18:06:05 JST 2010 # mkfs.btrfs /dev/sdd10 # mount /dev/sdd10 /test1 # ls -ld /test1 dr-xr-xr-x 1 root root 0 Nov 16 18:06 /test1 Thanks, Tsutomu Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
* btrfs-progs: add discard support to mkfsChristoph Hellwig2011-10-25
| | | | | | | | Discard the whole device before starting to create the filesystem structures. Modelled after similar support in mkfs.xfs. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Add the "btrfs filesystem label" commandGoffredo Baroncelli2011-10-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi all, this patch adds the command "btrfs filesystem label" to change (or show) the label of a filesystem. This patch is a subset of the one written previously by Morey Roof. I included the user space part only. So it is possible only to change/show a label of a *single device* and *unounted* filesystem. The reason of excluding the kernel space part, is to simplify the patch in order to speed the check and then the merging of the patch itself. In fact I have to point out that in the past there was almost three attempts to propose this patch, without success neither complaints. Chris, let me know how you want to proceed. I know that you are very busy, and you prefer to work to stabilize btrfs instead adding new feature. But I think that changing a label is a *essential* feature for a filesystem managing tool. Think about a mount by LABEL. To show a label $ btrfs filesystem label <device> To set a label $ btrfs filesystem label <device> <newlabel> Please guys, give a look to the source. Comments are welcome. You can pull the source from the branch "label" of the repository http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git Regards G.Baroncelli 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>
* Btrfs-progs: update super fields for space cacheJosef Bacik2011-10-25
| | | | | | | | | This patch updates the super field to add the cache_generation member. It also makes us set it to -1 on mkfs so any new filesystem will get the space cache stuff turned on. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Improve error handling in the btrfs commandGoffredo Baroncelli2011-10-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hi Chris, below is enclosed a trivial patch, which has the aim to improve the error reporting of the "btrfs" command. You can pull from http://cassiopea.homelinux.net/git/btrfs-progs-unstable.git branch strerror I changed every printf("some-error") to something like: e = errno; fprintf(stderr, "ERROR: .... - %s", strerror(e)); so: 1) all the error are reported to standard error 2) At the end of the message is printed the error as returned by the system. The change is quite simple, I replaced every printf("some-error") to the line above. I don't touched anything other. I also integrated a missing "printf" on the basis of the Ben patch. This patch leads the btrfs command to be more "user friendly" :-) Regards G.Baroncelli btrfs-list.c | 40 ++++++++++++++++++++++-------- btrfs_cmds.c | 77 ++++++++++++++++++++++++++++++++++++++++----------------- utils.c | 6 ++++ 3 files changed, 89 insertions(+), 34 deletions(-) Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs-progs utils Informative errorsGoldwyn Rodrigues2011-10-25
| | | | Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Btrfs-progs use safe string manipulation functionsEduardo Silva2011-10-25
| | | | | Signed-off-by: Eduardo Silva <eduardo.silva@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
* multidevice support for check_mountedAndi Drebes2010-09-23
| | | | | | | | | | | | | | Check_mount() should also work with multi device filesystems. This patch adds checks that allow to detect if a file is a device file used by a mounted single or multi device btrfs or if it is a regular file used by a loopback device that is part of a mounted single or multi device btrfs. The single device checks also work for non-btrfs filesystems. This might be helpful to prevent users from running btrfs programs (e.g. mkfs.btrfs) accidentally on a filesystem used somewhere else. Signed-off-by: Andi Drebes <lists-receive@programmierforen.de>
* 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
* Mention minimum size on devices that are considered too smallJan Engelhardt2009-01-21
| | | | | Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
* Fix ioctl arg size (userland incompatible change!)Chris Mason2009-01-16
| | | | | | | | | | | | | | | The structure used to send device in btrfs ioctl calls was not properly aligned, and so 32 bit ioctls would not work properly on 64 bit kernels. We could fix this with compat ioctls, but we're just one byte away and it doesn't make sense at this stage to carry about the compat ioctls forever at this stage in the project. This patch brings the ioctl arg up to an evenly aligned 4k. Signed-off-by: Chris Mason <chris.mason@oracle.com>
* Add error processing for btrfsctl -aShen Feng2009-01-07
| | | | | | | | | | | brfsctl -a will do nothing and no error is output if btrfs.ko is not inserted. Since no caller do error processing for btrfs_register_one_device, make its return void and do error processing inside. 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>
* btrfs-progs: support for different csum algorithimsJosef Bacik2008-12-02
| | | | | | | | | | | | | This is the btrfs-progs version of the patch to add the ability to have different csum algorithims. Note I didn't change the image maker since it seemed a bit more complicated than just changing some stuff around so I will let Yan take care of that. Everything else was converted and for now a mkfs just sets the type to be BTRFS_CSUM_TYPE_CRC32. Signed-off-by: Josef Bacik <jbacik@redhat.com>
* update btrfs-progs for seed device supportYan Zheng2008-11-18
| | | | | | | | | | | | This patch does the following: 1) Update device management code to match the kernel code. 2) Allocator fixes. 3) Add a program called btrfstune to set/clear the SEEDING super block flags.
* 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>
* Count space allocated to file in bytesYan Zheng2008-10-09
| | | | | | | | This patch updates btrfs-progs for counting space allocated to file in bytes. 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.
* btrfs-progs new dir index supportJosef Bacik2008-07-24
|
* Fix the pretty print code for num_bytes == 0Chris Mason2008-05-12
|
* 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)
* 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
|
* Add support for filesystem labels via mkfs.btrfs -LChris Mason2008-04-18
|
* 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.
* Write all super blocks during commitChris Mason2008-04-10
|
* Retry metadata reads in the face of checksum failuresChris 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 mirroring support across multiple drivesChris Mason2008-04-03
|
* btrfs-progs: Fix printf format casting errorsAlex Chiang2008-04-01
| | | | | | | | | | | We get lots of warnings of the flavor: utils.c:441: warning: format '%Lu' expects type 'long long unsigned int' but argument 2 has type 'u64' And thanks to -Werror, the build fails. Clean up these printfs by properly casting the arg to the format specified. Signed-off-by: Alex Chiang <achiang@hp.com>
* 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
|
* Btrfsck updates for multi-device filesystemsChris Mason2008-03-24
|
* Add support for multiple devices per filesystemChris Mason2008-03-24
|
* btrfs-progs: fix a buffer overflow during mkfsJan Engelhardt2008-01-22
| | | | | | | | | | | | Using strncpy avoids a 1 byte overflow into the next field of the struct. The overflow is harmless, but does trip automated tools. Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de> --- utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
* Add rollback support for the converterYan2008-01-08
| | | | | | This patch adds rollback support for the converter, the converter can roll back a conversion if the image file haven't been modified. In addition, I rearrange some codes in convert.c and add a few comments.
* Update btrfs-progs to match kernel sourcesYan2008-01-04