aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/btrfs_inode.h31
-rw-r--r--fs/btrfs/compression.c43
-rw-r--r--fs/btrfs/compression.h30
-rw-r--r--fs/btrfs/ctree.c2
-rw-r--r--fs/btrfs/ctree.h39
-rw-r--r--fs/btrfs/delayed-inode.c2
-rw-r--r--fs/btrfs/dev-replace.c5
-rw-r--r--fs/btrfs/dev-replace.h5
-rw-r--r--fs/btrfs/dir-item.c9
-rw-r--r--fs/btrfs/disk-io.c17
-rw-r--r--fs/btrfs/disk-io.h2
-rw-r--r--fs/btrfs/extent-tree.c135
-rw-r--r--fs/btrfs/extent_io.c75
-rw-r--r--fs/btrfs/extent_io.h50
-rw-r--r--fs/btrfs/file-item.c12
-rw-r--r--fs/btrfs/file.c139
-rw-r--r--fs/btrfs/free-space-cache.c5
-rw-r--r--fs/btrfs/inode-map.c2
-rw-r--r--fs/btrfs/inode.c416
-rw-r--r--fs/btrfs/ioctl.c38
-rw-r--r--fs/btrfs/lzo.c12
-rw-r--r--fs/btrfs/ordered-data.c9
-rw-r--r--fs/btrfs/ordered-data.h7
-rw-r--r--fs/btrfs/relocation.c17
-rw-r--r--fs/btrfs/scrub.c11
-rw-r--r--fs/btrfs/tests/inode-tests.c46
-rw-r--r--fs/btrfs/transaction.c6
-rw-r--r--fs/btrfs/tree-log.c92
-rw-r--r--fs/btrfs/volumes.c21
-rw-r--r--fs/btrfs/volumes.h12
-rw-r--r--fs/btrfs/zlib.c9
31 files changed, 673 insertions, 626 deletions
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 819a6d27218a..0c6baaba0651 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -237,20 +237,20 @@ static inline u64 btrfs_ino(struct btrfs_inode *inode)
237 return ino; 237 return ino;
238} 238}
239 239
240static inline void btrfs_i_size_write(struct inode *inode, u64 size) 240static inline void btrfs_i_size_write(struct btrfs_inode *inode, u64 size)
241{ 241{
242 i_size_write(inode, size); 242 i_size_write(&inode->vfs_inode, size);
243 BTRFS_I(inode)->disk_i_size = size; 243 inode->disk_i_size = size;
244} 244}
245 245
246static inline bool btrfs_is_free_space_inode(struct inode *inode) 246static inline bool btrfs_is_free_space_inode(struct btrfs_inode *inode)
247{ 247{
248 struct btrfs_root *root = BTRFS_I(inode)->root; 248 struct btrfs_root *root = inode->root;
249 249
250 if (root == root->fs_info->tree_root && 250 if (root == root->fs_info->tree_root &&
251 btrfs_ino(BTRFS_I(inode)) != BTRFS_BTREE_INODE_OBJECTID) 251 btrfs_ino(inode) != BTRFS_BTREE_INODE_OBJECTID)
252 return true; 252 return true;
253 if (BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) 253 if (inode->location.objectid == BTRFS_FREE_INO_OBJECTID)
254 return true; 254 return true;
255 return false; 255 return false;
256} 256}
@@ -311,34 +311,33 @@ struct btrfs_dio_private {
311 * to grab i_mutex. It is used to avoid the endless truncate due to 311 * to grab i_mutex. It is used to avoid the endless truncate due to
312 * nonlocked dio read. 312 * nonlocked dio read.
313 */ 313 */
314static inline void btrfs_inode_block_unlocked_dio(struct inode *inode) 314static inline void btrfs_inode_block_unlocked_dio(struct btrfs_inode *inode)
315{ 315{
316 set_bit(BTRFS_INODE_READDIO_NEED_LOCK, &BTRFS_I(inode)->runtime_flags); 316 set_bit(BTRFS_INODE_READDIO_NEED_LOCK, &inode->runtime_flags);
317 smp_mb(); 317 smp_mb();
318} 318}
319 319
320static inline void btrfs_inode_resume_unlocked_dio(struct inode *inode) 320static inline void btrfs_inode_resume_unlocked_dio(struct btrfs_inode *inode)
321{ 321{
322 smp_mb__before_atomic(); 322 smp_mb__before_atomic();
323 clear_bit(BTRFS_INODE_READDIO_NEED_LOCK, 323 clear_bit(BTRFS_INODE_READDIO_NEED_LOCK, &inode->runtime_flags);
324 &BTRFS_I(inode)->runtime_flags);
325} 324}
326 325
327static inline void btrfs_print_data_csum_error(struct inode *inode, 326static inline void btrfs_print_data_csum_error(struct btrfs_inode *inode,
328 u64 logical_start, u32 csum, u32 csum_expected, int mirror_num) 327 u64 logical_start, u32 csum, u32 csum_expected, int mirror_num)
329{ 328{
330 struct btrfs_root *root = BTRFS_I(inode)->root; 329 struct btrfs_root *root = inode->root;
331 330
332 /* Output minus objectid, which is more meaningful */ 331 /* Output minus objectid, which is more meaningful */
333 if (root->objectid >= BTRFS_LAST_FREE_OBJECTID) 332 if (root->objectid >= BTRFS_LAST_FREE_OBJECTID)
334 btrfs_warn_rl(root->fs_info, 333 btrfs_warn_rl(root->fs_info,
335 "csum failed root %lld ino %lld off %llu csum 0x%08x expected csum 0x%08x mirror %d", 334 "csum failed root %lld ino %lld off %llu csum 0x%08x expected csum 0x%08x mirror %d",
336 root->objectid, btrfs_ino(BTRFS_I(inode)), 335 root->objectid, btrfs_ino(inode),
337 logical_start, csum, csum_expected, mirror_num); 336 logical_start, csum, csum_expected, mirror_num);
338 else 337 else
339 btrfs_warn_rl(root->fs_info, 338 btrfs_warn_rl(root->fs_info,
340 "csum failed root %llu ino %llu off %llu csum 0x%08x expected csum 0x%08x mirror %d", 339 "csum failed root %llu ino %llu off %llu csum 0x%08x expected csum 0x%08x mirror %d",
341 root->objectid, btrfs_ino(BTRFS_I(inode)), 340 root->objectid, btrfs_ino(inode),
342 logical_start, csum, csum_expected, mirror_num); 341 logical_start, csum, csum_expected, mirror_num);
343} 342}
344 343
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 903c32c9eb22..c7721a6aa3bb 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -100,7 +100,7 @@ static struct bio *compressed_bio_alloc(struct block_device *bdev,
100 return btrfs_bio_alloc(bdev, first_byte >> 9, BIO_MAX_PAGES, gfp_flags); 100 return btrfs_bio_alloc(bdev, first_byte >> 9, BIO_MAX_PAGES, gfp_flags);
101} 101}
102 102
103static int check_compressed_csum(struct inode *inode, 103static int check_compressed_csum(struct btrfs_inode *inode,
104 struct compressed_bio *cb, 104 struct compressed_bio *cb,
105 u64 disk_start) 105 u64 disk_start)
106{ 106{
@@ -111,7 +111,7 @@ static int check_compressed_csum(struct inode *inode,
111 u32 csum; 111 u32 csum;
112 u32 *cb_sum = &cb->sums; 112 u32 *cb_sum = &cb->sums;
113 113
114 if (BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM) 114 if (inode->flags & BTRFS_INODE_NODATASUM)
115 return 0; 115 return 0;
116 116
117 for (i = 0; i < cb->nr_pages; i++) { 117 for (i = 0; i < cb->nr_pages; i++) {
@@ -125,7 +125,7 @@ static int check_compressed_csum(struct inode *inode,
125 125
126 if (csum != *cb_sum) { 126 if (csum != *cb_sum) {
127 btrfs_print_data_csum_error(inode, disk_start, csum, 127 btrfs_print_data_csum_error(inode, disk_start, csum,
128 *cb_sum, cb->mirror_num); 128 *cb_sum, cb->mirror_num);
129 ret = -EIO; 129 ret = -EIO;
130 goto fail; 130 goto fail;
131 } 131 }
@@ -165,7 +165,7 @@ static void end_compressed_bio_read(struct bio *bio)
165 goto out; 165 goto out;
166 166
167 inode = cb->inode; 167 inode = cb->inode;
168 ret = check_compressed_csum(inode, cb, 168 ret = check_compressed_csum(BTRFS_I(inode), cb,
169 (u64)bio->bi_iter.bi_sector << 9); 169 (u64)bio->bi_iter.bi_sector << 9);
170 if (ret) 170 if (ret)
171 goto csum_failed; 171 goto csum_failed;
@@ -911,32 +911,28 @@ static void free_workspaces(void)
911} 911}
912 912
913/* 913/*
914 * given an address space and start/len, compress the bytes. 914 * Given an address space and start and length, compress the bytes into @pages
915 * that are allocated on demand.
915 * 916 *
916 * pages are allocated to hold the compressed result and stored 917 * @out_pages is an in/out parameter, holds maximum number of pages to allocate
917 * in 'pages' 918 * and returns number of actually allocated pages
918 * 919 *
919 * out_pages is used to return the number of pages allocated. There 920 * @total_in is used to return the number of bytes actually read. It
920 * may be pages allocated even if we return an error 921 * may be smaller than the input length if we had to exit early because we
921 *
922 * total_in is used to return the number of bytes actually read. It
923 * may be smaller then len if we had to exit early because we
924 * ran out of room in the pages array or because we cross the 922 * ran out of room in the pages array or because we cross the
925 * max_out threshold. 923 * max_out threshold.
926 * 924 *
927 * total_out is used to return the total number of compressed bytes 925 * @total_out is an in/out parameter, must be set to the input length and will
926 * be also used to return the total number of compressed bytes
928 * 927 *
929 * max_out tells us the max number of bytes that we're allowed to