Lines Matching defs:hint

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