Lines Matching refs:hint
765 static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint) in new_hashed_relocation() argument
769 if (hint->formatted_node) { in new_hashed_relocation()
770 hash_in = (char *)&hint->key.k_dir_id; in new_hashed_relocation()
772 if (!hint->inode) { in new_hashed_relocation()
774 hash_in = (char *)&hint->key.k_dir_id; in new_hashed_relocation()
776 if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super)) in new_hashed_relocation()
777 hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id); in new_hashed_relocation()
780 (char *)(&INODE_PKEY(hint->inode)->k_objectid); in new_hashed_relocation()
783 hint->search_start = in new_hashed_relocation()
784 hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg); in new_hashed_relocation()
791 static void dirid_groups(reiserfs_blocknr_hint_t * hint) in dirid_groups() argument
796 struct super_block *sb = hint->th->t_super; in dirid_groups()
798 if (hint->inode) in dirid_groups()
799 dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id); in dirid_groups()
800 else if (hint->formatted_node) in dirid_groups()
801 dirid = hint->key.k_dir_id; in dirid_groups()
807 if (hint->inode) in dirid_groups()
809 hint->search_start = hash; in dirid_groups()
817 static void oid_groups(reiserfs_blocknr_hint_t * hint) in oid_groups() argument
819 if (hint->inode) { in oid_groups()
825 dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id); in oid_groups()
832 hash = (hint->inode->i_sb->s_blocksize << 3); in oid_groups()
834 oid = le32_to_cpu(INODE_PKEY(hint->inode)->k_objectid); in oid_groups()
835 bm = bmap_hash_id(hint->inode->i_sb, oid); in oid_groups()
836 hash = bm * (hint->inode->i_sb->s_blocksize << 3); in oid_groups()
838 hint->search_start = hash; in oid_groups()
846 static int get_left_neighbor(reiserfs_blocknr_hint_t * hint) in get_left_neighbor() argument
859 if (!hint->path) in get_left_neighbor()
862 path = hint->path; in get_left_neighbor()
869 hint->search_start = bh->b_blocknr; in get_left_neighbor()
875 if (!hint->formatted_node && is_indirect_le_ih(ih)) { in get_left_neighbor()
881 hint->search_start = t; in get_left_neighbor()
900 reiserfs_blocknr_hint_t * hint) in set_border_in_hint() argument
905 if (hint->formatted_node) in set_border_in_hint()
906 hint->end = border - 1; in set_border_in_hint()
908 hint->beg = border; in set_border_in_hint()
911 static inline void displace_large_file(reiserfs_blocknr_hint_t * hint) in displace_large_file() argument
913 if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super)) in displace_large_file()
914 hint->search_start = in displace_large_file()
915 hint->beg + in displace_large_file()
916 keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_dir_id), in displace_large_file()
917 4) % (hint->end - hint->beg); in displace_large_file()
919 hint->search_start = in displace_large_file()
920 hint->beg + in displace_large_file()
921 keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_objectid), in displace_large_file()
922 4) % (hint->end - hint->beg); in displace_large_file()
925 static inline void hash_formatted_node(reiserfs_blocknr_hint_t * hint) in hash_formatted_node() argument
929 if (!hint->inode) in hash_formatted_node()
930 hash_in = (char *)&hint->key.k_dir_id; in hash_formatted_node()
931 else if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super)) in hash_formatted_node()
932 hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id); in hash_formatted_node()
934 hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid); in hash_formatted_node()
936 hint->search_start = in hash_formatted_node()
937 hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg); in hash_formatted_node()
942 hint) in this_blocknr_allocation_would_make_it_a_large_file()
944 return hint->block == in this_blocknr_allocation_would_make_it_a_large_file()
945 REISERFS_SB(hint->th->t_super)->s_alloc_options.large_file_size; in this_blocknr_allocation_would_make_it_a_large_file()
949 static inline void displace_new_packing_locality(reiserfs_blocknr_hint_t * hint) in displace_new_packing_locality() argument
951 struct in_core_key *key = &hint->key; in displace_new_packing_locality()
953 hint->th->displace_new_blocks = 0; in displace_new_packing_locality()
954 hint->search_start = in displace_new_packing_locality()
955 hint->beg + keyed_hash((char *)(&key->k_objectid), in displace_new_packing_locality()
956 4) % (hint->end - hint->beg); in displace_new_packing_locality()
960 static inline int old_hashed_relocation(reiserfs_blocknr_hint_t * hint) in old_hashed_relocation() argument
965 if (hint->formatted_node || hint->inode == NULL) { in old_hashed_relocation()
969 hash_in = le32_to_cpu((INODE_PKEY(hint->inode))->k_dir_id); in old_hashed_relocation()
971 hint->beg + (u32) keyed_hash(((char *)(&hash_in)), in old_hashed_relocation()
972 4) % (hint->end - hint->beg - 1); in old_hashed_relocation()
973 if (border > hint->search_start) in old_hashed_relocation()
974 hint->search_start = border; in old_hashed_relocation()
979 static inline int old_way(reiserfs_blocknr_hint_t * hint) in old_way() argument
983 if (hint->formatted_node || hint->inode == NULL) { in old_way()
988 hint->beg + in old_way()
989 le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id) % (hint->end - in old_way()
990 hint->beg); in old_way()
991 if (border > hint->search_start) in old_way()
992 hint->search_start = border; in old_way()
997 static inline void hundredth_slices(reiserfs_blocknr_hint_t * hint) in hundredth_slices() argument
999 struct in_core_key *key = &hint->key; in hundredth_slices()
1003 (keyed_hash((char *)(&key->k_dir_id), 4) % 100) * (hint->end / 100); in hundredth_slices()
1004 if (slice_start > hint->search_start in hundredth_slices()
1005 || slice_start + (hint->end / 100) <= hint->search_start) { in hundredth_slices()
1006 hint->search_start = slice_start; in hundredth_slices()
1010 static void determine_search_start(reiserfs_blocknr_hint_t * hint, in determine_search_start() argument
1013 struct super_block *s = hint->th->t_super; in determine_search_start()
1016 hint->beg = 0; in determine_search_start()
1017 hint->end = SB_BLOCK_COUNT(s) - 1; in determine_search_start()
1021 set_border_in_hint(s, hint); in determine_search_start()
1030 && hint->th->displace_new_blocks) { in determine_search_start()
1031 displace_new_packing_locality(hint); in determine_search_start()
1046 if (displacing_large_files(s) && !hint->formatted_node in determine_search_start()
1047 && this_blocknr_allocation_would_make_it_a_large_file(hint)) { in determine_search_start()
1048 displace_large_file(hint); in determine_search_start()
1056 if (hint->formatted_node && TEST_OPTION(hashed_formatted_nodes, s)) { in determine_search_start()
1057 hash_formatted_node(hint); in determine_search_start()
1061 unfm_hint = get_left_neighbor(hint); in determine_search_start()
1071 if (!hint->formatted_node) { in determine_search_start()
1073 old_way(hint); in determine_search_start()
1075 old_hashed_relocation(hint); in determine_search_start()
1077 if (hint->inode in determine_search_start()
1078 && hint->search_start < in determine_search_start()
1079 REISERFS_I(hint->inode)->i_prealloc_block) in determine_search_start()
1080 hint->search_start = in determine_search_start()
1081 REISERFS_I(hint->inode)->i_prealloc_block; in determine_search_start()
1088 && !(displacing_large_files(s) && !hint->formatted_node)) { in determine_search_start()
1089 hundredth_slices(hint); in determine_search_start()
1094 if (!unfm_hint && !hint->formatted_node && in determine_search_start()
1096 old_hashed_relocation(hint); in determine_search_start()
1100 if ((!unfm_hint || hint->formatted_node) && in determine_search_start()
1102 new_hashed_relocation(hint); in determine_search_start()
1106 if (!unfm_hint && !hint->formatted_node && TEST_OPTION(dirid_groups, s)) { in determine_search_start()
1107 dirid_groups(hint); in determine_search_start()
1110 if (hint->formatted_node && TEST_OPTION(dirid_groups, s)) { in determine_search_start()
1111 dirid_groups(hint); in determine_search_start()
1116 if (!unfm_hint && !hint->formatted_node && TEST_OPTION(oid_groups, s)) { in determine_search_start()
1117 oid_groups(hint); in determine_search_start()
1122 static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint) in determine_prealloc_size() argument
1128 hint->prealloc_size = 0; in determine_prealloc_size()
1130 if (!hint->formatted_node && hint->preallocate) { in determine_prealloc_size()
1131 if (S_ISREG(hint->inode->i_mode) in determine_prealloc_size()
1132 && hint->inode->i_size >= in determine_prealloc_size()
1133 REISERFS_SB(hint->th->t_super)->s_alloc_options. in determine_prealloc_size()
1134 preallocmin * hint->inode->i_sb->s_blocksize) in determine_prealloc_size()
1135 hint->prealloc_size = in determine_prealloc_size()
1136 REISERFS_SB(hint->th->t_super)->s_alloc_options. in determine_prealloc_size()
1142 static inline int allocate_without_wrapping_disk(reiserfs_blocknr_hint_t * hint, in allocate_without_wrapping_disk() argument
1153 nr_allocated = scan_bitmap(hint->th, &start, finish, min, in allocate_without_wrapping_disk()
1155 !hint->formatted_node, hint->block); in allocate_without_wrapping_disk()
1173 list_add(&REISERFS_I(hint->inode)->i_prealloc_list, in allocate_without_wrapping_disk()
1174 &SB_JOURNAL(hint->th->t_super)-> in allocate_without_wrapping_disk()
1176 REISERFS_I(hint->inode)->i_prealloc_block = start; in allocate_without_wrapping_disk()
1177 REISERFS_I(hint->inode)->i_prealloc_count = in allocate_without_wrapping_disk()
1187 (reiserfs_blocknr_hint_t * hint, b_blocknr_t * new_blocknrs, in blocknrs_and_prealloc_arrays_from_search_start() argument
1189 struct super_block *s = hint->th->t_super; in blocknrs_and_prealloc_arrays_from_search_start()
1190 b_blocknr_t start = hint->search_start; in blocknrs_and_prealloc_arrays_from_search_start()
1196 determine_prealloc_size(hint); in blocknrs_and_prealloc_arrays_from_search_start()
1197 if (!hint->formatted_node) { in blocknrs_and_prealloc_arrays_from_search_start()
1202 amount_needed, hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1206 dquot_alloc_block_nodirty(hint->inode, amount_needed); in blocknrs_and_prealloc_arrays_from_search_start()
1211 if (hint->preallocate && hint->prealloc_size) { in blocknrs_and_prealloc_arrays_from_search_start()
1215 hint->prealloc_size, hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1217 quota_ret = dquot_prealloc_block_nodirty(hint->inode, in blocknrs_and_prealloc_arrays_from_search_start()
1218 hint->prealloc_size); in blocknrs_and_prealloc_arrays_from_search_start()
1220 hint->preallocate = hint->prealloc_size = 0; in blocknrs_and_prealloc_arrays_from_search_start()
1229 start = hint->search_start; in blocknrs_and_prealloc_arrays_from_search_start()
1233 start = hint->beg; in blocknrs_and_prealloc_arrays_from_search_start()
1234 finish = hint->search_start; in blocknrs_and_prealloc_arrays_from_search_start()
1238 finish = hint->beg; in blocknrs_and_prealloc_arrays_from_search_start()
1243 if (!hint->formatted_node) { in blocknrs_and_prealloc_arrays_from_search_start()
1248 hint->prealloc_size - in blocknrs_and_prealloc_arrays_from_search_start()
1250 hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1254 dquot_free_block_nodirty(hint->inode, in blocknrs_and_prealloc_arrays_from_search_start()
1255 amount_needed + hint->prealloc_size - in blocknrs_and_prealloc_arrays_from_search_start()
1260 reiserfs_free_block(hint->th, hint->inode, in blocknrs_and_prealloc_arrays_from_search_start()
1262 !hint->formatted_node); in blocknrs_and_prealloc_arrays_from_search_start()
1266 } while ((nr_allocated += allocate_without_wrapping_disk(hint, in blocknrs_and_prealloc_arrays_from_search_start()
1273 hint-> in blocknrs_and_prealloc_arrays_from_search_start()
1276 if (!hint->formatted_node && in blocknrs_and_prealloc_arrays_from_search_start()
1277 amount_needed + hint->prealloc_size > in blocknrs_and_prealloc_arrays_from_search_start()
1278 nr_allocated + REISERFS_I(hint->inode)->i_prealloc_count) { in blocknrs_and_prealloc_arrays_from_search_start()
1283 amount_needed + hint->prealloc_size - in blocknrs_and_prealloc_arrays_from_search_start()
1285 REISERFS_I(hint->inode)->i_prealloc_count, in blocknrs_and_prealloc_arrays_from_search_start()
1286 hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1290 dquot_free_block_nodirty(hint->inode, amount_needed + in blocknrs_and_prealloc_arrays_from_search_start()
1291 hint->prealloc_size - nr_allocated - in blocknrs_and_prealloc_arrays_from_search_start()
1292 REISERFS_I(hint->inode)-> in blocknrs_and_prealloc_arrays_from_search_start()
1302 static int use_preallocated_list_if_available(reiserfs_blocknr_hint_t * hint, in use_preallocated_list_if_available() argument
1306 struct inode *inode = hint->inode; in use_preallocated_list_if_available()
1326 int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *hint, in reiserfs_allocate_blocknrs() argument
1334 struct super_block *s = hint->th->t_super; in reiserfs_allocate_blocknrs()
1348 if (!hint->formatted_node && hint->preallocate) { in reiserfs_allocate_blocknrs()
1350 (hint, new_blocknrs, amount_needed); in reiserfs_allocate_blocknrs()
1362 determine_search_start(hint, amount_needed); in reiserfs_allocate_blocknrs()
1363 if (hint->search_start >= SB_BLOCK_COUNT(s)) in reiserfs_allocate_blocknrs()
1364 hint->search_start = SB_BLOCK_COUNT(s) - 1; in reiserfs_allocate_blocknrs()
1368 (hint, new_blocknrs, amount_needed); in reiserfs_allocate_blocknrs()
1378 reiserfs_free_block(hint->th, hint->inode, in reiserfs_allocate_blocknrs()