* [PATCH 01/16] Btrfs: copy string correctly in INO_LOOKUP ioctl
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
@ 2011-07-14 3:16 ` Li Zefan
2011-07-14 3:16 ` [PATCH 02/16] Btrfs: fix space leak when skipping small extents during trimming Li Zefan
` (15 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:16 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
Memory areas [ptr, ptr+total_len] and [name, name+total_len]
may overlap, so it's wrong to use memcpy().
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/ioctl.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index a3c4751..08a4580 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1755,11 +1755,10 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
key.objectid = key.offset;
key.offset = (u64)-1;
dirid = key.objectid;
-
}
if (ptr < name)
goto out;
- memcpy(name, ptr, total_len);
+ memmove(name, ptr, total_len);
name[total_len]='\0';
ret = 0;
out:
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 02/16] Btrfs: fix space leak when skipping small extents during trimming
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
2011-07-14 3:16 ` [PATCH 01/16] Btrfs: copy string correctly in INO_LOOKUP ioctl Li Zefan
@ 2011-07-14 3:16 ` Li Zefan
2011-07-14 3:16 ` [PATCH 03/16] Btrfs: fix space leak when trimming free extents Li Zefan
` (14 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:16 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
We're taking a free space extent out of the free space cache, trimming
it and then putting it back into the cache.
However for an extent that is smaller than the specified minimum length,
it's taken out but won't be put back, which causes space leak.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/free-space-cache.c | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index bf0d615..901585d 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2463,6 +2463,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
u64 bytes = 0;
u64 actually_trimmed;
int ret = 0;
+ int update_ret;
*trimmed = 0;
@@ -2486,6 +2487,7 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
}
if (entry->bitmap) {
+ bytes = 0;
ret = search_bitmap(ctl, entry, &start, &bytes);
if (!ret) {
if (start >= end) {
@@ -2493,6 +2495,8 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
break;
}
bytes = min(bytes, end - start);
+ if (bytes < minlen)
+ goto next;
bitmap_clear_bits(ctl, entry, start, bytes);
if (entry->bytes == 0)
free_bitmap(ctl, entry);
@@ -2506,33 +2510,29 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
} else {
start = entry->offset;
bytes = min(entry->bytes, end - start);
+ if (bytes < minlen)
+ goto next;
unlink_free_space(ctl, entry);
kmem_cache_free(btrfs_free_space_cachep, entry);
}
spin_unlock(&ctl->tree_lock);
- if (bytes >= minlen) {
- int update_ret;
- update_ret = btrfs_update_reserved_bytes(block_group,
- bytes, 1, 1);
+ update_ret = btrfs_update_reserved_bytes(block_group,
+ bytes, 1, 1);
- ret = btrfs_error_discard_extent(fs_info->extent_root,
- start,
- bytes,
- &actually_trimmed);
+ ret = btrfs_error_discard_extent(fs_info->extent_root, start,
+ bytes, &actually_trimmed);
- btrfs_add_free_space(block_group, start, bytes);
- if (!update_ret)
- btrfs_update_reserved_bytes(block_group,
- bytes, 0, 1);
+ btrfs_add_free_space(block_group, start, bytes);
+ if (!update_ret)
+ btrfs_update_reserved_bytes(block_group, bytes, 0, 1);
- if (ret)
- break;
- *trimmed += actually_trimmed;
- }
+ if (ret)
+ break;
+ *trimmed += actually_trimmed;
+next:
start += bytes;
- bytes = 0;
if (fatal_signal_pending(current)) {
ret = -ERESTARTSYS;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 03/16] Btrfs: fix space leak when trimming free extents
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
2011-07-14 3:16 ` [PATCH 01/16] Btrfs: copy string correctly in INO_LOOKUP ioctl Li Zefan
2011-07-14 3:16 ` [PATCH 02/16] Btrfs: fix space leak when skipping small extents during trimming Li Zefan
@ 2011-07-14 3:16 ` Li Zefan
2011-07-14 3:16 ` [PATCH 04/16] Btrfs: check the nodatasum flag when writing compressed files Li Zefan
` (13 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:16 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
When the end of an extent exceeds the end of the specified range,
the extent will be accidentally truncated.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/free-space-cache.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 901585d..cf4bffd 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -2512,8 +2512,15 @@ int btrfs_trim_block_group(struct btrfs_block_group_cache *block_group,
bytes = min(entry->bytes, end - start);
if (bytes < minlen)
goto next;
+
unlink_free_space(ctl, entry);
- kmem_cache_free(btrfs_free_space_cachep, entry);
+ if (bytes < entry->bytes) {
+ entry->offset = entry->offset + bytes;
+ entry->bytes = entry->bytes - bytes;
+ link_free_space(ctl, entry);
+ } else {
+ kmem_cache_free(btrfs_free_space_cachep, entry);
+ }
}
spin_unlock(&ctl->tree_lock);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 04/16] Btrfs: check the nodatasum flag when writing compressed files
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (2 preceding siblings ...)
2011-07-14 3:16 ` [PATCH 03/16] Btrfs: fix space leak when trimming free extents Li Zefan
@ 2011-07-14 3:16 ` Li Zefan
2011-07-14 3:17 ` [PATCH 05/16] Btrfs: use wait_event() Li Zefan
` (12 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:16 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
If mounting with nodatasum option, we won't csum file data for
general write or direct-io write, and this rule should also be
applied when writing compressed files.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/compression.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index bfe42b0..8ec5d86 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -338,6 +338,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
u64 first_byte = disk_start;
struct block_device *bdev;
int ret;
+ int skip_sum = BTRFS_I(inode)->flags & BTRFS_INODE_NODATASUM;
WARN_ON(start & ((u64)PAGE_CACHE_SIZE - 1));
cb = kmalloc(compressed_bio_size(root, compressed_len), GFP_NOFS);
@@ -392,8 +393,11 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
BUG_ON(ret);
- ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
- BUG_ON(ret);
+ if (!skip_sum) {
+ ret = btrfs_csum_one_bio(root, inode, bio,
+ start, 1);
+ BUG_ON(ret);
+ }
ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
BUG_ON(ret);
@@ -418,8 +422,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
ret = btrfs_bio_wq_end_io(root->fs_info, bio, 0);
BUG_ON(ret);
- ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
- BUG_ON(ret);
+ if (!skip_sum) {
+ ret = btrfs_csum_one_bio(root, inode, bio, start, 1);
+ BUG_ON(ret);
+ }
ret = btrfs_map_bio(root, WRITE, bio, 0, 1);
BUG_ON(ret);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 05/16] Btrfs: use wait_event()
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (3 preceding siblings ...)
2011-07-14 3:16 ` [PATCH 04/16] Btrfs: check the nodatasum flag when writing compressed files Li Zefan
@ 2011-07-14 3:17 ` Li Zefan
2011-07-14 3:17 ` [PATCH 06/16] Btrfs: remove a BUG_ON() in btrfs_commit_transaction() Li Zefan
` (11 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:17 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
Use wait_event() when possible to avoid code duplication.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/transaction.c | 59 +++++------------------------------------------
1 files changed, 7 insertions(+), 52 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 51dcec8..34a30ea 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -216,17 +216,11 @@ static void wait_current_trans(struct btrfs_root *root)
spin_lock(&root->fs_info->trans_lock);
cur_trans = root->fs_info->running_transaction;
if (cur_trans && cur_trans->blocked) {
- DEFINE_WAIT(wait);
atomic_inc(&cur_trans->use_count);
spin_unlock(&root->fs_info->trans_lock);
- while (1) {
- prepare_to_wait(&root->fs_info->transaction_wait, &wait,
- TASK_UNINTERRUPTIBLE);
- if (!cur_trans->blocked)
- break;
- schedule();
- }
- finish_wait(&root->fs_info->transaction_wait, &wait);
+
+ wait_event(root->fs_info->transaction_wait,
+ !cur_trans->blocked);
put_transaction(cur_trans);
} else {
spin_unlock(&root->fs_info->trans_lock);
@@ -362,15 +356,7 @@ struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root
static noinline int wait_for_commit(struct btrfs_root *root,
struct btrfs_transaction *commit)
{
- DEFINE_WAIT(wait);
- while (!commit->commit_done) {
- prepare_to_wait(&commit->commit_wait, &wait,
- TASK_UNINTERRUPTIBLE);
- if (commit->commit_done)
- break;
- schedule();
- }
- finish_wait(&commit->commit_wait, &wait);
+ wait_event(commit->commit_wait, commit->commit_done);
return 0;
}
@@ -1080,22 +1066,7 @@ int btrfs_transaction_blocked(struct btrfs_fs_info *info)
static void wait_current_trans_commit_start(struct btrfs_root *root,
struct btrfs_transaction *trans)
{
- DEFINE_WAIT(wait);
-
- if (trans->in_commit)
- return;
-
- while (1) {
- prepare_to_wait(&root->fs_info->transaction_blocked_wait, &wait,
- TASK_UNINTERRUPTIBLE);
- if (trans->in_commit) {
- finish_wait(&root->fs_info->transaction_blocked_wait,
- &wait);
- break;
- }
- schedule();
- finish_wait(&root->fs_info->transaction_blocked_wait, &wait);
- }
+ wait_event(root->fs_info->transaction_blocked_wait, trans->in_commit);
}
/*
@@ -1105,24 +1076,8 @@ static void wait_current_trans_commit_start(struct btrfs_root *root,
static void wait_current_trans_commit_start_and_unblock(struct btrfs_root *root,
struct btrfs_transaction *trans)
{
- DEFINE_WAIT(wait);
-
- if (trans->commit_done || (trans->in_commit && !trans->blocked))
- return;
-
- while (1) {
- prepare_to_wait(&root->fs_info->transaction_wait, &wait,
- TASK_UNINTERRUPTIBLE);
- if (trans->commit_done ||
- (trans->in_commit && !trans->blocked)) {
- finish_wait(&root->fs_info->transaction_wait,
- &wait);
- break;
- }
- schedule();
- finish_wait(&root->fs_info->transaction_wait,
- &wait);
- }
+ wait_event(root->fs_info->transaction_wait,
+ trans->commit_done || (trans->in_commit && !trans->blocked));
}
/*
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 06/16] Btrfs: remove a BUG_ON() in btrfs_commit_transaction()
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (4 preceding siblings ...)
2011-07-14 3:17 ` [PATCH 05/16] Btrfs: use wait_event() Li Zefan
@ 2011-07-14 3:17 ` Li Zefan
2011-07-14 3:17 ` [PATCH 07/16] Btrfs: remove remaining ref-cache code Li Zefan
` (10 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:17 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
wait_for_commit() always returns 0.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/transaction.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 34a30ea..40726ac 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -353,11 +353,10 @@ struct btrfs_trans_handle *btrfs_start_ioctl_transaction(struct btrfs_root *root
}
/* wait for a transaction commit to be fully complete */
-static noinline int wait_for_commit(struct btrfs_root *root,
+static noinline void wait_for_commit(struct btrfs_root *root,
struct btrfs_transaction *commit)
{
wait_event(commit->commit_wait, commit->commit_done);
- return 0;
}
int btrfs_wait_for_commit(struct btrfs_root *root, u64 transid)
@@ -1184,8 +1183,7 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
atomic_inc(&cur_trans->use_count);
btrfs_end_transaction(trans, root);
- ret = wait_for_commit(root, cur_trans);
- BUG_ON(ret);
+ wait_for_commit(root, cur_trans);
put_transaction(cur_trans);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 07/16] Btrfs: remove remaining ref-cache code
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (5 preceding siblings ...)
2011-07-14 3:17 ` [PATCH 06/16] Btrfs: remove a BUG_ON() in btrfs_commit_transaction() Li Zefan
@ 2011-07-14 3:17 ` Li Zefan
2011-07-14 3:17 ` [PATCH 08/16] Btrfs: make acl functions really no-op if acl is not enabled Li Zefan
` (9 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:17 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
Since commit f2a97a9dbd86eb1ef956bdf20e05c507b32beb96
("btrfs: remove all unused functions"), there's no extern functions
at all in ref-cache.c, so just remove the remaining dead code.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/ref-cache.c | 68 --------------------------------------------------
fs/btrfs/ref-cache.h | 52 --------------------------------------
2 files changed, 0 insertions(+), 120 deletions(-)
delete mode 100644 fs/btrfs/ref-cache.c
delete mode 100644 fs/btrfs/ref-cache.h
diff --git a/fs/btrfs/ref-cache.c b/fs/btrfs/ref-cache.c
deleted file mode 100644
index 82d569c..0000000
--- a/fs/btrfs/ref-cache.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2008 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License v2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- */
-
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include <linux/sort.h>
-#include "ctree.h"
-#include "ref-cache.h"
-#include "transaction.h"
-
-static struct rb_node *tree_insert(struct rb_root *root, u64 bytenr,
- struct rb_node *node)
-{
- struct rb_node **p = &root->rb_node;
- struct rb_node *parent = NULL;
- struct btrfs_leaf_ref *entry;
-
- while (*p) {
- parent = *p;
- entry = rb_entry(parent, struct btrfs_leaf_ref, rb_node);
-
- if (bytenr < entry->bytenr)
- p = &(*p)->rb_left;
- else if (bytenr > entry->bytenr)
- p = &(*p)->rb_right;
- else
- return parent;
- }
-
- entry = rb_entry(node, struct btrfs_leaf_ref, rb_node);
- rb_link_node(node, parent, p);
- rb_insert_color(node, root);
- return NULL;
-}
-
-static struct rb_node *tree_search(struct rb_root *root, u64 bytenr)
-{
- struct rb_node *n = root->rb_node;
- struct btrfs_leaf_ref *entry;
-
- while (n) {
- entry = rb_entry(n, struct btrfs_leaf_ref, rb_node);
- WARN_ON(!entry->in_tree);
-
- if (bytenr < entry->bytenr)
- n = n->rb_left;
- else if (bytenr > entry->bytenr)
- n = n->rb_right;
- else
- return n;
- }
- return NULL;
-}
diff --git a/fs/btrfs/ref-cache.h b/fs/btrfs/ref-cache.h
deleted file mode 100644
index 24f7001..0000000
--- a/fs/btrfs/ref-cache.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2008 Oracle. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License v2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- */
-#ifndef __REFCACHE__
-#define __REFCACHE__
-
-struct btrfs_extent_info {
- /* bytenr and num_bytes find the extent in the extent allocation tree */
- u64 bytenr;
- u64 num_bytes;
-
- /* objectid and offset find the back reference for the file */
- u64 objectid;
- u64 offset;
-};
-
-struct btrfs_leaf_ref {
- struct rb_node rb_node;
- struct btrfs_leaf_ref_tree *tree;
- int in_tree;
- atomic_t usage;
-
- u64 root_gen;
- u64 bytenr;
- u64 owner;
- u64 generation;
- int nritems;
-
- struct list_head list;
- struct btrfs_extent_info extents[];
-};
-
-static inline size_t btrfs_leaf_ref_size(int nr_extents)
-{
- return sizeof(struct btrfs_leaf_ref) +
- sizeof(struct btrfs_extent_info) * nr_extents;
-}
-#endif
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 08/16] Btrfs: make acl functions really no-op if acl is not enabled
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (6 preceding siblings ...)
2011-07-14 3:17 ` [PATCH 07/16] Btrfs: remove remaining ref-cache code Li Zefan
@ 2011-07-14 3:17 ` Li Zefan
2011-07-14 3:17 ` [PATCH 09/16] Btrfs: remove redundant code for dir item lookup Li Zefan
` (8 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:17 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
So there's no overhead for something we don't use.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/Makefile | 4 +++-
fs/btrfs/acl.c | 17 -----------------
fs/btrfs/ctree.h | 15 ++++++++++++---
3 files changed, 15 insertions(+), 21 deletions(-)
diff --git a/fs/btrfs/Makefile b/fs/btrfs/Makefile
index 9b72dcf..40e6ac0 100644
--- a/fs/btrfs/Makefile
+++ b/fs/btrfs/Makefile
@@ -6,5 +6,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \
transaction.o inode.o file.o tree-defrag.o \
extent_map.o sysfs.o struct-funcs.o xattr.o ordered-data.o \
extent_io.o volumes.o async-thread.o ioctl.o locking.o orphan.o \
- export.o tree-log.o acl.o free-space-cache.o zlib.o lzo.o \
+ export.o tree-log.o free-space-cache.o zlib.o lzo.o \
compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o
+
+btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index f66fc99..b206d4c 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -28,8 +28,6 @@
#include "btrfs_inode.h"
#include "xattr.h"
-#ifdef CONFIG_BTRFS_FS_POSIX_ACL
-
static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
{
int size;
@@ -318,18 +316,3 @@ const struct xattr_handler btrfs_xattr_acl_access_handler = {
.get = btrfs_xattr_acl_get,
.set = btrfs_xattr_acl_set,
};
-
-#else /* CONFIG_BTRFS_FS_POSIX_ACL */
-
-int btrfs_acl_chmod(struct inode *inode)
-{
- return 0;
-}
-
-int btrfs_init_acl(struct btrfs_trans_handle *trans,
- struct inode *inode, struct inode *dir)
-{
- return 0;
-}
-
-#endif /* CONFIG_BTRFS_FS_POSIX_ACL */
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 60e13ef..b5097e2 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -2644,12 +2644,21 @@ do { \
/* acl.c */
#ifdef CONFIG_BTRFS_FS_POSIX_ACL
int btrfs_check_acl(struct inode *inode, int mask, unsigned int flags);
-#else
-#define btrfs_check_acl NULL
-#endif
int btrfs_init_acl(struct btrfs_trans_handle *trans,
struct inode *inode, struct inode *dir);
int btrfs_acl_chmod(struct inode *inode);
+#else
+#define btrfs_check_acl NULL
+static inline int btrfs_init_acl(struct btrfs_trans_handle *trans,
+ struct inode *inode, struct inode *dir)
+{
+ return 0;
+}
+static inline int btrfs_acl_chmod(struct inode *inode)
+{
+ return 0;
+}
+#endif
/* relocation.c */
int btrfs_relocate_block_group(struct btrfs_root *root, u64 group_start);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 09/16] Btrfs: remove redundant code for dir item lookup
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (7 preceding siblings ...)
2011-07-14 3:17 ` [PATCH 08/16] Btrfs: make acl functions really no-op if acl is not enabled Li Zefan
@ 2011-07-14 3:17 ` Li Zefan
2011-07-14 3:18 ` [PATCH 10/16] Btrfs: clean up search_extent_mapping() Li Zefan
` (7 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:17 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
When we search a dir item with a specific hash code, we can
just return NULL without further checking if btrfs_search_slot()
returns 1.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/dir-item.c | 30 ++----------------------------
1 files changed, 2 insertions(+), 28 deletions(-)
diff --git a/fs/btrfs/dir-item.c b/fs/btrfs/dir-item.c
index 685f259..81533a0 100644
--- a/fs/btrfs/dir-item.c
+++ b/fs/btrfs/dir-item.c
@@ -203,8 +203,6 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
struct btrfs_key key;
int ins_len = mod < 0 ? -1 : 0;
int cow = mod != 0;
- struct btrfs_key found_key;
- struct extent_buffer *leaf;
key.objectid = dir;
btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY);
@@ -214,18 +212,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
if (ret < 0)
return ERR_PTR(ret);
- if (ret > 0) {
- if (path->slots[0] == 0)
- return NULL;
- path->slots[0]--;
- }
-
- leaf = path->nodes[0];
- btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
-
- if (found_key.objectid != dir ||
- btrfs_key_type(&found_key) != BTRFS_DIR_ITEM_KEY ||
- found_key.offset != key.offset)
+ if (ret > 0)
return NULL;
return btrfs_match_dir_item_name(root, path, name, name_len);
@@ -320,8 +307,6 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
struct btrfs_key key;
int ins_len = mod < 0 ? -1 : 0;
int cow = mod != 0;
- struct btrfs_key found_key;
- struct extent_buffer *leaf;
key.objectid = dir;
btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY);
@@ -329,18 +314,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
if (ret < 0)
return ERR_PTR(ret);
- if (ret > 0) {
- if (path->slots[0] == 0)
- return NULL;
- path->slots[0]--;
- }
-
- leaf = path->nodes[0];
- btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
-
- if (found_key.objectid != dir ||
- btrfs_key_type(&found_key) != BTRFS_XATTR_ITEM_KEY ||
- found_key.offset != key.offset)
+ if (ret > 0)
return NULL;
return btrfs_match_dir_item_name(root, path, name, name_len);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 10/16] Btrfs: clean up search_extent_mapping()
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (8 preceding siblings ...)
2011-07-14 3:17 ` [PATCH 09/16] Btrfs: remove redundant code for dir item lookup Li Zefan
@ 2011-07-14 3:18 ` Li Zefan
2011-07-14 3:18 ` [PATCH 11/16] Btrfs: clean up code for extent_map lookup Li Zefan
` (6 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:18 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
rb_node returned by __tree_search() can be a valid pointer or NULL,
but won't be some errno.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/extent_map.c | 17 +++--------------
1 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 2d04103..911a9db 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -379,23 +379,12 @@ struct extent_map *search_extent_mapping(struct extent_map_tree *tree,
em = rb_entry(next, struct extent_map, rb_node);
goto found;
}
- if (!rb_node) {
- em = NULL;
- goto out;
- }
- if (IS_ERR(rb_node)) {
- em = ERR_CAST(rb_node);
- goto out;
- }
- em = rb_entry(rb_node, struct extent_map, rb_node);
- goto found;
-
- em = NULL;
- goto out;
+ if (!rb_node)
+ return NULL;
+ em = rb_entry(rb_node, struct extent_map, rb_node);
found:
atomic_inc(&em->refs);
-out:
return em;
}
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 11/16] Btrfs: clean up code for extent_map lookup
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (9 preceding siblings ...)
2011-07-14 3:18 ` [PATCH 10/16] Btrfs: clean up search_extent_mapping() Li Zefan
@ 2011-07-14 3:18 ` Li Zefan
2011-07-22 13:20 ` David Sterba
2011-07-14 3:18 ` [PATCH 12/16] Btrfs: clean up code for merging extent maps Li Zefan
` (5 subsequent siblings)
16 siblings, 1 reply; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:18 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
lookup_extent_map() and search_extent_map() can share most of code.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/extent_map.c | 85 +++++++++++++++++--------------------------------
1 files changed, 29 insertions(+), 56 deletions(-)
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 911a9db..df7a803 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -299,19 +299,8 @@ static u64 range_end(u64 start, u64 len)
return start + len;
}
-/**
- * lookup_extent_mapping - lookup extent_map
- * @tree: tree to lookup in
- * @start: byte offset to start the search
- * @len: length of the lookup range
- *
- * Find and return the first extent_map struct in @tree that intersects the
- * [start, len] range. There may be additional objects in the tree that
- * intersect, so check the object returned carefully to make sure that no
- * additional lookups are needed.
- */
-struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
- u64 start, u64 len)
+struct extent_map *__lookup_extent_mapping(struct extent_map_tree *tree,
+ u64 start, u64 len, int strict)
{
struct extent_map *em;
struct rb_node *rb_node;
@@ -320,38 +309,42 @@ struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
u64 end = range_end(start, len);
rb_node = __tree_search(&tree->map, start, &prev, &next);
- if (!rb_node && prev) {
- em = rb_entry(prev, struct extent_map, rb_node);
- if (end > em->start && start < extent_map_end(em))
- goto found;
- }
- if (!rb_node && next) {
- em = rb_entry(next, struct extent_map, rb_node);
- if (end > em->start && start < extent_map_end(em))
- goto found;
- }
if (!rb_node) {
- em = NULL;
- goto out;
- }
- if (IS_ERR(rb_node)) {
- em = ERR_CAST(rb_node);
- goto out;
+ if (prev)
+ rb_node = prev;
+ else if (next)
+ rb_node = next;
+ else
+ return NULL;
}
+
em = rb_entry(rb_node, struct extent_map, rb_node);
- if (end > em->start && start < extent_map_end(em))
- goto found;
- em = NULL;
- goto out;
+ if (strict && !(end > em->start && start < extent_map_end(em)))
+ return NULL;
-found:
atomic_inc(&em->refs);
-out:
return em;
}
/**
+ * lookup_extent_mapping - lookup extent_map
+ * @tree: tree to lookup in
+ * @start: byte offset to start the search
+ * @len: length of the lookup range
+ *
+ * Find and return the first extent_map struct in @tree that intersects the
+ * [start, len] range. There may be additional objects in the tree that
+ * intersect, so check the object returned carefully to make sure that no
+ * additional lookups are needed.
+ */
+struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
+ u64 start, u64 len)
+{
+ return __lookup_extent_mapping(tree, start, len, 1);
+}
+
+/**
* search_extent_mapping - find a nearby extent map
* @tree: tree to lookup in
* @start: byte offset to start the search
@@ -365,27 +358,7 @@ out:
struct extent_map *search_extent_mapping(struct extent_map_tree *tree,
u64 start, u64 len)
{
- struct extent_map *em;
- struct rb_node *rb_node;
- struct rb_node *prev = NULL;
- struct rb_node *next = NULL;
-
- rb_node = __tree_search(&tree->map, start, &prev, &next);
- if (!rb_node && prev) {
- em = rb_entry(prev, struct extent_map, rb_node);
- goto found;
- }
- if (!rb_node && next) {
- em = rb_entry(next, struct extent_map, rb_node);
- goto found;
- }
- if (!rb_node)
- return NULL;
-
- em = rb_entry(rb_node, struct extent_map, rb_node);
-found:
- atomic_inc(&em->refs);
- return em;
+ return __lookup_extent_mapping(tree, start, len, 0);
}
/**
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 11/16] Btrfs: clean up code for extent_map lookup
2011-07-14 3:18 ` [PATCH 11/16] Btrfs: clean up code for extent_map lookup Li Zefan
@ 2011-07-22 13:20 ` David Sterba
0 siblings, 0 replies; 19+ messages in thread
From: David Sterba @ 2011-07-22 13:20 UTC (permalink / raw)
To: Li Zefan; +Cc: Chris Mason, linux-btrfs@vger.kernel.org
On Thu, Jul 14, 2011 at 11:18:15AM +0800, Li Zefan wrote:
> lookup_extent_map() and search_extent_map() can share most of code.
>
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
> ---
> fs/btrfs/extent_map.c | 85 +++++++++++++++++--------------------------------
> 1 files changed, 29 insertions(+), 56 deletions(-)
>
> diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
> index 911a9db..df7a803 100644
> --- a/fs/btrfs/extent_map.c
> +++ b/fs/btrfs/extent_map.c
> @@ -299,19 +299,8 @@ static u64 range_end(u64 start, u64 len)
> return start + len;
> }
>
> -/**
> - * lookup_extent_mapping - lookup extent_map
> - * @tree: tree to lookup in
> - * @start: byte offset to start the search
> - * @len: length of the lookup range
> - *
> - * Find and return the first extent_map struct in @tree that intersects the
> - * [start, len] range. There may be additional objects in the tree that
> - * intersect, so check the object returned carefully to make sure that no
> - * additional lookups are needed.
> - */
> -struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
> - u64 start, u64 len)
> +struct extent_map *__lookup_extent_mapping(struct extent_map_tree *tree,
> + u64 start, u64 len, int strict)
just minor thing: can be defined static
> {
> struct extent_map *em;
> struct rb_node *rb_node;
> @@ -320,38 +309,42 @@ struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
> u64 end = range_end(start, len);
>
> rb_node = __tree_search(&tree->map, start, &prev, &next);
> - if (!rb_node && prev) {
> - em = rb_entry(prev, struct extent_map, rb_node);
> - if (end > em->start && start < extent_map_end(em))
> - goto found;
> - }
> - if (!rb_node && next) {
> - em = rb_entry(next, struct extent_map, rb_node);
> - if (end > em->start && start < extent_map_end(em))
> - goto found;
> - }
> if (!rb_node) {
> - em = NULL;
> - goto out;
> - }
> - if (IS_ERR(rb_node)) {
> - em = ERR_CAST(rb_node);
> - goto out;
> + if (prev)
> + rb_node = prev;
> + else if (next)
> + rb_node = next;
> + else
> + return NULL;
> }
> +
> em = rb_entry(rb_node, struct extent_map, rb_node);
> - if (end > em->start && start < extent_map_end(em))
> - goto found;
>
> - em = NULL;
> - goto out;
> + if (strict && !(end > em->start && start < extent_map_end(em)))
> + return NULL;
>
> -found:
> atomic_inc(&em->refs);
> -out:
> return em;
> }
>
> /**
> + * lookup_extent_mapping - lookup extent_map
> + * @tree: tree to lookup in
> + * @start: byte offset to start the search
> + * @len: length of the lookup range
> + *
> + * Find and return the first extent_map struct in @tree that intersects the
> + * [start, len] range. There may be additional objects in the tree that
> + * intersect, so check the object returned carefully to make sure that no
> + * additional lookups are needed.
> + */
> +struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
> + u64 start, u64 len)
> +{
> + return __lookup_extent_mapping(tree, start, len, 1);
> +}
> +
> +/**
> * search_extent_mapping - find a nearby extent map
> * @tree: tree to lookup in
> * @start: byte offset to start the search
> @@ -365,27 +358,7 @@ out:
> struct extent_map *search_extent_mapping(struct extent_map_tree *tree,
> u64 start, u64 len)
> {
> - struct extent_map *em;
> - struct rb_node *rb_node;
> - struct rb_node *prev = NULL;
> - struct rb_node *next = NULL;
> -
> - rb_node = __tree_search(&tree->map, start, &prev, &next);
> - if (!rb_node && prev) {
> - em = rb_entry(prev, struct extent_map, rb_node);
> - goto found;
> - }
> - if (!rb_node && next) {
> - em = rb_entry(next, struct extent_map, rb_node);
> - goto found;
> - }
> - if (!rb_node)
> - return NULL;
> -
> - em = rb_entry(rb_node, struct extent_map, rb_node);
> -found:
> - atomic_inc(&em->refs);
> - return em;
> + return __lookup_extent_mapping(tree, start, len, 0);
> }
>
> /**
> --
> 1.7.3.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 12/16] Btrfs: clean up code for merging extent maps
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (10 preceding siblings ...)
2011-07-14 3:18 ` [PATCH 11/16] Btrfs: clean up code for extent_map lookup Li Zefan
@ 2011-07-14 3:18 ` Li Zefan
2011-07-14 3:18 ` [PATCH 13/16] Btrfs: remove unused members from struct extent_state Li Zefan
` (4 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:18 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
unpin_extent_cache() and add_extent_mapping() shares the same code
that merges extent maps.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/extent_map.c | 59 +++++++++++++++++-------------------------------
1 files changed, 21 insertions(+), 38 deletions(-)
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index df7a803..7c97b33 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -183,22 +183,10 @@ static int mergable_maps(struct extent_map *prev, struct extent_map *next)
return 0;
}
-int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len)
+static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)
{
- int ret = 0;
struct extent_map *merge = NULL;
struct rb_node *rb;
- struct extent_map *em;
-
- write_lock(&tree->lock);
- em = lookup_extent_mapping(tree, start, len);
-
- WARN_ON(!em || em->start != start);
-
- if (!em)
- goto out;
-
- clear_bit(EXTENT_FLAG_PINNED, &em->flags);
if (em->start != 0) {
rb = rb_prev(&em->rb_node);
@@ -225,6 +213,24 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len)
merge->in_tree = 0;
free_extent_map(merge);
}
+}
+
+int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len)
+{
+ int ret = 0;
+ struct extent_map *em;
+
+ write_lock(&tree->lock);
+ em = lookup_extent_mapping(tree, start, len);
+
+ WARN_ON(!em || em->start != start);
+
+ if (!em)
+ goto out;
+
+ clear_bit(EXTENT_FLAG_PINNED, &em->flags);
+
+ try_merge_map(tree, em);
free_extent_map(em);
out:
@@ -247,7 +253,6 @@ int add_extent_mapping(struct extent_map_tree *tree,
struct extent_map *em)
{
int ret = 0;
- struct extent_map *merge = NULL;
struct rb_node *rb;
struct extent_map *exist;
@@ -263,30 +268,8 @@ int add_extent_mapping(struct extent_map_tree *tree,
goto out;
}
atomic_inc(&em->refs);
- if (em->start != 0) {
- rb = rb_prev(&em->rb_node);
- if (rb)
- merge = rb_entry(rb, struct extent_map, rb_node);
- if (rb && mergable_maps(merge, em)) {
- em->start = merge->start;
- em->len += merge->len;
- em->block_len += merge->block_len;
- em->block_start = merge->block_start;
- merge->in_tree = 0;
- rb_erase(&merge->rb_node, &tree->map);
- free_extent_map(merge);
- }
- }
- rb = rb_next(&em->rb_node);
- if (rb)
- merge = rb_entry(rb, struct extent_map, rb_node);
- if (rb && mergable_maps(em, merge)) {
- em->len += merge->len;
- em->block_len += merge->len;
- rb_erase(&merge->rb_node, &tree->map);
- merge->in_tree = 0;
- free_extent_map(merge);
- }
+
+ try_merge_map(tree, em);
out:
return ret;
}
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 13/16] Btrfs: remove unused members from struct extent_state
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (11 preceding siblings ...)
2011-07-14 3:18 ` [PATCH 12/16] Btrfs: clean up code for merging extent maps Li Zefan
@ 2011-07-14 3:18 ` Li Zefan
2011-07-14 3:19 ` [PATCH 14/16] Btrfs: clean up for insert_state() Li Zefan
` (3 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:18 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, Xiao Guangrong
From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
These members are not used at all.
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/extent_io.h | 2 --
1 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/extent_io.h b/fs/btrfs/extent_io.h
index a11a92e..d04ca37 100644
--- a/fs/btrfs/extent_io.h
+++ b/fs/btrfs/extent_io.h
@@ -108,8 +108,6 @@ struct extent_state {
wait_queue_head_t wq;
atomic_t refs;
unsigned long state;
- u64 split_start;
- u64 split_end;
/* for use by the FS */
u64 private;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 14/16] Btrfs: clean up for insert_state()
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (12 preceding siblings ...)
2011-07-14 3:18 ` [PATCH 13/16] Btrfs: remove unused members from struct extent_state Li Zefan
@ 2011-07-14 3:19 ` Li Zefan
2011-07-14 3:19 ` [PATCH 15/16] Btrfs: clean up for wait_extent_bit() Li Zefan
` (2 subsequent siblings)
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:19 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Don't duplicate set_state_bits().
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/extent_io.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index b181a94..6c7394f 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -308,6 +308,9 @@ static void clear_state_cb(struct extent_io_tree *tree,
tree->ops->clear_bit_hook(tree->mapping->host, state, bits);
}
+static int set_state_bits(struct extent_io_tree *tree,
+ struct extent_state *state, int *bits);
+
/*
* insert an extent_state struct into the tree. 'bits' are set on the
* struct before it is inserted.
@@ -323,7 +326,6 @@ static int insert_state(struct extent_io_tree *tree,
int *bits)
{
struct rb_node *node;
- int bits_to_set = *bits & ~EXTENT_CTLBITS;
int ret;
if (end < start) {
@@ -334,13 +336,11 @@ static int insert_state(struct extent_io_tree *tree,
}
state->start = start;
state->end = end;
- ret = set_state_cb(tree, state, bits);
+
+ ret = set_state_bits(tree, state, bits);
if (ret)
return ret;
- if (bits_to_set & EXTENT_DIRTY)
- tree->dirty_bytes += end - start + 1;
- state->state |= bits_to_set;
node = tree_insert(&tree->state, end, &state->rb_node);
if (node) {
struct extent_state *found;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 15/16] Btrfs: clean up for wait_extent_bit()
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (13 preceding siblings ...)
2011-07-14 3:19 ` [PATCH 14/16] Btrfs: clean up for insert_state() Li Zefan
@ 2011-07-14 3:19 ` Li Zefan
2011-07-14 3:19 ` [PATCH 16/16] Btrfs: clean up for find_first_extent_bit() Li Zefan
2011-07-14 3:21 ` [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:19 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, Xiao Guangrong
From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
We can just use cond_resched_lock().
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/extent_io.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 6c7394f..1959a63 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -658,11 +658,7 @@ again:
if (start > end)
break;
- if (need_resched()) {
- spin_unlock(&tree->lock);
- cond_resched();
- spin_lock(&tree->lock);
- }
+ cond_resched_lock(&tree->lock);
}
out:
spin_unlock(&tree->lock);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* [PATCH 16/16] Btrfs: clean up for find_first_extent_bit()
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (14 preceding siblings ...)
2011-07-14 3:19 ` [PATCH 15/16] Btrfs: clean up for wait_extent_bit() Li Zefan
@ 2011-07-14 3:19 ` Li Zefan
2011-07-14 3:21 ` [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:19 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org, Xiao Guangrong
From: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
find_first_extent_bit() and find_first_extent_bit_state() share
most of the code, and we can just make the former call the latter.
Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/extent_io.c | 64 ++++++++++++++++++-------------------------------
1 files changed, 24 insertions(+), 40 deletions(-)
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 1959a63..a31ffa5 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1055,46 +1055,6 @@ static int set_range_writeback(struct extent_io_tree *tree, u64 start, u64 end)
return 0;
}
-/*
- * find the first offset in the io tree with 'bits' set. zero is
- * returned if we find something, and *start_ret and *end_ret are
- * set to reflect the state struct that was found.
- *
- * If nothing was found, 1 is returned, < 0 on error
- */
-int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
- u64 *start_ret, u64 *end_ret, int bits)
-{
- struct rb_node *node;
- struct extent_state *state;
- int ret = 1;
-
- spin_lock(&tree->lock);
- /*
- * this search will find all the extents that end after
- * our range starts.
- */
- node = tree_search(tree, start);
- if (!node)
- goto out;
-
- while (1) {
- state = rb_entry(node, struct extent_state, rb_node);
- if (state->end >= start && (state->state & bits)) {
- *start_ret = state->start;
- *end_ret = state->end;
- ret = 0;
- break;
- }
- node = rb_next(node);
- if (!node)
- break;
- }
-out:
- spin_unlock(&tree->lock);
- return ret;
-}
-
/* find the first state struct with 'bits' set after 'start', and
* return it. tree->lock must be held. NULL will returned if
* nothing was found after 'start'
@@ -1127,6 +1087,30 @@ out:
}
/*
+ * find the first offset in the io tree with 'bits' set. zero is
+ * returned if we find something, and *start_ret and *end_ret are
+ * set to reflect the state struct that was found.
+ *
+ * If nothing was found, 1 is returned, < 0 on error
+ */
+int find_first_extent_bit(struct extent_io_tree *tree, u64 start,
+ u64 *start_ret, u64 *end_ret, int bits)
+{
+ struct extent_state *state;
+ int ret = 1;
+
+ spin_lock(&tree->lock);
+ state = find_first_extent_bit_state(tree, start, bits);
+ if (state) {
+ *start_ret = state->start;
+ *end_ret = state->end;
+ ret = 0;
+ }
+ spin_unlock(&tree->lock);
+ return ret;
+}
+
+/*
* find a contiguous range of bytes in the file marked as delalloc, not
* more than 'max_bytes'. start and end are used to return the range,
*
--
1.7.3.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 00/16] Btrfs: fixes and cleanups for 3.1
2011-07-14 3:15 [PATCH 00/16] Btrfs: fixes and cleanups for 3.1 Li Zefan
` (15 preceding siblings ...)
2011-07-14 3:19 ` [PATCH 16/16] Btrfs: clean up for find_first_extent_bit() Li Zefan
@ 2011-07-14 3:21 ` Li Zefan
16 siblings, 0 replies; 19+ messages in thread
From: Li Zefan @ 2011-07-14 3:21 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
Li Zefan wrote:
> The first 4 patches are bug-fixes, and the remaining are small
> cleanups that have sit in my git tree for some time.
>
> The first 3 patches have been sent to the list before.
>
To pull the patchset:
git://repo.or.cz/linux-btrfs-devel.git for-chris
It's based on the for-linus branch of btrfs-unstable tree.
^ permalink raw reply [flat|nested] 19+ messages in thread