Lines Matching refs:hint
773 static inline void new_hashed_relocation(reiserfs_blocknr_hint_t * hint) in new_hashed_relocation() argument
777 if (hint->formatted_node) { in new_hashed_relocation()
778 hash_in = (char *)&hint->key.k_dir_id; in new_hashed_relocation()
780 if (!hint->inode) { in new_hashed_relocation()
782 hash_in = (char *)&hint->key.k_dir_id; in new_hashed_relocation()
784 if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super)) in new_hashed_relocation()
785 hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id); in new_hashed_relocation()
788 (char *)(&INODE_PKEY(hint->inode)->k_objectid); in new_hashed_relocation()
791 hint->search_start = in new_hashed_relocation()
792 hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg); in new_hashed_relocation()
799 static void dirid_groups(reiserfs_blocknr_hint_t * hint) in dirid_groups() argument
804 struct super_block *sb = hint->th->t_super; in dirid_groups()
806 if (hint->inode) in dirid_groups()
807 dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id); in dirid_groups()
808 else if (hint->formatted_node) in dirid_groups()
809 dirid = hint->key.k_dir_id; in dirid_groups()
815 if (hint->inode) in dirid_groups()
817 hint->search_start = hash; in dirid_groups()
825 static void oid_groups(reiserfs_blocknr_hint_t * hint) in oid_groups() argument
827 if (hint->inode) { in oid_groups()
833 dirid = le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id); in oid_groups()
840 hash = (hint->inode->i_sb->s_blocksize << 3); in oid_groups()
842 oid = le32_to_cpu(INODE_PKEY(hint->inode)->k_objectid); in oid_groups()
843 bm = bmap_hash_id(hint->inode->i_sb, oid); in oid_groups()
844 hash = bm * (hint->inode->i_sb->s_blocksize << 3); in oid_groups()
846 hint->search_start = hash; in oid_groups()
854 static int get_left_neighbor(reiserfs_blocknr_hint_t * hint) in get_left_neighbor() argument
867 if (!hint->path) in get_left_neighbor()
870 path = hint->path; in get_left_neighbor()
877 hint->search_start = bh->b_blocknr; in get_left_neighbor()
883 if (!hint->formatted_node && is_indirect_le_ih(ih)) { in get_left_neighbor()
889 hint->search_start = t; in get_left_neighbor()
908 reiserfs_blocknr_hint_t * hint) in set_border_in_hint() argument
913 if (hint->formatted_node) in set_border_in_hint()
914 hint->end = border - 1; in set_border_in_hint()
916 hint->beg = border; in set_border_in_hint()
919 static inline void displace_large_file(reiserfs_blocknr_hint_t * hint) in displace_large_file() argument
921 if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super)) in displace_large_file()
922 hint->search_start = in displace_large_file()
923 hint->beg + in displace_large_file()
924 keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_dir_id), in displace_large_file()
925 4) % (hint->end - hint->beg); in displace_large_file()
927 hint->search_start = in displace_large_file()
928 hint->beg + in displace_large_file()
929 keyed_hash((char *)(&INODE_PKEY(hint->inode)->k_objectid), in displace_large_file()
930 4) % (hint->end - hint->beg); in displace_large_file()
933 static inline void hash_formatted_node(reiserfs_blocknr_hint_t * hint) in hash_formatted_node() argument
937 if (!hint->inode) in hash_formatted_node()
938 hash_in = (char *)&hint->key.k_dir_id; in hash_formatted_node()
939 else if (TEST_OPTION(displace_based_on_dirid, hint->th->t_super)) in hash_formatted_node()
940 hash_in = (char *)(&INODE_PKEY(hint->inode)->k_dir_id); in hash_formatted_node()
942 hash_in = (char *)(&INODE_PKEY(hint->inode)->k_objectid); in hash_formatted_node()
944 hint->search_start = in hash_formatted_node()
945 hint->beg + keyed_hash(hash_in, 4) % (hint->end - hint->beg); in hash_formatted_node()
950 hint) in this_blocknr_allocation_would_make_it_a_large_file()
952 return hint->block == in this_blocknr_allocation_would_make_it_a_large_file()
953 REISERFS_SB(hint->th->t_super)->s_alloc_options.large_file_size; in this_blocknr_allocation_would_make_it_a_large_file()
957 static inline void displace_new_packing_locality(reiserfs_blocknr_hint_t * hint) in displace_new_packing_locality() argument
959 struct in_core_key *key = &hint->key; in displace_new_packing_locality()
961 hint->th->displace_new_blocks = 0; in displace_new_packing_locality()
962 hint->search_start = in displace_new_packing_locality()
963 hint->beg + keyed_hash((char *)(&key->k_objectid), in displace_new_packing_locality()
964 4) % (hint->end - hint->beg); in displace_new_packing_locality()
968 static inline int old_hashed_relocation(reiserfs_blocknr_hint_t * hint) in old_hashed_relocation() argument
973 if (hint->formatted_node || hint->inode == NULL) { in old_hashed_relocation()
977 hash_in = le32_to_cpu((INODE_PKEY(hint->inode))->k_dir_id); in old_hashed_relocation()
979 hint->beg + (u32) keyed_hash(((char *)(&hash_in)), in old_hashed_relocation()
980 4) % (hint->end - hint->beg - 1); in old_hashed_relocation()
981 if (border > hint->search_start) in old_hashed_relocation()
982 hint->search_start = border; in old_hashed_relocation()
987 static inline int old_way(reiserfs_blocknr_hint_t * hint) in old_way() argument
991 if (hint->formatted_node || hint->inode == NULL) { in old_way()
996 hint->beg + in old_way()
997 le32_to_cpu(INODE_PKEY(hint->inode)->k_dir_id) % (hint->end - in old_way()
998 hint->beg); in old_way()
999 if (border > hint->search_start) in old_way()
1000 hint->search_start = border; in old_way()
1005 static inline void hundredth_slices(reiserfs_blocknr_hint_t * hint) in hundredth_slices() argument
1007 struct in_core_key *key = &hint->key; in hundredth_slices()
1011 (keyed_hash((char *)(&key->k_dir_id), 4) % 100) * (hint->end / 100); in hundredth_slices()
1012 if (slice_start > hint->search_start in hundredth_slices()
1013 || slice_start + (hint->end / 100) <= hint->search_start) { in hundredth_slices()
1014 hint->search_start = slice_start; in hundredth_slices()
1018 static void determine_search_start(reiserfs_blocknr_hint_t * hint, in determine_search_start() argument
1021 struct super_block *s = hint->th->t_super; in determine_search_start()
1024 hint->beg = 0; in determine_search_start()
1025 hint->end = SB_BLOCK_COUNT(s) - 1; in determine_search_start()
1029 set_border_in_hint(s, hint); in determine_search_start()
1038 && hint->th->displace_new_blocks) { in determine_search_start()
1039 displace_new_packing_locality(hint); in determine_search_start()
1054 if (displacing_large_files(s) && !hint->formatted_node in determine_search_start()
1055 && this_blocknr_allocation_would_make_it_a_large_file(hint)) { in determine_search_start()
1056 displace_large_file(hint); in determine_search_start()
1064 if (hint->formatted_node && TEST_OPTION(hashed_formatted_nodes, s)) { in determine_search_start()
1065 hash_formatted_node(hint); in determine_search_start()
1069 unfm_hint = get_left_neighbor(hint); in determine_search_start()
1079 if (!hint->formatted_node) { in determine_search_start()
1081 old_way(hint); in determine_search_start()
1083 old_hashed_relocation(hint); in determine_search_start()
1085 if (hint->inode in determine_search_start()
1086 && hint->search_start < in determine_search_start()
1087 REISERFS_I(hint->inode)->i_prealloc_block) in determine_search_start()
1088 hint->search_start = in determine_search_start()
1089 REISERFS_I(hint->inode)->i_prealloc_block; in determine_search_start()
1096 && !(displacing_large_files(s) && !hint->formatted_node)) { in determine_search_start()
1097 hundredth_slices(hint); in determine_search_start()
1102 if (!unfm_hint && !hint->formatted_node && in determine_search_start()
1104 old_hashed_relocation(hint); in determine_search_start()
1108 if ((!unfm_hint || hint->formatted_node) && in determine_search_start()
1110 new_hashed_relocation(hint); in determine_search_start()
1114 if (!unfm_hint && !hint->formatted_node && TEST_OPTION(dirid_groups, s)) { in determine_search_start()
1115 dirid_groups(hint); in determine_search_start()
1118 if (hint->formatted_node && TEST_OPTION(dirid_groups, s)) { in determine_search_start()
1119 dirid_groups(hint); in determine_search_start()
1124 if (!unfm_hint && !hint->formatted_node && TEST_OPTION(oid_groups, s)) { in determine_search_start()
1125 oid_groups(hint); in determine_search_start()
1130 static int determine_prealloc_size(reiserfs_blocknr_hint_t * hint) in determine_prealloc_size() argument
1136 hint->prealloc_size = 0; in determine_prealloc_size()
1138 if (!hint->formatted_node && hint->preallocate) { in determine_prealloc_size()
1139 if (S_ISREG(hint->inode->i_mode) && !IS_PRIVATE(hint->inode) in determine_prealloc_size()
1140 && hint->inode->i_size >= in determine_prealloc_size()
1141 REISERFS_SB(hint->th->t_super)->s_alloc_options. in determine_prealloc_size()
1142 preallocmin * hint->inode->i_sb->s_blocksize) in determine_prealloc_size()
1143 hint->prealloc_size = in determine_prealloc_size()
1144 REISERFS_SB(hint->th->t_super)->s_alloc_options. in determine_prealloc_size()
1150 static inline int allocate_without_wrapping_disk(reiserfs_blocknr_hint_t * hint, in allocate_without_wrapping_disk() argument
1161 nr_allocated = scan_bitmap(hint->th, &start, finish, min, in allocate_without_wrapping_disk()
1163 !hint->formatted_node, hint->block); in allocate_without_wrapping_disk()
1181 list_add(&REISERFS_I(hint->inode)->i_prealloc_list, in allocate_without_wrapping_disk()
1182 &SB_JOURNAL(hint->th->t_super)-> in allocate_without_wrapping_disk()
1184 REISERFS_I(hint->inode)->i_prealloc_block = start; in allocate_without_wrapping_disk()
1185 REISERFS_I(hint->inode)->i_prealloc_count = in allocate_without_wrapping_disk()
1195 (reiserfs_blocknr_hint_t * hint, b_blocknr_t * new_blocknrs, in blocknrs_and_prealloc_arrays_from_search_start() argument
1197 struct super_block *s = hint->th->t_super; in blocknrs_and_prealloc_arrays_from_search_start()
1198 b_blocknr_t start = hint->search_start; in blocknrs_and_prealloc_arrays_from_search_start()
1204 determine_prealloc_size(hint); in blocknrs_and_prealloc_arrays_from_search_start()
1205 if (!hint->formatted_node) { in blocknrs_and_prealloc_arrays_from_search_start()
1210 amount_needed, hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1214 dquot_alloc_block_nodirty(hint->inode, amount_needed); in blocknrs_and_prealloc_arrays_from_search_start()
1219 if (hint->preallocate && hint->prealloc_size) { in blocknrs_and_prealloc_arrays_from_search_start()
1223 hint->prealloc_size, hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1225 quota_ret = dquot_prealloc_block_nodirty(hint->inode, in blocknrs_and_prealloc_arrays_from_search_start()
1226 hint->prealloc_size); in blocknrs_and_prealloc_arrays_from_search_start()
1228 hint->preallocate = hint->prealloc_size = 0; in blocknrs_and_prealloc_arrays_from_search_start()
1237 start = hint->search_start; in blocknrs_and_prealloc_arrays_from_search_start()
1241 start = hint->beg; in blocknrs_and_prealloc_arrays_from_search_start()
1242 finish = hint->search_start; in blocknrs_and_prealloc_arrays_from_search_start()
1246 finish = hint->beg; in blocknrs_and_prealloc_arrays_from_search_start()
1251 if (!hint->formatted_node) { in blocknrs_and_prealloc_arrays_from_search_start()
1256 hint->prealloc_size - in blocknrs_and_prealloc_arrays_from_search_start()
1258 hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1262 dquot_free_block_nodirty(hint->inode, in blocknrs_and_prealloc_arrays_from_search_start()
1263 amount_needed + hint->prealloc_size - in blocknrs_and_prealloc_arrays_from_search_start()
1268 reiserfs_free_block(hint->th, hint->inode, in blocknrs_and_prealloc_arrays_from_search_start()
1270 !hint->formatted_node); in blocknrs_and_prealloc_arrays_from_search_start()
1274 } while ((nr_allocated += allocate_without_wrapping_disk(hint, in blocknrs_and_prealloc_arrays_from_search_start()
1281 hint-> in blocknrs_and_prealloc_arrays_from_search_start()
1284 if (!hint->formatted_node && in blocknrs_and_prealloc_arrays_from_search_start()
1285 amount_needed + hint->prealloc_size > in blocknrs_and_prealloc_arrays_from_search_start()
1286 nr_allocated + REISERFS_I(hint->inode)->i_prealloc_count) { in blocknrs_and_prealloc_arrays_from_search_start()
1291 amount_needed + hint->prealloc_size - in blocknrs_and_prealloc_arrays_from_search_start()
1293 REISERFS_I(hint->inode)->i_prealloc_count, in blocknrs_and_prealloc_arrays_from_search_start()
1294 hint->inode->i_uid); in blocknrs_and_prealloc_arrays_from_search_start()
1298 dquot_free_block_nodirty(hint->inode, amount_needed + in blocknrs_and_prealloc_arrays_from_search_start()
1299 hint->prealloc_size - nr_allocated - in blocknrs_and_prealloc_arrays_from_search_start()
1300 REISERFS_I(hint->inode)-> in blocknrs_and_prealloc_arrays_from_search_start()
1310 static int use_preallocated_list_if_available(reiserfs_blocknr_hint_t * hint, in use_preallocated_list_if_available() argument
1314 struct inode *inode = hint->inode; in use_preallocated_list_if_available()
1334 int reiserfs_allocate_blocknrs(reiserfs_blocknr_hint_t *hint, in reiserfs_allocate_blocknrs() argument
1342 struct super_block *s = hint->th->t_super; in reiserfs_allocate_blocknrs()
1356 if (!hint->formatted_node && hint->preallocate) { in reiserfs_allocate_blocknrs()
1358 (hint, new_blocknrs, amount_needed); in reiserfs_allocate_blocknrs()
1370 determine_search_start(hint, amount_needed); in reiserfs_allocate_blocknrs()
1371 if (hint->search_start >= SB_BLOCK_COUNT(s)) in reiserfs_allocate_blocknrs()
1372 hint->search_start = SB_BLOCK_COUNT(s) - 1; in reiserfs_allocate_blocknrs()
1376 (hint, new_blocknrs, amount_needed); in reiserfs_allocate_blocknrs()
1386 reiserfs_free_block(hint->th, hint->inode, in reiserfs_allocate_blocknrs()