@@ -3301,126 +3301,6 @@ int ext4_discard_partial_page_buffers_no_lock(handle_t *handle,
3301
3301
return err ;
3302
3302
}
3303
3303
3304
- /*
3305
- * ext4_block_truncate_page() zeroes out a mapping from file offset `from'
3306
- * up to the end of the block which corresponds to `from'.
3307
- * This required during truncate. We need to physically zero the tail end
3308
- * of that block so it doesn't yield old data if the file is later grown.
3309
- */
3310
- int ext4_block_truncate_page (handle_t * handle ,
3311
- struct address_space * mapping , loff_t from )
3312
- {
3313
- unsigned offset = from & (PAGE_CACHE_SIZE - 1 );
3314
- unsigned length ;
3315
- unsigned blocksize ;
3316
- struct inode * inode = mapping -> host ;
3317
-
3318
- blocksize = inode -> i_sb -> s_blocksize ;
3319
- length = blocksize - (offset & (blocksize - 1 ));
3320
-
3321
- return ext4_block_zero_page_range (handle , mapping , from , length );
3322
- }
3323
-
3324
- /*
3325
- * ext4_block_zero_page_range() zeros out a mapping of length 'length'
3326
- * starting from file offset 'from'. The range to be zero'd must
3327
- * be contained with in one block. If the specified range exceeds
3328
- * the end of the block it will be shortened to end of the block
3329
- * that cooresponds to 'from'
3330
- */
3331
- int ext4_block_zero_page_range (handle_t * handle ,
3332
- struct address_space * mapping , loff_t from , loff_t length )
3333
- {
3334
- ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT ;
3335
- unsigned offset = from & (PAGE_CACHE_SIZE - 1 );
3336
- unsigned blocksize , max , pos ;
3337
- ext4_lblk_t iblock ;
3338
- struct inode * inode = mapping -> host ;
3339
- struct buffer_head * bh ;
3340
- struct page * page ;
3341
- int err = 0 ;
3342
-
3343
- page = find_or_create_page (mapping , from >> PAGE_CACHE_SHIFT ,
3344
- mapping_gfp_mask (mapping ) & ~__GFP_FS );
3345
- if (!page )
3346
- return - ENOMEM ;
3347
-
3348
- blocksize = inode -> i_sb -> s_blocksize ;
3349
- max = blocksize - (offset & (blocksize - 1 ));
3350
-
3351
- /*
3352
- * correct length if it does not fall between
3353
- * 'from' and the end of the block
3354
- */
3355
- if (length > max || length < 0 )
3356
- length = max ;
3357
-
3358
- iblock = index << (PAGE_CACHE_SHIFT - inode -> i_sb -> s_blocksize_bits );
3359
-
3360
- if (!page_has_buffers (page ))
3361
- create_empty_buffers (page , blocksize , 0 );
3362
-
3363
- /* Find the buffer that contains "offset" */
3364
- bh = page_buffers (page );
3365
- pos = blocksize ;
3366
- while (offset >= pos ) {
3367
- bh = bh -> b_this_page ;
3368
- iblock ++ ;
3369
- pos += blocksize ;
3370
- }
3371
-
3372
- err = 0 ;
3373
- if (buffer_freed (bh )) {
3374
- BUFFER_TRACE (bh , "freed: skip" );
3375
- goto unlock ;
3376
- }
3377
-
3378
- if (!buffer_mapped (bh )) {
3379
- BUFFER_TRACE (bh , "unmapped" );
3380
- ext4_get_block (inode , iblock , bh , 0 );
3381
- /* unmapped? It's a hole - nothing to do */
3382
- if (!buffer_mapped (bh )) {
3383
- BUFFER_TRACE (bh , "still unmapped" );
3384
- goto unlock ;
3385
- }
3386
- }
3387
-
3388
- /* Ok, it's mapped. Make sure it's up-to-date */
3389
- if (PageUptodate (page ))
3390
- set_buffer_uptodate (bh );
3391
-
3392
- if (!buffer_uptodate (bh )) {
3393
- err = - EIO ;
3394
- ll_rw_block (READ , 1 , & bh );
3395
- wait_on_buffer (bh );
3396
- /* Uhhuh. Read error. Complain and punt. */
3397
- if (!buffer_uptodate (bh ))
3398
- goto unlock ;
3399
- }
3400
-
3401
- if (ext4_should_journal_data (inode )) {
3402
- BUFFER_TRACE (bh , "get write access" );
3403
- err = ext4_journal_get_write_access (handle , bh );
3404
- if (err )
3405
- goto unlock ;
3406
- }
3407
-
3408
- zero_user (page , offset , length );
3409
-
3410
- BUFFER_TRACE (bh , "zeroed end of block" );
3411
-
3412
- err = 0 ;
3413
- if (ext4_should_journal_data (inode )) {
3414
- err = ext4_handle_dirty_metadata (handle , inode , bh );
3415
- } else
3416
- mark_buffer_dirty (bh );
3417
-
3418
- unlock :
3419
- unlock_page (page );
3420
- page_cache_release (page );
3421
- return err ;
3422
- }
3423
-
3424
3304
int ext4_can_truncate (struct inode * inode )
3425
3305
{
3426
3306
if (S_ISREG (inode -> i_mode ))
0 commit comments