super.c (3c09ec59cdea5b132212d97154d625fd34e436dd) | super.c (5b316468983dfa9473ff0f1c42e4e30b4c267141) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2007 Oracle. All rights reserved. 4 */ 5 6#include <linux/blkdev.h> 7#include <linux/module.h> 8#include <linux/fs.h> --- 226 unchanged lines hidden (view full) --- 235 ratelimit = &printk_limits[kern_level - '0']; 236 } 237 fmt += size; 238 } 239 240 vaf.fmt = fmt; 241 vaf.va = &args; 242 | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (C) 2007 Oracle. All rights reserved. 4 */ 5 6#include <linux/blkdev.h> 7#include <linux/module.h> 8#include <linux/fs.h> --- 226 unchanged lines hidden (view full) --- 235 ratelimit = &printk_limits[kern_level - '0']; 236 } 237 fmt += size; 238 } 239 240 vaf.fmt = fmt; 241 vaf.va = &args; 242 |
243 if (__ratelimit(ratelimit)) 244 printk("%sBTRFS %s (device %s): %pV\n", lvl, type, 245 fs_info ? fs_info->sb->s_id : "<unknown>", &vaf); | 243 if (__ratelimit(ratelimit)) { 244 if (fs_info) 245 printk("%sBTRFS %s (device %s): %pV\n", lvl, type, 246 fs_info->sb->s_id, &vaf); 247 else 248 printk("%sBTRFS %s: %pV\n", lvl, type, &vaf); 249 } |
246 247 va_end(args); 248} 249#endif 250 251/* 252 * We only mark the transaction aborted and then set the file system read-only. 253 * This will prevent new transactions from starting or trying to join this --- 101 unchanged lines hidden (view full) --- 355 Opt_thread_pool, 356 Opt_treelog, Opt_notreelog, 357 Opt_user_subvol_rm_allowed, 358 359 /* Rescue options */ 360 Opt_rescue, 361 Opt_usebackuproot, 362 Opt_nologreplay, | 250 251 va_end(args); 252} 253#endif 254 255/* 256 * We only mark the transaction aborted and then set the file system read-only. 257 * This will prevent new transactions from starting or trying to join this --- 101 unchanged lines hidden (view full) --- 359 Opt_thread_pool, 360 Opt_treelog, Opt_notreelog, 361 Opt_user_subvol_rm_allowed, 362 363 /* Rescue options */ 364 Opt_rescue, 365 Opt_usebackuproot, 366 Opt_nologreplay, |
367 Opt_ignorebadroots, 368 Opt_ignoredatacsums, 369 Opt_rescue_all, |
|
363 364 /* Deprecated options */ 365 Opt_recovery, 366 367 /* Debugging options */ 368 Opt_check_integrity, 369 Opt_check_integrity_including_extent_data, 370 Opt_check_integrity_print_mask, --- 79 unchanged lines hidden (view full) --- 450 {Opt_ref_verify, "ref_verify"}, 451#endif 452 {Opt_err, NULL}, 453}; 454 455static const match_table_t rescue_tokens = { 456 {Opt_usebackuproot, "usebackuproot"}, 457 {Opt_nologreplay, "nologreplay"}, | 370 371 /* Deprecated options */ 372 Opt_recovery, 373 374 /* Debugging options */ 375 Opt_check_integrity, 376 Opt_check_integrity_including_extent_data, 377 Opt_check_integrity_print_mask, --- 79 unchanged lines hidden (view full) --- 457 {Opt_ref_verify, "ref_verify"}, 458#endif 459 {Opt_err, NULL}, 460}; 461 462static const match_table_t rescue_tokens = { 463 {Opt_usebackuproot, "usebackuproot"}, 464 {Opt_nologreplay, "nologreplay"}, |
465 {Opt_ignorebadroots, "ignorebadroots"}, 466 {Opt_ignorebadroots, "ibadroots"}, 467 {Opt_ignoredatacsums, "ignoredatacsums"}, 468 {Opt_ignoredatacsums, "idatacsums"}, 469 {Opt_rescue_all, "all"}, |
|
458 {Opt_err, NULL}, 459}; 460 | 470 {Opt_err, NULL}, 471}; 472 |
473static bool check_ro_option(struct btrfs_fs_info *fs_info, unsigned long opt, 474 const char *opt_name) 475{ 476 if (fs_info->mount_opt & opt) { 477 btrfs_err(fs_info, "%s must be used with ro mount option", 478 opt_name); 479 return true; 480 } 481 return false; 482} 483 |
|
461static int parse_rescue_options(struct btrfs_fs_info *info, const char *options) 462{ 463 char *opts; 464 char *orig; 465 char *p; 466 substring_t args[MAX_OPT_ARGS]; 467 int ret = 0; 468 --- 13 unchanged lines hidden (view full) --- 482 btrfs_info(info, 483 "trying to use backup root at mount time"); 484 btrfs_set_opt(info->mount_opt, USEBACKUPROOT); 485 break; 486 case Opt_nologreplay: 487 btrfs_set_and_info(info, NOLOGREPLAY, 488 "disabling log replay at mount time"); 489 break; | 484static int parse_rescue_options(struct btrfs_fs_info *info, const char *options) 485{ 486 char *opts; 487 char *orig; 488 char *p; 489 substring_t args[MAX_OPT_ARGS]; 490 int ret = 0; 491 --- 13 unchanged lines hidden (view full) --- 505 btrfs_info(info, 506 "trying to use backup root at mount time"); 507 btrfs_set_opt(info->mount_opt, USEBACKUPROOT); 508 break; 509 case Opt_nologreplay: 510 btrfs_set_and_info(info, NOLOGREPLAY, 511 "disabling log replay at mount time"); 512 break; |
513 case Opt_ignorebadroots: 514 btrfs_set_and_info(info, IGNOREBADROOTS, 515 "ignoring bad roots"); 516 break; 517 case Opt_ignoredatacsums: 518 btrfs_set_and_info(info, IGNOREDATACSUMS, 519 "ignoring data csums"); 520 break; 521 case Opt_rescue_all: 522 btrfs_info(info, "enabling all of the rescue options"); 523 btrfs_set_and_info(info, IGNOREDATACSUMS, 524 "ignoring data csums"); 525 btrfs_set_and_info(info, IGNOREBADROOTS, 526 "ignoring bad roots"); 527 btrfs_set_and_info(info, NOLOGREPLAY, 528 "disabling log replay at mount time"); 529 break; |
|
490 case Opt_err: 491 btrfs_info(info, "unrecognized rescue option '%s'", p); 492 ret = -EINVAL; 493 goto out; 494 default: 495 break; 496 } 497 --- 465 unchanged lines hidden (view full) --- 963 btrfs_err(info, "unrecognized mount option '%s'", p); 964 ret = -EINVAL; 965 goto out; 966 default: 967 break; 968 } 969 } 970check: | 530 case Opt_err: 531 btrfs_info(info, "unrecognized rescue option '%s'", p); 532 ret = -EINVAL; 533 goto out; 534 default: 535 break; 536 } 537 --- 465 unchanged lines hidden (view full) --- 1003 btrfs_err(info, "unrecognized mount option '%s'", p); 1004 ret = -EINVAL; 1005 goto out; 1006 default: 1007 break; 1008 } 1009 } 1010check: |
971 /* 972 * Extra check for current option against current flag 973 */ 974 if (btrfs_test_opt(info, NOLOGREPLAY) && !(new_flags & SB_RDONLY)) { 975 btrfs_err(info, 976 "nologreplay must be used with ro mount option"); | 1011 /* We're read-only, don't have to check. */ 1012 if (new_flags & SB_RDONLY) 1013 goto out; 1014 1015 if (check_ro_option(info, BTRFS_MOUNT_NOLOGREPLAY, "nologreplay") || 1016 check_ro_option(info, BTRFS_MOUNT_IGNOREBADROOTS, "ignorebadroots") || 1017 check_ro_option(info, BTRFS_MOUNT_IGNOREDATACSUMS, "ignoredatacsums")) |
977 ret = -EINVAL; | 1018 ret = -EINVAL; |
978 } | |
979out: 980 if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE) && 981 !btrfs_test_opt(info, FREE_SPACE_TREE) && 982 !btrfs_test_opt(info, CLEAR_CACHE)) { 983 btrfs_err(info, "cannot disable free space tree"); 984 ret = -EINVAL; 985 986 } --- 135 unchanged lines hidden (view full) --- 1122 int len; 1123 int ret; 1124 1125 path = btrfs_alloc_path(); 1126 if (!path) { 1127 ret = -ENOMEM; 1128 goto err; 1129 } | 1019out: 1020 if (btrfs_fs_compat_ro(info, FREE_SPACE_TREE) && 1021 !btrfs_test_opt(info, FREE_SPACE_TREE) && 1022 !btrfs_test_opt(info, CLEAR_CACHE)) { 1023 btrfs_err(info, "cannot disable free space tree"); 1024 ret = -EINVAL; 1025 1026 } --- 135 unchanged lines hidden (view full) --- 1162 int len; 1163 int ret; 1164 1165 path = btrfs_alloc_path(); 1166 if (!path) { 1167 ret = -ENOMEM; 1168 goto err; 1169 } |
1130 path->leave_spinning = 1; | |
1131 1132 name = kmalloc(PATH_MAX, GFP_KERNEL); 1133 if (!name) { 1134 ret = -ENOMEM; 1135 goto err; 1136 } 1137 ptr = name + PATH_MAX - 1; 1138 ptr[0] = '\0'; --- 112 unchanged lines hidden (view full) --- 1251 struct btrfs_dir_item *di; 1252 struct btrfs_path *path; 1253 struct btrfs_key location; 1254 u64 dir_id; 1255 1256 path = btrfs_alloc_path(); 1257 if (!path) 1258 return -ENOMEM; | 1170 1171 name = kmalloc(PATH_MAX, GFP_KERNEL); 1172 if (!name) { 1173 ret = -ENOMEM; 1174 goto err; 1175 } 1176 ptr = name + PATH_MAX - 1; 1177 ptr[0] = '\0'; --- 112 unchanged lines hidden (view full) --- 1290 struct btrfs_dir_item *di; 1291 struct btrfs_path *path; 1292 struct btrfs_key location; 1293 u64 dir_id; 1294 1295 path = btrfs_alloc_path(); 1296 if (!path) 1297 return -ENOMEM; |
1259 path->leave_spinning = 1; | |
1260 1261 /* 1262 * Find the "default" dir item which points to the root item that we 1263 * will mount by default if we haven't been given a specific subvolume 1264 * to mount. 1265 */ 1266 dir_id = btrfs_super_root_dir(fs_info->super_copy); 1267 di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); --- 110 unchanged lines hidden (view full) --- 1378 trans = btrfs_start_transaction(root, 0); 1379 } 1380 if (IS_ERR(trans)) 1381 return PTR_ERR(trans); 1382 } 1383 return btrfs_commit_transaction(trans); 1384} 1385 | 1298 1299 /* 1300 * Find the "default" dir item which points to the root item that we 1301 * will mount by default if we haven't been given a specific subvolume 1302 * to mount. 1303 */ 1304 dir_id = btrfs_super_root_dir(fs_info->super_copy); 1305 di = btrfs_lookup_dir_item(NULL, root, path, dir_id, "default", 7, 0); --- 110 unchanged lines hidden (view full) --- 1416 trans = btrfs_start_transaction(root, 0); 1417 } 1418 if (IS_ERR(trans)) 1419 return PTR_ERR(trans); 1420 } 1421 return btrfs_commit_transaction(trans); 1422} 1423 |
1424static void print_rescue_option(struct seq_file *seq, const char *s, bool *printed) 1425{ 1426 seq_printf(seq, "%s%s", (*printed) ? ":" : ",rescue=", s); 1427 *printed = true; 1428} 1429 |
|
1386static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) 1387{ 1388 struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb); 1389 const char *compress_type; 1390 const char *subvol_name; | 1430static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry) 1431{ 1432 struct btrfs_fs_info *info = btrfs_sb(dentry->d_sb); 1433 const char *compress_type; 1434 const char *subvol_name; |
1435 bool printed = false; |
|
1391 1392 if (btrfs_test_opt(info, DEGRADED)) 1393 seq_puts(seq, ",degraded"); 1394 if (btrfs_test_opt(info, NODATASUM)) 1395 seq_puts(seq, ",nodatasum"); 1396 if (btrfs_test_opt(info, NODATACOW)) 1397 seq_puts(seq, ",nodatacow"); 1398 if (btrfs_test_opt(info, NOBARRIER)) --- 16 unchanged lines hidden (view full) --- 1415 seq_puts(seq, ",nossd"); 1416 if (btrfs_test_opt(info, SSD_SPREAD)) 1417 seq_puts(seq, ",ssd_spread"); 1418 else if (btrfs_test_opt(info, SSD)) 1419 seq_puts(seq, ",ssd"); 1420 if (btrfs_test_opt(info, NOTREELOG)) 1421 seq_puts(seq, ",notreelog"); 1422 if (btrfs_test_opt(info, NOLOGREPLAY)) | 1436 1437 if (btrfs_test_opt(info, DEGRADED)) 1438 seq_puts(seq, ",degraded"); 1439 if (btrfs_test_opt(info, NODATASUM)) 1440 seq_puts(seq, ",nodatasum"); 1441 if (btrfs_test_opt(info, NODATACOW)) 1442 seq_puts(seq, ",nodatacow"); 1443 if (btrfs_test_opt(info, NOBARRIER)) --- 16 unchanged lines hidden (view full) --- 1460 seq_puts(seq, ",nossd"); 1461 if (btrfs_test_opt(info, SSD_SPREAD)) 1462 seq_puts(seq, ",ssd_spread"); 1463 else if (btrfs_test_opt(info, SSD)) 1464 seq_puts(seq, ",ssd"); 1465 if (btrfs_test_opt(info, NOTREELOG)) 1466 seq_puts(seq, ",notreelog"); 1467 if (btrfs_test_opt(info, NOLOGREPLAY)) |
1423 seq_puts(seq, ",rescue=nologreplay"); | 1468 print_rescue_option(seq, "nologreplay", &printed); 1469 if (btrfs_test_opt(info, USEBACKUPROOT)) 1470 print_rescue_option(seq, "usebackuproot", &printed); 1471 if (btrfs_test_opt(info, IGNOREBADROOTS)) 1472 print_rescue_option(seq, "ignorebadroots", &printed); 1473 if (btrfs_test_opt(info, IGNOREDATACSUMS)) 1474 print_rescue_option(seq, "ignoredatacsums", &printed); |
1424 if (btrfs_test_opt(info, FLUSHONCOMMIT)) 1425 seq_puts(seq, ",flushoncommit"); 1426 if (btrfs_test_opt(info, DISCARD_SYNC)) 1427 seq_puts(seq, ",discard"); 1428 if (btrfs_test_opt(info, DISCARD_ASYNC)) 1429 seq_puts(seq, ",discard=async"); 1430 if (!(info->sb->s_flags & SB_POSIXACL)) 1431 seq_puts(seq, ",noacl"); --- 719 unchanged lines hidden (view full) --- 2151static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) 2152{ 2153 struct btrfs_fs_info *fs_info = btrfs_sb(dentry->d_sb); 2154 struct btrfs_super_block *disk_super = fs_info->super_copy; 2155 struct btrfs_space_info *found; 2156 u64 total_used = 0; 2157 u64 total_free_data = 0; 2158 u64 total_free_meta = 0; | 1475 if (btrfs_test_opt(info, FLUSHONCOMMIT)) 1476 seq_puts(seq, ",flushoncommit"); 1477 if (btrfs_test_opt(info, DISCARD_SYNC)) 1478 seq_puts(seq, ",discard"); 1479 if (btrfs_test_opt(info, DISCARD_ASYNC)) 1480 seq_puts(seq, ",discard=async"); 1481 if (!(info->sb->s_flags & SB_POSIXACL)) 1482 seq_puts(seq, ",noacl"); --- 719 unchanged lines hidden (view full) --- 2202static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) 2203{ 2204 struct btrfs_fs_info *fs_info = btrfs_sb(dentry->d_sb); 2205 struct btrfs_super_block *disk_super = fs_info->super_copy; 2206 struct btrfs_space_info *found; 2207 u64 total_used = 0; 2208 u64 total_free_data = 0; 2209 u64 total_free_meta = 0; |
2159 int bits = dentry->d_sb->s_blocksize_bits; | 2210 u32 bits = fs_info->sectorsize_bits; |
2160 __be32 *fsid = (__be32 *)fs_info->fs_devices->fsid; 2161 unsigned factor = 1; 2162 struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv; 2163 int ret; 2164 u64 thresh = 0; 2165 int mixed = 0; 2166 2167 list_for_each_entry(found, &fs_info->space_info, list) { --- 290 unchanged lines hidden (view full) --- 2458 ", assert=on" 2459#endif 2460#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 2461 ", integrity-checker=on" 2462#endif 2463#ifdef CONFIG_BTRFS_FS_REF_VERIFY 2464 ", ref-verify=on" 2465#endif | 2211 __be32 *fsid = (__be32 *)fs_info->fs_devices->fsid; 2212 unsigned factor = 1; 2213 struct btrfs_block_rsv *block_rsv = &fs_info->global_block_rsv; 2214 int ret; 2215 u64 thresh = 0; 2216 int mixed = 0; 2217 2218 list_for_each_entry(found, &fs_info->space_info, list) { --- 290 unchanged lines hidden (view full) --- 2509 ", assert=on" 2510#endif 2511#ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 2512 ", integrity-checker=on" 2513#endif 2514#ifdef CONFIG_BTRFS_FS_REF_VERIFY 2515 ", ref-verify=on" 2516#endif |
2517#ifdef CONFIG_BLK_DEV_ZONED 2518 ", zoned=yes" 2519#else 2520 ", zoned=no" 2521#endif |
|
2466 ; 2467 pr_info("Btrfs loaded, crc32c=%s%s\n", crc32c_impl(), options); 2468} 2469 2470static int __init init_btrfs_fs(void) 2471{ 2472 int err; 2473 --- 44 unchanged lines hidden (view full) --- 2518 err = btrfs_end_io_wq_init(); 2519 if (err) 2520 goto free_prelim_ref; 2521 2522 err = btrfs_interface_init(); 2523 if (err) 2524 goto free_end_io_wq; 2525 | 2522 ; 2523 pr_info("Btrfs loaded, crc32c=%s%s\n", crc32c_impl(), options); 2524} 2525 2526static int __init init_btrfs_fs(void) 2527{ 2528 int err; 2529 --- 44 unchanged lines hidden (view full) --- 2574 err = btrfs_end_io_wq_init(); 2575 if (err) 2576 goto free_prelim_ref; 2577 2578 err = btrfs_interface_init(); 2579 if (err) 2580 goto free_end_io_wq; 2581 |
2526 btrfs_init_lockdep(); 2527 | |
2528 btrfs_print_mod_info(); 2529 2530 err = btrfs_run_sanity_tests(); 2531 if (err) 2532 goto unregister_ioctl; 2533 2534 err = register_filesystem(&btrfs_fs_type); 2535 if (err) --- 60 unchanged lines hidden --- | 2582 btrfs_print_mod_info(); 2583 2584 err = btrfs_run_sanity_tests(); 2585 if (err) 2586 goto unregister_ioctl; 2587 2588 err = register_filesystem(&btrfs_fs_type); 2589 if (err) --- 60 unchanged lines hidden --- |