diff options
author | Maxim Patlasov <MPatlasov@parallels.com> | 2013-08-12 20:39:30 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-26 16:52:49 -0700 |
commit | f35b12e6453f12bb65f7d492b751f05cdeb41518 (patch) | |
tree | 7de892dd0688af4e058b7ecdd75406c70dfca6c7 /fs/xfs/xfs_bit.c | |
parent | cd76cc4459ac83aa17226ceac9058abbfe8385c8 (diff) | |
download | kernel_samsung_smdk4412-f35b12e6453f12bb65f7d492b751f05cdeb41518.zip kernel_samsung_smdk4412-f35b12e6453f12bb65f7d492b751f05cdeb41518.tar.gz kernel_samsung_smdk4412-f35b12e6453f12bb65f7d492b751f05cdeb41518.tar.bz2 |
fuse: postpone end_page_writeback() in fuse_writepage_locked()
commit 4a4ac4eba1010ef9a804569058ab29e3450c0315 upstream.
The patch fixes a race between ftruncate(2), mmap-ed write and write(2):
1) An user makes a page dirty via mmap-ed write.
2) The user performs shrinking truncate(2) intended to purge the page.
3) Before fuse_do_setattr calls truncate_pagecache, the page goes to
writeback. fuse_writepage_locked fills FUSE_WRITE request and releases
the original page by end_page_writeback.
4) fuse_do_setattr() completes and successfully returns. Since now, i_mutex
is free.
5) Ordinary write(2) extends i_size back to cover the page. Note that
fuse_send_write_pages do wait for fuse writeback, but for another
page->index.
6) fuse_writepage_locked proceeds by queueing FUSE_WRITE request.
fuse_send_writepage is supposed to crop inarg->size of the request,
but it doesn't because i_size has already been extended back.
Moving end_page_writeback to the end of fuse_writepage_locked fixes the
race because now the fact that truncate_pagecache is successfully returned
infers that fuse_writepage_locked has already called end_page_writeback.
And this, in turn, infers that fuse_flush_writepages has already called
fuse_send_writepage, and the latter used valid (shrunk) i_size. write(2)
could not extend it because of i_mutex held by ftruncate(2).
Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/xfs/xfs_bit.c')
0 files changed, 0 insertions, 0 deletions