* [PATCH 0/3] Btrfs: some cleanups around btrfs_read_fs_root_no_name()
@ 2013-05-13 13:53 Stefan Behrens
2013-05-13 13:53 ` [PATCH 1/3] Btrfs: delete unused function Stefan Behrens
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Stefan Behrens @ 2013-05-13 13:53 UTC (permalink / raw)
To: linux-btrfs
Just some line deletions for callers of btrfs_read_fs_root_no_name().
They repeat the check for btrfs_root_refs() after calling
btrfs_read_fs_root_no_name() and map the error to ENOENT in this case,
and btrfs_read_fs_root_no_name() already does the same for you.
send.c even checked the result for NULL which cannot happen.
And one static inline function in delayed-inode.c that called
btrfs_read_fs_root_no_name() was not at all used anymore.
Stefan Behrens (3):
Btrfs: delete unused function
Btrfs: cleanup, btrfs_read_fs_root_no_name() doesn't return NULL
Btrfs: cleanup: don't check the same thing twice
fs/btrfs/delayed-inode.c | 14 --------------
fs/btrfs/export.c | 5 -----
fs/btrfs/file.c | 4 ----
fs/btrfs/inode.c | 10 ----------
fs/btrfs/ioctl.c | 5 -----
fs/btrfs/send.c | 8 ++------
fs/btrfs/super.c | 3 ---
7 files changed, 2 insertions(+), 47 deletions(-)
--
1.8.2.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] Btrfs: delete unused function
2013-05-13 13:53 [PATCH 0/3] Btrfs: some cleanups around btrfs_read_fs_root_no_name() Stefan Behrens
@ 2013-05-13 13:53 ` Stefan Behrens
2013-05-13 13:53 ` [PATCH 2/3] Btrfs: cleanup, btrfs_read_fs_root_no_name() doesn't return NULL Stefan Behrens
2013-05-13 13:53 ` [PATCH 3/3] Btrfs: cleanup: don't check the same thing twice Stefan Behrens
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Behrens @ 2013-05-13 13:53 UTC (permalink / raw)
To: linux-btrfs
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
fs/btrfs/delayed-inode.c | 14 --------------
1 file changed, 14 deletions(-)
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index f26f38c..5615eac 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -535,20 +535,6 @@ static struct btrfs_delayed_item *__btrfs_next_delayed_item(
return next;
}
-static inline struct btrfs_root *btrfs_get_fs_root(struct btrfs_root *root,
- u64 root_id)
-{
- struct btrfs_key root_key;
-
- if (root->objectid == root_id)
- return root;
-
- root_key.objectid = root_id;
- root_key.type = BTRFS_ROOT_ITEM_KEY;
- root_key.offset = (u64)-1;
- return btrfs_read_fs_root_no_name(root->fs_info, &root_key);
-}
-
static int btrfs_delayed_item_reserve_metadata(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct btrfs_delayed_item *item)
--
1.8.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] Btrfs: cleanup, btrfs_read_fs_root_no_name() doesn't return NULL
2013-05-13 13:53 [PATCH 0/3] Btrfs: some cleanups around btrfs_read_fs_root_no_name() Stefan Behrens
2013-05-13 13:53 ` [PATCH 1/3] Btrfs: delete unused function Stefan Behrens
@ 2013-05-13 13:53 ` Stefan Behrens
2013-05-13 13:53 ` [PATCH 3/3] Btrfs: cleanup: don't check the same thing twice Stefan Behrens
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Behrens @ 2013-05-13 13:53 UTC (permalink / raw)
To: linux-btrfs
No need to check for NULL in send.c.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
fs/btrfs/send.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index ff40f1c..f075c82 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -4663,10 +4663,6 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
key.type = BTRFS_ROOT_ITEM_KEY;
key.offset = (u64)-1;
clone_root = btrfs_read_fs_root_no_name(fs_info, &key);
- if (!clone_root) {
- ret = -EINVAL;
- goto out;
- }
if (IS_ERR(clone_root)) {
ret = PTR_ERR(clone_root);
goto out;
@@ -4682,8 +4678,8 @@ long btrfs_ioctl_send(struct file *mnt_file, void __user *arg_)
key.type = BTRFS_ROOT_ITEM_KEY;
key.offset = (u64)-1;
sctx->parent_root = btrfs_read_fs_root_no_name(fs_info, &key);
- if (!sctx->parent_root) {
- ret = -EINVAL;
+ if (IS_ERR(sctx->parent_root)) {
+ ret = PTR_ERR(sctx->parent_root);
goto out;
}
}
--
1.8.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] Btrfs: cleanup: don't check the same thing twice
2013-05-13 13:53 [PATCH 0/3] Btrfs: some cleanups around btrfs_read_fs_root_no_name() Stefan Behrens
2013-05-13 13:53 ` [PATCH 1/3] Btrfs: delete unused function Stefan Behrens
2013-05-13 13:53 ` [PATCH 2/3] Btrfs: cleanup, btrfs_read_fs_root_no_name() doesn't return NULL Stefan Behrens
@ 2013-05-13 13:53 ` Stefan Behrens
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Behrens @ 2013-05-13 13:53 UTC (permalink / raw)
To: linux-btrfs
btrfs_read_fs_root_no_name() already checks if btrfs_root_refs()
is zero and returns ENOENT in this case. There is no need to do
it again in six places.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
---
fs/btrfs/export.c | 5 -----
fs/btrfs/file.c | 4 ----
fs/btrfs/inode.c | 10 ----------
fs/btrfs/ioctl.c | 5 -----
fs/btrfs/super.c | 3 ---
5 files changed, 27 deletions(-)
diff --git a/fs/btrfs/export.c b/fs/btrfs/export.c
index 81ee29e..4b86916 100644
--- a/fs/btrfs/export.c
+++ b/fs/btrfs/export.c
@@ -82,11 +82,6 @@ static struct dentry *btrfs_get_dentry(struct super_block *sb, u64 objectid,
goto fail;
}
- if (btrfs_root_refs(&root->root_item) == 0) {
- err = -ENOENT;
- goto fail;
- }
-
key.objectid = objectid;
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
key.offset = 0;
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index b3e359b..185af15 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -308,10 +308,6 @@ static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,
ret = PTR_ERR(inode_root);
goto cleanup;
}
- if (btrfs_root_refs(&inode_root->root_item) == 0) {
- ret = -ENOENT;
- goto cleanup;
- }
key.objectid = defrag->ino;
btrfs_set_key_type(&key, BTRFS_INODE_ITEM_KEY);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 1669c3b..0457347 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2258,11 +2258,6 @@ static noinline int relink_extent_backref(struct btrfs_path *path,
return 0;
return PTR_ERR(root);
}
- if (btrfs_root_refs(&root->root_item) == 0) {
- srcu_read_unlock(&fs_info->subvol_srcu, index);
- /* parse ENOENT to 0 */
- return 0;
- }
/* step 2: get inode */
key.objectid = backref->inum;
@@ -4816,11 +4811,6 @@ static int fixup_tree_root_location(struct btrfs_root *root,
goto out;
}
- if (btrfs_root_refs(&new_root->root_item) == 0) {
- err = -ENOENT;
- goto out;
- }
-
*sub_root = new_root;
location->objectid = btrfs_root_dirid(&new_root->root_item);
location->type = BTRFS_INODE_ITEM_KEY;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 1e0dda1..b2537c7 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -2951,11 +2951,6 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
goto out;
}
- if (btrfs_root_refs(&new_root->root_item) == 0) {
- ret = -ENOENT;
- goto out;
- }
-
path = btrfs_alloc_path();
if (!path) {
ret = -ENOMEM;
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index c02c59a..b6af7d3 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -775,9 +775,6 @@ find_root:
if (IS_ERR(new_root))
return ERR_CAST(new_root);
- if (btrfs_root_refs(&new_root->root_item) == 0)
- return ERR_PTR(-ENOENT);
-
dir_id = btrfs_root_dirid(&new_root->root_item);
setup_root:
location.objectid = dir_id;
--
1.8.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-05-13 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-13 13:53 [PATCH 0/3] Btrfs: some cleanups around btrfs_read_fs_root_no_name() Stefan Behrens
2013-05-13 13:53 ` [PATCH 1/3] Btrfs: delete unused function Stefan Behrens
2013-05-13 13:53 ` [PATCH 2/3] Btrfs: cleanup, btrfs_read_fs_root_no_name() doesn't return NULL Stefan Behrens
2013-05-13 13:53 ` [PATCH 3/3] Btrfs: cleanup: don't check the same thing twice Stefan Behrens
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).