Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 374866
b: refs/heads/master
c: ceda086
h: refs/heads/master
v: v3
  • Loading branch information
Miao Xie authored and Josef Bacik committed May 6, 2013
1 parent 5fcd4b6 commit 2bc733d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f42a34b2f10c411ef45f247f3000ed03ba4e80c0
refs/heads/master: ceda08642459e31673d24d7968d864390d2ce5fa
22 changes: 20 additions & 2 deletions trunk/fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,17 @@ struct btrfs_fs_info {
wait_queue_head_t transaction_blocked_wait;
wait_queue_head_t async_submit_wait;

/*
* Used to protect the incompat_flags, compat_flags, compat_ro_flags
* when they are updated.
*
* Because we do not clear the flags for ever, so we needn't use
* the lock on the read side.
*
* We also needn't use the lock when we mount the fs, because
* there is no other task which will update the flag.
*/
spinlock_t super_lock;
struct btrfs_super_block *super_copy;
struct btrfs_super_block *super_for_commit;
struct block_device *__bdev;
Expand Down Expand Up @@ -3688,8 +3699,15 @@ static inline void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info,
disk_super = fs_info->super_copy;
features = btrfs_super_incompat_flags(disk_super);
if (!(features & flag)) {
features |= flag;
btrfs_set_super_incompat_flags(disk_super, features);
spin_lock(&fs_info->super_lock);
features = btrfs_super_incompat_flags(disk_super);
if (!(features & flag)) {
features |= flag;
btrfs_set_super_incompat_flags(disk_super, features);
printk(KERN_INFO "btrfs: setting %llu feature flag\n",
flag);
}
spin_unlock(&fs_info->super_lock);
}
}

Expand Down
5 changes: 5 additions & 0 deletions trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2086,6 +2086,7 @@ int open_ctree(struct super_block *sb,
spin_lock_init(&fs_info->defrag_inodes_lock);
spin_lock_init(&fs_info->free_chunk_lock);
spin_lock_init(&fs_info->tree_mod_seq_lock);
spin_lock_init(&fs_info->super_lock);
rwlock_init(&fs_info->tree_mod_log_lock);
mutex_init(&fs_info->reloc_mutex);
seqlock_init(&fs_info->profiles_lock);
Expand Down Expand Up @@ -2349,6 +2350,10 @@ int open_ctree(struct super_block *sb,
goto fail_alloc;
}

/*
* Needn't use the lock because there is no other task which will
* update the flag.
*/
btrfs_set_super_incompat_flags(disk_super, features);

features = btrfs_super_compat_ro_flags(disk_super) &
Expand Down
10 changes: 1 addition & 9 deletions trunk/fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -3674,18 +3674,10 @@ static u32 find_raid56_stripe_len(u32 data_devices, u32 dev_stripe_target)

static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
{
u64 features;

if (!(type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)))
return;

features = btrfs_super_incompat_flags(info->super_copy);
if (features & BTRFS_FEATURE_INCOMPAT_RAID56)
return;

features |= BTRFS_FEATURE_INCOMPAT_RAID56;
btrfs_set_super_incompat_flags(info->super_copy, features);
printk(KERN_INFO "btrfs: setting RAID5/6 feature flag\n");
btrfs_set_fs_incompat(info, RAID56);
}

static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
Expand Down

0 comments on commit 2bc733d

Please sign in to comment.