Received: by 10.192.165.156 with SMTP id m28csp2090768imm; Thu, 12 Apr 2018 08:27:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Gm953Y8wMhPcG5w+NUC3rpTS3xzWjhEdGX0O3qOb/tUJvWeuVZ7fU2z63h9AiR25Zzqnf X-Received: by 2002:a17:902:9046:: with SMTP id w6-v6mr1536312plz.393.1523546862595; Thu, 12 Apr 2018 08:27:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523546862; cv=none; d=google.com; s=arc-20160816; b=NUjE1TKDAXrJ2ZlM8w7cKt2Jev8laeqh4kIGwTdzAw6tCLRiM1V0vlEp2OfSi/sH3A Y9T26STGszs8DzzYt9oMWghUebwy/qxtELzV7W1k0kza/+XbPnIgcgHUKvFlHUPifX5C Qv907mEVMljKmBbRIKjsZl5/lfMu8WXpzQWzx4YUjdQN/IkmWJ1VHxZcAlGOa1/c9o+v c0Z5hae81y6OJ/S4OoMYCcFJA7FJv7vhW3mO7EfpNdomFIW8wY4ScemsuaGgIHC3R6aM c3yXA+94I8mke9mwWhqSWvM96ZED7au6jze4vgKWWMgJlrWxRxeJe7CieEkZviANU82Z 21tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=rCTtcbDKZXF0c1i1Wkkh8uHzOuMNIKfNqc4AZVAAq6g=; b=uS5jaNKX3802ye+rJFWpoatGvZ8BQ4PZeIyEJAdoSnzy0/7o1ZRwUJ/7FWo5Z/6ttl FSaEEwWOqpU5E2bzyX0pLnp2+ebGAW4Q1U36K0gLHtKAGNPnKfL8viOWqd3vzmbl8NOm stIf5YT4f+xaMfkmYIWYp+PKZHukjAKoqUaRBGjebCf9/o5GZbDDtZxNgspLJkis4F45 qoro8qbSfjx2mV2TbCbq7qC52IgITPxHpJoAWeHFLVPP6gjocRcX8UNXEoLoVrMNh0MX oMtD/RtjTQ4lYstsC8Ps3z89hWlW1DSyCi7tqfF7w7MxVtP9lR+4YOOij7airCInr/tx 1z2g== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m15si2375703pgs.170.2018.04.12.08.27.05; Thu, 12 Apr 2018 08:27:42 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754252AbeDLPVr (ORCPT + 99 others); Thu, 12 Apr 2018 11:21:47 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:38287 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753348AbeDLPIq (ORCPT ); Thu, 12 Apr 2018 11:08:46 -0400 Received: by mail-wm0-f66.google.com with SMTP id i3so10171595wmf.3 for ; Thu, 12 Apr 2018 08:08:45 -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=rCTtcbDKZXF0c1i1Wkkh8uHzOuMNIKfNqc4AZVAAq6g=; b=doERGRZx3PqAajsnkBfw/b5w5pgunMl//duL0jjWdROBsOe1YcQEVn5NzU7YPic17A 9hlFeiAShhVRLYqDz4bwfZcrMfe4RbtIvlSpNgnWGaN34qNVkHW6YIAi0l2DNGNikYd4 LjqI6MmqMLplQcfwdmbHwIqUOlabI74M69aCYS1LXEGbQKxEj5wjjUFalAddtwHIveiS j/Rbe2zE1UIBJ55jY0k3sixaXn7V6NxbYkQ4dj1u7YfvQ3UiBemgLXEKcCeETfMMAl56 QGz8Et0DFQx9jD9Cmx/3uxkx3397qc7XUcuvOakGgwyFtrbB10M1KRnW720ItWx480I3 FddQ== X-Gm-Message-State: ALQs6tBKsWh7SpvEuagQWPNpreP+uN/ANpKwQfcvu8A5cnBPZo6DpPao ph3112K0KVdRmqsAVhFgyN+g5A== X-Received: by 10.28.138.69 with SMTP id m66mr1077855wmd.117.1523545724605; Thu, 12 Apr 2018 08:08:44 -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 p197sm2621783wme.43.2018.04.12.08.08.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:44 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 11/35] ovl: readd read_iter Date: Thu, 12 Apr 2018 17:08:02 +0200 Message-Id: <20180412150826.20988-12-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180412150826.20988-1-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement stacked reading. Signed-off-by: Miklos Szeredi --- fs/overlayfs/file.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 409b542ff30c..a19429c5965d 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "overlayfs.h" static struct file *ovl_open_realfile(const struct file *file) @@ -129,8 +130,63 @@ static loff_t ovl_llseek(struct file *file, loff_t offset, int whence) i_size_read(realinode)); } +static void ovl_file_accessed(struct file *file) +{ + struct inode *inode = file_inode(file); + + if ((file->f_flags & O_NOATIME) || !ovl_inode_upper(inode)) + return; + + ovl_copytimes(inode); + touch_atime(&file->f_path); +} + +static rwf_t ovl_iocb_to_rwf(struct kiocb *iocb) +{ + int ifl = iocb->ki_flags; + rwf_t flags = 0; + + if (ifl & IOCB_NOWAIT) + flags |= RWF_NOWAIT; + if (ifl & IOCB_HIPRI) + flags |= RWF_HIPRI; + if (ifl & IOCB_DSYNC) + flags |= RWF_DSYNC; + if (ifl & IOCB_SYNC) + flags |= RWF_SYNC; + + return flags; +} + +static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter) +{ + struct file *file = iocb->ki_filp; + struct fd real; + const struct cred *old_cred; + ssize_t ret; + + if (!iov_iter_count(iter)) + return 0; + + ret = ovl_real_file(file, &real); + if (ret) + return ret; + + old_cred = ovl_override_creds(file_inode(file)->i_sb); + ret = vfs_iter_read(real.file, iter, &iocb->ki_pos, + ovl_iocb_to_rwf(iocb)); + revert_creds(old_cred); + + ovl_file_accessed(file); + + 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, }; -- 2.14.3