From patchwork Wed Dec 29 14:55:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Hutchings X-Patchwork-Id: 439561 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBUMBEjs000490 for ; Thu, 30 Dec 2010 22:11:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753068Ab0L2Ozn (ORCPT ); Wed, 29 Dec 2010 09:55:43 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:45937 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752672Ab0L2Ozm convert rfc822-to-8bit (ORCPT ); Wed, 29 Dec 2010 09:55:42 -0500 Received: from [192.168.4.185] (helo=localhost) by shadbolt.decadent.org.uk with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1PXxQe-0006jO-QG; Wed, 29 Dec 2010 14:55:39 +0000 Received: from ben by localhost with local (Exim 4.72) (envelope-from ) id 1PXxQe-0002Qe-4e; Wed, 29 Dec 2010 14:55:04 +0000 From: Ben Hutchings To: Chris Mason Cc: linux-btrfs@vger.kernel.org, 608185@bugs.debian.org, Aron Xu Date: Wed, 29 Dec 2010 14:55:03 +0000 Message-ID: <1293634503.2928.132.camel@localhost> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 X-SA-Exim-Connect-IP: 192.168.4.185 X-SA-Exim-Mail-From: ben@decadent.org.uk X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on shadbolt.decadent.org.uk X-Spam-Level: X-Spam-Status: No, score=-1.4 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.2.5 Subject: [PATCH] btrfs: Require CAP_SYS_ADMIN for filesystem rebalance X-SA-Exim-Version: 4.2.1 (built Wed, 25 Jun 2008 17:14:11 +0000) X-SA-Exim-Scanned: Yes (on shadbolt.decadent.org.uk) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 30 Dec 2010 22:11:30 +0000 (UTC) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index cc04dc1..2313e8b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "compat.h" #include "ctree.h" @@ -1905,6 +1906,9 @@ int btrfs_balance(struct btrfs_root *dev_root) if (dev_root->fs_info->sb->s_flags & MS_RDONLY) return -EROFS; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + mutex_lock(&dev_root->fs_info->volume_mutex); dev_root = dev_root->fs_info->dev_root;