From patchwork Mon May 7 08:37:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10383575 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 BD48560159 for ; Mon, 7 May 2018 08:46:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1C2D286DF for ; Mon, 7 May 2018 08:46:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A679928A96; Mon, 7 May 2018 08:46:16 +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 4E0E2286DF for ; Mon, 7 May 2018 08:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752518AbeEGIqL (ORCPT ); Mon, 7 May 2018 04:46:11 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:43950 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752162AbeEGIif (ORCPT ); Mon, 7 May 2018 04:38:35 -0400 Received: by mail-wr0-f194.google.com with SMTP id v15-v6so27835075wrm.10 for ; Mon, 07 May 2018 01:38:35 -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=fG9h3LPDas+vGMu54qQY97pS6dLbeoATLqnmKlflYvU=; b=QtNVw6I/iEhvwvmVNjL1/vMHU29qawFRU5F6lryoFz7X9VB3UNPiOhUC6Y8ZC6QwbT ZX8aySsCbGyqzZsiQNL7Ok54VaD3exjwTTBsMEqZ7VePLacsxTKRirQ2fzdKmd5RHpVB 01Va3PBZWFpo1nkbvlWVcp63sR3uGmeKBtn3e4SRPswpXf1tCvH+P3yUBmug+4zIY0K0 gH99NeNeuAIZSU4Qmvu+FREKxhJ91WHQeYyvuHNgPBOy8Y3Rg17cUmgLdP7vxfWYsVno L7YtQ6lcVsow7D4W31hGFY4EbKdhAVMWgWVsaEHlTiq43qbTk+oz7MnvP+R2L56F0GdW up7w== X-Gm-Message-State: ALQs6tDLQkvoagrcfiypVuipeMIqGV/RLPjfcK8icEhmVWMiKS9mxk9O AiXxiakTFMp1PHl7o0j+fvH9Un1GLj4= X-Google-Smtp-Source: AB8JxZrG4totPxBEEAWGMq3YdtcJUwTg+Cp4fvaxIOdLo8fX+QK+AsbHzQh7lz7HyD1P9QjUv4X5IA== X-Received: by 2002:adf:e5c6:: with SMTP id a6-v6mr29380987wrn.229.1525682314471; Mon, 07 May 2018 01:38:34 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id h8-v6sm5908050wmc.16.2018.05.07.01.38.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 01:38:33 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 19/35] ovl: add ovl_fiemap() Date: Mon, 7 May 2018 10:37:51 +0200 Message-Id: <20180507083807.28792-20-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180507083807.28792-1-mszeredi@redhat.com> References: <20180507083807.28792-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 fiemap(). Need to split inode operations for regular file (which has fiemap) and special file (which doesn't have fiemap). Signed-off-by: Miklos Szeredi --- fs/overlayfs/inode.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index a228eda66ad8..7abcf96e94fc 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -448,6 +448,23 @@ int ovl_update_time(struct inode *inode, struct timespec *ts, int flags) return 0; } +static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, + u64 start, u64 len) +{ + int err; + struct inode *realinode = ovl_inode_real(inode); + const struct cred *old_cred; + + if (!realinode->i_op->fiemap) + return -EOPNOTSUPP; + + old_cred = ovl_override_creds(inode->i_sb); + err = realinode->i_op->fiemap(realinode, fieinfo, start, len); + revert_creds(old_cred); + + return err; +} + static const struct inode_operations ovl_file_inode_operations = { .setattr = ovl_setattr, .permission = ovl_permission, @@ -455,6 +472,7 @@ static const struct inode_operations ovl_file_inode_operations = { .listxattr = ovl_listxattr, .get_acl = ovl_get_acl, .update_time = ovl_update_time, + .fiemap = ovl_fiemap, }; static const struct inode_operations ovl_symlink_inode_operations = { @@ -465,6 +483,15 @@ static const struct inode_operations ovl_symlink_inode_operations = { .update_time = ovl_update_time, }; +static const struct inode_operations ovl_special_inode_operations = { + .setattr = ovl_setattr, + .permission = ovl_permission, + .getattr = ovl_getattr, + .listxattr = ovl_listxattr, + .get_acl = ovl_get_acl, + .update_time = ovl_update_time, +}; + /* * It is possible to stack overlayfs instance on top of another * overlayfs instance as lower layer. We need to annonate the @@ -548,7 +575,7 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode, dev_t rdev, break; default: - inode->i_op = &ovl_file_inode_operations; + inode->i_op = &ovl_special_inode_operations; init_special_inode(inode, mode, rdev); break; }