From: Kirill Tkhai Date: Mon, 26 Nov 2018 09:46:20 +0000 (+0300) Subject: fuse: Replace page without copying in fuse_writepage_in_flight() X-Git-Tag: v5.1-rc1~50^2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5de16cca2d7268833abfd6456d73fbba447c19b;p=thirdparty%2Flinux.git fuse: Replace page without copying in fuse_writepage_in_flight() It looks like we can optimize page replacement and avoid copying by simple updating the request's page. [SzM: swap with new request's tmp page to avoid use after free.] Signed-off-by: Kirill Tkhai Signed-off-by: Miklos Szeredi --- diff --git a/fs/fuse/file.c b/fs/fuse/file.c index ee59599f4947f..6b6e2574e7335 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -1789,7 +1789,7 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req, if (curr_index == page->index) { WARN_ON(tmp->num_pages != 1); WARN_ON(!test_bit(FR_PENDING, &tmp->flags)); - copy_highpage(tmp->pages[0], page); + swap(tmp->pages[0], new_req->pages[0]); break; } }