btrfs: introduce seperate structure to avoid
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest7 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | btrfs: introduce btrfs_file_header structurefs/ fs/ fs/ +2 more | +52 | 0 replies | |
| 2/7 | btrfs: use btrfs_file_header structure for tree-checkerfs/ fs/ | +113 | 0 replies | |
| 3/7 | btrfs: use btrfs_file_header structure for trace eventsfs/ fs/ fs/ +3 more | +71 | 0 replies | |
| 4/7 | btrfs: use btrfs_file_header structure for inode.cfs/ fs/ fs/ +3 more | +103 | 0 replies | |
| 5/7 | btrfs: use btrfs_file_header structure for simple usagesfs/ fs/ fs/ +5 more | +110 | 0 replies | |
| 6/7 | btrfs: use btrfs_file_header structure for file.cfs/ | +101 | 0 replies | |
| 7/7 | btrfs: use btrfs_file_header structure for send.c and tree-log.cfs/ fs/ | +93 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/7] btrfs: introduce seperate structure to avoid
The structure btrfs_file_extent_item is defined that if one file extent is inlined, the data starts after btrfs_file_extent_item::type, aka, overlapping with btrfs_file_extent_item::disk_bytenr and other members.
This makes it harder to understand btrfs on-disk format.
This also requires every user of btrfs_file_extent_item::disk_bytenr and other non-inline members to check btrfs_file_extent_item::type first.
But not all callers are strictly following that, and when access-beyond-boundary happens, we have no built-in checks to catch them.
This series address the problem by:
- Introduce btrfs_file_header structure to define the shared part Initially I'm planning to use ms-extension to define an unnamed structure inside btrfs_file_extent_item, to avoid duplicated definition, but it doesn't work for arm64.
So have to do duplicated definition.
- Introduce btrfs_file_header_*() helpers for the shared members
- Introduce btrfs_file_header_disk_bytenr() for btrfs_file_extent_item This allows using the same btrfs_file_header pointer to access the btrfs_file_extent_item exclusive members, with built-in ASSERT() to catch incorrect types.
- Convert existing btrfs_file_extent_item pointer users to btrfs_file_header
This also reduce the lifespan of those pointers to minimal, e.g. only define them in the minimal scope, even if it means to define such pointer again and again in different scopes.
There are some exceptions:
* On-stack ones are still using btrfs_file_extent_item
* Certain write paths are still using btrfs_file_extent_item pointer Those sites are known to handling non-inlined extents, thus can still use the old pointer, but not recommended anymore.
Qu Wenruo (7):
btrfs: introduce btrfs_file_header structure
btrfs: use btrfs_file_header structure for tree-checker
btrfs: use btrfs_file_header structure for trace events
btrfs: use btrfs_file_header structure for inode.c
btrfs: use btrfs_file_header structure for simple usages
btrfs: use btrfs_file_header structure for file.c
btrfs: use btrfs_file_header structure for send.c and tree-log.c
fs/btrfs/accessors.h | 79 +++++++++++++ fs/btrfs/backref.c | 36 +++--- fs/btrfs/ctree.c | 33 +++--- fs/btrfs/defrag.c | 8 +- fs/btrfs/extent-tree.c | 26 ++-- fs/btrfs/fiemap.c | 30 ++--- fs/btrfs/file-item.c | 26 ++-- fs/btrfs/file-item.h | 23 ++-- fs/btrfs/file.c | 204 ++++++++++++++++---------------- fs/btrfs/inode-item.c | 47 ++++---- fs/btrfs/inode.c | 151 ++++++++++++----------- fs/btrfs/print-tree.c | 28 ++--- fs/btrfs/qgroup.c | 11 +- fs/btrfs/reflink.c | 34 +++--- fs/btrfs/relocation.c | 42 +++---- fs/btrfs/send.c | 145 +++++++++++------------ fs/btrfs/tree-checker.c | 82 ++++++------- fs/btrfs/tree-log.c | 70 +++++------ include/trace/events/btrfs.h | 58 ++++----- include/uapi/linux/btrfs_tree.h | 61 ++++++---- 20 files changed, 643 insertions(+), 551 deletions(-)
Signature · 1 line
2.52.0