From patchwork Thu May 11 21:17:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sargun Dhillon X-Patchwork-Id: 9723177 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 129D8601E7 for ; Thu, 11 May 2017 21:17:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0983F286DB for ; Thu, 11 May 2017 21:17:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0E34286EF; Thu, 11 May 2017 21:17:38 +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 9E1AE286DB for ; Thu, 11 May 2017 21:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755121AbdEKVRg (ORCPT ); Thu, 11 May 2017 17:17:36 -0400 Received: from mail-it0-f48.google.com ([209.85.214.48]:36725 "EHLO mail-it0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751681AbdEKVRf (ORCPT ); Thu, 11 May 2017 17:17:35 -0400 Received: by mail-it0-f48.google.com with SMTP id o5so597309ith.1 for ; Thu, 11 May 2017 14:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sargun.me; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=vTzm9cQsGHsJEW68tQ4yVRF0/9iVAXHqBeYY/UL1zTQ=; b=IPnDYWa8KSj7BBXOjD+jfyP8A8r2X5gVKUalBn6nZRIltPCYp6w/mCu+vJzuGadZYq uJlyXmErRdfjO9dl+XrAnFlp6KSHVpee86qkbY9yBhZ3APMs2ZLaBG1XCc+AJM36SNE1 IvrvkxU3Vf348MF9Nqe2EdqyqpOlOLBPx0BvM= 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:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=vTzm9cQsGHsJEW68tQ4yVRF0/9iVAXHqBeYY/UL1zTQ=; b=r0D64matOv1NHtcnEXlB5ymSFDlbitPUKLvkOYrqRsgWkwQUqDwvD/hhi2G0AMjNaj hONsb76LnWROJTyb2oBy2jOUDfoxAYmJicRlVOeW/BNBBLhczaZhdC+9vo17uuMqGgvM G8JmeDcRZlOI9/2cB8y3bGuK46Y5Uj+zaqEmCJPnrGGrcex6WnPV3iaX2PNflooAP02F u67suInNqryuteF2e52MOHaZVdaT1cWbcjxbf1gdqZJ6/zs7bVJgzxVb7wctqfNDtlMD hgiAeB/D5GpKov0O/bmHnG69+veMxHg/to5h+YvAju6fBCsKhF9e6tCFGa3LguSaBH+Z Y9ZQ== X-Gm-Message-State: AODbwcCGl4iu8j8dLGTIl790vjvpOchizlPN7RIK3xrGsaez9QaIXfoO xfzNdDdRIkTxuw== X-Received: by 10.36.135.70 with SMTP id f67mr621636ite.3.1494537454868; Thu, 11 May 2017 14:17:34 -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 192sm1629040itl.1.2017.05.11.14.17.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 14:17:34 -0700 (PDT) Date: Thu, 11 May 2017 21:17:33 +0000 From: Sargun Dhillon To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, quwenruo@cn.fujitsu.com Subject: [PATCH v2 1/2] btrfs: add quota override flag to enable quota override for sys_resource Message-ID: <20170511211731.GA8413@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 introduces the quota override flag to btrfs_fs_info, and a change to quota limit checking code to temporarily allow for quota to be overridden for processes with cap_sys_resource. 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. Eventually, we may want to add the idea of an operator-specific quota, operator reserved space, or something else to allow for administrative override, but this is perhaps the simplest solution. Signed-off-by: Sargun Dhillon --- fs/btrfs/ctree.h | 2 ++ fs/btrfs/qgroup.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 643c70d..e86cb7c 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -716,6 +716,8 @@ struct btrfs_delayed_root; #define BTRFS_FS_BTREE_ERR 11 #define BTRFS_FS_LOG1_ERR 12 #define BTRFS_FS_LOG2_ERR 13 +#define BTRFS_FS_QUOTA_OVERRIDE 14 + /* * Indicate that a whole-filesystem exclusive operation is running * (device replace, resize, device add/delete, balance) diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index deffbeb..458fec0 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -2338,6 +2338,11 @@ static int qgroup_reserve(struct btrfs_root *root, u64 num_bytes, bool enforce) if (num_bytes == 0) return 0; + + if (test_bit(BTRFS_FS_QUOTA_OVERRIDE, &fs_info->flags) && + capable(CAP_SYS_RESOURCE)) + enforce = false; + retry: spin_lock(&fs_info->qgroup_lock); quota_root = fs_info->quota_root;