diff options
author | David Sterba <dsterba@suse.cz> | 2014-05-30 13:29:05 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2014-11-12 10:53:15 -0500 |
commit | a6f69dc8018dbb4ce2009ccba49b53f68c8bdc64 (patch) | |
tree | 19636e48cb2486764abcd934aba16fbb0e880866 | |
parent | 0eae2747ec1ddcef5018827bce8f7d33b7d920e1 (diff) |
btrfs: move commit out of sysfs when changing label
Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r-- | fs/btrfs/sysfs.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 226f7261533a..92db3f648df4 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c | |||
@@ -369,9 +369,6 @@ static ssize_t btrfs_label_store(struct kobject *kobj, | |||
369 | const char *buf, size_t len) | 369 | const char *buf, size_t len) |
370 | { | 370 | { |
371 | struct btrfs_fs_info *fs_info = to_fs_info(kobj); | 371 | struct btrfs_fs_info *fs_info = to_fs_info(kobj); |
372 | struct btrfs_trans_handle *trans; | ||
373 | struct btrfs_root *root = fs_info->fs_root; | ||
374 | int ret; | ||
375 | size_t p_len; | 372 | size_t p_len; |
376 | 373 | ||
377 | if (fs_info->sb->s_flags & MS_RDONLY) | 374 | if (fs_info->sb->s_flags & MS_RDONLY) |
@@ -386,20 +383,18 @@ static ssize_t btrfs_label_store(struct kobject *kobj, | |||
386 | if (p_len >= BTRFS_LABEL_SIZE) | 383 | if (p_len >= BTRFS_LABEL_SIZE) |
387 | return -EINVAL; | 384 | return -EINVAL; |
388 | 385 | ||
389 | trans = btrfs_start_transaction(root, 0); | 386 | spin_lock(&fs_info->super_lock); |
390 | if (IS_ERR(trans)) | ||
391 | return PTR_ERR(trans); | ||
392 | |||
393 | spin_lock(&root->fs_info->super_lock); | ||
394 | memset(fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE); | 387 | memset(fs_info->super_copy->label, 0, BTRFS_LABEL_SIZE); |
395 | memcpy(fs_info->super_copy->label, buf, p_len); | 388 | memcpy(fs_info->super_copy->label, buf, p_len); |
396 | spin_unlock(&root->fs_info->super_lock); | 389 | spin_unlock(&fs_info->super_lock); |
397 | ret = btrfs_commit_transaction(trans, root); | ||
398 | 390 | ||
399 | if (!ret) | 391 | /* |
400 | 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); | ||
401 | 396 | ||
402 | return ret; | 397 | return len; |
403 | } | 398 | } |
404 | BTRFS_ATTR_RW(label, btrfs_label_show, btrfs_label_store); | 399 | BTRFS_ATTR_RW(label, btrfs_label_show, btrfs_label_store); |
405 | 400 | ||