From patchwork Fri Apr 21 10:09:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sargun Dhillon X-Patchwork-Id: 9692345 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 A590A60328 for ; Fri, 21 Apr 2017 10:09:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9D5FF21E5A for ; Fri, 21 Apr 2017 10:09:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 91A2228614; Fri, 21 Apr 2017 10:09:53 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 5E0E221E5A for ; Fri, 21 Apr 2017 10:09:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1037697AbdDUKJv (ORCPT ); Fri, 21 Apr 2017 06:09:51 -0400 Received: from mail-io0-f175.google.com ([209.85.223.175]:35934 "EHLO mail-io0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1037683AbdDUKJt (ORCPT ); Fri, 21 Apr 2017 06:09:49 -0400 Received: by mail-io0-f175.google.com with SMTP id o22so123939091iod.3 for ; Fri, 21 Apr 2017 03:09:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=Rscb3bDSyInF2dEyT0OaypSeB933CeYvXgiFZkQ2U5E=; b=JiD3vS4Q+NooKlSMfAiTqDm1rrgQsYw42JgycQs+c36rDbo1+Cxst3JjH9ks+yaBnw YwFYlySbR1zYJRN2xKCyR/W8cShs16/iDK+yStbUkxM2SdngJu4aXfQk12n+pI7mJBxf b+cdEfqcsUz7EfB/ukhSbQ//n587/KHQf1V88= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=Rscb3bDSyInF2dEyT0OaypSeB933CeYvXgiFZkQ2U5E=; b=KI5er/SpLiMMlRViF9yq6CtDMCHnpFB7s9Yeuw/9vWuWcwXXwik6KGljaAm4TipFtV 0RkPf+FyrHk+Dlv7/D3YIo2vFHXSWFZefNM4u3MUpKlqbJFI1fIg9MrOjgS6yCpxg6fI ZYd1N6aF9/Vmq/1lMbAZlHaOreiYTdV484eowuzTdebIMlMtRKAjsbQ7KjFb5Fc8fhyw TZS+CXOqkb2iLPcMs8TtnLR+9X7W/Ub2HgwuYrK+nmKwQ3ZEs5ymVaQS8g/UuTRDl2wX dtaWqe1g8syY794kA9xvNACbHN2UmoCvfvYps/XW78rXqPxSzncVDUEdIdzU/xq0QjV1 zKrw== X-Gm-Message-State: AN3rC/5zkMAud8s6noWuOPP3nM6DhhoC/3eD12Ns1O0Ow4Co51CVlV0O WtdRM3YRxvg5p+noklM= X-Received: by 10.36.253.73 with SMTP id m70mr9273463ith.19.1492769387850; Fri, 21 Apr 2017 03:09:47 -0700 (PDT) Received: from ircssh-2.c.rugged-nimbus-611.internal (80.60.198.104.bc.googleusercontent.com. [104.198.60.80]) by smtp.gmail.com with ESMTPSA id f19sm379221itf.19.2017.04.21.03.09.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Apr 2017 03:09:47 -0700 (PDT) Date: Fri, 21 Apr 2017 10:09:46 +0000 From: Sargun Dhillon To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: allow processes with cap_sys_resource to exceed quota Message-ID: <20170421100943.GA2942@ircssh-2.c.rugged-nimbus-611.internal> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch allows processes with CAP_SYS_RESOURCE to exceed the qgroup limit. It's useful for administrative programs, such as log rotation, that may need to temporarily use more disk space in order to free up a greater amount of overall disk space without yielding more disk space to the rest of userland. Signed-off-by: Sargun Dhillon --- fs/btrfs/qgroup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index a59801d..b0af39c 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -2349,6 +2349,9 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, static bool qgroup_check_limits(const struct btrfs_qgroup *qg, u64 num_bytes) { + if (capable(CAP_SYS_RESOURCE)) + return true; + if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) && qg->reserved + (s64)qg->rfer + num_bytes > qg->max_rfer) return false;