From: Jeff Mahoney <jeffm@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 4/8] btrfs: free-space-cache, clean up unnecessary root arguments
Date: Wed, 15 Feb 2017 17:06:20 -0500 [thread overview]
Message-ID: <a10e9596-5675-af76-b923-d7ca8b3bca60@suse.com> (raw)
In-Reply-To: <1487194114-12786-5-git-send-email-jeffm@suse.com>
[-- Attachment #1.1: Type: text/plain, Size: 9124 bytes --]
On 2/15/17 4:28 PM, jeffm@suse.com wrote:
> From: Jeff Mahoney <jeffm@suse.com>
>
> The free space cache APIs accept a root but always use the tree root.
>
> Also, btrfs_truncate_free_space_cache accepts a root AND an inode but
> the inode always points to the root anyway, so let's just pass the inode.
This one has minor conflicts with Dave's patchset that removes path and
objectid.
-Jeff
> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
> ---
> fs/btrfs/extent-tree.c | 9 +++++----
> fs/btrfs/free-space-cache.c | 25 +++++++++++--------------
> fs/btrfs/free-space-cache.h | 7 +++----
> fs/btrfs/inode-map.c | 2 +-
> fs/btrfs/relocation.c | 5 ++---
> 5 files changed, 22 insertions(+), 26 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 20bedc7..a557249 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -3372,7 +3372,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
> if (trans->aborted)
> return 0;
> again:
> - inode = lookup_free_space_inode(root, block_group, path);
> + inode = lookup_free_space_inode(fs_info, block_group, path);
> if (IS_ERR(inode) && PTR_ERR(inode) != -ENOENT) {
> ret = PTR_ERR(inode);
> btrfs_release_path(path);
> @@ -3386,7 +3386,8 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
> if (block_group->ro)
> goto out_free;
>
> - ret = create_free_space_inode(root, trans, block_group, path);
> + ret = create_free_space_inode(fs_info, trans, block_group,
> + path);
> if (ret)
> goto out_free;
> goto again;
> @@ -3428,7 +3429,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
> if (ret)
> goto out_put;
>
> - ret = btrfs_truncate_free_space_cache(root, trans, NULL, inode);
> + ret = btrfs_truncate_free_space_cache(trans, NULL, inode);
> if (ret)
> goto out_put;
> }
> @@ -10319,7 +10320,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
> * get the inode first so any iput calls done for the io_list
> * aren't the final iput (no unlinks allowed now)
> */
> - inode = lookup_free_space_inode(tree_root, block_group, path);
> + inode = lookup_free_space_inode(fs_info, block_group, path);
>
> mutex_lock(&trans->transaction->cache_write_mutex);
> /*
> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
> index 7015892..61a72fb 100644
> --- a/fs/btrfs/free-space-cache.c
> +++ b/fs/btrfs/free-space-cache.c
> @@ -94,12 +94,11 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
> return inode;
> }
>
> -struct inode *lookup_free_space_inode(struct btrfs_root *root,
> +struct inode *lookup_free_space_inode(struct btrfs_fs_info *fs_info,
> struct btrfs_block_group_cache
> *block_group, struct btrfs_path *path)
> {
> struct inode *inode = NULL;
> - struct btrfs_fs_info *fs_info = root->fs_info;
> u32 flags = BTRFS_INODE_NODATASUM | BTRFS_INODE_NODATACOW;
>
> spin_lock(&block_group->lock);
> @@ -109,7 +108,7 @@ struct inode *lookup_free_space_inode(struct btrfs_root *root,
> if (inode)
> return inode;
>
> - inode = __lookup_free_space_inode(root, path,
> + inode = __lookup_free_space_inode(fs_info->tree_root, path,
> block_group->key.objectid);
> if (IS_ERR(inode))
> return inode;
> @@ -192,7 +191,7 @@ static int __create_free_space_inode(struct btrfs_root *root,
> return 0;
> }
>
> -int create_free_space_inode(struct btrfs_root *root,
> +int create_free_space_inode(struct btrfs_fs_info *fs_info,
> struct btrfs_trans_handle *trans,
> struct btrfs_block_group_cache *block_group,
> struct btrfs_path *path)
> @@ -200,11 +199,11 @@ int create_free_space_inode(struct btrfs_root *root,
> int ret;
> u64 ino;
>
> - ret = btrfs_find_free_objectid(root, &ino);
> + ret = btrfs_find_free_objectid(fs_info->tree_root, &ino);
> if (ret < 0)
> return ret;
>
> - return __create_free_space_inode(root, trans, path, ino,
> + return __create_free_space_inode(fs_info->tree_root, trans, path, ino,
> block_group->key.objectid);
> }
>
> @@ -227,11 +226,11 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
> return ret;
> }
>
> -int btrfs_truncate_free_space_cache(struct btrfs_root *root,
> - struct btrfs_trans_handle *trans,
> +int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
> struct btrfs_block_group_cache *block_group,
> struct inode *inode)
> {
> + struct btrfs_root *root = BTRFS_I(inode)->root;
> int ret = 0;
> struct btrfs_path *path = btrfs_alloc_path();
> bool locked = false;
> @@ -828,7 +827,6 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
> struct btrfs_block_group_cache *block_group)
> {
> struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
> - struct btrfs_root *root = fs_info->tree_root;
> struct inode *inode;
> struct btrfs_path *path;
> int ret = 0;
> @@ -852,7 +850,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
> path->search_commit_root = 1;
> path->skip_locking = 1;
>
> - inode = lookup_free_space_inode(root, block_group, path);
> + inode = lookup_free_space_inode(fs_info, block_group, path);
> if (IS_ERR(inode)) {
> btrfs_free_path(path);
> return 0;
> @@ -1378,7 +1376,6 @@ int btrfs_write_out_cache(struct btrfs_fs_info *fs_info,
> struct btrfs_block_group_cache *block_group,
> struct btrfs_path *path)
> {
> - struct btrfs_root *root = fs_info->tree_root;
> struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
> struct inode *inode;
> int ret = 0;
> @@ -1390,12 +1387,12 @@ int btrfs_write_out_cache(struct btrfs_fs_info *fs_info,
> }
> spin_unlock(&block_group->lock);
>
> - inode = lookup_free_space_inode(root, block_group, path);
> + inode = lookup_free_space_inode(fs_info, block_group, path);
> if (IS_ERR(inode))
> return 0;
>
> - ret = __btrfs_write_out_cache(root, inode, ctl, block_group,
> - &block_group->io_ctl, trans,
> + ret = __btrfs_write_out_cache(fs_info->tree_root, inode, ctl,
> + block_group, &block_group->io_ctl, trans,
> path, block_group->key.objectid);
> if (ret) {
> #ifdef DEBUG
> diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h
> index 6f3c025..79eca4c 100644
> --- a/fs/btrfs/free-space-cache.h
> +++ b/fs/btrfs/free-space-cache.h
> @@ -51,18 +51,17 @@ struct btrfs_free_space_op {
>
> struct btrfs_io_ctl;
>
> -struct inode *lookup_free_space_inode(struct btrfs_root *root,
> +struct inode *lookup_free_space_inode(struct btrfs_fs_info *fs_info,
> struct btrfs_block_group_cache
> *block_group, struct btrfs_path *path);
> -int create_free_space_inode(struct btrfs_root *root,
> +int create_free_space_inode(struct btrfs_fs_info *fs_info,
> struct btrfs_trans_handle *trans,
> struct btrfs_block_group_cache *block_group,
> struct btrfs_path *path);
>
> int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
> struct btrfs_block_rsv *rsv);
> -int btrfs_truncate_free_space_cache(struct btrfs_root *root,
> - struct btrfs_trans_handle *trans,
> +int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
> struct btrfs_block_group_cache *block_group,
> struct inode *inode);
> int load_free_space_cache(struct btrfs_fs_info *fs_info,
> diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c
> index 144b119..3bbb8f0 100644
> --- a/fs/btrfs/inode-map.c
> +++ b/fs/btrfs/inode-map.c
> @@ -467,7 +467,7 @@ int btrfs_save_ino_cache(struct btrfs_root *root,
> }
>
> if (i_size_read(inode) > 0) {
> - ret = btrfs_truncate_free_space_cache(root, trans, NULL, inode);
> + ret = btrfs_truncate_free_space_cache(trans, NULL, inode);
> if (ret) {
> if (ret != -ENOSPC)
> btrfs_abort_transaction(trans, ret);
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 2e9deb9..bee4b5b 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -3543,7 +3543,7 @@ static int delete_block_group_cache(struct btrfs_fs_info *fs_info,
> goto out;
> }
>
> - ret = btrfs_truncate_free_space_cache(root, trans, block_group, inode);
> + ret = btrfs_truncate_free_space_cache(trans, block_group, inode);
>
> btrfs_end_transaction(trans);
> btrfs_btree_balance_dirty(fs_info);
> @@ -4347,8 +4347,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
> goto out;
> }
>
> - inode = lookup_free_space_inode(fs_info->tree_root, rc->block_group,
> - path);
> + inode = lookup_free_space_inode(fs_info, rc->block_group, path);
> btrfs_free_path(path);
>
> if (!IS_ERR(inode))
>
--
Jeff Mahoney
SUSE Labs
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2017-02-15 22:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-15 21:28 [PATCH 0/8] btrfs: cleanup patches jeffm
2017-02-15 21:28 ` [PATCH 1/8] btrfs: pass fs_info to (more) routines that are only called with extent_root jeffm
2017-02-15 21:28 ` [PATCH 2/8] btrfs: flush_space always takes fs_info->fs_root jeffm
2017-02-15 21:28 ` [PATCH 3/8] btrfs: convert btrfs_inc_block_group_ro to accept fs_info jeffm
2017-02-15 21:28 ` [PATCH 4/8] btrfs: free-space-cache, clean up unnecessary root arguments jeffm
2017-02-15 22:06 ` Jeff Mahoney [this message]
2017-02-15 21:28 ` [PATCH 5/8] btrfs: btrfs_wait_cache_io_root doesn't use path argument jeffm
2017-02-15 22:04 ` Jeff Mahoney
2017-02-15 21:28 ` [PATCH 6/8] btrfs: btrfs_truncate_free_space_cache always allocates path jeffm
2017-02-15 21:28 ` [PATCH 7/8] btrfs: drop unused extent_op arg from btrfs_add_delayed_data_ref jeffm
2017-02-15 21:28 ` [PATCH 8/8] btrfs: use btrfs_debug instead of pr_debug in transaction abort jeffm
2017-02-16 16:41 ` [PATCH 0/8] btrfs: cleanup patches David Sterba
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=a10e9596-5675-af76-b923-d7ca8b3bca60@suse.com \
--to=jeffm@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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).