Messages in this thread Patches in this message | | | Date | Wed, 19 Dec 2001 19:56:53 +0300 | From | Oleg Drokin <> | Subject | [PATCH] Reiserfs fixes for 2.4.17-rc2 |
| |
Hello!
Attached are 2 fixes for reiserfs in 2.4.17-rc2 map_block_for_writepage_highmem_fix-1.diff fixes oops on incorerct access to (possibly) unkmapped highmem pages. mmaped_data_loss_fix.diff fixes a problem where some data may be lost if mmap-writed data is subsequently appended by data written with write(2), and because of that mmapped data is lost. (Originally found by fsx tool)
Bye, Oleg --- linux/fs/reiserfs/inode.c.orig Wed Dec 19 16:26:05 2001 +++ linux/fs/reiserfs/inode.c Wed Dec 19 16:32:02 2001 @@ -1772,6 +1772,7 @@ int bytes_copied = 0 ; int copy_size ; + kmap(bh_result->b_page) ; start_over: lock_kernel() ; journal_begin(&th, inode->i_sb, jbegin_count) ; @@ -1844,10 +1845,8 @@ /* this is where we fill in holes in the file. */ if (use_get_block) { - kmap(bh_result->b_page) ; retval = reiserfs_get_block(inode, block, bh_result, GET_BLOCK_CREATE | GET_BLOCK_NO_ISEM) ; - kunmap(bh_result->b_page) ; if (!retval) { if (!buffer_mapped(bh_result) || bh_result->b_blocknr == 0) { /* get_block failed to find a mapped unformatted node. */ @@ -1856,6 +1855,7 @@ } } } + kunmap(bh_result->b_page) ; return retval ; } --- linux/fs/reiserfs/inode.c.orig Tue Dec 18 14:50:24 2001 +++ linux/fs/reiserfs/inode.c Tue Dec 18 14:52:04 2001 @@ -273,7 +273,9 @@ pathrelse (&path); if (p) kunmap(bh_result->b_page) ; - if ((args & GET_BLOCK_NO_HOLE)) { + // We do not return -ENOENT if there is a hole but page is uptodate, because it means + // That there is some MMAPED data associated with it that is yet to be written to disk. + if ((args & GET_BLOCK_NO_HOLE) && !Page_Uptodate(bh_result->b_page) ) { return -ENOENT ; } return 0 ; @@ -294,9 +296,13 @@ bh_result->b_dev = inode->i_dev; bh_result->b_blocknr = blocknr; bh_result->b_state |= (1UL << BH_Mapped); - } else if ((args & GET_BLOCK_NO_HOLE)) { - ret = -ENOENT ; - } + } else + // We do not return -ENOENT if there is a hole but page is uptodate, because it means + // That there is some MMAPED data associated with it that is yet to be written to disk. + if ((args & GET_BLOCK_NO_HOLE) && !Page_Uptodate(bh_result->b_page) ) { + ret = -ENOENT ; + } + pathrelse (&path); if (p) kunmap(bh_result->b_page) ; | |