indirect.c (dae1e52cb1267bf8f52e5e47a80fab566d7e8aa4) | indirect.c (f86186b44b4164600cce03d0d93ad48ec21fa429) |
---|---|
1/* 2 * linux/fs/ext4/indirect.c 3 * 4 * from 5 * 6 * linux/fs/ext4/inode.c 7 * 8 * Copyright (C) 1992, 1993, 1994, 1995 --- 193 unchanged lines hidden (view full) --- 202 * 203 * Caller must make sure that @ind is valid and will stay that way. 204 */ 205static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind) 206{ 207 struct ext4_inode_info *ei = EXT4_I(inode); 208 __le32 *start = ind->bh ? (__le32 *) ind->bh->b_data : ei->i_data; 209 __le32 *p; | 1/* 2 * linux/fs/ext4/indirect.c 3 * 4 * from 5 * 6 * linux/fs/ext4/inode.c 7 * 8 * Copyright (C) 1992, 1993, 1994, 1995 --- 193 unchanged lines hidden (view full) --- 202 * 203 * Caller must make sure that @ind is valid and will stay that way. 204 */ 205static ext4_fsblk_t ext4_find_near(struct inode *inode, Indirect *ind) 206{ 207 struct ext4_inode_info *ei = EXT4_I(inode); 208 __le32 *start = ind->bh ? (__le32 *) ind->bh->b_data : ei->i_data; 209 __le32 *p; |
210 ext4_fsblk_t bg_start; 211 ext4_fsblk_t last_block; 212 ext4_grpblk_t colour; 213 ext4_group_t block_group; 214 int flex_size = ext4_flex_bg_size(EXT4_SB(inode->i_sb)); | |
215 216 /* Try to find previous block */ 217 for (p = ind->p - 1; p >= start; p--) { 218 if (*p) 219 return le32_to_cpu(*p); 220 } 221 222 /* No such thing, so let's try location of indirect block */ 223 if (ind->bh) 224 return ind->bh->b_blocknr; 225 226 /* 227 * It is going to be referred to from the inode itself? OK, just put it 228 * into the same cylinder group then. 229 */ | 210 211 /* Try to find previous block */ 212 for (p = ind->p - 1; p >= start; p--) { 213 if (*p) 214 return le32_to_cpu(*p); 215 } 216 217 /* No such thing, so let's try location of indirect block */ 218 if (ind->bh) 219 return ind->bh->b_blocknr; 220 221 /* 222 * It is going to be referred to from the inode itself? OK, just put it 223 * into the same cylinder group then. 224 */ |
230 block_group = ei->i_block_group; 231 if (flex_size >= EXT4_FLEX_SIZE_DIR_ALLOC_SCHEME) { 232 block_group &= ~(flex_size-1); 233 if (S_ISREG(inode->i_mode)) 234 block_group++; 235 } 236 bg_start = ext4_group_first_block_no(inode->i_sb, block_group); 237 last_block = ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es) - 1; 238 239 /* 240 * If we are doing delayed allocation, we don't need take 241 * colour into account. 242 */ 243 if (test_opt(inode->i_sb, DELALLOC)) 244 return bg_start; 245 246 if (bg_start + EXT4_BLOCKS_PER_GROUP(inode->i_sb) <= last_block) 247 colour = (current->pid % 16) * 248 (EXT4_BLOCKS_PER_GROUP(inode->i_sb) / 16); 249 else 250 colour = (current->pid % 16) * ((last_block - bg_start) / 16); 251 return bg_start + colour; | 225 return ext4_inode_to_goal_block(inode); |
252} 253 254/** 255 * ext4_find_goal - find a preferred place for allocation. 256 * @inode: owner 257 * @block: block we want 258 * @partial: pointer to the last triple within a chain 259 * --- 1251 unchanged lines hidden --- | 226} 227 228/** 229 * ext4_find_goal - find a preferred place for allocation. 230 * @inode: owner 231 * @block: block we want 232 * @partial: pointer to the last triple within a chain 233 * --- 1251 unchanged lines hidden --- |