From patchwork Tue May 29 14:43:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10436105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2E256601C7 for ; Tue, 29 May 2018 15:12:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E5312880D for ; Tue, 29 May 2018 15:12:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1337428830; Tue, 29 May 2018 15:12:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC6452880D for ; Tue, 29 May 2018 15:12:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935650AbeE2PMr (ORCPT ); Tue, 29 May 2018 11:12:47 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54548 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935623AbeE2OoD (ORCPT ); Tue, 29 May 2018 10:44:03 -0400 Received: by mail-wm0-f66.google.com with SMTP id f6-v6so41348724wmc.4 for ; Tue, 29 May 2018 07:44:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SFE+MCC9wmIJeML2N/pwQ7qEKYtb4lIpa+qdxpSA0MA=; b=DG11vZgk22E9oznIugUp6VGlWdPQd/W0wUua5y/fvAiLwDkmaVqyiCc3rn5ADZnpsv L1h5XHewulmoWVeu9Ftlx0eC66luO9H9UdvJuierB/XlvtElCY7/5T8YkktwWOi8XzWi 7tAYQf7sacxLzdd3IK3RyQCxvRDTubT7mJC35Bz5nxPkO9tKZm/HeMfYyTGBRWNeAXvj 1ewk+7hiHi1fe8JYVi/nGZfVfduQFX/Dzk3qCxXKzuHYSSx0BoI6ZyAs/5Jp5+7J3fTy lYaJhRWeSLAHksHmLQjfbyhny+3rBvP0gfw3N+fXtBUOmxcQW/rf9h17CWLm93bsCU28 5r3w== X-Gm-Message-State: ALKqPwfJkrCqicihFbilxL6DD3tr8T0rhokSRuqn7IN0b5a4rUYuJ/oQ 1myTLBCYDFKhOkwDlH+iwQJ/3w== X-Google-Smtp-Source: ADUXVKIxLuhwtWky7gsRwNVDhen4cHTjxPIoebHYf3c6Hkfa42fRK6qlpVPmTtB0PBm/ub3W/mDgBA== X-Received: by 2002:a1c:d1c2:: with SMTP id i185-v6mr12715406wmg.10.1527605042811; Tue, 29 May 2018 07:44:02 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id t198-v6sm18834422wmt.23.2018.05.29.07.44.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:44:02 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/39] ovl: add ovl_fsync() Date: Tue, 29 May 2018 16:43:18 +0200 Message-Id: <20180529144339.16538-19-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144339.16538-1-mszeredi@redhat.com> References: <20180529144339.16538-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement stacked fsync(). Don't sync if lower (noticed by Amir Goldstein). Signed-off-by: Miklos Szeredi --- fs/overlayfs/file.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index a7af56861aa5..7b47dce4b072 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -233,10 +233,33 @@ 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_fdget(file, &real); + if (ret) + return ret; + + /* Don't sync lower file for fear of receiving EROFS error */ + if (file_inode(real.file) == ovl_inode_upper(file_inode(file))) { + old_cred = ovl_override_creds(file_inode(file)->i_sb); + ret = vfs_fsync_range(real.file, start, end, datasync); + revert_creds(old_cred); + } + + fdput(real); + + return ret; +} + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, .llseek = ovl_llseek, .read_iter = ovl_read_iter, .write_iter = ovl_write_iter, + .fsync = ovl_fsync, };