Lines Matching +full:block +full:- +full:fetch

1 /* SPDX-License-Identifier: GPL-2.0+ */
5 * Copyright (C) 2006-2008 Nokia Corporation.
12 * This header contains various key-related definitions and helper function.
19 * Keys are 64-bits long. First 32-bits are inode number (parent inode number
29 * key_mask_hash - mask a valid hash value.
45 * key_r5_hash - R5 hash function (borrowed from reiserfs).
65 * key_test_hash - testing hash function.
79 * ino_key_init - initialize inode key.
80 * @c: UBIFS file-system description object
87 key->u32[0] = inum; in ino_key_init()
88 key->u32[1] = UBIFS_INO_KEY << UBIFS_S_KEY_BLOCK_BITS; in ino_key_init()
92 * ino_key_init_flash - initialize on-flash inode key.
93 * @c: UBIFS file-system description object
102 key->j32[0] = cpu_to_le32(inum); in ino_key_init_flash()
103 key->j32[1] = cpu_to_le32(UBIFS_INO_KEY << UBIFS_S_KEY_BLOCK_BITS); in ino_key_init_flash()
104 memset(k + 8, 0, UBIFS_MAX_KEY_LEN - 8); in ino_key_init_flash()
108 * lowest_ino_key - get the lowest possible inode key.
109 * @c: UBIFS file-system description object
116 key->u32[0] = inum; in lowest_ino_key()
117 key->u32[1] = 0; in lowest_ino_key()
121 * highest_ino_key - get the highest possible inode key.
122 * @c: UBIFS file-system description object
129 key->u32[0] = inum; in highest_ino_key()
130 key->u32[1] = 0xffffffff; in highest_ino_key()
134 * dent_key_init - initialize directory entry key.
135 * @c: UBIFS file-system description object
144 uint32_t hash = c->key_hash(nm->name, nm->len); in dent_key_init()
147 key->u32[0] = inum; in dent_key_init()
148 key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); in dent_key_init()
152 * dent_key_init_hash - initialize directory entry key without re-calculating
154 * @c: UBIFS file-system description object
164 key->u32[0] = inum; in dent_key_init_hash()
165 key->u32[1] = hash | (UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS); in dent_key_init_hash()
169 * dent_key_init_flash - initialize on-flash directory entry key.
170 * @c: UBIFS file-system description object
179 uint32_t hash = c->key_hash(nm->name, nm->len); in dent_key_init_flash()
182 key->j32[0] = cpu_to_le32(inum); in dent_key_init_flash()
183 key->j32[1] = cpu_to_le32(hash | in dent_key_init_flash()
185 memset(k + 8, 0, UBIFS_MAX_KEY_LEN - 8); in dent_key_init_flash()
189 * lowest_dent_key - get the lowest possible directory entry key.
190 * @c: UBIFS file-system description object
197 key->u32[0] = inum; in lowest_dent_key()
198 key->u32[1] = UBIFS_DENT_KEY << UBIFS_S_KEY_HASH_BITS; in lowest_dent_key()
202 * xent_key_init - initialize extended attribute entry key.
203 * @c: UBIFS file-system description object
212 uint32_t hash = c->key_hash(nm->name, nm->len); in xent_key_init()
215 key->u32[0] = inum; in xent_key_init()
216 key->u32[1] = hash | (UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS); in xent_key_init()
220 * xent_key_init_flash - initialize on-flash extended attribute entry key.
221 * @c: UBIFS file-system description object
230 uint32_t hash = c->key_hash(nm->name, nm->len); in xent_key_init_flash()
233 key->j32[0] = cpu_to_le32(inum); in xent_key_init_flash()
234 key->j32[1] = cpu_to_le32(hash | in xent_key_init_flash()
236 memset(k + 8, 0, UBIFS_MAX_KEY_LEN - 8); in xent_key_init_flash()
240 * lowest_xent_key - get the lowest possible extended attribute entry key.
241 * @c: UBIFS file-system description object
248 key->u32[0] = inum; in lowest_xent_key()
249 key->u32[1] = UBIFS_XENT_KEY << UBIFS_S_KEY_HASH_BITS; in lowest_xent_key()
253 * data_key_init - initialize data key.
254 * @c: UBIFS file-system description object
257 * @block: block number
261 unsigned int block) in data_key_init() argument
263 ubifs_assert(!(block & ~UBIFS_S_KEY_BLOCK_MASK)); in data_key_init()
264 key->u32[0] = inum; in data_key_init()
265 key->u32[1] = block | (UBIFS_DATA_KEY << UBIFS_S_KEY_BLOCK_BITS); in data_key_init()
269 * highest_data_key - get the highest possible data key for an inode.
270 * @c: UBIFS file-system description object
281 * trun_key_init - initialize truncation node key.
282 * @c: UBIFS file-system description object
292 key->u32[0] = inum; in trun_key_init()
293 key->u32[1] = UBIFS_TRUN_KEY << UBIFS_S_KEY_BLOCK_BITS; in trun_key_init()
297 * invalid_key_init - initialize invalid node key.
298 * @c: UBIFS file-system description object
306 key->u32[0] = 0xDEADBEAF; in invalid_key_init()
307 key->u32[1] = UBIFS_INVALID_KEY; in invalid_key_init()
311 * key_type - get key type.
312 * @c: UBIFS file-system description object
318 return key->u32[1] >> UBIFS_S_KEY_BLOCK_BITS; in key_type()
322 * key_type_flash - get type of a on-flash formatted key.
323 * @c: UBIFS file-system description object
330 return le32_to_cpu(key->j32[1]) >> UBIFS_S_KEY_BLOCK_BITS; in key_type_flash()
334 * key_inum - fetch inode number from key.
335 * @c: UBIFS file-system description object
336 * @k: key to fetch inode number from
342 return key->u32[0]; in key_inum()
346 * key_inum_flash - fetch inode number from an on-flash formatted key.
347 * @c: UBIFS file-system description object
348 * @k: key to fetch inode number from
354 return le32_to_cpu(key->j32[0]); in key_inum_flash()
358 * key_hash - get directory entry hash.
359 * @c: UBIFS file-system description object
365 return key->u32[1] & UBIFS_S_KEY_HASH_MASK; in key_hash()
369 * key_hash_flash - get directory entry hash from an on-flash formatted key.
370 * @c: UBIFS file-system description object
377 return le32_to_cpu(key->j32[1]) & UBIFS_S_KEY_HASH_MASK; in key_hash_flash()
381 * key_block - get data block number.
382 * @c: UBIFS file-system description object
383 * @key: the key to get the block number from
388 return key->u32[1] & UBIFS_S_KEY_BLOCK_MASK; in key_block()
392 * key_block_flash - get data block number from an on-flash formatted key.
393 * @c: UBIFS file-system description object
394 * @k: the key to get the block number from
401 return le32_to_cpu(key->j32[1]) & UBIFS_S_KEY_BLOCK_MASK; in key_block_flash()
405 * key_read - transform a key to in-memory format.
406 * @c: UBIFS file-system description object
415 to->u32[0] = le32_to_cpu(f->j32[0]); in key_read()
416 to->u32[1] = le32_to_cpu(f->j32[1]); in key_read()
420 * key_write - transform a key from in-memory format.
421 * @c: UBIFS file-system description object
430 t->j32[0] = cpu_to_le32(from->u32[0]); in key_write()
431 t->j32[1] = cpu_to_le32(from->u32[1]); in key_write()
432 memset(to + 8, 0, UBIFS_MAX_KEY_LEN - 8); in key_write()
436 * key_write_idx - transform a key from in-memory format for the index.
437 * @c: UBIFS file-system description object
446 t->j32[0] = cpu_to_le32(from->u32[0]); in key_write_idx()
447 t->j32[1] = cpu_to_le32(from->u32[1]); in key_write_idx()
451 * key_copy - copy a key.
452 * @c: UBIFS file-system description object
459 to->u64[0] = from->u64[0]; in key_copy()
463 * keys_cmp - compare keys.
464 * @c: UBIFS file-system description object
468 * This function compares 2 keys and returns %-1 if @key1 is less than
475 if (key1->u32[0] < key2->u32[0]) in keys_cmp()
476 return -1; in keys_cmp()
477 if (key1->u32[0] > key2->u32[0]) in keys_cmp()
479 if (key1->u32[1] < key2->u32[1]) in keys_cmp()
480 return -1; in keys_cmp()
481 if (key1->u32[1] > key2->u32[1]) in keys_cmp()
488 * keys_eq - determine if keys are equivalent.
489 * @c: UBIFS file-system description object
500 if (key1->u32[0] != key2->u32[0]) in keys_eq()
502 if (key1->u32[1] != key2->u32[1]) in keys_eq()
508 * is_hash_key - is a key vulnerable to hash collisions.
509 * @c: UBIFS file-system description object
523 * key_max_inode_size - get maximum file size allowed by current key format.
524 * @c: UBIFS file-system description object
528 switch (c->key_fmt) { in key_max_inode_size()