From patchwork Fri Jul 15 10:35:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Topi Miettinen X-Patchwork-Id: 9231637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A421060865 for ; Fri, 15 Jul 2016 10:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 960C5262F2 for ; Fri, 15 Jul 2016 10:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8AA9A2819A; Fri, 15 Jul 2016 10:41:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3840C262F2 for ; Fri, 15 Jul 2016 10:41:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932607AbcGOKlA (ORCPT ); Fri, 15 Jul 2016 06:41:00 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36630 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932187AbcGOKhX (ORCPT ); Fri, 15 Jul 2016 06:37:23 -0400 Received: by mail-wm0-f67.google.com with SMTP id x83so1722982wma.3; Fri, 15 Jul 2016 03:37:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sBY9tYyOrThO7B65ulmc6/5cuSGoLhmPqLaGBp5cHp8=; b=oxwndo+Qj0zxAiIsEk6Lpj6ylF/U2DKlg3s7Bqu/xG0pn6zPPGeAL6qoDGh4BuRWW6 SFFR7a4txqutomDh5C0ZE7B8L+v8UjZheYwWkl2QmsIYa7JXEo6FXmx7yieiyzcJn/OS oHfhQoanypbcPMYLdUF+zb2ygVzbttHB7eL6TYVFhGLb3qW9ckhD7XoK0Ew0SzAh7f+b BlXnVRPKatrirTNQHWhrmTGc/g4ZiTipsI30W1kOXUj1gTHu+sf0VfU6vyzDVTrlFSWi zLvJAA2nig9jUxa32ZfnkDAwMTHeLbywmCJlc50ZVbrnk4nUfKrKlm5M0E4L9WHQ5Sd/ x8JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=sBY9tYyOrThO7B65ulmc6/5cuSGoLhmPqLaGBp5cHp8=; b=lCt/8GZWJ2qRU9M+2U4ZV1menhmZVnsdoS2tDFYKFbWOErdCASj0fLdmW9VM/shaJZ qYm44eR58aX4Uh1H/MZT4Hdgu+P5Cx8QSaWJ1jDp/Di/aAjsmRt92lZxXGqG+MejPznM gbZpjxIQPbfZZcMtxZN9Fum64K1wfME3UUZso9OjgbIBLVsSJG7qSQ/fKzH4i8yFaTY8 kQeC3FvmZOLDW+IspGkNASwalNPKqE3DUxjlPw8GJge/SGR0z1q5Oh6e8cvEvDoLcd1b GORUbUMQgkGxaQvjEOXIfZZHNATDDC945bMYxKtifivRJB3wKhviCmSXbgOs9J5VLMQz V5PA== X-Gm-Message-State: ALyK8tJqUqILMpS7czJLmV9dXOE+hHBUU2MXjz4bnq6PubfUPZYkVctMVKXCxfspoBuelg== X-Received: by 10.28.203.200 with SMTP id b191mr37071930wmg.1.1468579041617; Fri, 15 Jul 2016 03:37:21 -0700 (PDT) Received: from localhost.localdomain ([2001:2003:f54a:b700:2ab2:bdff:fe10:799e]) by smtp.gmail.com with ESMTPSA id jq9sm60564wjb.38.2016.07.15.03.37.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jul 2016 03:37:21 -0700 (PDT) From: Topi Miettinen To: linux-kernel@vger.kernel.org Cc: Topi Miettinen , Alexander Viro , linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and infrastructure)) Subject: [PATCH 06/14] resource limits: track highwater mark of cores dumped Date: Fri, 15 Jul 2016 13:35:53 +0300 Message-Id: <1468578983-28229-7-git-send-email-toiwoton@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1468578983-28229-1-git-send-email-toiwoton@gmail.com> References: <1468578983-28229-1-git-send-email-toiwoton@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);