linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <josef@redhat.com>
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	[thread overview]
Message-ID: <1300117060-13613-3-git-send-email-josef@redhat.com> (raw)
In-Reply-To: <1300117060-13613-1-git-send-email-josef@redhat.com>

This patch implements the super op contains_bdev.  We just loop through the
fs_devices on this super looking for the block device that was requested.
Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
---
 fs/btrfs/super.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

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 = {
-- 
1.7.2.3


  parent reply	other threads:[~2011-03-14 15:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-14 15:37 [RFE] Add a new super operation for finding block devices in a super Josef Bacik
2011-03-14 15:37 ` [PATCH 1/2] fs: add super operation contains_bdev Josef Bacik
2011-03-14 15:37 ` Josef Bacik [this message]
2011-03-14 16:31 ` [RFE] Add a new super operation for finding block devices in a super Christoph Hellwig
2011-03-14 17:50   ` Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1300117060-13613-3-git-send-email-josef@redhat.com \
    --to=josef@redhat.com \
    --cc=hch@infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).