Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77900
b: refs/heads/master
c: 4df3d26
h: refs/heads/master
v: v3
  • Loading branch information
Aneesh Kumar K.V authored and Theodore Ts'o committed Jan 29, 2008
1 parent 88f0eaa commit d93f73e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 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: 0e855ac8b103ef579052936b59fe7c599ac422a4
refs/heads/master: 4df3d265bf8f3762e1d77f554ee279c39dedb020
32 changes: 24 additions & 8 deletions trunk/fs/ext4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,23 +901,39 @@ int ext4_get_blocks_wrap(handle_t *handle, struct inode *inode, sector_t block,
int create, int extend_disksize)
{
int retval;
if (create) {
down_write((&EXT4_I(inode)->i_data_sem));
/*
* Try to see if we can get the block without requesting
* for new file system block.
*/
down_read((&EXT4_I(inode)->i_data_sem));
if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) {
retval = ext4_ext_get_blocks(handle, inode, block, max_blocks,
bh, 0, 0);
} else {
down_read((&EXT4_I(inode)->i_data_sem));
retval = ext4_get_blocks_handle(handle,
inode, block, max_blocks, bh, 0, 0);
}
up_read((&EXT4_I(inode)->i_data_sem));
if (!create || (retval > 0))
return retval;

/*
* We need to allocate new blocks which will result
* in i_data update
*/
down_write((&EXT4_I(inode)->i_data_sem));
/*
* We need to check for EXT4 here because migrate
* could have changed the inode type in between
*/
if (EXT4_I(inode)->i_flags & EXT4_EXTENTS_FL) {
retval = ext4_ext_get_blocks(handle, inode, block, max_blocks,
bh, create, extend_disksize);
} else {
retval = ext4_get_blocks_handle(handle, inode, block,
max_blocks, bh, create, extend_disksize);
}
if (create) {
up_write((&EXT4_I(inode)->i_data_sem));
} else {
up_read((&EXT4_I(inode)->i_data_sem));
}
up_write((&EXT4_I(inode)->i_data_sem));
return retval;
}

Expand Down

0 comments on commit d93f73e

Please sign in to comment.