From patchwork Mon Aug 27 12:55:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10577065 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E004139B for ; Mon, 27 Aug 2018 12:54:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ACD02943E for ; Mon, 27 Aug 2018 12:54:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2E4F29958; Mon, 27 Aug 2018 12:54:17 +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=-4.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS 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 99C312943E for ; Mon, 27 Aug 2018 12:54:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727142AbeH0Qkt (ORCPT ); Mon, 27 Aug 2018 12:40:49 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:33653 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726925AbeH0Qks (ORCPT ); Mon, 27 Aug 2018 12:40:48 -0400 Received: by mail-wr1-f67.google.com with SMTP id v90-v6so13550717wrc.0; Mon, 27 Aug 2018 05:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z8UVetByIKcQIl6vyypHPQbvphTK18rJPPyUIR7dOF4=; b=ABWPiBaC5vQZGQv3Ci3smGKpmufV8p5JtyXPARrwxQOiE5K8jdKLrmizGx9smUQ0ep pLs41J6xGUEJbS6q1bPX2jehlKku2U33rLaGzs/zn2x2J6BN3BPCLQm4z3tOLgsj6qwS tQ/WYm511yZf8hC9LQgPNMkYpQ9DYEytolQLiwIJsTtEEt/ighFvrTCtYh4MwqFuZJnu C78uFeQNmNTWzKtphrlLE7xggBS/PfKfvZiigXPFnyVNTjJFvRXFsE93uKJPL93sVC6w 0fAZUeS2wZNBV3eDxXXiTopYCWTwCZ7akp3io5argxy2DFxojlMDfeWT2OPRyVhFpEYd YfVQ== 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=Z8UVetByIKcQIl6vyypHPQbvphTK18rJPPyUIR7dOF4=; b=lN8N7B9mgL4w/LBHuti5sz0ywpBaYySekwNg0KywQMCYnjcIgZuQ94XO+w/677yZE1 YgRHJvTYlMRuRTPNTcX2CZZAHcwHuBvdZbAFn1jxVfBnIiKgBSge0dXjBFtJ3JT48lSa kuHcEyj5DI+0PD33KpJAb40ddNS3bzfPnzXhNZ07OiXHq4FulxDSeh7v5ItOp/tWMdBn TbVmjs7j2DWunuqGJFEZqPt8j/E3MIRqOUa4U9Z+Bbioewzk+RtqE7cNMa9HE/FptxjK kktHPhUbYljbg79A9MsYoAGKmHJJzRVYL6+AkzAIp907Ou7+oyA2UhCOvv97ax91boPb cm9g== X-Gm-Message-State: APzg51BzxsIPbjcgue/QtTEfB5X5VEdZveGd4ZoLmkKEc9SX5eKzDgKU uVNLWE3NNIBPkN7lvRDBUSw= X-Google-Smtp-Source: ANB0VdaprLrCn14+M0DQ9Q18RUFkKia8dXxGsBBC4GepJAtXESJGdhIs/KwgSIZ9wJ/eOFie5wqTfQ== X-Received: by 2002:adf:806d:: with SMTP id 100-v6mr8411076wrk.23.1535374454638; Mon, 27 Aug 2018 05:54:14 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id z14-v6sm8504046wma.18.2018.08.27.05.54.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 05:54:14 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , Dave Chinner , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 1/6] ovl: respect FIEMAP_FLAG_SYNC flag Date: Mon, 27 Aug 2018 15:55:59 +0300 Message-Id: <1535374564-8257-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535374564-8257-1-git-send-email-amir73il@gmail.com> References: <1535374564-8257-1-git-send-email-amir73il@gmail.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 Stacked overlayfs fiemap operation broke xfstests that test delayed allocation (with "_test_generic_punch -d"), because ovl_fiemap() failed to write dirty pages when requested. Fixes: 9e142c4102db ("ovl: add ovl_fiemap()") Signed-off-by: Amir Goldstein --- fs/overlayfs/inode.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index e0bb217c01e2..5014749fd4b4 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -467,6 +467,10 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, return -EOPNOTSUPP; old_cred = ovl_override_creds(inode->i_sb); + + if (fieinfo->fi_flags & FIEMAP_FLAG_SYNC) + filemap_write_and_wait(realinode->i_mapping); + err = realinode->i_op->fiemap(realinode, fieinfo, start, len); revert_creds(old_cred); From patchwork Mon Aug 27 12:56:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10577067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1DEF139B for ; Mon, 27 Aug 2018 12:54:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF28D298D8 for ; Mon, 27 Aug 2018 12:54:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2D892943E; Mon, 27 Aug 2018 12:54:18 +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=-4.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS 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 64A902943E for ; Mon, 27 Aug 2018 12:54:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727217AbeH0Qkt (ORCPT ); Mon, 27 Aug 2018 12:40:49 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40578 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727078AbeH0Qkt (ORCPT ); Mon, 27 Aug 2018 12:40:49 -0400 Received: by mail-wm0-f68.google.com with SMTP id 207-v6so8164366wme.5; Mon, 27 Aug 2018 05:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HswLq/OWp7k6e0Ikyp5vQlEUpWGg3FDrBN49yAh1Zow=; b=PracRvP7Ov0bEur3XxghCpy1o5mSpsXOaH2JlgJ+mW8a5uRryUs9fffW/pyAmWfdeI uLNlY5IVrWVWhDMH0+BtUyld9uxXsn/agGGQJjyAao0Br4PIZGqHdNz3BwiB6Iml6eRv 2UacO/B9JpZTYshWamjq0vj4RGsko3qils3KLRGUWOMSsg00xvMlXN8yfZeETMX9YoFW MbiJUR1cBgG31DnIkUWo1o9RdU3LzLsJNG9C353CzvYInPGs6aj+fUV+udug5i+ryItj 3XpyZFpzmUn3qZgygIcYGNr0xN9ANr5+d1683AiD5t9vOrD6gutF3QilFSh+tifpESoq 0+Qw== 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=HswLq/OWp7k6e0Ikyp5vQlEUpWGg3FDrBN49yAh1Zow=; b=j9cNP/455LSMSKLD+sL3gjFvrWIf/hyBp6sk449abPcIR6z2iJNu9j2buKI/mLS12j 4eU+fi9BtcyOuJamqljrTyCfAkSKiR2ILXhnvRIIX3/Cp6L8VFwUW45iHA4oU0osZ9D5 cBaIThiVm6/eXaI33uKPRTagbc2LO4w2IhE4XSpJxE7qy1vuEs7JnRXTwTYo3XjceLfi 93hCiFrnjQs2bJ+8+mBjEfuFTjeRTj7LSFtL/qaIN+9ywsiI7c+FBcFnykb92EuJN71k xKhjgsbAL5iY0rYBqO9Ff0DtYnuuJhlOInDKg4gj4Y3jTp0xvHhJueVVDeQsYvhJBGQa 5yqw== X-Gm-Message-State: APzg51CEq59Ah5ccXmUr06/Ocy/K24maefceOW0ryAgwAz/9omb7WqrW pyr3iDwFL/7Kv3NuKn1NPPU= X-Google-Smtp-Source: ANB0VdYW0AbM3twJfUUDj//dY8IqTiUyKGG1MmBN5L2E9j5Xwcd9kVwugZyHURcCF2mbM8Dyz/fpag== X-Received: by 2002:a1c:19c2:: with SMTP id 185-v6mr5711213wmz.79.1535374455979; Mon, 27 Aug 2018 05:54:15 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id z14-v6sm8504046wma.18.2018.08.27.05.54.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 05:54:15 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , Dave Chinner , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 2/6] ovl: fix GPF in swapfile_activate of file from overlayfs over xfs Date: Mon, 27 Aug 2018 15:56:00 +0300 Message-Id: <1535374564-8257-3-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535374564-8257-1-git-send-email-amir73il@gmail.com> References: <1535374564-8257-1-git-send-email-amir73il@gmail.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 Since overlayfs implements stacked file operations, the underlying filesystems are not supposed to be exposed to the overlayfs file, whose f_inode is an overlayfs inode. Assigning an overlayfs file to swap_file results in an attempt of xfs code to dereference an xfs_inode struct from an ovl_inode pointer: CPU: 0 PID: 2462 Comm: swapon Not tainted 4.18.0-xfstests-12721-g33e17876ea4e #3402 RIP: 0010:xfs_find_bdev_for_inode+0x23/0x2f Call Trace: xfs_iomap_swapfile_activate+0x1f/0x43 __se_sys_swapon+0xb1a/0xee9 Fix this by not assigning the real inode mapping to f_mapping, which will cause swapon() to return an error (-EINVAL). Although it makes sense not to allow setting swpafile on an overlayfs file, some users may depend on it, so we may need to fix this up in the future. Keeping f_mapping pointing to overlay inode mapping will cause O_DIRECT open to fail. Fix this by installing ovl_aops with noop_direct_IO in overlay inode mapping. Keeping f_mapping pointing to overlay inode mapping will cause other a_ops related operations to fail (e.g. readahead()). Those will be fixed by follow up patches. Suggested-by: Miklos Szeredi Fixes: f7c72396d0de ("ovl: add O_DIRECT support") Signed-off-by: Amir Goldstein --- fs/overlayfs/file.c | 3 --- fs/overlayfs/inode.c | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 32e9282893c9..a4acd84591d4 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -131,9 +131,6 @@ static int ovl_open(struct inode *inode, struct file *file) if (IS_ERR(realfile)) return PTR_ERR(realfile); - /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */ - file->f_mapping = realfile->f_mapping; - file->private_data = realfile; return 0; diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 5014749fd4b4..b6ac545b5a32 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -504,6 +504,11 @@ static const struct inode_operations ovl_special_inode_operations = { .update_time = ovl_update_time, }; +const struct address_space_operations ovl_aops = { + /* For O_DIRECT dentry_open() checks f_mapping->a_ops->direct_IO */ + .direct_IO = noop_direct_IO, +}; + /* * It is possible to stack overlayfs instance on top of another * overlayfs instance as lower layer. We need to annonate the @@ -575,6 +580,7 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode, dev_t rdev, case S_IFREG: inode->i_op = &ovl_file_inode_operations; inode->i_fop = &ovl_file_operations; + inode->i_mapping->a_ops = &ovl_aops; break; case S_IFDIR: From patchwork Mon Aug 27 12:56:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10577069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 78845920 for ; Mon, 27 Aug 2018 12:54:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66C5F2943E for ; Mon, 27 Aug 2018 12:54:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A40829958; Mon, 27 Aug 2018 12:54:20 +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=-4.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS 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 E6B602943E for ; Mon, 27 Aug 2018 12:54:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727308AbeH0Qkv (ORCPT ); Mon, 27 Aug 2018 12:40:51 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44924 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727078AbeH0Qkv (ORCPT ); Mon, 27 Aug 2018 12:40:51 -0400 Received: by mail-wr1-f66.google.com with SMTP id v16-v6so13525948wro.11; Mon, 27 Aug 2018 05:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6mNJq1bdQTU8q4SD+Qao1STjN/Nn+P+YBh4Bs7nCHSc=; b=RSIKhWj+QXnjIWHIEy9O4uneckiwy+N668B/qImszZLSvnYwULHsUeGSMe05xGkcIq Q5wRLoO5M+R2y3GNukNpBWzq+KFFY8oGQJMMyYmJ+z3BkUjs6j6EY1eZmmwgtkMFMqvW U0pmaSYuSc6szea5S2NwCMapLijmUoz+udadH54KBikGAjtT+onFmjj6ecLZGzV4/sC1 nNwzE4tZdK2PWduBx0SNUQHwQIfy7ngniPmYhPE0zSG/lnP/AkkKTKfHFp9M5YjVwL4g v+CBoREYoltmAbYLPFOOFwS2F58Bq/x7cyhjC6LkJpMdb2VsDKZqB6Fypi+Jai7MKz2P 7u9A== 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=6mNJq1bdQTU8q4SD+Qao1STjN/Nn+P+YBh4Bs7nCHSc=; b=kx6112oMqIw0p6Ev6HvBnFcAd5MvEuQhFbyOoqCdg3PmC+XguhcVuAEmM9zlVmIHep rVkDyT9VXizUw7Gl5CYwoqpPMfyyUVOrPkC6owyhoxsoczghpX2eyR5Wq0Xkz4MXMyfA RyIsDvS9smyYneRay5N5VnZA8jSqIon6MTtSJN9JpfSUXVIEdrWccYxWUyQ9kfKWRBct sd6gAy8liS9CaFKWdX5g5vwaXJ55U04gIpyGIZPYHdTSoInbBIhzKb6CpU4Q9OirNAB3 ICBPfv2A3B2KHeiQ7MWmwNxQn22i1/5RxOf2Ws/2FgGnAs4Sf3r5hQacFQvtX19kDbWl CpUQ== X-Gm-Message-State: APzg51C5qlaaQ5onw5YU2CsYqcIHzWq+v5Nzc95YLEi/l1/xibDaL/9b BM5HjKwsXQ0doTlNYMo8epg= X-Google-Smtp-Source: ANB0VdbFoC0xIujtVO5iaMeC0RGtFKw1sYlSbc1adkBV7sbMYSTzwVTp0OSX4ZwaySXL/wmiTyTMAQ== X-Received: by 2002:adf:eb47:: with SMTP id u7-v6mr1267350wrn.22.1535374457182; Mon, 27 Aug 2018 05:54:17 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id z14-v6sm8504046wma.18.2018.08.27.05.54.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 05:54:16 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , Dave Chinner , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 3/6] Documentation/filesystems: update documentation of file_operations to kernel 4.18 Date: Mon, 27 Aug 2018 15:56:01 +0300 Message-Id: <1535374564-8257-4-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535374564-8257-1-git-send-email-amir73il@gmail.com> References: <1535374564-8257-1-git-send-email-amir73il@gmail.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 Signed-off-by: Amir Goldstein --- Documentation/filesystems/vfs.txt | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 4b2084d0f1fb..e0ace944a0e1 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -848,7 +848,7 @@ struct file_operations ---------------------- This describes how the VFS can manipulate an open file. As of kernel -4.1, the following members are defined: +4.18, the following members are defined: struct file_operations { struct module *owner; @@ -858,11 +858,11 @@ struct file_operations { ssize_t (*read_iter) (struct kiocb *, struct iov_iter *); ssize_t (*write_iter) (struct kiocb *, struct iov_iter *); int (*iterate) (struct file *, struct dir_context *); + int (*iterate_shared) (struct file *, struct dir_context *); __poll_t (*poll) (struct file *, struct poll_table_struct *); long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long); long (*compat_ioctl) (struct file *, unsigned int, unsigned long); int (*mmap) (struct file *, struct vm_area_struct *); - int (*mremap)(struct file *, struct vm_area_struct *); int (*open) (struct inode *, struct file *); int (*flush) (struct file *, fl_owner_t id); int (*release) (struct inode *, struct file *); @@ -882,6 +882,9 @@ struct file_operations { #ifndef CONFIG_MMU unsigned (*mmap_capabilities)(struct file *); #endif + ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); + int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); + int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, u64); }; Again, all methods are called without any locks being held, unless @@ -899,6 +902,9 @@ otherwise noted. iterate: called when the VFS needs to read the directory contents + iterate_shared: called when the VFS needs to read the directory contents + when filesystem supports concurrent dir iterators + poll: called by the VFS when a process wants to check if there is activity on this file and (optionally) go to sleep until there is activity. Called by the select(2) and poll(2) system calls @@ -906,7 +912,7 @@ otherwise noted. unlocked_ioctl: called by the ioctl(2) system call. compat_ioctl: called by the ioctl(2) system call when 32 bit system calls - are used on 64 bit kernels. + are used on 64 bit kernels. mmap: called by the mmap(2) system call @@ -931,7 +937,7 @@ otherwise noted. (non-blocking) mode is enabled for a file lock: called by the fcntl(2) system call for F_GETLK, F_SETLK, and F_SETLKW - commands + commands get_unmapped_area: called by the mmap(2) system call @@ -951,6 +957,14 @@ otherwise noted. fallocate: called by the VFS to preallocate blocks or punch a hole. + copy_file_range: called by the copy_file_range(2) system call. + + clone_file_range: called by the ioctl(2) system call for FICLONERANGE and + FICLONE commands. + + dedupe_file_range: called by the ioctl(2) system call for FIDEDUPERANGE + command. + Note that the file operations are implemented by the specific filesystem in which the inode resides. When opening a device node (character or block special) most filesystems will call special From patchwork Mon Aug 27 12:56:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10577071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B793139B for ; Mon, 27 Aug 2018 12:54:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78EB02943E for ; Mon, 27 Aug 2018 12:54:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CCD829958; Mon, 27 Aug 2018 12:54:22 +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=-4.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS 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 E570E2943E for ; Mon, 27 Aug 2018 12:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbeH0Qkx (ORCPT ); Mon, 27 Aug 2018 12:40:53 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33956 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbeH0Qkx (ORCPT ); Mon, 27 Aug 2018 12:40:53 -0400 Received: by mail-wr1-f66.google.com with SMTP id g33-v6so13538733wrd.1; Mon, 27 Aug 2018 05:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jL7sLTbCyO5RPe3elSBCqo4TTca8IHg7L7s7xUmWDhk=; b=nJGd2FHpUYu/CufB8fWDYaM3D8zvbpbFGiMKqlQbrMxAb83diG65S88Djtqwp+OhA5 wKGaKyIGSW/CupsuwVe2xgTFgm9+tIwrkVqUtbK09cbX0q1NbfOP9oyJ75Z6P1YjsV6f OjYEvR7Whn3xhuTzlQdtuwm9kWHIO9urLsOV83Pm+uKc+Vy4HLQUmvtxNU5dDZGRoyEC l1rAQP0Z6DjAdjUBEuq0WcKZZqT8BfYeRqKTheU1cX4TJx94Fv2djhlXPUsQj1zahl6N Gf5RmCIw29Idkm4khD/Qm1Og4qbHxdqic6z31jJCMmVZZLyzPc7yavSfXjkYxoD3RTYy abRQ== 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=jL7sLTbCyO5RPe3elSBCqo4TTca8IHg7L7s7xUmWDhk=; b=T/6ekmFTjE8+OGcMR80P6SPwHK6bGCJgnNYRDWmb4bNDcG2T30w6sFAbW/BIoIXsXj 2113jmpWvd964sbavbxoF9V1Zm1WWN7qeY8128Ho4zux+oxlh1nTxB8s2W4KffQsP56i 8Z19gh9Nuzr9phTFpA08HXVMYsI9ViamLhY4l90ka3YzTbKGwES1swC9BV+aotkX5QqH ipfQYQauGzxJ6cnId5iolm7DGT/nzAO28I3lCGTOfsA4OhM/TZPQnlf2DBhXk50ZpzaI U6BP8fwbymtTHtpWtlvS6knAIk5YEaGQOD7mKrcLeUfT+q9yTD0imDMy3erG5RraTAxI uaAw== X-Gm-Message-State: APzg51DjJ2wWDU05CwlpbFoPvLzoCM7mCLG8o99S5FtC22QdcoSfOtAb DXXhBsIBtkxWIQnM3Cw7X4w= X-Google-Smtp-Source: ANB0Vdajc/pcta+sEHI3A0ZXuJ9bg2ouw7GG7BNajmtmh0dg4GkLMVpRE0H8l1xcjEgDsiyKQgdpTQ== X-Received: by 2002:adf:ad34:: with SMTP id p49-v6mr8905335wrc.10.1535374458526; Mon, 27 Aug 2018 05:54:18 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id z14-v6sm8504046wma.18.2018.08.27.05.54.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 05:54:17 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , Dave Chinner , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 4/6] vfs: add the fadvise() file operation Date: Mon, 27 Aug 2018 15:56:02 +0300 Message-Id: <1535374564-8257-5-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535374564-8257-1-git-send-email-amir73il@gmail.com> References: <1535374564-8257-1-git-send-email-amir73il@gmail.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 This is going to be used by overlayfs and possibly useful for other filesystems. Signed-off-by: Amir Goldstein --- Documentation/filesystems/vfs.txt | 3 ++ include/linux/fs.h | 5 +++ mm/fadvise.c | 78 ++++++++++++++++++++++----------------- 3 files changed, 53 insertions(+), 33 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index e0ace944a0e1..4868fa9c0758 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -885,6 +885,7 @@ struct file_operations { ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, u64); + int (*fadvise)(struct file *, loff_t, loff_t, int); }; Again, all methods are called without any locks being held, unless @@ -965,6 +966,8 @@ otherwise noted. dedupe_file_range: called by the ioctl(2) system call for FIDEDUPERANGE command. + fadvise: possibly called by the fadvise64() system call. + Note that the file operations are implemented by the specific filesystem in which the inode resides. When opening a device node (character or block special) most filesystems will call special diff --git a/include/linux/fs.h b/include/linux/fs.h index 33322702c910..6c0b4a1c22ff 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1763,6 +1763,7 @@ struct file_operations { u64); int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, u64); + int (*fadvise)(struct file *, loff_t, loff_t, int); } __randomize_layout; struct inode_operations { @@ -3459,4 +3460,8 @@ static inline bool dir_relax_shared(struct inode *inode) extern bool path_noexec(const struct path *path); extern void inode_nohighmem(struct inode *inode); +/* mm/fadvise.c */ +extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len, + int advice); + #endif /* _LINUX_FS_H */ diff --git a/mm/fadvise.c b/mm/fadvise.c index 2d8376e3c640..2f59bac1cb77 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -27,9 +27,9 @@ * deactivate the pages and clear PG_Referenced. */ -int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) +static int generic_fadvise(struct file *file, loff_t offset, loff_t len, + int advice) { - struct fd f = fdget(fd); struct inode *inode; struct address_space *mapping; struct backing_dev_info *bdi; @@ -37,22 +37,14 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) pgoff_t start_index; pgoff_t end_index; unsigned long nrpages; - int ret = 0; - if (!f.file) - return -EBADF; + inode = file_inode(file); + if (S_ISFIFO(inode->i_mode)) + return -ESPIPE; - inode = file_inode(f.file); - if (S_ISFIFO(inode->i_mode)) { - ret = -ESPIPE; - goto out; - } - - mapping = f.file->f_mapping; - if (!mapping || len < 0) { - ret = -EINVAL; - goto out; - } + mapping = file->f_mapping; + if (!mapping || len < 0) + return -EINVAL; bdi = inode_to_bdi(mapping->host); @@ -67,9 +59,9 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) /* no bad return value, but ignore advice */ break; default: - ret = -EINVAL; + return -EINVAL; } - goto out; + return 0; } /* @@ -85,21 +77,21 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) switch (advice) { case POSIX_FADV_NORMAL: - f.file->f_ra.ra_pages = bdi->ra_pages; - spin_lock(&f.file->f_lock); - f.file->f_mode &= ~FMODE_RANDOM; - spin_unlock(&f.file->f_lock); + file->f_ra.ra_pages = bdi->ra_pages; + spin_lock(&file->f_lock); + file->f_mode &= ~FMODE_RANDOM; + spin_unlock(&file->f_lock); break; case POSIX_FADV_RANDOM: - spin_lock(&f.file->f_lock); - f.file->f_mode |= FMODE_RANDOM; - spin_unlock(&f.file->f_lock); + spin_lock(&file->f_lock); + file->f_mode |= FMODE_RANDOM; + spin_unlock(&file->f_lock); break; case POSIX_FADV_SEQUENTIAL: - f.file->f_ra.ra_pages = bdi->ra_pages * 2; - spin_lock(&f.file->f_lock); - f.file->f_mode &= ~FMODE_RANDOM; - spin_unlock(&f.file->f_lock); + file->f_ra.ra_pages = bdi->ra_pages * 2; + spin_lock(&file->f_lock); + file->f_mode &= ~FMODE_RANDOM; + spin_unlock(&file->f_lock); break; case POSIX_FADV_WILLNEED: /* First and last PARTIAL page! */ @@ -115,8 +107,7 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) * Ignore return value because fadvise() shall return * success even if filesystem can't retrieve a hint, */ - force_page_cache_readahead(mapping, f.file, start_index, - nrpages); + force_page_cache_readahead(mapping, file, start_index, nrpages); break; case POSIX_FADV_NOREUSE: break; @@ -183,9 +174,30 @@ int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) } break; default: - ret = -EINVAL; + return -EINVAL; } -out: + return 0; +} + +int vfs_fadvise(struct file *file, loff_t offset, loff_t len, int advice) +{ + if (file->f_op->fadvise) + return file->f_op->fadvise(file, offset, len, advice); + + return generic_fadvise(file, offset, len, advice); +} +EXPORT_SYMBOL(vfs_fadvise); + +int ksys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice) +{ + struct fd f = fdget(fd); + int ret; + + if (!f.file) + return -EBADF; + + ret = vfs_fadvise(f.file, offset, len, advice); + fdput(f); return ret; } From patchwork Mon Aug 27 12:56:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10577073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F415139B for ; Mon, 27 Aug 2018 12:54:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D92C2943E for ; Mon, 27 Aug 2018 12:54:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3226129958; Mon, 27 Aug 2018 12:54:23 +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=-4.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS 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 C9B792943E for ; Mon, 27 Aug 2018 12:54:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727329AbeH0Qky (ORCPT ); Mon, 27 Aug 2018 12:40:54 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:36362 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727078AbeH0Qky (ORCPT ); Mon, 27 Aug 2018 12:40:54 -0400 Received: by mail-wr1-f66.google.com with SMTP id m27-v6so13541831wrf.3; Mon, 27 Aug 2018 05:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1leOW5IS9WgN/qZzhdESiRoQq8v9eQaKcNoCScgbpRw=; b=b540I5h9bOIsh3e8ioKzmcuXdu8byFnpG646CSlvc2JxRlOn8+NZZ9nplqxfIG03Hv dC5e0vT+HPSzAFbwvSMek4VVPPgziyaWx4LzBvDgKh73fDeEKvgMP2T+x8Efnk6EI4is HDcqmCVeE+NBIhLES4LODz5r3wZyIy2NDlczCbYvAVuP1Uojme/YqOKdVo77kW+62wSg qrxbdDlvbOTyceaMrv4v56lDONTh/R6q5rCeE/Fiy2f8mJkxJDghEq0mlEsk7/BjP7I/ TJA3cA/TvrVSlGHkFC0HYNp/2/rrwGuaGt+UQoe3IjWaP0WR/YPP7eI2GtW1LB8RpwHS zVaw== 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=1leOW5IS9WgN/qZzhdESiRoQq8v9eQaKcNoCScgbpRw=; b=J+14tQ5znOu7JNrxRF54py8icbzyEEsKO4YQ7bDjiqsR0CoFVzuG4Tlr+G4RaPQVsj 7ap7UuGghHvjrFLBy7r58Un1vNYQJXWCh6X1qzn0+FKNW/EVhdNOaseL56PrYwZ3W+Z2 jiErk2/4crcxDzPEGpQE1OgRDCD2HuzI11RXwvjY9tDO0eOmfMfVBNSKJeo5cSwUrPXO SucRJianedKG0Ts7AycS/3nY1Axod2n+jC7YeMwn5vXKlx6pCu9woU+7TLLlNsU0o94b pCwQzIFnFzMO+H5W6wxUAqgXWwHRdEd5xftMBluoPjsBl5eBlzX4AncIP6NAASgpJp8Q oaUA== X-Gm-Message-State: APzg51AMFqo0nkRpT8WSZRWzxNMyqB6TNc/O+GRxmx3CttOuMzdujW6p JwVxQzRa81AW5z5JLGAokUM= X-Google-Smtp-Source: ANB0VdZ3qgXas7YZtcXr+k1uvnOuiiQ1DEltbkSkX8PsAaJjMGCVu+I7im9Jpg6SBf7UtI6AtfvFAg== X-Received: by 2002:a5d:428a:: with SMTP id k10-v6mr9234935wrq.225.1535374459907; Mon, 27 Aug 2018 05:54:19 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id z14-v6sm8504046wma.18.2018.08.27.05.54.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 05:54:19 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , Dave Chinner , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 5/6] vfs: implement readahead(2) using POSIX_FADV_WILLNEED Date: Mon, 27 Aug 2018 15:56:03 +0300 Message-Id: <1535374564-8257-6-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535374564-8257-1-git-send-email-amir73il@gmail.com> References: <1535374564-8257-1-git-send-email-amir73il@gmail.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 The implementation of readahead(2) syscall is identical to that of fadvise64(POSIX_FADV_WILLNEED) with a few exceptions: 1. readahead(2) returns -EINVAL for !mapping->a_ops and fadvise64() ignores the request and returns 0. 2. fadvise64() checks for integer overflow corner case 3. fadvise64() calls the optional filesystem fadvice() file operation Unite the two implementations by calling vfs_fadvice() from readahead(2) syscall. Check the !mapping->a_ops in readahead(2) syscall to preserve legacy behavior. Suggested-by: Miklos Szeredi Fixes: d1d04ef8572b ("ovl: stack file ops") Signed-off-by: Amir Goldstein --- mm/readahead.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index a59ea70527b9..867a5cc3a62e 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "internal.h" @@ -576,21 +577,19 @@ page_cache_async_readahead(struct address_space *mapping, EXPORT_SYMBOL_GPL(page_cache_async_readahead); static ssize_t -do_readahead(struct address_space *mapping, struct file *filp, - pgoff_t index, unsigned long nr) +do_readahead(struct file *file, loff_t offset, size_t count) { - if (!mapping || !mapping->a_ops) - return -EINVAL; + struct address_space *mapping = file->f_mapping; /* - * Readahead doesn't make sense for DAX inodes, but we don't want it - * to report a failure either. Instead, we just return success and - * don't do any work. + * fadvise() silently ignores an advice for a file with !a_ops and + * returns -EPIPE for a pipe. Keep this check here to comply with legacy + * -EINVAL behavior of readahead(2). */ - if (dax_mapping(mapping)) - return 0; + if (!mapping || !mapping->a_ops || !S_ISREG(file_inode(file)->i_mode)) + return -EINVAL; - return force_page_cache_readahead(mapping, filp, index, nr); + return vfs_fadvise(file, offset, count, POSIX_FADV_WILLNEED); } ssize_t ksys_readahead(int fd, loff_t offset, size_t count) @@ -601,13 +600,8 @@ ssize_t ksys_readahead(int fd, loff_t offset, size_t count) ret = -EBADF; f = fdget(fd); if (f.file) { - if (f.file->f_mode & FMODE_READ) { - struct address_space *mapping = f.file->f_mapping; - pgoff_t start = offset >> PAGE_SHIFT; - pgoff_t end = (offset + count - 1) >> PAGE_SHIFT; - unsigned long len = end - start + 1; - ret = do_readahead(mapping, f.file, start, len); - } + if (f.file->f_mode & FMODE_READ) + ret = do_readahead(f.file, offset, count); fdput(f); } return ret; From patchwork Mon Aug 27 12:56:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10577075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3690920 for ; Mon, 27 Aug 2018 12:54:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B04C72943E for ; Mon, 27 Aug 2018 12:54:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4DC529958; Mon, 27 Aug 2018 12:54:24 +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=-4.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SBL_CSS 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 53CAE2943E for ; Mon, 27 Aug 2018 12:54:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727354AbeH0Qkz (ORCPT ); Mon, 27 Aug 2018 12:40:55 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36366 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbeH0Qkz (ORCPT ); Mon, 27 Aug 2018 12:40:55 -0400 Received: by mail-wr1-f67.google.com with SMTP id m27-v6so13541902wrf.3; Mon, 27 Aug 2018 05:54:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4qLxciv+NeYBOhSV7lYItD823fqJpeqTfUVsnT5UQn8=; b=XakwqXjPfqiztv9IWnm4tol76BDC5813Bqb6zAMSrUHx/aPGG9ClY2AC9uc3ZrxySA /Sb9TFOROt3SIsNRQOiQ1BlSp4ISP4XAr09Bp9CDJlg/TGsWmqtc64Iz7979GAvzX3En 6m3qeE/vFHSjHPgtsCZFFFy+P9SHGapo0um+3kpqhd//7cOv66in+H/ZiL5Itbq/OAJp 6Ft1+4Wz6XHY+x6gbAZlC5AXUi5UTc+yWorPBb25K8Cy3u+rRiCxTTzZCLd+j5gwAw2N QOwv/clJYGhu97wPuboVzRHaiytbGelQKIO95zZHPtJF7tz6RxjsaBIDbKI6cbHEgf8l rT7A== 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=4qLxciv+NeYBOhSV7lYItD823fqJpeqTfUVsnT5UQn8=; b=dtgte4Jp5NROQRs118Xw1KZmsablTACg7dw5G/ztgcpNlXBgtDlvoFt96voqOJpeUp KGOZX/mb3OR+1J8nCW+/f9xZkckrrSG5ko25gS0C+0wzoNKE760Zo/mWhNl6S1I+R7BR zpjlAQAse76IlbWp+ES/2b00mpJyO1pDEIIEc96nEDlupn4gtIuC2Fx6Ky4FnQ+b1qQD mFCcpezAZBvE/DDnvlb+s4n5A4JGQ3Mr7fiv1dTj53cV/Rp5NANj/BE33zmNh1raYf75 xuBUacDa7zaeOx42iFDvcUtezkPZW5xywPvAOKxa+E85Ah5k/ITXejzjTk82OWG/2ms4 HEIw== X-Gm-Message-State: APzg51CgJgfSJUh7hOvJWRLpmfLYFJ4e8aARS7g7YA2X96M9l585uZPc 5Cn6qQOwuuYpqRFQbWRqgh4N74DS X-Google-Smtp-Source: ANB0VdbbqM4qdGB7xCD5et9oijXmf3BNyEyXcuAq1qek4jw4WTGIPk38wKxiMsL/zNHusR4NcqLG6g== X-Received: by 2002:adf:afd3:: with SMTP id y19-v6mr8535738wrd.176.1535374461260; Mon, 27 Aug 2018 05:54:21 -0700 (PDT) Received: from localhost.localdomain ([141.226.8.68]) by smtp.gmail.com with ESMTPSA id z14-v6sm8504046wma.18.2018.08.27.05.54.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 05:54:20 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi Cc: Al Viro , Dave Chinner , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v3 6/6] ovl: add ovl_fadvise() Date: Mon, 27 Aug 2018 15:56:04 +0300 Message-Id: <1535374564-8257-7-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535374564-8257-1-git-send-email-amir73il@gmail.com> References: <1535374564-8257-1-git-send-email-amir73il@gmail.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 fadvise to fix syscalls readahead(2) and fadvise64(2) on an overlayfs file. Suggested-by: Miklos Szeredi Fixes: d1d04ef8572b ("ovl: stack file ops") Signed-off-by: Amir Goldstein --- fs/overlayfs/file.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index a4acd84591d4..42d2d034d85c 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -331,6 +331,23 @@ static long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len return ret; } +int ovl_fadvise(struct file *file, loff_t offset, loff_t len, int advice) +{ + struct fd real; + int ret; + + ret = ovl_real_fdget(file, &real); + if (ret) + return ret; + + /* XXX: do we need mounter credentials? */ + ret = vfs_fadvise(real.file, offset, len, advice); + + fdput(real); + + return ret; +} + static long ovl_real_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -499,6 +516,7 @@ const struct file_operations ovl_file_operations = { .fsync = ovl_fsync, .mmap = ovl_mmap, .fallocate = ovl_fallocate, + .fadvise = ovl_fadvise, .unlocked_ioctl = ovl_ioctl, .compat_ioctl = ovl_compat_ioctl,