ocfs2/mmap: return 0 in page_mkwrite to let VFS retry.
PATCH 1/1 ocfs2/mmap: return 0 in page_mkwrite to let VFS retry.
In ocfs2_page_mkwrite, we return -EINVAL when we found the page mapping isn't updated, and it will cause the user space program get SIGBUS and exit. The reason is that during race writeable mmap, we will do unmap_mapping_range in ocfs2_data_downconvert_worker. The good thing is that if we reuturn 0 in page_mkwrite, VFS will retry fault and then call page_mkwrite again, so it is safe to return 0 here.
--- fs/ocfs2/mmap.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
fs/ocfs2/mmap.c +5 -1
@@ -113,7 +113,11 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh,* ocfs2_write_begin_nolock(). */ if (!PageUptodate (page) || page->mapping != inode->i_mapping) { - ret = -EINVAL ; +/* +* the page has been umapped in ocfs2_data_downconvert_worker. +* So return 0 here and let VFS retry. +*/ + ret =0 ; goto out; }
Signature · 1 line
1.5.3.6.861.gd794-dirty
PATCH 1/1 ocfs2/mmap: return 0 in page_mkwrite to let VFS retry.
Tao,
Please can you attach this to the bugzilla.
http://oss.oracle.com/bugzilla/show_bug.cgi?id=1019
Easier to track fixes.
Thanks
Sunil
Quoted 30 lines · Tao Ma
In
ocfs2_page_mkwrite, we return-EINVALwhen we found the page mapping isn't updated, and it will cause the user space program get SIGBUS and exit. The reason is that during race writeable mmap, we will dounmap_mapping_rangeinocfs2_data_downconvert_worker. The good thing is that if we reuturn 0 inpage_mkwrite, VFS will retry fault and then callpage_mkwriteagain, so it is safe to return 0 here.Signed-off-by Tao Ma <[email protected]>--- fs/ocfs2/mmap.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)fs/ocfs2/mmap.c +5
-1@@ -113,7 +113,11 @@ static int __ocfs2_page_mkwrite(struct inode *inode, struct buffer_head *di_bh,* ocfs2_write_begin_nolock(). */ if (!PageUptodate (page) || page->mapping != inode->i_mapping) { - ret = -EINVAL ; +/* +* the page has been umapped in ocfs2_data_downconvert_worker. +* So return 0 here and let VFS retry. +*/ + ret =0 ; goto out; }