Skip to content
Snippets Groups Projects
Commit e906f49b authored by Phil Schwan's avatar Phil Schwan
Browse files

b=2306

r=alex
Replace i_sem with BKL in ext3_fsfilt_write_record
parent a7870d22
No related merge requests found
...@@ -677,14 +677,19 @@ static int fsfilt_ext3_read_record(struct file * file, void *buf, ...@@ -677,14 +677,19 @@ static int fsfilt_ext3_read_record(struct file * file, void *buf,
int err, blocksize, csize, boffs; int err, blocksize, csize, boffs;
/* prevent reading after eof */ /* prevent reading after eof */
lock_kernel();
if (inode->i_size < *offs + size) { if (inode->i_size < *offs + size) {
size = inode->i_size - *offs; size = inode->i_size - *offs;
unlock_kernel();
if (size < 0) { if (size < 0) {
CERROR("size %llu is too short for read %u@%llu\n", CERROR("size %llu is too short for read %u@%llu\n",
inode->i_size, size, *offs); inode->i_size, size, *offs);
return -EIO; return -EIO;
} else if (size == 0) } else if (size == 0) {
return 0; return 0;
}
} else {
unlock_kernel();
} }
blocksize = 1 << inode->i_blkbits; blocksize = 1 << inode->i_blkbits;
...@@ -725,14 +730,14 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize, ...@@ -725,14 +730,14 @@ static int fsfilt_ext3_write_record(struct file *file, void *buf, int bufsize,
blocksize = 1 << inode->i_blkbits; blocksize = 1 << inode->i_blkbits;
block_count = (*offs & (blocksize - 1)) + bufsize; block_count = (*offs & (blocksize - 1)) + bufsize;
block_count = (block_count + blocksize - 1) >> inode->i_blkbits; block_count = (block_count + blocksize - 1) >> inode->i_blkbits;
down(&inode->i_sem);
journal = EXT3_SB(inode->i_sb)->s_journal; journal = EXT3_SB(inode->i_sb)->s_journal;
lock_kernel();
handle = journal_start(journal, handle = journal_start(journal,
block_count * EXT3_DATA_TRANS_BLOCKS + 2); block_count * EXT3_DATA_TRANS_BLOCKS + 2);
unlock_kernel();
if (IS_ERR(handle)) { if (IS_ERR(handle)) {
CERROR("can't start transaction\n"); CERROR("can't start transaction\n");
up(&inode->i_sem);
return PTR_ERR(handle); return PTR_ERR(handle);
} }
...@@ -778,16 +783,19 @@ out: ...@@ -778,16 +783,19 @@ out:
/* correct in-core and on-disk sizes */ /* correct in-core and on-disk sizes */
if (new_size > inode->i_size) { if (new_size > inode->i_size) {
lock_kernel();
if (new_size > inode->i_size) if (new_size > inode->i_size)
inode->i_size = new_size; inode->i_size = new_size;
if (inode->i_size > EXT3_I(inode)->i_disksize) if (inode->i_size > EXT3_I(inode)->i_disksize)
EXT3_I(inode)->i_disksize = inode->i_size; EXT3_I(inode)->i_disksize = inode->i_size;
if (inode->i_size > old_size) if (inode->i_size > old_size)
mark_inode_dirty(inode); mark_inode_dirty(inode);
unlock_kernel();
} }
lock_kernel();
journal_stop(handle); journal_stop(handle);
up(&inode->i_sem); unlock_kernel();
if (err == 0) if (err == 0)
*offs = offset; *offs = offset;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment