From patchwork Thu Apr 12 15:08:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10338677 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 4DBBB60134 for ; Thu, 12 Apr 2018 15:08:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4178426D08 for ; Thu, 12 Apr 2018 15:08:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 361C926E74; Thu, 12 Apr 2018 15:08:59 +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 CEDC326D08 for ; Thu, 12 Apr 2018 15:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753525AbeDLPI4 (ORCPT ); Thu, 12 Apr 2018 11:08:56 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:45405 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753412AbeDLPIw (ORCPT ); Thu, 12 Apr 2018 11:08:52 -0400 Received: by mail-wr0-f194.google.com with SMTP id u11so5450448wri.12 for ; Thu, 12 Apr 2018 08:08:52 -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=E3v1I/C8FIzl227nlxteK2UWpwdarGcNfRYeFQHCZxM=; b=gLN6JptE9qfxA66NAWOIqSrpRBtIn+ulldNow2kLSQ7tj3mnP0j3+l16/bKSZIJI30 YLawi5GHz4KSjDDlR84xBh/D7XOGykJHtU+nqP+A2mi/1wq3P1G9105cpmK2aULm3vsZ pRmZ881GrzG1jJ1dIw0cg+LqRR5p5GW0owqzY8lBYjQaq1x+3zDgDOzAJNyqL+K75UdU 10kG3THALZGRh7rDe44GC2AJPhFvIym8ir0e1tubqKlKtKfyTtmcyZTFEQq9VMmUmBRw VOGys8pnDCmcNM7HmQUZ7VplZ1DseZItj5gx0Tz5M7AhEX8CwSii+rwFEqkosjeQQIb/ m3XA== X-Gm-Message-State: ALQs6tCl6pHOn8ru7WilSs6mXPwHIfiwZ7wdsKBOHkX+HYesReIGsyhD uXljT6KWRXUrjJAAo2MGQ1QqvQ== X-Google-Smtp-Source: AIpwx49WrQlIm9T/q3Hvayo0XJza8cGApbLHujWLvc0tnHfIUWYMvD8wBFnqHPL172ZlOB4wbHPH5g== X-Received: by 10.223.135.155 with SMTP id b27mr1081253wrb.119.1523545731411; Thu, 12 Apr 2018 08:08:51 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:50 -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 17/35] ovl: readd fiemap Date: Thu, 12 Apr 2018 17:08:08 +0200 Message-Id: <20180412150826.20988-18-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-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 3b996639e1ad..b723327501f7 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -455,6 +455,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, @@ -462,6 +479,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 = { @@ -472,6 +490,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 @@ -555,7 +582,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; }