diff options
Diffstat (limited to 'fs/btrfs/sysfs.c')
-rw-r--r-- | fs/btrfs/sysfs.c | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index b2e7bb4393f6..92db3f648df4 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c | |||
@@ -111,7 +111,6 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, | |||
111 | { | 111 | { |
112 | struct btrfs_fs_info *fs_info; | 112 | struct btrfs_fs_info *fs_info; |
113 | struct btrfs_feature_attr *fa = to_btrfs_feature_attr(a); | 113 | struct btrfs_feature_attr *fa = to_btrfs_feature_attr(a); |
114 | struct btrfs_trans_handle *trans; | ||
115 | u64 features, set, clear; | 114 | u64 features, set, clear; |
116 | unsigned long val; | 115 | unsigned long val; |
117 | int ret; | 116 | int ret; |
@@ -153,10 +152,6 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, | |||
153 | btrfs_info(fs_info, "%s %s feature flag", | 152 | btrfs_info(fs_info, "%s %s feature flag", |
154 | val ? "Setting" : "Clearing", fa->kobj_attr.attr.name); | 153 | val ? "Setting" : "Clearing", fa->kobj_attr.attr.name); |
155 | 154 | ||
156 | trans = btrfs_start_transaction(fs_info->fs_root, 0); | ||
157 | if (IS_ERR(trans)) | ||
158 | return PTR_ERR(trans); | ||
159 | |||
160 | spin_lock(&fs_info->super_lock); | 155 | spin_lock(&fs_info->super_lock); |
161 | features = get_features(fs_info, fa->feature_set); | 156 | features = get_features(fs_info, fa->feature_set); |
162 | if (val) | 157 | if (val) |
@@ -166,9 +161,11 @@ static ssize_t btrfs_feature_attr_store(struct kobject *kobj, | |||
166 | set_features(fs_info, fa->feature_set, features); | 161 | set_features(fs_info, fa->feature_set, features); |
167 | spin_unlock(&fs_info->super_lock); | 162 | spin_unlock(&fs_info->super_lock); |
168 | 163 | ||
169 | ret = btrfs_commit_transaction(trans, fs_info->fs_root); | 164 | /* |
170 | if (ret) | 165 | * We don't want to do full transaction commit from inside sysfs |
171 | return ret; | 166 | */ |
167 | btrfs_set_pending(fs_info, COMMIT); | ||
168 | wake_up_process(fs_info->transaction_kthread); | ||
172 | 169 | ||
173 | return count; | 170 | return count; |
174 | } | 171 | } |
@@ -372,9 +369,6 @@ static ssize_t btrfs_label_store(struct kobject *kobj, | |||
372 | const char *buf, size_t len) | 369 | const char *buf, size_t len) |
373 | { | 370 | { |
374 | struct btrfs_fs_info *fs_info = to_fs_info(kobj); | 371 | struct btrfs_fs_info *fs_info = to_fs_info(kobj); |
375 | struct btrfs_trans_handle *trans; | ||
376 | struct btrfs_root *root = fs_info->fs_root; | ||
377 | int ret; | ||
378 | size_t p_len; | 372 | size_t p_len; |
379 | 373 | ||
380 | if (fs_info->sb->s_flags & MS_RDONLY) | 374 | if (fs_info->sb->s_flags & MS_RDONLY) |
@@ -389,20 +383,18 @@ static ssize_t btrfs_label_store(struct kobject *kobj, | |||
389 | if (p_len >= BTRFS_LABEL_SIZE) | 383 | if (p_len >= BTRFS_LABEL_SIZE) |
390 | return -EINVAL; | 384 | return -EINVAL; |
391 | 385 | ||
392 | trans = btrfs_start_transaction(root, 0); | 386 | spin_lock(&fs_info->super_lock); |
393 | if (IS_ERR(trans)) | ||
394 | return PTR_ERR(trans); | ||
395 | |||
396 | spin_lock(&root->fs_info->super_lock); | ||
397 | memset(fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE); | 387 | memset(fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE); |
398 | memcpy(fs_info->super_copy->label, buf, p_len); | 388 | memcpy(fs_info->super_copy->label, buf, p_len); |
399 | spin_unlock(&root->fs_info->super_lock); | 389 | spin_unlock(&fs_info->super_lock); |
400 | ret = btrfs_commit_transaction(trans, root); | ||
401 | 390 | ||
402 | if (!ret) | 391 | /* |
403 | return len; | 392 | * We don't want to do full transaction commit from inside sysfs |
393 | */ | ||
394 | btrfs_set_pending(fs_info, COMMIT); | ||
395 | wake_up_process(fs_info->transaction_kthread); | ||
404 | 396 | ||
405 | return ret; | 397 | return len; |
406 | } | 398 | } |
407 | BTRFS_ATTR_RW(label, btrfs_label_show, btrfs_label_store); | 399 | BTRFS_ATTR_RW(label, btrfs_label_show, btrfs_label_store); |
408 | 400 | ||