Please consider including the attached patch to stable trees between 2.6.30 and 2.6.37. This is the modified version of the following commit which is already in upstream. commit: 34094537943113467faee98fe67c8a3d3f9a0a8b From: Ryusuke Konishi <konishi.ryusuke at lab.ntt.co.jp> Date: Sun, 27 Mar 2011 22:50:49 +0900 Subject: [PATCH] nilfs2: fix data loss in mmap page write for hole blocks This commit is applicable to 2.6.38, but is not to prior kernels as is. It will cause a build error against older kernels due to a change of nilfs_set_file_dirty function. I tested the attached patch for every kernel through from 2.6.30 to 2.6.37. It was all right except that 3-way merge was required for 2.6.30 and 2.6.31. Thanks, Ryusuke Konishi -- From: Ryusuke Konishi <konishi.ryusuke@xxxxxxxxxxxxx> nilfs2: fix data loss in mmap page write for hole blocks >From the result of a function test of mmap, mmap write to shared pages turned out to be broken for hole blocks. It doesn't write out filled blocks and the data will be lost after umount. This is due to a bug that the target file is not queued for log writer when filling hole blocks. Also, nilfs_page_mkwrite function exits normal code path even after successfully filled hole blocks due to a change of block_page_mkwrite function; just after nilfs was merged into the mainline, block_page_mkwrite() started to return VM_FAULT_LOCKED instead of zero by the patch "mm: close page_mkwrite races" (commit: b827e496c893de0c). The current nilfs_page_mkwrite() is not handling this value properly. This corrects nilfs_page_mkwrite() and will resolve the data loss problem in mmap write. [A minor adjustment was applied for 2.6.37 and prior kernels] Signed-off-by: Ryusuke Konishi <konishi.ryusuke@xxxxxxxxxxxxx> Tested-by: Ryusuke Konishi <konishi.ryusuke@xxxxxxxxxxxxx> Cc: stable <stable@xxxxxxxxxx> [2.6.30-2.6.37] --- fs/nilfs2/file.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index c9a30d7..d9d5d81 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -72,10 +72,9 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) /* * check to see if the page is mapped already (no holes) */ - if (PageMappedToDisk(page)) { - unlock_page(page); + if (PageMappedToDisk(page)) goto mapped; - } + if (page_has_buffers(page)) { struct buffer_head *bh, *head; int fully_mapped = 1; @@ -90,7 +89,6 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) if (fully_mapped) { SetPageMappedToDisk(page); - unlock_page(page); goto mapped; } } @@ -105,16 +103,18 @@ static int nilfs_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) return VM_FAULT_SIGBUS; ret = block_page_mkwrite(vma, vmf, nilfs_get_block); - if (unlikely(ret)) { + if (ret != VM_FAULT_LOCKED) { nilfs_transaction_abort(inode->i_sb); return ret; } + nilfs_set_file_dirty(NILFS_SB(inode->i_sb), inode, + 1 << (PAGE_SHIFT - inode->i_blkbits)); nilfs_transaction_commit(inode->i_sb); mapped: SetPageChecked(page); wait_on_page_writeback(page); - return 0; + return VM_FAULT_LOCKED; } static const struct vm_operations_struct nilfs_file_vm_ops = { -- 1.7.3.5 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html