From patchwork Mon Mar 14 15:37:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 633811 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 p2EFmtGn021177 for ; Mon, 14 Mar 2011 15:48:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755569Ab1CNPsn (ORCPT ); Mon, 14 Mar 2011 11:48:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3083 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754550Ab1CNPsm (ORCPT ); Mon, 14 Mar 2011 11:48:42 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2EFmbvn031737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Mar 2011 11:48:38 -0400 Received: from test1244.test.redhat.com (test1244.test.redhat.com [10.10.10.244]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p2EFmZkj010225; Mon, 14 Mar 2011 11:48:37 -0400 From: Josef Bacik To: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, viro@ZenIV.linux.org.uk, hch@infradead.org Subject: [PATCH 2/2] btrfs: implement super op contains_bdev Date: Mon, 14 Mar 2011 11:37:40 -0400 Message-Id: <1300117060-13613-3-git-send-email-josef@redhat.com> In-Reply-To: <1300117060-13613-1-git-send-email-josef@redhat.com> References: <1300117060-13613-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 14 Mar 2011 15:48:55 +0000 (UTC) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d39a989..1487bef 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1095,6 +1095,26 @@ static int btrfs_unfreeze(struct super_block *sb) return 0; } +static int btrfs_contains_bdev(struct super_block *sb, + struct block_device *bdev) +{ + struct btrfs_root *root = btrfs_sb(sb); + struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; + struct btrfs_device *device; + int ret = 0; + + mutex_lock(&fs_devices->device_list_mutex); + list_for_each_entry(device, &fs_devices->devices, dev_list) { + if (device->bdev == bdev) { + ret = 1; + break; + } + } + mutex_unlock(&fs_devices->device_list_mutex); + + return ret; +} + static const struct super_operations btrfs_super_ops = { .drop_inode = btrfs_drop_inode, .evict_inode = btrfs_evict_inode, @@ -1109,6 +1129,7 @@ static const struct super_operations btrfs_super_ops = { .remount_fs = btrfs_remount, .freeze_fs = btrfs_freeze, .unfreeze_fs = btrfs_unfreeze, + .contains_bdev = btrfs_contains_bdev, }; static const struct file_operations btrfs_ctl_fops = {