summaryrefslogtreecommitdiff
path: root/file.c
Commit message (Collapse)AuthorAge
* btrfs-progs: Get rid of the confusing btrfs_file_extent_inline_len()Qu Wenruo2018-08-06
| | | | | | | | | | | | | | | | | | | | | | | | [BUG] If one uncompressed inline extent has incorrect ram_bytes, neither btrfs check nor dump-tree could detect such corruption. [CAUSE] Every caller tries to read inline extent ram_bytes is using btrfs_file_extent_inline_len(), other than directly calling btrfs_file_extent_ram_bytes(). For compressed extent, it's just calling btrfs_file_extent_ram_bytes(). However for uncompressed extent, it falls back to btrfs_file_extent_inline_item_len(), makes us unable to detect anything wrong in ram_bytes. [FIX] Just get rid of such confusing btrfs_file_extent_inline_len() function. Reported-by: Steve Leung <sjleung@shaw.ca> Tested-by: Steve Leung <sjleung@shaw.ca> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Refactor read_extent_data to use btrfs_fs_infoQu Wenruo2017-07-12
| | | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
* btrfs-progs: Refactor sectorsize users in file.cQu Wenruo2017-07-03
| | | | Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.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: typo review of strings and commentsNicholas D Steeves2016-06-01
| | | | | Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com> Signed-off-by: David Sterba <dsterba@suse.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>