[Devel] [PATCH hci-8.1 v10 09/13] ve: add mnt failcounter

Konstantin Khorenko khorenko at virtuozzo.com
Fri Sep 25 19:53:30 MSK 2026


From: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>

Count hits of the per-VE mount limit in ve.failcount.

The old warning in alloc_vfsmnt is dropped, otherwise every failed
mount would produce two ratelimited messages. The one printed by
ve_failcount_inc also names the counter to look at and goes to the
container log as well.

https://virtuozzo.atlassian.net/browse/VSTOR-135520

Feature: per-ve failcounters
Signed-off-by: Vladimir Riabchun <vladimir.riabchun at virtuozzo.com>
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 fs/namespace.c     | 8 +++-----
 include/linux/ve.h | 1 +
 kernel/ve/ve.c     | 3 +++
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index 1d6e66cd71745..cf77c3fb98407 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -329,12 +329,8 @@ static struct mount *alloc_vfsmnt(const char *name, struct ve_struct *owner_ve)
 	if (!ve)
 		ve = get_exec_env();
 
-	if (!ve_try_reserve_mount(ve)) {
-		pr_warn_ratelimited(
-			"CT#%s reached the limit on mounts.\n",
-			ve_name(ve));
+	if (!ve_try_reserve_mount(ve))
 		return NULL;
-	}
 
 	mnt = kmem_cache_zalloc(mnt_cache, GFP_KERNEL);
 	if (mnt) {
@@ -3380,6 +3376,8 @@ static inline int ve_try_reserve_mount(struct ve_struct *ve)
 
 	if (ret)
 		get_ve(ve);
+	else
+		ve_failcount_inc(ve, mnt);
 	return ret;
 }
 
diff --git a/include/linux/ve.h b/include/linux/ve.h
index 969390bb511e7..0395e37208849 100644
--- a/include/linux/ve.h
+++ b/include/linux/ve.h
@@ -103,6 +103,7 @@ struct ve_struct {
 	 * other containers.
 	 */
 	atomic_t		mnt_avail_nr; /* number of available VE mounts */
+	atomic_t		mnt_failcount;
 	int			mnt_max_nr;
 
 #ifdef CONFIG_COREDUMP
diff --git a/kernel/ve/ve.c b/kernel/ve/ve.c
index 56936ef4cc92b..4c3acda6b135e 100644
--- a/kernel/ve/ve.c
+++ b/kernel/ve/ve.c
@@ -118,6 +118,7 @@ struct ve_struct ve0 = {
 	.nd_neigh_nr		= ATOMIC_INIT(0),
 	.mnt_avail_nr		= ATOMIC_INIT(INT_MAX),
 	.mnt_max_nr		= INT_MAX,
+	.mnt_failcount		= ATOMIC_INIT(0),
 #ifdef CONFIG_AIO
 	.aio_nr_lock		= __SPIN_LOCK_UNLOCKED(ve0.aio_nr_lock),
 	.aio_nr			= 0,
@@ -829,6 +830,7 @@ static struct cgroup_subsys_state *ve_create(struct cgroup_subsys_state *parent_
 	atomic_set(&ve->arp_neigh_nr, 0);
 	atomic_set(&ve->nd_neigh_nr, 0);
 	ve->mnt_max_nr = MNT_MAX_NR_DEFAULT;
+	atomic_set(&ve->mnt_failcount, 0);
 	atomic_set(&ve->mnt_avail_nr, MNT_MAX_NR_DEFAULT);
 
 #ifdef CONFIG_COREDUMP
@@ -1087,6 +1089,7 @@ static const struct ve_failcount_entry {
 } ve_failcounts[] = {
 #define VE_FC_ENTRY(name) { #name, offsetof(struct ve_struct, name##_failcount) }
 	VE_FC_ENTRY(netns),
+	VE_FC_ENTRY(mnt),
 	{}
 };
 

-- 
2.43.0



More information about the Devel mailing list