Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ufs: no retries are needed on truncate

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 0d23cf76 68785793

+17 -40
+17 -40
fs/ufs/truncate.c
··· 169 169 } 170 170 171 171 172 - static int ufs_trunc_indirect(struct inode *inode, u64 offset, void *p) 172 + static void ufs_trunc_indirect(struct inode *inode, u64 offset, void *p) 173 173 { 174 174 struct super_block * sb; 175 175 struct ufs_sb_private_info * uspi; ··· 177 177 void *ind; 178 178 u64 tmp, indirect_block, i, frag_to_free; 179 179 unsigned free_count; 180 - int retry; 181 180 182 181 UFSD("ENTER: ino %lu, offset %llu, p: %p\n", 183 182 inode->i_ino, (unsigned long long)offset, p); ··· 188 189 189 190 frag_to_free = 0; 190 191 free_count = 0; 191 - retry = 0; 192 192 193 193 tmp = ufs_data_ptr_to_cpu(sb, p); 194 194 if (!tmp) 195 - return 0; 195 + return; 196 196 ind_ubh = ubh_bread(sb, tmp, uspi->s_bsize); 197 197 if (!ind_ubh) { 198 198 write_seqlock(&UFS_I(inode)->meta_lock); 199 199 ufs_data_ptr_clear(uspi, p); 200 200 write_sequnlock(&UFS_I(inode)->meta_lock); 201 - return 0; 201 + return; 202 202 } 203 203 204 204 indirect_block = (DIRECT_BLOCK > offset) ? (DIRECT_BLOCK - offset) : 0; ··· 248 250 ubh_brelse (ind_ubh); 249 251 250 252 UFSD("EXIT: ino %lu\n", inode->i_ino); 251 - 252 - return retry; 253 253 } 254 254 255 - static int ufs_trunc_dindirect(struct inode *inode, u64 offset, void *p) 255 + static void ufs_trunc_dindirect(struct inode *inode, u64 offset, void *p) 256 256 { 257 257 struct super_block * sb; 258 258 struct ufs_sb_private_info * uspi; 259 259 struct ufs_buffer_head *dind_bh; 260 260 u64 i, tmp, dindirect_block; 261 261 void *dind; 262 - int retry = 0; 263 262 264 263 UFSD("ENTER: ino %lu\n", inode->i_ino); 265 264 ··· 265 270 266 271 dindirect_block = (DIRECT_BLOCK > offset) 267 272 ? ((DIRECT_BLOCK - offset) >> uspi->s_apbshift) : 0; 268 - retry = 0; 269 273 270 274 tmp = ufs_data_ptr_to_cpu(sb, p); 271 275 if (!tmp) 272 - return 0; 276 + return; 273 277 dind_bh = ubh_bread(sb, tmp, uspi->s_bsize); 274 278 if (!dind_bh) { 275 279 write_seqlock(&UFS_I(inode)->meta_lock); 276 280 ufs_data_ptr_clear(uspi, p); 277 281 write_sequnlock(&UFS_I(inode)->meta_lock); 278 - return 0; 282 + return; 279 283 } 280 284 281 285 for (i = dindirect_block ; i < uspi->s_apb ; i++) { ··· 282 288 tmp = ufs_data_ptr_to_cpu(sb, dind); 283 289 if (!tmp) 284 290 continue; 285 - retry |= ufs_trunc_indirect (inode, offset + (i << uspi->s_apbshift), dind); 291 + ufs_trunc_indirect (inode, offset + (i << uspi->s_apbshift), dind); 286 292 ubh_mark_buffer_dirty(dind_bh); 287 293 } 288 294 ··· 306 312 ubh_brelse (dind_bh); 307 313 308 314 UFSD("EXIT: ino %lu\n", inode->i_ino); 309 - 310 - return retry; 311 315 } 312 316 313 - static int ufs_trunc_tindirect(struct inode *inode) 317 + static void ufs_trunc_tindirect(struct inode *inode) 314 318 { 315 319 struct super_block *sb = inode->i_sb; 316 320 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; ··· 316 324 struct ufs_buffer_head * tind_bh; 317 325 u64 tindirect_block, tmp, i; 318 326 void *tind, *p; 319 - int retry; 320 327 321 328 UFSD("ENTER: ino %lu\n", inode->i_ino); 322 329 323 - retry = 0; 324 - 325 330 tindirect_block = (DIRECT_BLOCK > (UFS_NDADDR + uspi->s_apb + uspi->s_2apb)) 326 331 ? ((DIRECT_BLOCK - UFS_NDADDR - uspi->s_apb - uspi->s_2apb) >> uspi->s_2apbshift) : 0; 327 332 328 333 p = ufs_get_direct_data_ptr(uspi, ufsi, UFS_TIND_BLOCK); 329 334 if (!(tmp = ufs_data_ptr_to_cpu(sb, p))) 330 - return 0; 335 + return; 331 336 tind_bh = ubh_bread (sb, tmp, uspi->s_bsize); 332 337 if (!tind_bh) { 333 338 write_seqlock(&ufsi->meta_lock); 334 339 ufs_data_ptr_clear(uspi, p); 335 340 write_sequnlock(&ufsi->meta_lock); 336 - return 0; 341 + return; 337 342 } 338 343 339 344 for (i = tindirect_block ; i < uspi->s_apb ; i++) { 340 345 tind = ubh_get_data_ptr(uspi, tind_bh, i); 341 - retry |= ufs_trunc_dindirect(inode, UFS_NDADDR + 346 + ufs_trunc_dindirect(inode, UFS_NDADDR + 342 347 uspi->s_apb + ((i + 1) << uspi->s_2apbshift), tind); 343 348 ubh_mark_buffer_dirty(tind_bh); 344 349 } ··· 359 370 ubh_brelse (tind_bh); 360 371 361 372 UFSD("EXIT: ino %lu\n", inode->i_ino); 362 - return retry; 363 373 } 364 374 365 375 static int ufs_alloc_lastblock(struct inode *inode, loff_t size) ··· 436 448 struct ufs_inode_info *ufsi = UFS_I(inode); 437 449 struct super_block *sb = inode->i_sb; 438 450 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; 439 - int retry; 440 451 441 452 mutex_lock(&ufsi->truncate_mutex); 442 - while (1) { 443 - ufs_trunc_direct(inode); 444 - retry = ufs_trunc_indirect(inode, UFS_IND_BLOCK, 445 - ufs_get_direct_data_ptr(uspi, ufsi, 446 - UFS_IND_BLOCK)); 447 - retry |= ufs_trunc_dindirect(inode, UFS_IND_BLOCK + uspi->s_apb, 448 - ufs_get_direct_data_ptr(uspi, ufsi, 449 - UFS_DIND_BLOCK)); 450 - retry |= ufs_trunc_tindirect (inode); 451 - if (!retry) 452 - break; 453 - if (IS_SYNC(inode) && (inode->i_state & I_DIRTY)) 454 - ufs_sync_inode (inode); 455 - yield(); 456 - } 457 - 453 + ufs_trunc_direct(inode); 454 + ufs_trunc_indirect(inode, UFS_IND_BLOCK, 455 + ufs_get_direct_data_ptr(uspi, ufsi, UFS_IND_BLOCK)); 456 + ufs_trunc_dindirect(inode, UFS_IND_BLOCK + uspi->s_apb, 457 + ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK)); 458 + ufs_trunc_tindirect(inode); 458 459 ufsi->i_lastfrag = DIRECT_FRAGMENT; 459 460 mutex_unlock(&ufsi->truncate_mutex); 460 461 }