From patchwork Tue Jul 15 23:07:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 4561701 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 DF2279F295 for ; Tue, 15 Jul 2014 23:08:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0EA9420108 for ; Tue, 15 Jul 2014 23:08:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3318E201B4 for ; Tue, 15 Jul 2014 23:08:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932982AbaGOXHy (ORCPT ); Tue, 15 Jul 2014 19:07:54 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:63202 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758985AbaGOXHU (ORCPT ); Tue, 15 Jul 2014 19:07:20 -0400 Received: by mail-pd0-f169.google.com with SMTP id y10so119552pdj.14 for ; Tue, 15 Jul 2014 16:07:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=YNteYJUJM6NsHCXwU7xwNUEtMvAx6sIJxQ3EE9HvT0c=; b=mzkff2NI7rg3scCC+fh4h+L9Wj77lOKT1+5EKFxWRIMb37ZGRTSof/zKDtE84e85gO jEHUaOi6H6w6oqHaxDdR82mfsaQTA0/d3Xqvwe81zWQJrimI1BFEDyEfH7yFkicYIXwV U9kbp9xolGayyzwV1t/QgDx6IDu8clvu2doHD2Kdo/NGdlQASYr6ibDUarFem1MW3hN3 VAOBvzYgaylqymbCZr75hUA9y3P9kkaktwxKqxMyFnO9UpPMwjm2vtZwif8THNTKU/Xj v+lcOBJyqgyiks0kF0Q+PsApgsT3kfMMvT3G452dIBYO8NDSQuc7mpInnKqeCfaMEc3v mqRA== X-Received: by 10.70.90.207 with SMTP id by15mr25715848pdb.31.1405465639747; Tue, 15 Jul 2014 16:07:19 -0700 (PDT) Received: from mcgrof@gmail.com (c-98-234-145-61.hsd1.ca.comcast.net. [98.234.145.61]) by mx.google.com with ESMTPSA id nw13sm63000920pab.37.2014.07.15.16.07.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 15 Jul 2014 16:07:18 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Tue, 15 Jul 2014 16:07:15 -0700 From: "Luis R. Rodriguez" To: viro@zeniv.linux.org.uk, clm@fb.com, jbacik@fb.com Cc: linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, jeffm@suse.com, fdmanana@suse.com, "Luis R. Rodriguez" Subject: [RFC 2/2] btrfs: use the new VFS super_block_dev Date: Tue, 15 Jul 2014 16:07:05 -0700 Message-Id: <1405465625-1122-3-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405465625-1122-1-git-send-email-mcgrof@do-not-panic.com> References: <1405465625-1122-1-git-send-email-mcgrof@do-not-panic.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable 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 From: "Luis R. Rodriguez" Use the new VFS layer struct super_block_dev instead of carrying the anonymous bdev's on our own. This makes the VFS layer aware of all of our anonymous dev's on the super block. Signed-off-by: Luis R. Rodriguez --- fs/btrfs/ctree.h | 7 ++----- fs/btrfs/disk-io.c | 10 +++++----- fs/btrfs/inode.c | 2 +- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index be91397..34247f6 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -1846,11 +1846,8 @@ struct btrfs_root { * protected by inode_lock */ struct radix_tree_root delayed_nodes_tree; - /* - * right now this just gets used so that a root has its own devid - * for stat. It may be used for more later - */ - dev_t anon_dev; + + struct super_block_dev *sbdev; spinlock_t root_item_lock; atomic_t refs; diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8bb4aa1..edc64a8 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1269,7 +1269,6 @@ static void __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, root->defrag_trans_start = 0; init_completion(&root->kobj_unregister); root->root_key.objectid = objectid; - root->anon_dev = 0; spin_lock_init(&root->root_item_lock); } @@ -1572,9 +1571,11 @@ int btrfs_init_fs_root(struct btrfs_root *root) spin_lock_init(&root->cache_lock); init_waitqueue_head(&root->cache_wait); - ret = get_anon_bdev(&root->anon_dev); - if (ret) + root->sbdev = get_anon_sbdev(root->fs_info->sb); + if (!root->sbdev) { + ret = -ENOMEM; goto free_writers; + } return 0; free_writers: @@ -3529,8 +3530,7 @@ static void free_fs_root(struct btrfs_root *root) WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); btrfs_free_block_rsv(root, root->orphan_block_rsv); root->orphan_block_rsv = NULL; - if (root->anon_dev) - free_anon_bdev(root->anon_dev); + free_anon_sbdev(root->sbdev); if (root->subv_writers) btrfs_free_subvolume_writers(root->subv_writers); free_extent_buffer(root->node); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 3668048..41a8bab 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8277,7 +8277,7 @@ static int btrfs_getattr(struct vfsmount *mnt, u32 blocksize = inode->i_sb->s_blocksize; generic_fillattr(inode, stat); - stat->dev = BTRFS_I(inode)->root->anon_dev; + stat->dev = BTRFS_I(inode)->root->sbdev->anon_dev; stat->blksize = PAGE_CACHE_SIZE; spin_lock(&BTRFS_I(inode)->lock);