From patchwork Wed Mar 13 09:50:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Pisati X-Patchwork-Id: 227217 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id 3A25E2C02A3 for ; Wed, 13 Mar 2013 20:51:16 +1100 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UFiKz-0001nR-HW; Wed, 13 Mar 2013 09:51:09 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1UFiKn-0001dG-1j for kernel-team@lists.ubuntu.com; Wed, 13 Mar 2013 09:50:57 +0000 Received: from 2-230-238-136.ip204.fastwebnet.it ([2.230.238.136] helo=canonical.com) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1UFiKm-0000tw-V1 for kernel-team@lists.ubuntu.com; Wed, 13 Mar 2013 09:50:57 +0000 From: Paolo Pisati To: kernel-team@lists.ubuntu.com Subject: [PATCH 06/11] UBUNTU: ubuntu: overlayfs -- overlayfs: add statfs support Date: Wed, 13 Mar 2013 10:50:46 +0100 Message-Id: <1363168251-9374-7-git-send-email-paolo.pisati@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1363168251-9374-1-git-send-email-paolo.pisati@canonical.com> References: <1363168251-9374-1-git-send-email-paolo.pisati@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Andy Whitcroft Add support for statfs to the overlayfs filesystem. As the upper layer is the target of all write operations assume that the space in that filesystem is the space in the overlayfs. There will be some inaccuracy as overwriting a file will copy it up and consume space we were not expecting, but it is better than nothing. Use the upper layer dentry and mount from the overlayfs root inode, passing the statfs call to that filesystem. Signed-off-by: Andy Whitcroft Signed-off-by: Miklos Szeredi Signed-off-by: Andy Whitcroft (cherry picked from commit 3a375b0e617e3f8a54619d0d569fb2918c379289) BugLink: http://bugs.launchpad.net/bugs/1076317 Signed-off-by: Paolo Pisati --- fs/overlayfs/super.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index 18042cf..8091f76 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -404,9 +404,29 @@ static int ovl_remount_fs(struct super_block *sb, int *flagsp, char *data) return mnt_want_write(ufs->upper_mnt); } +/** + * ovl_statfs + * @sb: The overlayfs super block + * @buf: The struct kstatfs to fill in with stats + * + * Get the filesystem statistics. As writes always target the upper layer + * filesystem pass the statfs to the same filesystem. + */ +static int ovl_statfs(struct dentry *dentry, struct kstatfs *buf) +{ + struct dentry *root_dentry = dentry->d_sb->s_root; + struct path path; + ovl_path_upper(root_dentry, &path); + + if (!path.dentry->d_sb->s_op->statfs) + return -ENOSYS; + return path.dentry->d_sb->s_op->statfs(path.dentry, buf); +} + static const struct super_operations ovl_super_operations = { .put_super = ovl_put_super, .remount_fs = ovl_remount_fs, + .statfs = ovl_statfs, }; struct ovl_config {