Commit f391475812ba39afa322c835217ffe936f5e754a
Committed by
Linus Torvalds
1 parent
96710b29e0
Exists in
master
and in
39 other branches
[PATCH] ufs: missed brelse and wrong baseblk
This patch fixes two bugs, which introduced by previous patches: 1) Missed "brelse" 2) Sometimes "baseblk" may be wrongly calculated, if i_size is equal to zero, which lead infinite cycle in "mpage_writepages". Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 2 changed files with 6 additions and 7 deletions Side-by-side Diff
fs/ufs/balloc.c
... | ... | @@ -269,20 +269,17 @@ |
269 | 269 | * We can come here from ufs_writepage or ufs_prepare_write, |
270 | 270 | * locked_page is argument of these functions, so we already lock it. |
271 | 271 | */ |
272 | -static void ufs_change_blocknr(struct inode *inode, unsigned int count, | |
273 | - unsigned int oldb, unsigned int newb, | |
274 | - struct page *locked_page) | |
272 | +static void ufs_change_blocknr(struct inode *inode, unsigned int baseblk, | |
273 | + unsigned int count, unsigned int oldb, | |
274 | + unsigned int newb, struct page *locked_page) | |
275 | 275 | { |
276 | 276 | unsigned int blk_per_page = 1 << (PAGE_CACHE_SHIFT - inode->i_blkbits); |
277 | - sector_t baseblk; | |
278 | 277 | struct address_space *mapping = inode->i_mapping; |
279 | 278 | pgoff_t index, cur_index = locked_page->index; |
280 | 279 | unsigned int i, j; |
281 | 280 | struct page *page; |
282 | 281 | struct buffer_head *head, *bh; |
283 | 282 | |
284 | - baseblk = ((i_size_read(inode) - 1) >> inode->i_blkbits) + 1 - count; | |
285 | - | |
286 | 283 | UFSD("ENTER, ino %lu, count %u, oldb %u, newb %u\n", |
287 | 284 | inode->i_ino, count, oldb, newb); |
288 | 285 | |
... | ... | @@ -439,7 +436,8 @@ |
439 | 436 | } |
440 | 437 | result = ufs_alloc_fragments (inode, cgno, goal, request, err); |
441 | 438 | if (result) { |
442 | - ufs_change_blocknr(inode, oldcount, tmp, result, locked_page); | |
439 | + ufs_change_blocknr(inode, fragment - oldcount, oldcount, tmp, | |
440 | + result, locked_page); | |
443 | 441 | |
444 | 442 | *p = cpu_to_fs32(sb, result); |
445 | 443 | *err = 0; |