From patchwork Thu Oct 10 17:40:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 3017741 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D98F39F245 for ; Thu, 10 Oct 2013 17:41:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA202202FF for ; Thu, 10 Oct 2013 17:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E972202BE for ; Thu, 10 Oct 2013 17:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756379Ab3JJRkz (ORCPT ); Thu, 10 Oct 2013 13:40:55 -0400 Received: from mail-ee0-f48.google.com ([74.125.83.48]:49058 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755569Ab3JJRky (ORCPT ); Thu, 10 Oct 2013 13:40:54 -0400 Received: by mail-ee0-f48.google.com with SMTP id l10so1336592eei.35 for ; Thu, 10 Oct 2013 10:40:53 -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; bh=ksWyJk5HxLZYu3bw6dUEu1Uct4A9x+Fnxmv8+vuSG7w=; b=xBxG29OMlk4kpZ/hPP+yNdABCq+9G+MhWdnug5w2QLDmORpdQkmbRC0qv/Opeh+acm 5TZDjI8BreEXIvecxWOJKhWN/5DRR0KpRsIo+ilfdMZBdJqWQGbaebVp7vmDNky91Vil VFMBAyn9RVD8pJSv5QxX1m88J0P8RfWw2od19GXP6ZyDVLDIRfGs2JXgwl8G06E7V4oN F+Iu9wnyLoMKTVw3jsILJ0lBs5C8Z12/ji4EDjojVAqWH/v4xzMAkaJp1cc5utwy51hx L7yoSlU1tempNht6FGclzqyo8duwmtDeT5bqiwOOSBU4PyEzrozmcjwdAI+RyzTVHGLD NRZg== X-Received: by 10.14.202.193 with SMTP id d41mr4734387eeo.69.1381426853373; Thu, 10 Oct 2013 10:40:53 -0700 (PDT) Received: from localhost ([109.110.75.198]) by mx.google.com with ESMTPSA id z12sm104108879eev.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 10 Oct 2013 10:40:51 -0700 (PDT) From: Ilya Dryomov To: linux-btrfs@vger.kernel.org Cc: Chris Mason , Stefan Behrens , idryomov@gmail.com Subject: [PATCH] Btrfs: disallow 'btrfs {balance, replace} cancel' on ro mounts Date: Thu, 10 Oct 2013 20:40:21 +0300 Message-Id: <1381426821-31981-1-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP For both balance and replace, cancelling involves changing the on-disk state and committing a transaction, which is not a good thing to do on read-only filesystems. Cc: Stefan Behrens Signed-off-by: Ilya Dryomov --- fs/btrfs/dev-replace.c | 3 +++ fs/btrfs/volumes.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 9efb94e..98df261 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -650,6 +650,9 @@ static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info) u64 result; int ret; + if (fs_info->sb->s_flags & MS_RDONLY) + return -EROFS; + mutex_lock(&dev_replace->lock_finishing_cancel_unmount); btrfs_dev_replace_lock(dev_replace); switch (dev_replace->replace_state) { diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index a306db9..2630f38 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -3424,6 +3424,9 @@ int btrfs_pause_balance(struct btrfs_fs_info *fs_info) int btrfs_cancel_balance(struct btrfs_fs_info *fs_info) { + if (fs_info->sb->s_flags & MS_RDONLY) + return -EROFS; + mutex_lock(&fs_info->balance_mutex); if (!fs_info->balance_ctl) { mutex_unlock(&fs_info->balance_mutex);