From patchwork Thu May 24 21:41:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10425583 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 8002F602D8 for ; Thu, 24 May 2018 21:41:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71942295B5 for ; Thu, 24 May 2018 21:41:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 66114295BD; Thu, 24 May 2018 21:41:55 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 ED9CB295B5 for ; Thu, 24 May 2018 21:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971645AbeEXVlw (ORCPT ); Thu, 24 May 2018 17:41:52 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:33059 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S971631AbeEXVln (ORCPT ); Thu, 24 May 2018 17:41:43 -0400 Received: by mail-pl0-f67.google.com with SMTP id n10-v6so1834465plp.0 for ; Thu, 24 May 2018 14:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=UtdASuhzApjy8wtJpM/DvzZ6e28x4N2e8lQ7ndxjT4o=; b=y7krpXx3PC3NLIIgyfDSk+jdeMlkyYSpYftBYq/xo4bUfmy7xFAG5H0egM13W/2y5+ KdK/nAioFx38zyeG3bkvlVlE9YbogarJSSvOSceBBbxDGYXHQMTqqyi9QRwWwTSbl8jK MZkR/2Wq38wzT8EZXDMOW7n7+i5aMSs3sqNH54BDg6dHAs19fDnQPK7pCgGiH2m07i6u apoQQpgL2l9N2CLxEIPQew1pyla+5KIOmygeW3HGPgnwVfsrGyoBw6RNOxwPymE7W1pS vGgKbepwHZ5vD98gFAYUlVIR7qxGlGopXe/ux3Rm/O9LAXHu8dN2lEXYZXMf8grNi9Rx tTiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=UtdASuhzApjy8wtJpM/DvzZ6e28x4N2e8lQ7ndxjT4o=; b=ZDkG1y5GJ5DPYlOWN3DcZMgw2N+dtiZie94HaaOZWHvOhDOqg/sbXPYFpj/DP5d5x5 3otGFyXuR5cIqZ+Xi9KVO3qgnzbHhsP763ESyDQIDbDuXlm7u9C8yQLCOF6oczPfSBXP 9kyvpO+dktnZLmW5rluJX1GtQuQ8fWQbmMuIii16YDKm+JHbkAIrGgDpbExi5L2vG4+I gJAqQXih30wjX1bYPT16wBG4/Isu8J43DTXo0rqwJElEnfvVT6wtYeca2ZQ5H7wrbeUg 0PWizHkz+p3QwIYKgitWcfhVBkIK3uxGPqpAelc4CGrD0XYX+qXnXdNt8pa+RwHScT7I mipA== X-Gm-Message-State: ALKqPwcHOjbKQFZHKDpzD5mIxrgTnH1+6b8jInKSLYmHKkGog8t5pWFg r0TSfdbMChgEGOUw63ZzLsgt7w== X-Google-Smtp-Source: AB8JxZpto1KPUk7XBcTlaGtaEnVE5ObNY8uUHuLZ+vVrwO9WN8hSsdFh7BgOvnY0pCpjRpkjhA4opQ== X-Received: by 2002:a17:902:4301:: with SMTP id i1-v6mr9152359pld.280.1527198102936; Thu, 24 May 2018 14:41:42 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::6:a0b5]) by smtp.gmail.com with ESMTPSA id g68-v6sm37388994pfk.53.2018.05.24.14.41.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 14:41:42 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, linux-fsdevel@vger.kernel.org, Tejun Heo Subject: [RFC PATCH v4 3/6] Btrfs: push EXCL_OP set into btrfs_rm_device() Date: Thu, 24 May 2018 14:41:27 -0700 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: In-Reply-To: References: 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 From: Omar Sandoval btrfs_ioctl_rm_dev() and btrfs_ioctl_rm_dev_v2() both manipulate this bit. Let's move it into the common btrfs_rm_device(), which also makes the following change to deal with swap files easier. Signed-off-by: Omar Sandoval Reviewed-by: Nikolay Borisov --- fs/btrfs/ioctl.c | 13 ------------- fs/btrfs/volumes.c | 4 ++++ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 9af3be96099f..82be4a94334b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3091,18 +3091,12 @@ static long btrfs_ioctl_rm_dev_v2(struct file *file, void __user *arg) goto out; } - if (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) { - ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS; - goto out; - } - if (vol_args->flags & BTRFS_DEVICE_SPEC_BY_ID) { ret = btrfs_rm_device(fs_info, NULL, vol_args->devid); } else { vol_args->name[BTRFS_SUBVOL_NAME_MAX] = '\0'; ret = btrfs_rm_device(fs_info, vol_args->name, 0); } - clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags); if (!ret) { if (vol_args->flags & BTRFS_DEVICE_SPEC_BY_ID) @@ -3133,11 +3127,6 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) if (ret) return ret; - if (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) { - ret = BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS; - goto out_drop_write; - } - vol_args = memdup_user(arg, sizeof(*vol_args)); if (IS_ERR(vol_args)) { ret = PTR_ERR(vol_args); @@ -3151,8 +3140,6 @@ static long btrfs_ioctl_rm_dev(struct file *file, void __user *arg) btrfs_info(fs_info, "disk deleted %s", vol_args->name); kfree(vol_args); out: - clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags); -out_drop_write: mnt_drop_write_file(file); return ret; diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b6757b53c297..9cfac177214f 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1951,6 +1951,9 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, u64 num_devices; int ret = 0; + if (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) + return BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS; + mutex_lock(&uuid_mutex); num_devices = fs_devices->num_devices; @@ -2069,6 +2072,7 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, out: mutex_unlock(&uuid_mutex); + clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags); return ret; error_undo: