aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/check-integrity.c4
-rw-r--r--fs/btrfs/compression.c2
-rw-r--r--fs/btrfs/disk-io.c5
-rw-r--r--fs/btrfs/extent-tree.c1
-rw-r--r--fs/btrfs/inode.c4
-rw-r--r--fs/btrfs/ioctl.c22
-rw-r--r--fs/btrfs/send.c22
-rw-r--r--fs/btrfs/super.c13
-rw-r--r--fs/btrfs/sysfs.c10
9 files changed, 45 insertions, 38 deletions
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 49a62b4dda3b..0e8388e72d8d 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -92,11 +92,11 @@
92#include <linux/slab.h> 92#include <linux/slab.h>
93#include <linux/buffer_head.h> 93#include <linux/buffer_head.h>
94#include <linux/mutex.h> 94#include <linux/mutex.h>
95#include <linux/crc32c.h>
96#include <linux/genhd.h> 95#include <linux/genhd.h>
97#include <linux/blkdev.h> 96#include <linux/blkdev.h>
98#include "ctree.h" 97#include "ctree.h"
99#include "disk-io.h" 98#include "disk-io.h"
99#include "hash.h"
100#include "transaction.h" 100#include "transaction.h"
101#include "extent_io.h" 101#include "extent_io.h"
102#include "volumes.h" 102#include "volumes.h"
@@ -1823,7 +1823,7 @@ static int btrfsic_test_for_metadata(struct btrfsic_state *state,
1823 size_t sublen = i ? PAGE_CACHE_SIZE : 1823 size_t sublen = i ? PAGE_CACHE_SIZE :
1824 (PAGE_CACHE_SIZE - BTRFS_CSUM_SIZE); 1824 (PAGE_CACHE_SIZE - BTRFS_CSUM_SIZE);
1825 1825
1826 crc = crc32c(crc, data, sublen); 1826 crc = btrfs_crc32c(crc, data, sublen);
1827 } 1827 }
1828 btrfs_csum_final(crc, csum); 1828 btrfs_csum_final(crc, csum);
1829 if (memcmp(csum, h->csum, state->csum_size)) 1829 if (memcmp(csum, h->csum, state->csum_size))
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index e2600cdb6c25..b01fb6c527e3 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -1010,6 +1010,8 @@ int btrfs_decompress_buf2page(char *buf, unsigned long buf_start,
1010 bytes = min(bytes, working_bytes); 1010 bytes = min(bytes, working_bytes);
1011 kaddr = kmap_atomic(page_out); 1011 kaddr = kmap_atomic(page_out);
1012 memcpy(kaddr + *pg_offset, buf + buf_offset, bytes); 1012 memcpy(kaddr + *pg_offset, buf + buf_offset, bytes);
1013 if (*pg_index == (vcnt - 1) && *pg_offset == 0)
1014 memset(kaddr + bytes, 0, PAGE_CACHE_SIZE - bytes);
1013 kunmap_atomic(kaddr); 1015 kunmap_atomic(kaddr);
1014 flush_dcache_page(page_out); 1016 flush_dcache_page(page_out);
1015 1017
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0e69295d0031..81ea55314b1f 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -26,7 +26,6 @@
26#include <linux/workqueue.h> 26#include <linux/workqueue.h>
27#include <linux/kthread.h> 27#include <linux/kthread.h>
28#include <linux/freezer.h> 28#include <linux/freezer.h>
29#include <linux/crc32c.h>
30#include <linux/slab.h> 29#include <linux/slab.h>
31#include <linux/migrate.h> 30#include <linux/migrate.h>
32#include <linux/ratelimit.h> 31#include <linux/ratelimit.h>
@@ -35,6 +34,7 @@
35#include <asm/unaligned.h> 34#include <asm/unaligned.h>
36#include "ctree.h" 35#include "ctree.h"
37#include "disk-io.h" 36#include "disk-io.h"
37#include "hash.h"
38#include "transaction.h" 38#include "transaction.h"
39#include "btrfs_inode.h" 39#include "btrfs_inode.h"
40#include "volumes.h" 40#include "volumes.h"
@@ -244,7 +244,7 @@ out:
244 244
245u32 btrfs_csum_data(char *data, u32 seed, size_t len) 245u32 btrfs_csum_data(char *data, u32 seed, size_t len)
246{ 246{
247 return crc32c(seed, data, len); 247 return btrfs_crc32c(seed, data, len);
248} 248}
249 249
250void btrfs_csum_final(u32 crc, char *result) 250void btrfs_csum_final(u32 crc, char *result)
@@ -3839,7 +3839,6 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
3839 rb_erase(&ref->rb_node, &head->ref_root); 3839 rb_erase(&ref->rb_node, &head->ref_root);
3840 atomic_dec(&delayed_refs->num_entries); 3840 atomic_dec(&delayed_refs->num_entries);
3841 btrfs_put_delayed_ref(ref); 3841 btrfs_put_delayed_ref(ref);
3842 cond_resched_lock(&head->lock);
3843 } 3842 }
3844 if (head->must_insert_reserved) 3843 if (head->must_insert_reserved)
3845 pin_bytes = true; 3844 pin_bytes = true;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9c9ecc93ae2c..32312e09f0f5 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2385,6 +2385,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
2385 spin_unlock(&delayed_refs->lock); 2385 spin_unlock(&delayed_refs->lock);
2386 locked_ref = NULL; 2386 locked_ref = NULL;
2387 cond_resched(); 2387 cond_resched();
2388 count++;
2388 continue; 2389 continue;
2389 } 2390 }
2390 2391
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 5c4ab9c18940..d3d44486290b 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2629,7 +2629,7 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
2629 EXTENT_DEFRAG, 1, cached_state); 2629 EXTENT_DEFRAG, 1, cached_state);
2630 if (ret) { 2630 if (ret) {
2631 u64 last_snapshot = btrfs_root_last_snapshot(&root->root_item); 2631 u64 last_snapshot = btrfs_root_last_snapshot(&root->root_item);
2632 if (last_snapshot >= BTRFS_I(inode)->generation) 2632 if (0 && last_snapshot >= BTRFS_I(inode)->generation)
2633 /* the inode is shared */ 2633 /* the inode is shared */
2634 new = record_old_file_extents(inode, ordered_extent); 2634 new = record_old_file_extents(inode, ordered_extent);
2635 2635
@@ -5154,7 +5154,7 @@ static struct dentry *btrfs_lookup(struct inode *dir, struct dentry *dentry,
5154 return ERR_CAST(inode); 5154 return ERR_CAST(inode);
5155 } 5155 }
5156 5156
5157 return d_splice_alias(inode, dentry); 5157 return d_materialise_unique(dentry, inode);
5158} 5158}
5159 5159
5160unsigned char btrfs_filetype_table[] = { 5160unsigned char btrfs_filetype_table[] = {
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b0134892dc70..a6d8efa46bfe 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3537,20 +3537,6 @@ out:
3537 return ret; 3537 return ret;
3538} 3538}
3539 3539
3540static long btrfs_ioctl_global_rsv(struct btrfs_root *root, void __user *arg)
3541{
3542 struct btrfs_block_rsv *block_rsv = &root->fs_info->global_block_rsv;
3543 u64 reserved;
3544
3545 spin_lock(&block_rsv->lock);
3546 reserved = block_rsv->reserved;
3547 spin_unlock(&block_rsv->lock);
3548
3549 if (arg && copy_to_user(arg, &reserved, sizeof(reserved)))
3550 return -EFAULT;
3551 return 0;
3552}
3553
3554/* 3540/*
3555 * there are many ways the trans_start and trans_end ioctls can lead 3541 * there are many ways the trans_start and trans_end ioctls can lead
3556 * to deadlocks. They should only be used by applications that 3542 * to deadlocks. They should only be used by applications that
@@ -4525,7 +4511,7 @@ static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg)
4525 spin_lock(&root->fs_info->super_lock); 4511 spin_lock(&root->fs_info->super_lock);
4526 strcpy(super_block->label, label); 4512 strcpy(super_block->label, label);
4527 spin_unlock(&root->fs_info->super_lock); 4513 spin_unlock(&root->fs_info->super_lock);
4528 ret = btrfs_end_transaction(trans, root); 4514 ret = btrfs_commit_transaction(trans, root);
4529 4515
4530out_unlock: 4516out_unlock:
4531 mnt_drop_write_file(file); 4517 mnt_drop_write_file(file);
@@ -4668,7 +4654,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
4668 if (ret) 4654 if (ret)
4669 return ret; 4655 return ret;
4670 4656
4671 trans = btrfs_start_transaction(root, 1); 4657 trans = btrfs_start_transaction(root, 0);
4672 if (IS_ERR(trans)) 4658 if (IS_ERR(trans))
4673 return PTR_ERR(trans); 4659 return PTR_ERR(trans);
4674 4660
@@ -4689,7 +4675,7 @@ static int btrfs_ioctl_set_features(struct file *file, void __user *arg)
4689 btrfs_set_super_incompat_flags(super_block, newflags); 4675 btrfs_set_super_incompat_flags(super_block, newflags);
4690 spin_unlock(&root->fs_info->super_lock); 4676 spin_unlock(&root->fs_info->super_lock);
4691 4677
4692 return btrfs_end_transaction(trans, root); 4678 return btrfs_commit_transaction(trans, root);
4693} 4679}
4694 4680
4695long btrfs_ioctl(struct file *file, unsigned int 4681long btrfs_ioctl(struct file *file, unsigned int
@@ -4757,8 +4743,6 @@ long btrfs_ioctl(struct file *file, unsigned int
4757 return btrfs_ioctl_logical_to_ino(root, argp); 4743 return btrfs_ioctl_logical_to_ino(root, argp);
4758 case BTRFS_IOC_SPACE_INFO: 4744 case BTRFS_IOC_SPACE_INFO:
4759 return btrfs_ioctl_space_info(root, argp); 4745 return btrfs_ioctl_space_info(root, argp);
4760 case BTRFS_IOC_GLOBAL_RSV:
4761 return btrfs_ioctl_global_rsv(root, argp);
4762 case BTRFS_IOC_SYNC: { 4746 case BTRFS_IOC_SYNC: {
4763 int ret; 4747 int ret;
4764 4748
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index 730dce395858..9dde9717c1b9 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -24,12 +24,12 @@
24#include <linux/xattr.h> 24#include <linux/xattr.h>
25#include <linux/posix_acl_xattr.h> 25#include <linux/posix_acl_xattr.h>
26#include <linux/radix-tree.h> 26#include <linux/radix-tree.h>
27#include <linux/crc32c.h>
28#include <linux/vmalloc.h> 27#include <linux/vmalloc.h>
29#include <linux/string.h> 28#include <linux/string.h>
30 29
31#include "send.h" 30#include "send.h"
32#include "backref.h" 31#include "backref.h"
32#include "hash.h"
33#include "locking.h" 33#include "locking.h"
34#include "disk-io.h" 34#include "disk-io.h"
35#include "btrfs_inode.h" 35#include "btrfs_inode.h"
@@ -620,7 +620,7 @@ static int send_cmd(struct send_ctx *sctx)
620 hdr->len = cpu_to_le32(sctx->send_size - sizeof(*hdr)); 620 hdr->len = cpu_to_le32(sctx->send_size - sizeof(*hdr));
621 hdr->crc = 0; 621 hdr->crc = 0;
622 622
623 crc = crc32c(0, (unsigned char *)sctx->send_buf, sctx->send_size); 623 crc = btrfs_crc32c(0, (unsigned char *)sctx->send_buf, sctx->send_size);
624 hdr->crc = cpu_to_le32(crc); 624 hdr->crc = cpu_to_le32(crc);
625 625
626 ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size, 626 ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size,
@@ -1332,6 +1332,16 @@ verbose_printk(KERN_DEBUG "btrfs: find_extent_clone: data_offset=%llu, "
1332 } 1332 }
1333 1333
1334 if (cur_clone_root) { 1334 if (cur_clone_root) {
1335 if (compressed != BTRFS_COMPRESS_NONE) {
1336 /*
1337 * Offsets given by iterate_extent_inodes() are relative
1338 * to the start of the extent, we need to add logical
1339 * offset from the file extent item.
1340 * (See why at backref.c:check_extent_in_eb())
1341 */
1342 cur_clone_root->offset += btrfs_file_extent_offset(eb,
1343 fi);
1344 }
1335 *found = cur_clone_root; 1345 *found = cur_clone_root;
1336 ret = 0; 1346 ret = 0;
1337 } else { 1347 } else {
@@ -2774,8 +2784,6 @@ static int add_waiting_dir_move(struct send_ctx *sctx, u64 ino)
2774 return 0; 2784 return 0;
2775} 2785}
2776 2786
2777#ifdef CONFIG_BTRFS_ASSERT
2778
2779static int del_waiting_dir_move(struct send_ctx *sctx, u64 ino) 2787static int del_waiting_dir_move(struct send_ctx *sctx, u64 ino)
2780{ 2788{
2781 struct rb_node *n = sctx->waiting_dir_moves.rb_node; 2789 struct rb_node *n = sctx->waiting_dir_moves.rb_node;
@@ -2796,8 +2804,6 @@ static int del_waiting_dir_move(struct send_ctx *sctx, u64 ino)
2796 return -ENOENT; 2804 return -ENOENT;
2797} 2805}
2798 2806
2799#endif
2800
2801static int add_pending_dir_move(struct send_ctx *sctx, u64 parent_ino) 2807static int add_pending_dir_move(struct send_ctx *sctx, u64 parent_ino)
2802{ 2808{
2803 struct rb_node **p = &sctx->pending_dir_moves.rb_node; 2809 struct rb_node **p = &sctx->pending_dir_moves.rb_node;
@@ -2902,7 +2908,9 @@ static int apply_dir_move(struct send_ctx *sctx, struct pending_dir_move *pm)
2902 } 2908 }
2903 2909
2904 sctx->send_progress = sctx->cur_ino + 1; 2910 sctx->send_progress = sctx->cur_ino + 1;
2905 ASSERT(del_waiting_dir_move(sctx, pm->ino) == 0); 2911 ret = del_waiting_dir_move(sctx, pm->ino);
2912 ASSERT(ret == 0);
2913
2906 ret = get_cur_path(sctx, pm->ino, pm->gen, to_path); 2914 ret = get_cur_path(sctx, pm->ino, pm->gen, to_path);
2907 if (ret < 0) 2915 if (ret < 0)
2908 goto out; 2916 goto out;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c02f63356895..d04db817be5c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -566,7 +566,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
566 kfree(num); 566 kfree(num);
567 567
568 if (info->max_inline) { 568 if (info->max_inline) {
569 info->max_inline = max_t(u64, 569 info->max_inline = min_t(u64,
570 info->max_inline, 570 info->max_inline,
571 root->sectorsize); 571 root->sectorsize);
572 } 572 }
@@ -855,6 +855,7 @@ static struct dentry *get_default_root(struct super_block *sb,
855 struct btrfs_path *path; 855 struct btrfs_path *path;
856 struct btrfs_key location; 856 struct btrfs_key location;
857 struct inode *inode; 857 struct inode *inode;
858 struct dentry *dentry;
858 u64 dir_id; 859 u64 dir_id;
859 int new = 0; 860 int new = 0;
860 861
@@ -925,7 +926,13 @@ setup_root:
925 return dget(sb->s_root); 926 return dget(sb->s_root);
926 } 927 }
927 928
928 return d_obtain_alias(inode); 929 dentry = d_obtain_alias(inode);
930 if (!IS_ERR(dentry)) {
931 spin_lock(&dentry->d_lock);
932 dentry->d_flags &= ~DCACHE_DISCONNECTED;
933 spin_unlock(&dentry->d_lock);
934 }
935 return dentry;
929} 936}
930 937
931static int btrfs_fill_super(struct super_block *sb, 938static int btrfs_fill_super(struct super_block *sb,
@@ -1996,7 +2003,7 @@ static void __exit exit_btrfs_fs(void)
1996 btrfs_hash_exit(); 2003 btrfs_hash_exit();
1997} 2004}
1998 2005
1999module_init(init_btrfs_fs) 2006late_initcall(init_btrfs_fs);
2000module_exit(exit_btrfs_fs) 2007module_exit(exit_btrfs_fs)
2001 2008
2002MODULE_LICENSE("GPL"); 2009MODULE_LICENSE("GPL");
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 782374d8fd19..865f4cf9a769 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -578,8 +578,14 @@ static int add_device_membership(struct btrfs_fs_info *fs_info)
578 return -ENOMEM; 578 return -ENOMEM;
579 579
580 list_for_each_entry(dev, &fs_devices->devices, dev_list) { 580 list_for_each_entry(dev, &fs_devices->devices, dev_list) {
581 struct hd_struct *disk = dev->bdev->bd_part; 581 struct hd_struct *disk;
582 struct kobject *disk_kobj = &part_to_dev(disk)->kobj; 582 struct kobject *disk_kobj;
583
584 if (!dev->bdev)
585 continue;
586
587 disk = dev->bdev->bd_part;
588 disk_kobj = &part_to_dev(disk)->kobj;
583 589
584 error = sysfs_create_link(fs_info->device_dir_kobj, 590 error = sysfs_create_link(fs_info->device_dir_kobj,
585 disk_kobj, disk_kobj->name); 591 disk_kobj, disk_kobj->name);