Received: by 10.192.165.148 with SMTP id m20csp3472905imm; Mon, 23 Apr 2018 07:10:44 -0700 (PDT) X-Google-Smtp-Source: AIpwx4997/wVADqiQXm+4do3wlsDtn+MGpomdiEaiFlqi955qiCdGv9I6PwfoW3LYVL8BXXmGW4L X-Received: by 2002:a17:902:d909:: with SMTP id c9-v6mr20619585plz.229.1524492644914; Mon, 23 Apr 2018 07:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524492644; cv=none; d=google.com; s=arc-20160816; b=o43s0rMbyj4BTReySsajR1TC0AIe55n9MpMIq+IRD1xmQwH1V43msa4b99DjJ3RqY/ m9fHAXcu8TOR4vrMCakxO4JeyXi7alFV0vSDhmqOyK3cAI8TK9Naxx6wMI+aL1i2ParK blrLTu+Qvck7jzxjAWUX5zg0y9zfqVKrdW8HwxolOaupQq6txWoDxpMTFQ0hm+3I/sej xEyPkr4Nchzr4UfIczcAIlsYt+xRbfwSdIEZo0b82Y0trTbjd9O6sxsQy7MGZTKyRXui pUijChDZHGTeKiPBKoje8n72ie7P0/x2JhB2cygP4wnn6loPGdjKnUUwqmPDJtjnSqz5 45Bg== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=7L2f2+mbf80ASOXiBoiUVb3oBL3i9dDrrGa2X+Oberg=; b=QXcNpYwF3NM8QWl59i3uquu6Mn0KwToQ/6ZqgJ0r2uMMfIfjn4kLAWAloXo+REk5yK pe5uXjw+kaj6uMlbv7Nv/enPvMZNokNMLqkCATE6/71aa35P5g3UBSGIdS5SmVzPFY8H OROXPhilAG5t74vl060G7YpcqSPGa6KUgsaThAFj2JWg0ZRZBfDjUcZUOigIOWkomMSF SVoZZtUGo7Mftyc3h47fJGmOdsOtJgHD96+JZVZYSeYC+dAQdnDV32YHOmEaMhMjHRv3 udk4LxF4s0w58145OVpt/90ireZRomfpM8Nz8l9pyeqwYZqvcWhbw0KGjT1zK+yTfkbZ 0xtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=IejLJO4W; 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 k190si4883519pgc.141.2018.04.23.07.10.30; Mon, 23 Apr 2018 07:10:44 -0700 (PDT) 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=IejLJO4W; 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 S1755339AbeDWOJL (ORCPT + 99 others); Mon, 23 Apr 2018 10:09:11 -0400 Received: from mail-ot0-f195.google.com ([74.125.82.195]:46348 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755216AbeDWOJF (ORCPT ); Mon, 23 Apr 2018 10:09:05 -0400 Received: by mail-ot0-f195.google.com with SMTP id v64-v6so17326011otb.13 for ; Mon, 23 Apr 2018 07:09:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=7L2f2+mbf80ASOXiBoiUVb3oBL3i9dDrrGa2X+Oberg=; b=IejLJO4Wc9TuXegqUUR/0cG8aT4V1/sH90krrIQikfIYK9Go5zYbP06bDDV7mR4bKc cqhg62A04vV+wUt4gL66pVdopmbisud729erBqeatYrlIKjDc9QJZAKP600U042Hi2Tq mlwqmSOWKXx9I8317NXKgSL+8L8wV9WyzGW3A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=7L2f2+mbf80ASOXiBoiUVb3oBL3i9dDrrGa2X+Oberg=; b=UB2Wt0Cjn94Jx9kWIGvwv5JVgtcON/hwkIoNx/AwH6CF0c+hJ/HIpQ8Y/YCFrJRlXe MDN3FUYYPFvaruSAsz9sIrkh/2gVkLi7hHgfbXyNaM4d8HniW7O5Zk5YyfvSJ59/hVot zLQHvXKn/LM6lLDBQixyZFb5d9wrpmmN4qsgmg8jnpcgOLy3C5Tc+FtsclJ8zJxGf9Nl DTbGUmPSpILe7gtmxx05LJUU1UI80QPPQtGoh9K6jyOkbPznDx3jDvjhEqyN0PLwpN5U qqAJwm4SomT87UDjEr/GgKAhKjkP8KINFwfePttDoRJbq5l5/Xe4E+p4jgCeZqYJD3w8 RQCQ== X-Gm-Message-State: ALQs6tDzGXfWuWVYhg+XS+INaBI1rVfmojKp/b5FTuU82WgPlCwDifHF rgqNQIyvoBZzrrRXSL6P2C1TgqrP4gO+78xkYhzFCw== X-Received: by 2002:a9d:4814:: with SMTP id c20-v6mr7894785otf.306.1524492544773; Mon, 23 Apr 2018 07:09:04 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:5303:0:0:0:0:0 with HTTP; Mon, 23 Apr 2018 07:09:03 -0700 (PDT) X-Originating-IP: [176.63.54.97] In-Reply-To: <20180423135309.GC2794@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> <20180412150826.20988-14-mszeredi@redhat.com> <20180423133617.GB2794@redhat.com> <20180423135309.GC2794@redhat.com> From: Miklos Szeredi Date: Mon, 23 Apr 2018 16:09:03 +0200 Message-ID: Subject: Re: [RFC PATCH 13/35] ovl: readd fsync To: Vivek Goyal Cc: Miklos Szeredi , overlayfs , 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 Mon, Apr 23, 2018 at 3:53 PM, Vivek Goyal wrote: > On Mon, Apr 23, 2018 at 03:39:45PM +0200, Miklos Szeredi wrote: >> On Mon, Apr 23, 2018 at 3:36 PM, Vivek Goyal wrote: >> > On Thu, Apr 12, 2018 at 05:08:04PM +0200, Miklos Szeredi wrote: >> >> Implement stacked fsync(). >> >> >> >> Signed-off-by: Miklos Szeredi >> >> --- >> >> fs/overlayfs/file.c | 20 ++++++++++++++++++++ >> >> 1 file changed, 20 insertions(+) >> >> >> >> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c >> >> index b98204c1c19c..4417527667ff 100644 >> >> --- a/fs/overlayfs/file.c >> >> +++ b/fs/overlayfs/file.c >> >> @@ -222,10 +222,30 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) >> >> return ret; >> >> } >> >> >> >> +static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) >> >> +{ >> >> + struct fd real; >> >> + const struct cred *old_cred; >> >> + int ret; >> >> + >> >> + ret = ovl_real_file(file, &real); >> >> + if (ret) >> >> + return ret; >> >> + >> >> + old_cred = ovl_override_creds(file_inode(file)->i_sb); >> >> + ret = vfs_fsync_range(real.file, start, end, datasync); >> >> + revert_creds(old_cred); >> > >> > Can we avoid calling fsync() on real file if it is not upper. Is it worth >> > optimizing. >> >> Not sure it's worth bothering with. If caller of fsync(2) didn't >> worry about cost, then why should we? > > I was thinking more from the point of view of metadata copy up patches. > For a metacopy file, I was thinking if I can just issue fsync() on upper > file and skip it on lower file. Ah, in that case I agree with doing fsync only on upper. If there's a choice in implementing the given functionality (and performance doesn't matter) then the simplest one should be chosen. Thanks, Miklos