ctree.h (203f44c51982b80c437b49b32c843597c112f287) ctree.h (ce6ef5abe68251cb60c4585df2cc73e218ec0dba)
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#ifndef BTRFS_CTREE_H
7#define BTRFS_CTREE_H
8

--- 1881 unchanged lines hidden (view full) ---

1890}
1891
1892/* struct btrfs_disk_key */
1893BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key,
1894 objectid, 64);
1895BTRFS_SETGET_STACK_FUNCS(disk_key_offset, struct btrfs_disk_key, offset, 64);
1896BTRFS_SETGET_STACK_FUNCS(disk_key_type, struct btrfs_disk_key, type, 8);
1897
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2007 Oracle. All rights reserved.
4 */
5
6#ifndef BTRFS_CTREE_H
7#define BTRFS_CTREE_H
8

--- 1881 unchanged lines hidden (view full) ---

1890}
1891
1892/* struct btrfs_disk_key */
1893BTRFS_SETGET_STACK_FUNCS(disk_key_objectid, struct btrfs_disk_key,
1894 objectid, 64);
1895BTRFS_SETGET_STACK_FUNCS(disk_key_offset, struct btrfs_disk_key, offset, 64);
1896BTRFS_SETGET_STACK_FUNCS(disk_key_type, struct btrfs_disk_key, type, 8);
1897
1898#ifdef __LITTLE_ENDIAN
1899
1900/*
1901 * Optimized helpers for little-endian architectures where CPU and on-disk
1902 * structures have the same endianness and we can skip conversions.
1903 */
1904
1905static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu_key,
1906 const struct btrfs_disk_key *disk_key)
1907{
1908 memcpy(cpu_key, disk_key, sizeof(struct btrfs_key));
1909}
1910
1911static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk_key,
1912 const struct btrfs_key *cpu_key)
1913{
1914 memcpy(disk_key, cpu_key, sizeof(struct btrfs_key));
1915}
1916
1917static inline void btrfs_node_key_to_cpu(const struct extent_buffer *eb,
1918 struct btrfs_key *cpu_key, int nr)
1919{
1920 struct btrfs_disk_key *disk_key = (struct btrfs_disk_key *)cpu_key;
1921
1922 btrfs_node_key(eb, disk_key, nr);
1923}
1924
1925static inline void btrfs_item_key_to_cpu(const struct extent_buffer *eb,
1926 struct btrfs_key *cpu_key, int nr)
1927{
1928 struct btrfs_disk_key *disk_key = (struct btrfs_disk_key *)cpu_key;
1929
1930 btrfs_item_key(eb, disk_key, nr);
1931}
1932
1933static inline void btrfs_dir_item_key_to_cpu(const struct extent_buffer *eb,
1934 const struct btrfs_dir_item *item,
1935 struct btrfs_key *cpu_key)
1936{
1937 struct btrfs_disk_key *disk_key = (struct btrfs_disk_key *)cpu_key;
1938
1939 btrfs_dir_item_key(eb, item, disk_key);
1940}
1941
1942#else
1943
1898static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
1899 const struct btrfs_disk_key *disk)
1900{
1901 cpu->offset = le64_to_cpu(disk->offset);
1902 cpu->type = disk->type;
1903 cpu->objectid = le64_to_cpu(disk->objectid);
1904}
1905

--- 25 unchanged lines hidden (view full) ---

1931 const struct btrfs_dir_item *item,
1932 struct btrfs_key *key)
1933{
1934 struct btrfs_disk_key disk_key;
1935 btrfs_dir_item_key(eb, item, &disk_key);
1936 btrfs_disk_key_to_cpu(key, &disk_key);
1937}
1938
1944static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu,
1945 const struct btrfs_disk_key *disk)
1946{
1947 cpu->offset = le64_to_cpu(disk->offset);
1948 cpu->type = disk->type;
1949 cpu->objectid = le64_to_cpu(disk->objectid);
1950}
1951

--- 25 unchanged lines hidden (view full) ---

1977 const struct btrfs_dir_item *item,
1978 struct btrfs_key *key)
1979{
1980 struct btrfs_disk_key disk_key;
1981 btrfs_dir_item_key(eb, item, &disk_key);
1982 btrfs_disk_key_to_cpu(key, &disk_key);
1983}
1984
1985#endif
1986
1939/* struct btrfs_header */
1940BTRFS_SETGET_HEADER_FUNCS(header_bytenr, struct btrfs_header, bytenr, 64);
1941BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header,
1942 generation, 64);
1943BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
1944BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
1945BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64);
1946BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);

--- 1526 unchanged lines hidden ---
1987/* struct btrfs_header */
1988BTRFS_SETGET_HEADER_FUNCS(header_bytenr, struct btrfs_header, bytenr, 64);
1989BTRFS_SETGET_HEADER_FUNCS(header_generation, struct btrfs_header,
1990 generation, 64);
1991BTRFS_SETGET_HEADER_FUNCS(header_owner, struct btrfs_header, owner, 64);
1992BTRFS_SETGET_HEADER_FUNCS(header_nritems, struct btrfs_header, nritems, 32);
1993BTRFS_SETGET_HEADER_FUNCS(header_flags, struct btrfs_header, flags, 64);
1994BTRFS_SETGET_HEADER_FUNCS(header_level, struct btrfs_header, level, 8);

--- 1526 unchanged lines hidden ---