Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linux
linux-davinci
Commits
0783fcfc
Commit
0783fcfc
authored
Mar 12, 2007
by
Chris Mason
Committed by
David Woodhouse
Mar 12, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Btrfs: struct item endian fixes
Signed-off-by:
Chris Mason
<
chris.mason@oracle.com
>
parent
e2fa7227
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
141 additions
and
90 deletions
+141
-90
fs/btrfs/ctree.c
fs/btrfs/ctree.c
+71
-58
fs/btrfs/ctree.h
fs/btrfs/ctree.h
+30
-4
fs/btrfs/extent-tree.c
fs/btrfs/extent-tree.c
+7
-5
fs/btrfs/mkfs.c
fs/btrfs/mkfs.c
+21
-15
fs/btrfs/print-tree.c
fs/btrfs/print-tree.c
+9
-6
fs/btrfs/random-test.c
fs/btrfs/random-test.c
+3
-2
No files found.
fs/btrfs/ctree.c
View file @
0783fcfc
This diff is collapsed.
Click to expand it.
fs/btrfs/ctree.h
View file @
0783fcfc
...
...
@@ -98,10 +98,10 @@ struct ctree_super_block {
* the key flags parameter. offset and size tell us where to find
* the item in the leaf (relative to the start of the data area)
*/
struct
item
{
struct
btrfs_
item
{
struct
btrfs_disk_key
key
;
u
16
offset
;
u
16
size
;
__le
16
offset
;
__le
16
size
;
}
__attribute__
((
__packed__
));
/*
...
...
@@ -115,7 +115,8 @@ struct item {
struct
leaf
{
struct
btrfs_header
header
;
union
{
struct
item
items
[
LEAF_DATA_SIZE
/
sizeof
(
struct
item
)];
struct
btrfs_item
items
[
LEAF_DATA_SIZE
/
sizeof
(
struct
btrfs_item
)];
u8
data
[
CTREE_BLOCKSIZE
-
sizeof
(
struct
btrfs_header
)];
};
}
__attribute__
((
__packed__
));
...
...
@@ -152,6 +153,31 @@ struct ctree_path {
int
slots
[
MAX_LEVEL
];
};
static
inline
u16
btrfs_item_offset
(
struct
btrfs_item
*
item
)
{
return
le16_to_cpu
(
item
->
offset
);
}
static
inline
void
btrfs_set_item_offset
(
struct
btrfs_item
*
item
,
u16
val
)
{
item
->
offset
=
cpu_to_le16
(
val
);
}
static
inline
u16
btrfs_item_end
(
struct
btrfs_item
*
item
)
{
return
le16_to_cpu
(
item
->
offset
)
+
le16_to_cpu
(
item
->
size
);
}
static
inline
u16
btrfs_item_size
(
struct
btrfs_item
*
item
)
{
return
le16_to_cpu
(
item
->
size
);
}
static
inline
void
btrfs_set_item_size
(
struct
btrfs_item
*
item
,
u16
val
)
{
item
->
size
=
cpu_to_le16
(
val
);
}
static
inline
void
btrfs_disk_key_to_cpu
(
struct
btrfs_key
*
cpu
,
struct
btrfs_disk_key
*
disk
)
{
...
...
fs/btrfs/extent-tree.c
View file @
0783fcfc
...
...
@@ -40,8 +40,8 @@ static int inc_block_ref(struct ctree_root *root, u64 blocknr)
BUG
();
BUG_ON
(
ret
!=
0
);
l
=
&
path
.
nodes
[
0
]
->
leaf
;
item
=
(
struct
extent_item
*
)(
l
->
data
+
l
->
items
[
path
.
slots
[
0
]].
offset
);
item
=
(
struct
extent_item
*
)(
l
->
data
+
btrfs_item_offset
(
l
->
items
+
path
.
slots
[
0
])
);
item
->
refs
++
;
BUG_ON
(
list_empty
(
&
path
.
nodes
[
0
]
->
dirty
));
...
...
@@ -67,7 +67,8 @@ static int lookup_block_ref(struct ctree_root *root, u64 blocknr, u32 *refs)
BUG
();
l
=
&
path
.
nodes
[
0
]
->
leaf
;
item
=
(
struct
extent_item
*
)(
l
->
data
+
l
->
items
[
path
.
slots
[
0
]].
offset
);
btrfs_item_offset
(
l
->
items
+
path
.
slots
[
0
]));
*
refs
=
item
->
refs
;
release_path
(
root
->
extent_root
,
&
path
);
return
0
;
...
...
@@ -144,7 +145,7 @@ int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
struct
btrfs_key
key
;
struct
ctree_root
*
extent_root
=
root
->
extent_root
;
int
ret
;
struct
item
*
item
;
struct
btrfs_
item
*
item
;
struct
extent_item
*
ei
;
struct
btrfs_key
ins
;
...
...
@@ -162,7 +163,8 @@ int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
BUG
();
}
item
=
path
.
nodes
[
0
]
->
leaf
.
items
+
path
.
slots
[
0
];
ei
=
(
struct
extent_item
*
)(
path
.
nodes
[
0
]
->
leaf
.
data
+
item
->
offset
);
ei
=
(
struct
extent_item
*
)(
path
.
nodes
[
0
]
->
leaf
.
data
+
btrfs_item_offset
(
item
));
BUG_ON
(
ei
->
refs
==
0
);
ei
->
refs
--
;
if
(
ei
->
refs
==
0
)
{
...
...
fs/btrfs/mkfs.c
View file @
0783fcfc
...
...
@@ -14,7 +14,7 @@ int mkfs(int fd)
{
struct
ctree_root_info
info
[
2
];
struct
leaf
empty_leaf
;
struct
item
item
;
struct
btrfs_
item
item
;
struct
extent_item
extent_item
;
int
ret
;
...
...
@@ -45,31 +45,37 @@ int mkfs(int fd)
btrfs_set_header_nritems
(
&
empty_leaf
.
header
,
3
);
/* item1, reserve blocks 0-16 */
item
.
key
.
objectid
=
cpu_to_le64
(
0
);
item
.
key
.
offset
=
cpu_to_le64
(
17
);
item
.
key
.
flags
=
cpu_to_le32
(
0
);
item
.
offset
=
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
);
item
.
size
=
sizeof
(
struct
extent_item
);
btrfs_set_key_objectid
(
&
item
.
key
,
0
);
btrfs_set_key_offset
(
&
item
.
key
,
17
);
btrfs_set_key_flags
(
&
item
.
key
,
0
);
btrfs_set_item_offset
(
&
item
,
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
));
btrfs_set_item_size
(
&
item
,
sizeof
(
struct
extent_item
));
extent_item
.
refs
=
1
;
extent_item
.
owner
=
0
;
memcpy
(
empty_leaf
.
items
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
data
+
item
.
offset
,
&
extent_item
,
item
.
size
);
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
btrfs_item_size
(
&
item
));
/* item2, give block 17 to the root */
item
.
key
.
objectid
=
cpu_to_le64
(
17
);
item
.
key
.
offset
=
cpu_to_le64
(
1
);
item
.
offset
=
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
2
;
btrfs_set_key_objectid
(
&
item
.
key
,
17
);
btrfs_set_key_offset
(
&
item
.
key
,
1
);
btrfs_set_item_offset
(
&
item
,
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
2
);
extent_item
.
owner
=
1
;
memcpy
(
empty_leaf
.
items
+
1
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
data
+
item
.
offset
,
&
extent_item
,
item
.
size
);
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
btrfs_item_size
(
&
item
));
/* item3, give block 18 for the extent root */
item
.
key
.
objectid
=
cpu_to_le64
(
18
);
item
.
key
.
offset
=
cpu_to_le64
(
1
);
item
.
offset
=
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
3
;
btrfs_set_key_objectid
(
&
item
.
key
,
18
);
btrfs_set_key_offset
(
&
item
.
key
,
1
);
btrfs_set_item_offset
(
&
item
,
LEAF_DATA_SIZE
-
sizeof
(
struct
extent_item
)
*
3
);
extent_item
.
owner
=
2
;
memcpy
(
empty_leaf
.
items
+
2
,
&
item
,
sizeof
(
item
));
memcpy
(
empty_leaf
.
data
+
item
.
offset
,
&
extent_item
,
item
.
size
);
memcpy
(
empty_leaf
.
data
+
btrfs_item_offset
(
&
item
),
&
extent_item
,
btrfs_item_size
(
&
item
));
ret
=
pwrite
(
fd
,
&
empty_leaf
,
sizeof
(
empty_leaf
),
18
*
CTREE_BLOCKSIZE
);
if
(
ret
!=
sizeof
(
empty_leaf
))
return
-
1
;
...
...
fs/btrfs/print-tree.c
View file @
0783fcfc
...
...
@@ -9,7 +9,7 @@ void print_leaf(struct leaf *l)
{
int
i
;
u32
nr
=
btrfs_header_nritems
(
&
l
->
header
);
struct
item
*
item
;
struct
btrfs_
item
*
item
;
struct
extent_item
*
ei
;
printf
(
"leaf %Lu total ptrs %d free space %d
\n
"
,
btrfs_header_blocknr
(
&
l
->
header
),
nr
,
leaf_free_space
(
l
));
...
...
@@ -18,12 +18,15 @@ void print_leaf(struct leaf *l)
item
=
l
->
items
+
i
;
printf
(
"
\t
item %d key (%Lu %u %Lu) itemoff %d itemsize %d
\n
"
,
i
,
item
->
key
.
objectid
,
item
->
key
.
flags
,
item
->
key
.
offset
,
item
->
offset
,
item
->
size
);
btrfs_key_objectid
(
&
item
->
key
),
btrfs_key_flags
(
&
item
->
key
),
btrfs_key_offset
(
&
item
->
key
),
btrfs_item_offset
(
item
),
btrfs_item_size
(
item
));
fflush
(
stdout
);
printf
(
"
\t\t
item data %.*s
\n
"
,
item
->
size
,
l
->
data
+
item
->
offset
);
ei
=
(
struct
extent_item
*
)(
l
->
data
+
item
->
offset
);
printf
(
"
\t\t
item data %.*s
\n
"
,
btrfs_item_size
(
item
)
,
l
->
data
+
btrfs_item_offset
(
item
)
);
ei
=
(
struct
extent_item
*
)(
l
->
data
+
btrfs_item_offset
(
item
)
);
printf
(
"
\t\t
extent data refs %u owner %Lu
\n
"
,
ei
->
refs
,
ei
->
owner
);
fflush
(
stdout
);
...
...
fs/btrfs/random-test.c
View file @
0783fcfc
...
...
@@ -173,7 +173,7 @@ static int empty_tree(struct ctree_root *root, struct radix_tree_root *radix,
path
.
slots
[
0
]
-=
1
;
}
slot
=
path
.
slots
[
0
];
found
=
path
.
nodes
[
0
]
->
leaf
.
items
[
slot
].
key
.
objectid
;
found
=
btrfs_key_objectid
(
&
path
.
nodes
[
0
]
->
leaf
.
items
[
slot
].
key
)
;
ret
=
del_item
(
root
,
&
path
);
count
++
;
if
(
ret
)
{
...
...
@@ -274,7 +274,8 @@ static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix)
slot
-=
1
;
}
for
(
i
=
slot
;
i
>=
0
;
i
--
)
{
found
=
path
.
nodes
[
0
]
->
leaf
.
items
[
i
].
key
.
objectid
;
found
=
btrfs_key_objectid
(
&
path
.
nodes
[
0
]
->
leaf
.
items
[
i
].
key
);
radix_tree_preload
(
GFP_KERNEL
);
ret
=
radix_tree_insert
(
radix
,
found
,
(
void
*
)
found
);
if
(
ret
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment