Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758933Ab1FAMrG (ORCPT ); Wed, 1 Jun 2011 08:47:06 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:57207 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161730Ab1FAMq1 (ORCPT ); Wed, 1 Jun 2011 08:46:27 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=szeredi.hu; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=Dk3x7iCZudJqYDbxiN+nn9rt0s04zYRtZEwOBCm+h7Zrq6AqjCWsudo7HRhfn3EbGc Qi5irUic7qRPRhY6X+Np4hVVHXPYE0GTZeHwd0v4VbinB7UT+RpinKvIZ/9i/Wpnlkrp stf688CJYL1AE9Gk53L1c3IngCXPAdHrJ0hS8= From: Miklos Szeredi To: viro@ZenIV.linux.org.uk, torvalds@linux-foundation.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, apw@canonical.com, nbd@openwrt.org, neilb@suse.de, hramrach@centrum.cz, jordipujolp@gmail.com, ezk@fsl.cs.sunysb.edu, mszeredi@suse.cz Subject: [PATCH 5/7] overlayfs: add statfs support Date: Wed, 1 Jun 2011 14:46:18 +0200 Message-Id: <1306932380-10280-6-git-send-email-miklos@szeredi.hu> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1306932380-10280-1-git-send-email-miklos@szeredi.hu> References: <1306932380-10280-1-git-send-email-miklos@szeredi.hu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1956 Lines: 59 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 --- fs/overlayfs/super.c | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c index a344b42..c9db954 100644 --- a/fs/overlayfs/super.c +++ b/fs/overlayfs/super.c @@ -385,9 +385,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 { -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/