diff options
Diffstat (limited to 'fs/ufs/truncate.c')
-rw-r--r-- | fs/ufs/truncate.c | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c index 749581fa7729..79c54c85fb58 100644 --- a/fs/ufs/truncate.c +++ b/fs/ufs/truncate.c | |||
@@ -74,7 +74,7 @@ static int ufs_trunc_direct(struct inode *inode) | |||
74 | unsigned i, tmp; | 74 | unsigned i, tmp; |
75 | int retry; | 75 | int retry; |
76 | 76 | ||
77 | UFSD("ENTER\n"); | 77 | UFSD("ENTER: ino %lu\n", inode->i_ino); |
78 | 78 | ||
79 | sb = inode->i_sb; | 79 | sb = inode->i_sb; |
80 | uspi = UFS_SB(sb)->s_uspi; | 80 | uspi = UFS_SB(sb)->s_uspi; |
@@ -96,8 +96,8 @@ static int ufs_trunc_direct(struct inode *inode) | |||
96 | block2 = ufs_fragstoblks (frag3); | 96 | block2 = ufs_fragstoblks (frag3); |
97 | } | 97 | } |
98 | 98 | ||
99 | UFSD("frag1 %llu, frag2 %llu, block1 %llu, block2 %llu, frag3 %llu," | 99 | UFSD("ino %lu, frag1 %llu, frag2 %llu, block1 %llu, block2 %llu," |
100 | " frag4 %llu\n", | 100 | " frag3 %llu, frag4 %llu\n", inode->i_ino, |
101 | (unsigned long long)frag1, (unsigned long long)frag2, | 101 | (unsigned long long)frag1, (unsigned long long)frag2, |
102 | (unsigned long long)block1, (unsigned long long)block2, | 102 | (unsigned long long)block1, (unsigned long long)block2, |
103 | (unsigned long long)frag3, (unsigned long long)frag4); | 103 | (unsigned long long)frag3, (unsigned long long)frag4); |
@@ -163,7 +163,7 @@ next1: | |||
163 | mark_inode_dirty(inode); | 163 | mark_inode_dirty(inode); |
164 | next3: | 164 | next3: |
165 | 165 | ||
166 | UFSD("EXIT\n"); | 166 | UFSD("EXIT: ino %lu\n", inode->i_ino); |
167 | return retry; | 167 | return retry; |
168 | } | 168 | } |
169 | 169 | ||
@@ -248,7 +248,7 @@ static int ufs_trunc_indirect(struct inode *inode, u64 offset, void *p) | |||
248 | } | 248 | } |
249 | ubh_brelse (ind_ubh); | 249 | ubh_brelse (ind_ubh); |
250 | 250 | ||
251 | UFSD("EXIT\n"); | 251 | UFSD("EXIT: ino %lu\n", inode->i_ino); |
252 | 252 | ||
253 | return retry; | 253 | return retry; |
254 | } | 254 | } |
@@ -262,7 +262,7 @@ static int ufs_trunc_dindirect(struct inode *inode, u64 offset, void *p) | |||
262 | void *dind; | 262 | void *dind; |
263 | int retry = 0; | 263 | int retry = 0; |
264 | 264 | ||
265 | UFSD("ENTER\n"); | 265 | UFSD("ENTER: ino %lu\n", inode->i_ino); |
266 | 266 | ||
267 | sb = inode->i_sb; | 267 | sb = inode->i_sb; |
268 | uspi = UFS_SB(sb)->s_uspi; | 268 | uspi = UFS_SB(sb)->s_uspi; |
@@ -312,7 +312,7 @@ static int ufs_trunc_dindirect(struct inode *inode, u64 offset, void *p) | |||
312 | } | 312 | } |
313 | ubh_brelse (dind_bh); | 313 | ubh_brelse (dind_bh); |
314 | 314 | ||
315 | UFSD("EXIT\n"); | 315 | UFSD("EXIT: ino %lu\n", inode->i_ino); |
316 | 316 | ||
317 | return retry; | 317 | return retry; |
318 | } | 318 | } |
@@ -327,7 +327,7 @@ static int ufs_trunc_tindirect(struct inode *inode) | |||
327 | void *tind, *p; | 327 | void *tind, *p; |
328 | int retry; | 328 | int retry; |
329 | 329 | ||
330 | UFSD("ENTER\n"); | 330 | UFSD("ENTER: ino %lu\n", inode->i_ino); |
331 | 331 | ||
332 | retry = 0; | 332 | retry = 0; |
333 | 333 | ||
@@ -348,7 +348,7 @@ static int ufs_trunc_tindirect(struct inode *inode) | |||
348 | } | 348 | } |
349 | 349 | ||
350 | for (i = tindirect_block ; i < uspi->s_apb ; i++) { | 350 | for (i = tindirect_block ; i < uspi->s_apb ; i++) { |
351 | tind = ubh_get_addr32 (tind_bh, i); | 351 | tind = ubh_get_data_ptr(uspi, tind_bh, i); |
352 | retry |= ufs_trunc_dindirect(inode, UFS_NDADDR + | 352 | retry |= ufs_trunc_dindirect(inode, UFS_NDADDR + |
353 | uspi->s_apb + ((i + 1) << uspi->s_2apbshift), tind); | 353 | uspi->s_apb + ((i + 1) << uspi->s_2apbshift), tind); |
354 | ubh_mark_buffer_dirty(tind_bh); | 354 | ubh_mark_buffer_dirty(tind_bh); |
@@ -372,19 +372,21 @@ static int ufs_trunc_tindirect(struct inode *inode) | |||
372 | } | 372 | } |
373 | ubh_brelse (tind_bh); | 373 | ubh_brelse (tind_bh); |
374 | 374 | ||
375 | UFSD("EXIT\n"); | 375 | UFSD("EXIT: ino %lu\n", inode->i_ino); |
376 | return retry; | 376 | return retry; |
377 | } | 377 | } |
378 | 378 | ||
379 | static int ufs_alloc_lastblock(struct inode *inode) | 379 | static int ufs_alloc_lastblock(struct inode *inode) |
380 | { | 380 | { |
381 | int err = 0; | 381 | int err = 0; |
382 | struct super_block *sb = inode->i_sb; | ||
382 | struct address_space *mapping = inode->i_mapping; | 383 | struct address_space *mapping = inode->i_mapping; |
383 | struct ufs_sb_private_info *uspi = UFS_SB(inode->i_sb)->s_uspi; | 384 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
384 | unsigned i, end; | 385 | unsigned i, end; |
385 | sector_t lastfrag; | 386 | sector_t lastfrag; |
386 | struct page *lastpage; | 387 | struct page *lastpage; |
387 | struct buffer_head *bh; | 388 | struct buffer_head *bh; |
389 | u64 phys64; | ||
388 | 390 | ||
389 | lastfrag = (i_size_read(inode) + uspi->s_fsize - 1) >> uspi->s_fshift; | 391 | lastfrag = (i_size_read(inode) + uspi->s_fsize - 1) >> uspi->s_fshift; |
390 | 392 | ||
@@ -424,6 +426,20 @@ static int ufs_alloc_lastblock(struct inode *inode) | |||
424 | set_page_dirty(lastpage); | 426 | set_page_dirty(lastpage); |
425 | } | 427 | } |
426 | 428 | ||
429 | if (lastfrag >= UFS_IND_FRAGMENT) { | ||
430 | end = uspi->s_fpb - ufs_fragnum(lastfrag) - 1; | ||
431 | phys64 = bh->b_blocknr + 1; | ||
432 | for (i = 0; i < end; ++i) { | ||
433 | bh = sb_getblk(sb, i + phys64); | ||
434 | lock_buffer(bh); | ||
435 | memset(bh->b_data, 0, sb->s_blocksize); | ||
436 | set_buffer_uptodate(bh); | ||
437 | mark_buffer_dirty(bh); | ||
438 | unlock_buffer(bh); | ||
439 | sync_dirty_buffer(bh); | ||
440 | brelse(bh); | ||
441 | } | ||
442 | } | ||
427 | out_unlock: | 443 | out_unlock: |
428 | ufs_put_locked_page(lastpage); | 444 | ufs_put_locked_page(lastpage); |
429 | out: | 445 | out: |