Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp49915imu; Tue, 15 Jan 2019 16:22:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN7DwyzconLNjrkJ0vhN1JpnFkCOmz4FGUlPllQ8MCL4ePOmLwaLcXqQd5viMnyj9+YvaPJh X-Received: by 2002:a63:441e:: with SMTP id r30mr6329703pga.128.1547598134310; Tue, 15 Jan 2019 16:22:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547598134; cv=none; d=google.com; s=arc-20160816; b=aFFlcuT0lnH0Th7egNR7T7I1EeMfkXhpi6byyYw7j1D/t4lmuzqXOzUC6gBeoU7nK0 H5zhrOjm/BDH82DFYOMRlmDTJEROim5+ezj6hp9NV1fZN3FBYpUTTHxBC4PieppvTAU+ B40si98vsI0BxJRqmY/+1BKEELkpYbVf4wyemkZW5d+AAtR/Qn+CMdqS4eYQKEIen6Rh cscM86KziLSNoi+NKMreoERXY/9dK5HaT0kpk1QaF9hKYPvUrQX64G4OV+ILwPbc8AvC nzOwC+2m0+8f6yUh6UN4hYdB6rpmAlqJfXTf8GQZkZlgWfAud3FR26PACpXpZCZxziV2 z6/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=rzaTi5ocVbaUusXGpcAkzEP7mrqZ9s8Ewx1ITbNlfMQ=; b=qca43U/EPLnINCGG1uGJgurGqAu7AOcg7qHJYLdY0ZRQKv11c/0YGWeFangf/yizKv 2A/vWxue4WjuxosL5pNjY1EZp+OtHAd7sbWIK2n2Dtci1pEGqd9Cgd3UGFuTQ6aC5BUK mcBIk7FWjqNKDeHZvJhLBWvMzrD9q3I+nwIi1yabQHG5+D8aSJ0zs/RyIT8q8tAZooaA AleKKKSwODN8Qv3BvYxwjGT70cQbMMDyKCpl6Wj13xIymVRDV1ID01U3B05h6n57xy5+ aQFP+cy4u4r3/u+ITtoqMHoYpIXjnGdeXjP8OTyGZmetvBbY1hg04We7lMmY6GltCqbe HQ9Q== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z14si4262710pgu.525.2019.01.15.16.21.56; Tue, 15 Jan 2019 16:22:14 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731504AbfAORAL (ORCPT + 99 others); Tue, 15 Jan 2019 12:00:11 -0500 Received: from relay.sw.ru ([185.231.240.75]:52284 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732121AbfAOQij (ORCPT ); Tue, 15 Jan 2019 11:38:39 -0500 Received: from [172.16.25.169] by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1gjRjY-0004Ms-Ge; Tue, 15 Jan 2019 19:38:36 +0300 Subject: Re: [PATCH 2/2] fuse: Replace page without copying in fuse_writepage_in_flight() To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <154322517208.18737.3297786654135648324.stgit@localhost.localdomain> <154322557765.18737.14337090699283695815.stgit@localhost.localdomain> <30c6d750-01b1-fb7e-eb80-0f60f242974a@virtuozzo.com> From: Kirill Tkhai Message-ID: <1cf4d11f-224f-ca0c-55cb-01754d429fe1@virtuozzo.com> Date: Tue, 15 Jan 2019 19:38:35 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.01.2019 19:36, Miklos Szeredi wrote: > 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) Ok, thanks for the explanation. Kirill