From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pavel Emelyanov Subject: [PATCH 10/13] vfs: Routnes for setting mob size and getting stats Date: Tue, 03 May 2011 16:19:21 +0400 Message-ID: <4DBFF2C9.3090605@parallels.com> References: <4DBFF1AD.90303@parallels.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: linux-fsdevel To: Hugh Dickins , Nick Piggin , Andrea Arcangeli , Rik van Riel , Dave Hansen , Alexa Return-path: Received: from mailhub.sw.ru ([195.214.232.25]:11081 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752668Ab1ECMTI (ORCPT ); Tue, 3 May 2011 08:19:08 -0400 In-Reply-To: <4DBFF1AD.90303@parallels.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Very simple ones, just to make the further patching simpler. Signed-off-by: Pavel Emelyanov --- fs/dcache.c | 30 ++++++++++++++++++++++++++++++ include/linux/dcache.h | 7 +++++++ 2 files changed, 37 insertions(+), 0 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 51fb998..bdacea3 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -3006,6 +3006,36 @@ int dcache_new_mob(struct dentry *root) return 0; } +int dcache_set_mob_size(struct dentry *de, unsigned long size) +{ + struct dentry_mob *mob = de->d_mob; + unsigned long usage; + + if (mob == &init_dentry_mob) /* for safety */ + return 0; + + mob->nr_dentry_max = size; + usage = percpu_counter_sum_positive(&mob->nr_dentry); + if (usage > mob->nr_dentry_max) + prune_dcache(mob, usage - mob->nr_dentry_max); + + return 0; +} + +int dcache_get_mob_stat(struct dentry *de, struct dentry_mob_stat __user *stat) +{ + struct dentry_mob *mob = de->d_mob; + struct dentry_mob_stat kstat; + + kstat.nr_dentry = percpu_counter_sum_positive(&mob->nr_dentry); + kstat.nr_dentry_max = mob->nr_dentry_max; + + if (copy_to_user(stat, &kstat, sizeof(kstat))) + return -EFAULT; + + return 0; +} + static __initdata unsigned long dhash_entries; static int __init set_dhash_entries(char *str) { diff --git a/include/linux/dcache.h b/include/linux/dcache.h index 3681307..0d13966 100644 --- a/include/linux/dcache.h +++ b/include/linux/dcache.h @@ -55,7 +55,14 @@ struct dentry_mob { }; struct dentry; +struct dentry_mob_stat { + unsigned long nr_dentry; + unsigned long nr_dentry_max; +}; + int dcache_new_mob(struct dentry *root); +int dcache_set_mob_size(struct dentry *de, unsigned long size); +int dcache_get_mob_stat(struct dentry *de, struct dentry_mob_stat __user *stat); /* * Compare 2 name strings, return 0 if they match, otherwise non-zero. -- 1.5.5.6