diff options
Diffstat (limited to 'fs/btrfs/super.c')
| -rw-r--r-- | fs/btrfs/super.c | 254 |
1 files changed, 182 insertions, 72 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f8b4521de907..1866dff0538e 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include <linux/namei.h> | 38 | #include <linux/namei.h> |
| 39 | #include <linux/miscdevice.h> | 39 | #include <linux/miscdevice.h> |
| 40 | #include <linux/magic.h> | 40 | #include <linux/magic.h> |
| 41 | #include <linux/slab.h> | ||
| 41 | #include "compat.h" | 42 | #include "compat.h" |
| 42 | #include "ctree.h" | 43 | #include "ctree.h" |
| 43 | #include "disk-io.h" | 44 | #include "disk-io.h" |
| @@ -63,22 +64,21 @@ static void btrfs_put_super(struct super_block *sb) | |||
| 63 | } | 64 | } |
| 64 | 65 | ||
| 65 | enum { | 66 | enum { |
| 66 | Opt_degraded, Opt_subvol, Opt_device, Opt_nodatasum, Opt_nodatacow, | 67 | Opt_degraded, Opt_subvol, Opt_subvolid, Opt_device, Opt_nodatasum, |
| 67 | Opt_max_extent, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, | 68 | Opt_nodatacow, Opt_max_inline, Opt_alloc_start, Opt_nobarrier, Opt_ssd, |
| 68 | Opt_ssd, Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, | 69 | Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress, |
| 69 | Opt_compress, Opt_compress_force, Opt_notreelog, Opt_ratio, | 70 | Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit, |
| 70 | Opt_flushoncommit, | ||
| 71 | Opt_discard, Opt_err, | 71 | Opt_discard, Opt_err, |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| 74 | static match_table_t tokens = { | 74 | static match_table_t tokens = { |
| 75 | {Opt_degraded, "degraded"}, | 75 | {Opt_degraded, "degraded"}, |
| 76 | {Opt_subvol, "subvol=%s"}, | 76 | {Opt_subvol, "subvol=%s"}, |
| 77 | {Opt_subvolid, "subvolid=%d"}, | ||
| 77 | {Opt_device, "device=%s"}, | 78 | {Opt_device, "device=%s"}, |
| 78 | {Opt_nodatasum, "nodatasum"}, | 79 | {Opt_nodatasum, "nodatasum"}, |
| 79 | {Opt_nodatacow, "nodatacow"}, | 80 | {Opt_nodatacow, "nodatacow"}, |
| 80 | {Opt_nobarrier, "nobarrier"}, | 81 | {Opt_nobarrier, "nobarrier"}, |
| 81 | {Opt_max_extent, "max_extent=%s"}, | ||
| 82 | {Opt_max_inline, "max_inline=%s"}, | 82 | {Opt_max_inline, "max_inline=%s"}, |
| 83 | {Opt_alloc_start, "alloc_start=%s"}, | 83 | {Opt_alloc_start, "alloc_start=%s"}, |
| 84 | {Opt_thread_pool, "thread_pool=%d"}, | 84 | {Opt_thread_pool, "thread_pool=%d"}, |
| @@ -95,31 +95,6 @@ static match_table_t tokens = { | |||
| 95 | {Opt_err, NULL}, | 95 | {Opt_err, NULL}, |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| 98 | u64 btrfs_parse_size(char *str) | ||
| 99 | { | ||
| 100 | u64 res; | ||
| 101 | int mult = 1; | ||
| 102 | char *end; | ||
| 103 | char last; | ||
| 104 | |||
| 105 | res = simple_strtoul(str, &end, 10); | ||
| 106 | |||
| 107 | last = end[0]; | ||
| 108 | if (isalpha(last)) { | ||
| 109 | last = tolower(last); | ||
| 110 | switch (last) { | ||
| 111 | case 'g': | ||
| 112 | mult *= 1024; | ||
| 113 | case 'm': | ||
| 114 | mult *= 1024; | ||
| 115 | case 'k': | ||
| 116 | mult *= 1024; | ||
| 117 | } | ||
| 118 | res = res * mult; | ||
| 119 | } | ||
| 120 | return res; | ||
| 121 | } | ||
| 122 | |||
| 123 | /* | 98 | /* |
| 124 | * Regular mount options parser. Everything that is needed only when | 99 | * Regular mount options parser. Everything that is needed only when |
| 125 | * reading in a new superblock is parsed here. | 100 | * reading in a new superblock is parsed here. |
| @@ -157,6 +132,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 157 | btrfs_set_opt(info->mount_opt, DEGRADED); | 132 | btrfs_set_opt(info->mount_opt, DEGRADED); |
| 158 | break; | 133 | break; |
| 159 | case Opt_subvol: | 134 | case Opt_subvol: |
| 135 | case Opt_subvolid: | ||
| 160 | case Opt_device: | 136 | case Opt_device: |
| 161 | /* | 137 | /* |
| 162 | * These are parsed by btrfs_parse_early_options | 138 | * These are parsed by btrfs_parse_early_options |
| @@ -211,22 +187,10 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 211 | info->thread_pool_size); | 187 | info->thread_pool_size); |
| 212 | } | 188 | } |
| 213 | break; | 189 | break; |
| 214 | case Opt_max_extent: | ||
| 215 | num = match_strdup(&args[0]); | ||
| 216 | if (num) { | ||
| 217 | info->max_extent = btrfs_parse_size(num); | ||
| 218 | kfree(num); | ||
| 219 | |||
| 220 | info->max_extent = max_t(u64, | ||
| 221 | info->max_extent, root->sectorsize); | ||
| 222 | printk(KERN_INFO "btrfs: max_extent at %llu\n", | ||
| 223 | (unsigned long long)info->max_extent); | ||
| 224 | } | ||
| 225 | break; | ||
| 226 | case Opt_max_inline: | 190 | case Opt_max_inline: |
| 227 | num = match_strdup(&args[0]); | 191 | num = match_strdup(&args[0]); |
| 228 | if (num) { | 192 | if (num) { |
| 229 | info->max_inline = btrfs_parse_size(num); | 193 | info->max_inline = memparse(num, NULL); |
| 230 | kfree(num); | 194 | kfree(num); |
| 231 | 195 | ||
| 232 | if (info->max_inline) { | 196 | if (info->max_inline) { |
| @@ -241,7 +205,7 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
| 241 | case Opt_alloc_start: | 205 | case Opt_alloc_start: |
| 242 | num = match_strdup(&args[0]); | 206 | num = match_strdup(&args[0]); |
| 243 | if (num) { | 207 | if (num) { |
| 244 | info->alloc_start = btrfs_parse_size(num); | 208 | info->alloc_start = memparse(num, NULL); |
| 245 | kfree(num); | 209 | kfree(num); |
| 246 | printk(KERN_INFO | 210 | printk(KERN_INFO |
| 247 | "btrfs: allocations start at %llu\n", | 211 | "btrfs: allocations start at %llu\n", |
| @@ -292,12 +256,13 @@ out: | |||
| 292 | * only when we need to allocate a new super block. | 256 | * only when we need to allocate a new super block. |
| 293 | */ | 257 | */ |
| 294 | static int btrfs_parse_early_options(const char *options, fmode_t flags, | 258 | static int btrfs_parse_early_options(const char *options, fmode_t flags, |
| 295 | void *holder, char **subvol_name, | 259 | void *holder, char **subvol_name, u64 *subvol_objectid, |
| 296 | struct btrfs_fs_devices **fs_devices) | 260 | struct btrfs_fs_devices **fs_devices) |
| 297 | { | 261 | { |
| 298 | substring_t args[MAX_OPT_ARGS]; | 262 | substring_t args[MAX_OPT_ARGS]; |
| 299 | char *opts, *p; | 263 | char *opts, *p; |
| 300 | int error = 0; | 264 | int error = 0; |
| 265 | int intarg; | ||
| 301 | 266 | ||
| 302 | if (!options) | 267 | if (!options) |
| 303 | goto out; | 268 | goto out; |
| @@ -320,6 +285,18 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, | |||
| 320 | case Opt_subvol: | 285 | case Opt_subvol: |
| 321 | *subvol_name = match_strdup(&args[0]); | 286 | *subvol_name = match_strdup(&args[0]); |
| 322 | break; | 287 | break; |
| 288 | case Opt_subvolid: | ||
| 289 | intarg = 0; | ||
| 290 | error = match_int(&args[0], &intarg); | ||
| 291 | if (!error) { | ||
| 292 | /* we want the original fs_tree */ | ||
| 293 | if (!intarg) | ||
| 294 | *subvol_objectid = | ||
| 295 | BTRFS_FS_TREE_OBJECTID; | ||
| 296 | else | ||
| 297 | *subvol_objectid = intarg; | ||
| 298 | } | ||
| 299 | break; | ||
| 323 | case Opt_device: | 300 | case Opt_device: |
| 324 | error = btrfs_scan_one_device(match_strdup(&args[0]), | 301 | error = btrfs_scan_one_device(match_strdup(&args[0]), |
| 325 | flags, holder, fs_devices); | 302 | flags, holder, fs_devices); |
| @@ -347,6 +324,110 @@ static int btrfs_parse_early_options(const char *options, fmode_t flags, | |||
| 347 | return error; | 324 | return error; |
| 348 | } | 325 | } |
| 349 | 326 | ||
| 327 | static struct dentry *get_default_root(struct super_block *sb, | ||
| 328 | u64 subvol_objectid) | ||
| 329 | { | ||
| 330 | struct btrfs_root *root = sb->s_fs_info; | ||
| 331 | struct btrfs_root *new_root; | ||
| 332 | struct btrfs_dir_item *di; | ||
| 333 | struct btrfs_path *path; | ||
| 334 | struct btrfs_key location; | ||
| 335 | struct inode *inode; | ||
| 336 | struct dentry *dentry; | ||
| 337 | u64 dir_id; | ||
| 338 | int new = 0; | ||
| 339 | |||
| 340 | /* | ||
| 341 | * We have a specific subvol we want to mount, just setup location and | ||
| 342 | * go look up the root. | ||
| 343 | */ | ||
| 344 | if (subvol_objectid) { | ||
| 345 | location.objectid = subvol_objectid; | ||
| 346 | location.type = BTRFS_ROOT_ITEM_KEY; | ||
| 347 | location.offset = (u64)-1; | ||
| 348 | goto find_root; | ||
| 349 | } | ||
| 350 | |||
| 351 | path = btrfs_alloc_path(); | ||
| 352 | if (!path) | ||
| 353 | return ERR_PTR(-ENOMEM); | ||
| 354 | path->leave_spinning = 1; | ||
| 355 | |||
| 356 | /* | ||
| 357 | * Find the "default" dir item which points to the root item that we | ||
| 358 | * will mount by default if we haven't been given a specific subvolume | ||
| 359 | * to mount. | ||
| 360 | */ | ||
| 361 | dir_id = btrfs_super_root_dir(&root->fs_info->super_copy); | ||
| 362 | di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); | ||
| 363 | if (!di) { | ||
| 364 | /* | ||
| 365 | * Ok the default dir item isn't there. This is weird since | ||
| 366 | * it's always been there, but don't freak out, just try and | ||
| 367 | * mount to root most subvolume. | ||
| 368 | */ | ||
| 369 | btrfs_free_path(path); | ||
| 370 | dir_id = BTRFS_FIRST_FREE_OBJECTID; | ||
| 371 | new_root = root->fs_info->fs_root; | ||
| 372 | goto setup_root; | ||
| 373 | } | ||
| 374 | |||
| 375 | btrfs_dir_item_key_to_cpu(path->nodes[0], di, &location); | ||
| 376 | btrfs_free_path(path); | ||
| 377 | |||
| 378 | find_root: | ||
| 379 | new_root = btrfs_read_fs_root_no_name(root->fs_info, &location); | ||
| 380 | if (IS_ERR(new_root)) | ||
| 381 | return ERR_PTR(PTR_ERR(new_root)); | ||
| 382 | |||
| 383 | if (btrfs_root_refs(&new_root->root_item) == 0) | ||
| 384 | return ERR_PTR(-ENOENT); | ||
| 385 | |||
| 386 | dir_id = btrfs_root_dirid(&new_root->root_item); | ||
| 387 | setup_root: | ||
| 388 | location.objectid = dir_id; | ||
| 389 | location.type = BTRFS_INODE_ITEM_KEY; | ||
| 390 | location.offset = 0; | ||
| 391 | |||
| 392 | inode = btrfs_iget(sb, &location, new_root, &new); | ||
| 393 | if (!inode) | ||
| 394 | return ERR_PTR(-ENOMEM); | ||
| 395 | |||
| 396 | /* | ||
| 397 | * If we're just mounting the root most subvol put the inode and return | ||
| 398 | * a reference to the dentry. We will have already gotten a reference | ||
| 399 | * to the inode in btrfs_fill_super so we're good to go. | ||
| 400 | */ | ||
| 401 | if (!new && sb->s_root->d_inode == inode) { | ||
| 402 | iput(inode); | ||
| 403 | return dget(sb->s_root); | ||
| 404 | } | ||
| 405 | |||
| 406 | if (new) { | ||
| 407 | const struct qstr name = { .name = "/", .len = 1 }; | ||
| 408 | |||
| 409 | /* | ||
| 410 | * New inode, we need to make the dentry a sibling of s_root so | ||
| 411 | * everything gets cleaned up properly on unmount. | ||
| 412 | */ | ||
| 413 | dentry = d_alloc(sb->s_root, &name); | ||
| 414 | if (!dentry) { | ||
| 415 | iput(inode); | ||
| 416 | return ERR_PTR(-ENOMEM); | ||
| 417 | } | ||
| 418 | d_splice_alias(inode, dentry); | ||
| 419 | } else { | ||
| 420 | /* | ||
| 421 | * We found the inode in cache, just find a dentry for it and | ||
| 422 | * put the reference to the inode we just got. | ||
| 423 | */ | ||
| 424 | dentry = d_find_alias(inode); | ||
| 425 | iput(inode); | ||
| 426 | } | ||
| 427 | |||
| 428 | return dentry; | ||
| 429 | } | ||
| 430 | |||
| 350 | static int btrfs_fill_super(struct super_block *sb, | 431 | static int btrfs_fill_super(struct super_block *sb, |
| 351 | struct btrfs_fs_devices *fs_devices, | 432 | struct btrfs_fs_devices *fs_devices, |
| 352 | void *data, int silent) | 433 | void *data, int silent) |
| @@ -380,7 +461,7 @@ static int btrfs_fill_super(struct super_block *sb, | |||
| 380 | key.objectid = BTRFS_FIRST_FREE_OBJECTID; | 461 | key.objectid = BTRFS_FIRST_FREE_OBJECTID; |
| 381 | key.type = BTRFS_INODE_ITEM_KEY; | 462 | key.type = BTRFS_INODE_ITEM_KEY; |
| 382 | key.offset = 0; | 463 | key.offset = 0; |
| 383 | inode = btrfs_iget(sb, &key, tree_root->fs_info->fs_root); | 464 | inode = btrfs_iget(sb, &key, tree_root->fs_info->fs_root, NULL); |
| 384 | if (IS_ERR(inode)) { | 465 | if (IS_ERR(inode)) { |
| 385 | err = PTR_ERR(inode); | 466 | err = PTR_ERR(inode); |
| 386 | goto fail_close; | 467 | goto fail_close; |
| @@ -392,12 +473,6 @@ static int btrfs_fill_super(struct super_block *sb, | |||
| 392 | err = -ENOMEM; | 473 | err = -ENOMEM; |
| 393 | goto fail_close; | 474 | goto fail_close; |
| 394 | } | 475 | } |
| 395 | #if 0 | ||
| 396 | /* this does the super kobj at the same time */ | ||
| 397 | err = btrfs_sysfs_add_super(tree_root->fs_info); | ||
| 398 | if (err) | ||
| 399 | goto fail_close; | ||
| 400 | #endif | ||
| 401 | 476 | ||
| 402 | sb->s_root = root_dentry; | 477 | sb->s_root = root_dentry; |
| 403 | 478 | ||
| @@ -441,9 +516,6 @@ static int btrfs_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
| 441 | seq_puts(seq, ",nodatacow"); | 516 | seq_puts(seq, ",nodatacow"); |
| 442 | if (btrfs_test_opt(root, NOBARRIER)) | 517 | if (btrfs_test_opt(root, NOBARRIER)) |
| 443 | seq_puts(seq, ",nobarrier"); | 518 | seq_puts(seq, ",nobarrier"); |
| 444 | if (info->max_extent != (u64)-1) | ||
| 445 | seq_printf(seq, ",max_extent=%llu", | ||
| 446 | (unsigned long long)info->max_extent); | ||
| 447 | if (info->max_inline != 8192 * 1024) | 519 | if (info->max_inline != 8192 * 1024) |
| 448 | seq_printf(seq, ",max_inline=%llu", | 520 | seq_printf(seq, ",max_inline=%llu", |
| 449 | (unsigned long long)info->max_inline); | 521 | (unsigned long long)info->max_inline); |
| @@ -489,19 +561,22 @@ static int btrfs_test_super(struct super_block *s, void *data) | |||
| 489 | static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | 561 | static int btrfs_get_sb(struct file_system_type *fs_type, int flags, |
| 490 | const char *dev_name, void *data, struct vfsmount *mnt) | 562 | const char *dev_name, void *data, struct vfsmount *mnt) |
| 491 | { | 563 | { |
| 492 | char *subvol_name = NULL; | ||
| 493 | struct block_device *bdev = NULL; | 564 | struct block_device *bdev = NULL; |
| 494 | struct super_block *s; | 565 | struct super_block *s; |
| 495 | struct dentry *root; | 566 | struct dentry *root; |
| 496 | struct btrfs_fs_devices *fs_devices = NULL; | 567 | struct btrfs_fs_devices *fs_devices = NULL; |
| 497 | fmode_t mode = FMODE_READ; | 568 | fmode_t mode = FMODE_READ; |
| 569 | char *subvol_name = NULL; | ||
| 570 | u64 subvol_objectid = 0; | ||
| 498 | int error = 0; | 571 | int error = 0; |
| 572 | int found = 0; | ||
| 499 | 573 | ||
| 500 | if (!(flags & MS_RDONLY)) | 574 | if (!(flags & MS_RDONLY)) |
| 501 | mode |= FMODE_WRITE; | 575 | mode |= FMODE_WRITE; |
| 502 | 576 | ||
| 503 | error = btrfs_parse_early_options(data, mode, fs_type, | 577 | error = btrfs_parse_early_options(data, mode, fs_type, |
| 504 | &subvol_name, &fs_devices); | 578 | &subvol_name, &subvol_objectid, |
| 579 | &fs_devices); | ||
| 505 | if (error) | 580 | if (error) |
| 506 | return error; | 581 | return error; |
| 507 | 582 | ||
| @@ -530,6 +605,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 530 | goto error_close_devices; | 605 | goto error_close_devices; |
| 531 | } | 606 | } |
| 532 | 607 | ||
| 608 | found = 1; | ||
| 533 | btrfs_close_devices(fs_devices); | 609 | btrfs_close_devices(fs_devices); |
| 534 | } else { | 610 | } else { |
| 535 | char b[BDEVNAME_SIZE]; | 611 | char b[BDEVNAME_SIZE]; |
| @@ -547,25 +623,35 @@ static int btrfs_get_sb(struct file_system_type *fs_type, int flags, | |||
| 547 | s->s_flags |= MS_ACTIVE; | 623 | s->s_flags |= MS_ACTIVE; |
| 548 | } | 624 | } |
| 549 | 625 | ||
| 550 | if (!strcmp(subvol_name, ".")) | 626 | root = get_default_root(s, subvol_objectid); |
| 551 | root = dget(s->s_root); | 627 | if (IS_ERR(root)) { |
| 552 | else { | 628 | error = PTR_ERR(root); |
| 553 | mutex_lock(&s->s_root->d_inode->i_mutex); | 629 | deactivate_locked_super(s); |
| 554 | root = lookup_one_len(subvol_name, s->s_root, | 630 | goto error; |
| 631 | } | ||
| 632 | /* if they gave us a subvolume name bind mount into that */ | ||
| 633 | if (strcmp(subvol_name, ".")) { | ||
| 634 | struct dentry *new_root; | ||
| 635 | mutex_lock(&root->d_inode->i_mutex); | ||
| 636 | new_root = lookup_one_len(subvol_name, root, | ||
| 555 | strlen(subvol_name)); | 637 | strlen(subvol_name)); |
| 556 | mutex_unlock(&s->s_root->d_inode->i_mutex); | 638 | mutex_unlock(&root->d_inode->i_mutex); |
| 557 | 639 | ||
| 558 | if (IS_ERR(root)) { | 640 | if (IS_ERR(new_root)) { |
| 559 | deactivate_locked_super(s); | 641 | deactivate_locked_super(s); |
| 560 | error = PTR_ERR(root); | 642 | error = PTR_ERR(new_root); |
| 561 | goto error_free_subvol_name; | 643 | dput(root); |
| 644 | goto error_close_devices; | ||
| 562 | } | 645 | } |
| 563 | if (!root->d_inode) { | 646 | if (!new_root->d_inode) { |
| 564 | dput(root); | 647 | dput(root); |
| 648 | dput(new_root); | ||
| 565 | deactivate_locked_super(s); | 649 | deactivate_locked_super(s); |
| 566 | error = -ENXIO; | 650 | error = -ENXIO; |
| 567 | goto error_free_subvol_name; | 651 | goto error_close_devices; |
| 568 | } | 652 | } |
| 653 | dput(root); | ||
| 654 | root = new_root; | ||
| 569 | } | 655 | } |
| 570 | 656 | ||
| 571 | mnt->mnt_sb = s; | 657 | mnt->mnt_sb = s; |
| @@ -580,6 +666,7 @@ error_close_devices: | |||
| 580 | btrfs_close_devices(fs_devices); | 666 | btrfs_close_devices(fs_devices); |
| 581 | error_free_subvol_name: | 667 | error_free_subvol_name: |
| 582 | kfree(subvol_name); | 668 | kfree(subvol_name); |
| 669 | error: | ||
| 583 | return error; | 670 | return error; |
| 584 | } | 671 | } |
| 585 | 672 | ||
| @@ -624,14 +711,37 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
| 624 | { | 711 | { |
| 625 | struct btrfs_root *root = btrfs_sb(dentry->d_sb); | 712 | struct btrfs_root *root = btrfs_sb(dentry->d_sb); |
| 626 | struct btrfs_super_block *disk_super = &root->fs_info->super_copy; | 713 | struct btrfs_super_block *disk_super = &root->fs_info->super_copy; |
| 714 | struct list_head *head = &root->fs_info->space_info; | ||
| 715 | struct btrfs_space_info *found; | ||
| 716 | u64 total_used = 0; | ||
| 717 | u64 data_used = 0; | ||
| 627 | int bits = dentry->d_sb->s_blocksize_bits; | 718 | int bits = dentry->d_sb->s_blocksize_bits; |
| 628 | __be32 *fsid = (__be32 *)root->fs_info->fsid; | 719 | __be32 *fsid = (__be32 *)root->fs_info->fsid; |
| 629 | 720 | ||
| 721 | rcu_read_lock(); | ||
| 722 | list_for_each_entry_rcu(found, head, list) { | ||
| 723 | if (found->flags & (BTRFS_BLOCK_GROUP_DUP| | ||
| 724 | BTRFS_BLOCK_GROUP_RAID10| | ||
| 725 | BTRFS_BLOCK_GROUP_RAID1)) { | ||
| 726 | total_used += found->bytes_used; | ||
| 727 | if (found->flags & BTRFS_BLOCK_GROUP_DATA) | ||
| 728 | data_used += found->bytes_used; | ||
| 729 | else | ||
| 730 | data_used += found->total_bytes; | ||
| 731 | } | ||
| 732 | |||
| 733 | total_used += found->bytes_used; | ||
| 734 | if (found->flags & BTRFS_BLOCK_GROUP_DATA) | ||
| 735 | data_used += found->bytes_used; | ||
| 736 | else | ||
| 737 | data_used += found->total_bytes; | ||
| 738 | } | ||
| 739 | rcu_read_unlock(); | ||
| 740 | |||
| 630 | buf->f_namelen = BTRFS_NAME_LEN; | 741 | buf->f_namelen = BTRFS_NAME_LEN; |
| 631 | buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; | 742 | buf->f_blocks = btrfs_super_total_bytes(disk_super) >> bits; |
| 632 | buf->f_bfree = buf->f_blocks - | 743 | buf->f_bfree = buf->f_blocks - (total_used >> bits); |
| 633 | (btrfs_super_bytes_used(disk_super) >> bits); | 744 | buf->f_bavail = buf->f_blocks - (data_used >> bits); |
| 634 | buf->f_bavail = buf->f_bfree; | ||
| 635 | buf->f_bsize = dentry->d_sb->s_blocksize; | 745 | buf->f_bsize = dentry->d_sb->s_blocksize; |
| 636 | buf->f_type = BTRFS_SUPER_MAGIC; | 746 | buf->f_type = BTRFS_SUPER_MAGIC; |
| 637 | 747 | ||
