Commit 6de4561
btrfs-progs: mkfs/rootdir: enhance inode flags detection
Currently for --inode-flags parameter, we save the full path of the host
fs into rootdir_inode_flags_entry 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 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 inode flag parameters, and use st_dev/st_ino to check if we hit the
target inode.
This has two benefits:
- Reduce the memory usage of each rootdir_inode_flags_entry
Now we need no full_path member, replacing it with two u64.
This saves (4K - 16) bytes per rootdir_inode_flags_entry.
- Reduce the runtime of 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 d6c523b commit 6de4561
2 files changed
+23
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1139 | 1139 | | |
1140 | 1140 | | |
1141 | 1141 | | |
| 1142 | + | |
1142 | 1143 | | |
| 1144 | + | |
1143 | 1145 | | |
1144 | 1146 | | |
1145 | 1147 | | |
1146 | 1148 | | |
1147 | 1149 | | |
1148 | 1150 | | |
1149 | | - | |
| 1151 | + | |
1150 | 1152 | | |
1151 | 1153 | | |
1152 | 1154 | | |
1153 | 1155 | | |
1154 | | - | |
1155 | | - | |
| 1156 | + | |
| 1157 | + | |
1156 | 1158 | | |
1157 | 1159 | | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
1158 | 1168 | | |
1159 | 1169 | | |
1160 | 1170 | | |
1161 | 1171 | | |
1162 | 1172 | | |
1163 | 1173 | | |
1164 | 1174 | | |
1165 | | - | |
| 1175 | + | |
1166 | 1176 | | |
1167 | | - | |
| 1177 | + | |
1168 | 1178 | | |
1169 | 1179 | | |
1170 | 1180 | | |
| |||
1410 | 1420 | | |
1411 | 1421 | | |
1412 | 1422 | | |
1413 | | - | |
| 1423 | + | |
1414 | 1424 | | |
1415 | 1425 | | |
1416 | 1426 | | |
1417 | 1427 | | |
1418 | | - | |
| 1428 | + | |
1419 | 1429 | | |
1420 | 1430 | | |
1421 | 1431 | | |
| |||
1493 | 1503 | | |
1494 | 1504 | | |
1495 | 1505 | | |
1496 | | - | |
| 1506 | + | |
1497 | 1507 | | |
1498 | 1508 | | |
1499 | 1509 | | |
| |||
1687 | 1697 | | |
1688 | 1698 | | |
1689 | 1699 | | |
1690 | | - | |
| 1700 | + | |
1691 | 1701 | | |
1692 | 1702 | | |
1693 | 1703 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | 56 | | |
59 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
| |||
0 commit comments