[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1468578983-28229-7-git-send-email-toiwoton@gmail.com>
Date: Fri, 15 Jul 2016 13:35:53 +0300
From: Topi Miettinen <toiwoton@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Topi Miettinen <toiwoton@...il.com>,
Alexander Viro <viro@...iv.linux.org.uk>,
linux-fsdevel@...r.kernel.org (open list:FILESYSTEMS (VFS and
infrastructure))
Subject: [PATCH 06/14] resource limits: track highwater mark of cores dumped
Track maximum size of core dump written, to be able to configure
RLIMIT_CORE resource limits. The information is available
with taskstats and cgroupstats netlink socket.
Signed-off-by: Topi Miettinen <toiwoton@...il.com>
---
fs/coredump.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index 281b768..a0ace88 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -784,20 +784,25 @@ int dump_emit(struct coredump_params *cprm, const void *addr, int nr)
struct file *file = cprm->file;
loff_t pos = file->f_pos;
ssize_t n;
+ int r = 0;
+
if (cprm->written + nr > cprm->limit)
return 0;
while (nr) {
if (dump_interrupted())
- return 0;
+ goto err;
n = __kernel_write(file, addr, nr, &pos);
if (n <= 0)
- return 0;
+ goto err;
file->f_pos = pos;
cprm->written += n;
cprm->pos += n;
nr -= n;
}
- return 1;
+ r = 1;
+ err:
+ update_resource_highwatermark(RLIMIT_CORE, cprm->written);
+ return r;
}
EXPORT_SYMBOL(dump_emit);
--
2.8.1
Powered by blists - more mailing lists