From patchwork Tue May 29 14:43:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10436077 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 7098660327 for ; Tue, 29 May 2018 15:11:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 632A928891 for ; Tue, 29 May 2018 15:11:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4ECFC2884E; Tue, 29 May 2018 15:11:14 +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=unavailable 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 F05D72881A for ; Tue, 29 May 2018 15:11:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935454AbeE2PKo (ORCPT ); Tue, 29 May 2018 11:10:44 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38786 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935690AbeE2OoI (ORCPT ); Tue, 29 May 2018 10:44:08 -0400 Received: by mail-wr0-f194.google.com with SMTP id 94-v6so25970898wrf.5 for ; Tue, 29 May 2018 07:44:08 -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=lkZjtohdxdIdFiUznygulI4XLGdMF+1zm6MitRRtxi0=; b=iDt8Y96VSFuln3TAgsM5osYzD4vI/ii9Ds3wfEagcdyYubpx39uxfYA71Dtw+rzbkE HQMcsNe+hbDfiXNZyVP3vxbEwJ25OStx8AmmeHE3maBxyULuGZvpBOnhJzUqdTR4oA/E UWru+kuZQMhlEbmK+B6HmP2uuqaN0qcK4RPsdOgCPjvG/ihVFQTtsXjB87fyODx4EL6X aAdxd5lDfR7z9symqEp3EC5NZNuayt6yFz8fCq5BNa9/EKzZwZNw8pdIR7bnZRgICnSO rJ7eNtrGNhTlBRQQ7rhsB30U5GGcArC/2X2dynwO6KZPpQ48s/DNcSrpDfTX9Gf/eCTN PLFw== X-Gm-Message-State: ALKqPwdT3hX7SjaH47DaRhQAGVhzhsea/uIzHqZnU/NVG+iPyQmYy7HN +6FlJaHdoG94cc1JJCfDGlj2QQ== X-Google-Smtp-Source: AB8JxZqcgLiFkcjUXAW4wCYwyUnJ5NRDCdIkVXrSfPQK6MmIZ0spo5mGlg7/zqmChC7GIA7/bOZzcg== X-Received: by 2002:adf:afce:: with SMTP id y14-v6mr15161753wrd.249.1527605047528; Tue, 29 May 2018 07:44:07 -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.06 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:44:06 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/39] ovl: add ovl_fiemap() Date: Tue, 29 May 2018 16:43:22 +0200 Message-Id: <20180529144339.16538-23-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 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 d6a13da0740f..cd46dd8e7e54 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; }