Commit 2dcedbb
btrfs-progs: mkfs/rootdir: enhance subvols detection
Currently for --subvol parameter, we save the full path of the host fs
into rootdir_subvol sturcture, then compare each inode we hit with that
saved full path.
This string comparison can be time consuming (up to PATH_MAX
characters), and we're doing it for every directory inode.
On the other hand, nftw() also provides a stat structure of the current
inode, stat::st_dev and stat::st_ino pair can always uniquely locate an
inode in the host filesystem.
With that said, we can just save the st_dev/st_ino pair when validating
the subvol parameters, and use st_dev/st_ino to check if we hit the
target subvolume.
This has two benefits:
- Reduce the memory usage of each rootdir_subvol
Now we need no full_path member, replacing it with two u64.
This saves (4K - 16) bytes per rootdir_subvol.
- Reduce the runtime of direct inode comparison
Instead of doing strcmp() for up to 4K bytes, it's just two u64
comparison.
Signed-off-by: Qu Wenruo <wqu@suse.com>1 parent 679754a commit 2dcedbb
2 files changed
+40
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1083 | 1083 | | |
1084 | 1084 | | |
1085 | 1085 | | |
| 1086 | + | |
| 1087 | + | |
1086 | 1088 | | |
1087 | 1089 | | |
1088 | 1090 | | |
| |||
1092 | 1094 | | |
1093 | 1095 | | |
1094 | 1096 | | |
1095 | | - | |
| 1097 | + | |
1096 | 1098 | | |
1097 | 1099 | | |
1098 | 1100 | | |
1099 | 1101 | | |
1100 | | - | |
| 1102 | + | |
1101 | 1103 | | |
1102 | 1104 | | |
1103 | 1105 | | |
1104 | 1106 | | |
1105 | | - | |
| 1107 | + | |
1106 | 1108 | | |
1107 | 1109 | | |
1108 | 1110 | | |
1109 | 1111 | | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
| 1117 | + | |
| 1118 | + | |
| 1119 | + | |
1110 | 1120 | | |
1111 | 1121 | | |
1112 | 1122 | | |
1113 | 1123 | | |
1114 | 1124 | | |
1115 | 1125 | | |
1116 | 1126 | | |
1117 | | - | |
| 1127 | + | |
1118 | 1128 | | |
1119 | 1129 | | |
1120 | 1130 | | |
| |||
1424 | 1434 | | |
1425 | 1435 | | |
1426 | 1436 | | |
| 1437 | + | |
| 1438 | + | |
1427 | 1439 | | |
1428 | 1440 | | |
1429 | 1441 | | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
1430 | 1451 | | |
1431 | 1452 | | |
1432 | 1453 | | |
1433 | 1454 | | |
1434 | 1455 | | |
1435 | | - | |
| 1456 | + | |
1436 | 1457 | | |
1437 | 1458 | | |
1438 | 1459 | | |
| |||
1447 | 1468 | | |
1448 | 1469 | | |
1449 | 1470 | | |
1450 | | - | |
| 1471 | + | |
1451 | 1472 | | |
1452 | 1473 | | |
1453 | 1474 | | |
1454 | 1475 | | |
1455 | 1476 | | |
1456 | | - | |
1457 | | - | |
| 1477 | + | |
1458 | 1478 | | |
1459 | 1479 | | |
1460 | 1480 | | |
1461 | | - | |
1462 | | - | |
| 1481 | + | |
| 1482 | + | |
1463 | 1483 | | |
1464 | 1484 | | |
1465 | 1485 | | |
| |||
1469 | 1489 | | |
1470 | 1490 | | |
1471 | 1491 | | |
1472 | | - | |
| 1492 | + | |
1473 | 1493 | | |
1474 | 1494 | | |
1475 | 1495 | | |
| |||
1479 | 1499 | | |
1480 | 1500 | | |
1481 | 1501 | | |
1482 | | - | |
| 1502 | + | |
1483 | 1503 | | |
1484 | 1504 | | |
1485 | 1505 | | |
1486 | 1506 | | |
1487 | 1507 | | |
1488 | 1508 | | |
1489 | 1509 | | |
1490 | | - | |
| 1510 | + | |
1491 | 1511 | | |
1492 | 1512 | | |
1493 | | - | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
1494 | 1516 | | |
1495 | 1517 | | |
1496 | 1518 | | |
| |||
1611 | 1633 | | |
1612 | 1634 | | |
1613 | 1635 | | |
1614 | | - | |
| 1636 | + | |
1615 | 1637 | | |
1616 | 1638 | | |
1617 | 1639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
0 commit comments