Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 251756
b: refs/heads/master
c: 3084885
h: refs/heads/master
v: v3
  • Loading branch information
Allison Henderson authored and Theodore Ts'o committed May 25, 2011
1 parent b012407 commit 55e8dfd
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 55f020db66ce187fb8c8e4002a94b0eb714da450
refs/heads/master: 308488518dfcbe3be250085cd582f5b0c1ce72a9
2 changes: 2 additions & 0 deletions trunk/fs/ext4/ext4.h
Original file line number Diff line number Diff line change
Expand Up @@ -1825,6 +1825,8 @@ extern int ext4_writepage_trans_blocks(struct inode *);
extern int ext4_chunk_trans_blocks(struct inode *, int nrblocks);
extern int ext4_block_truncate_page(handle_t *handle,
struct address_space *mapping, loff_t from);
extern int ext4_block_zero_page_range(handle_t *handle,
struct address_space *mapping, loff_t from, loff_t length);
extern int ext4_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf);
extern qsize_t *ext4_get_reserved_space(struct inode *inode);
extern void ext4_da_update_reserve_space(struct inode *inode,
Expand Down
33 changes: 31 additions & 2 deletions trunk/fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -3913,10 +3913,31 @@ void ext4_set_aops(struct inode *inode)
*/
int ext4_block_truncate_page(handle_t *handle,
struct address_space *mapping, loff_t from)
{
unsigned offset = from & (PAGE_CACHE_SIZE-1);
unsigned length;
unsigned blocksize;
struct inode *inode = mapping->host;

blocksize = inode->i_sb->s_blocksize;
length = blocksize - (offset & (blocksize - 1));

return ext4_block_zero_page_range(handle, mapping, from, length);
}

/*
* ext4_block_zero_page_range() zeros out a mapping of length 'length'
* starting from file offset 'from'. The range to be zero'd must
* be contained with in one block. If the specified range exceeds
* the end of the block it will be shortened to end of the block
* that cooresponds to 'from'
*/
int ext4_block_zero_page_range(handle_t *handle,
struct address_space *mapping, loff_t from, loff_t length)
{
ext4_fsblk_t index = from >> PAGE_CACHE_SHIFT;
unsigned offset = from & (PAGE_CACHE_SIZE-1);
unsigned blocksize, length, pos;
unsigned blocksize, max, pos;
ext4_lblk_t iblock;
struct inode *inode = mapping->host;
struct buffer_head *bh;
Expand All @@ -3929,7 +3950,15 @@ int ext4_block_truncate_page(handle_t *handle,
return -EINVAL;

blocksize = inode->i_sb->s_blocksize;
length = blocksize - (offset & (blocksize - 1));
max = blocksize - (offset & (blocksize - 1));

/*
* correct length if it does not fall between
* 'from' and the end of the block
*/
if (length > max || length < 0)
length = max;

iblock = index << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);

if (!page_has_buffers(page))
Expand Down

0 comments on commit 55e8dfd

Please sign in to comment.