Reiserfs fixes for 2.4.17-rc2
PATCH 1/1 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
fs/reiserfs/inode.c renamed from fs/reiserfs/inode.c.orig +2 -2
@@ -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 ; }
fs/reiserfs/inode.c renamed from fs/reiserfs/inode.c.orig +10 -4
@@ -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) ;