Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5110879imu; Tue, 15 Jan 2019 11:23:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4chBkPbhFGIQ6aTgxl8jAlBPbDYYSpkSd7gkz3JTLE4gec0Au/d+pPQavY5kLG+n0WktZ6 X-Received: by 2002:a63:4566:: with SMTP id u38mr5197148pgk.4.1547580223026; Tue, 15 Jan 2019 11:23:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547580223; cv=none; d=google.com; s=arc-20160816; b=pNwqao7e2dQ1Ykza9vA0TN9j0QqU/Beh7BL+LI1/qPakSB1nDIdw3aQ7q39ra1yY8q EqcQb1OD8/oZm9sq7El9m+fSboL4ockhA+9BbZmK3Y1SDnSOI14Fea/tCUteZG1FJIuO KsXLPOJXwZSjhRavBpWJwZ8gTYqOa8uOoHUR5jnhoNlSC7qIiH+VIevifhzueYrGEbD9 vMgWnTMffobHSMxPbW2U33Gx7B42hpqlKRQ+hrrKYJyd14rWERo+bdg8JQvCJhZXg4vw u8NS/O4Lw/6BrfOWz0xhIpAE+gcXRIQOT+nJ5yTGiYbX6AZiK+9hyLne+696qN/5c98L 88VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ld3FJqveh+3j6+uH55ub7TfDDCfe/MQxZuZvzp/WU8Q=; b=S9JrX9MOQvS4x0KLFf8k2TaCedbR6eWPntxIlfYrsa1i0ORABmhkZsJYHlsc1YfVkH cTyK0pooh6cXX+9miXTjTB0QLq4RpoC3DmnEOkuHVvPN1bMKSsmJuSWRuNksQOeHzP3P b9ggEAD8/GmY0+Zs7y5I+Ht3Si+7TZ828efvhqmb9nXgGMdh+NRBqNKZmtEHeQROxagU q5MTc9f1WRGQp0Bx/mmsiG6bcrqIoBxhXUzuAKmf3XFqqnkSYay7Ren6/VqhfB7MzBCC 3GtculCl98cS0F57Id1ENO5s+UjRvWsM8HlCWLqqM5i21rW7XVnt5Piaz0m8nKS5YSSd /G8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=olpdrQ43; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o33si4074487pld.121.2019.01.15.11.23.26; Tue, 15 Jan 2019 11:23:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=olpdrQ43; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731665AbfAOQgr (ORCPT + 99 others); Tue, 15 Jan 2019 11:36:47 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:33812 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731655AbfAOQgq (ORCPT ); Tue, 15 Jan 2019 11:36:46 -0500 Received: by mail-it1-f193.google.com with SMTP id x124so1481868itd.1 for ; Tue, 15 Jan 2019 08:36:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ld3FJqveh+3j6+uH55ub7TfDDCfe/MQxZuZvzp/WU8Q=; b=olpdrQ43g7BH+YnxzwO0QQj5u82FqslAuT0j+OsCcsazL0DNWVbfUIilpqhaM7CUJ7 pV0Y1nNwF6PMy/1dvKkmJhbVkBSHdfAt/mtJNAI4xdkl1sZcwIZMyLGMuhxFAppTlz0l fTKCgibGh2m93MJTCNyakccko1/2lSFBfxLWg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ld3FJqveh+3j6+uH55ub7TfDDCfe/MQxZuZvzp/WU8Q=; b=QXLCruqjLS7TnaijHFJY7LKh8Wuml4kCXJJllyAdn3PRTABY65uFUXCrBhZK+j6BR2 2ncfWDsd3leHzllgBmMT1f4SMq9MEIsvLPHBdBlzkOw+MnpXOkLtJMXwB/xbGtLiXoC4 FKIHjgEd+9L8agVIgd2Q63Edv7Kxsm5V0SHdgrYIME4me6p7WN5Bf65KG/Pbm8FyYR+x /kVO7LE2qpV9qn1kHEwH1Zv2NSF9re0unmQ+Q8Sx6N7pK70BuyaExd1aoZp0c94eV2Pw qKUYaR1/pYrmIctomyvUxQVCwX3c6GKpdBpjuB5qphaw1Dl5MD6nJDKsZ5lCxmFVEiBP UsLw== X-Gm-Message-State: AJcUukdZtxK7gy758kxSuzSVJG3xfoKOFjj42Tnr5Ha9dqaETmTPVEyE NzrZyHDXf/YlO3YX6NhjI0IuZHMB6Ct4FtecOy94kQ== X-Received: by 2002:a24:e38f:: with SMTP id d137mr2841548ith.69.1547570202473; Tue, 15 Jan 2019 08:36:42 -0800 (PST) MIME-Version: 1.0 References: <154322517208.18737.3297786654135648324.stgit@localhost.localdomain> <154322557765.18737.14337090699283695815.stgit@localhost.localdomain> <30c6d750-01b1-fb7e-eb80-0f60f242974a@virtuozzo.com> In-Reply-To: <30c6d750-01b1-fb7e-eb80-0f60f242974a@virtuozzo.com> From: Miklos Szeredi Date: Tue, 15 Jan 2019 17:36:18 +0100 Message-ID: Subject: Re: [PATCH 2/2] fuse: Replace page without copying in fuse_writepage_in_flight() To: Kirill Tkhai Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 15, 2019 at 5:14 PM Kirill Tkhai wrote: > > On 15.01.2019 18:39, Miklos Szeredi wrote: > > On Mon, Nov 26, 2018 at 10:46 AM Kirill Tkhai wrote: > >> > >> It looks like we can optimize old_req page replacement > >> and avoid copying by simple updating the request's page. > >> > >> Signed-off-by: Kirill Tkhai > >> --- > >> fs/fuse/file.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/fs/fuse/file.c b/fs/fuse/file.c > >> index c6650c68b31a..83b54b082c86 100644 > >> --- a/fs/fuse/file.c > >> +++ b/fs/fuse/file.c > >> @@ -1778,7 +1778,7 @@ static bool fuse_writepage_in_flight(struct fuse_req *new_req, > >> if (old_req->num_pages == 1 && old_req != first_req) { > >> struct backing_dev_info *bdi = inode_to_bdi(page->mapping->host); > >> > >> - copy_highpage(old_req->pages[0], page); > >> + swap(old_req->pages[0], page); > > > > This would mess up refcounting for all pages involved. need to swap > > with the temp page in new_req. Fixed version in #for-next. > > You are sure, page is just a simple pointer, not struct **page. > Then we would have had to change fuse_writepage_in_flight() to use ** pointer. Using a struct page** would still have been broken, not because of refcounting, but because of putting the wrong page into the request (we do the temporary copy to avoid some issues with adding the page cache page directly into the request) Thanks, Miklos