* [PATCH 1/4] Btrfs: Check if btrfs_next_leaf() returns error in btrfs_listxattr()
2011-04-13 7:42 [PATCH 0/4] Btrfs: A few small bug fixes Li Zefan
@ 2011-04-13 7:42 ` Li Zefan
2011-04-13 7:42 ` [PATCH 2/4] Btrfs: Check if btrfs_next_leaf() returns error in btrfs_real_readdir() Li Zefan
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Li Zefan @ 2011-04-13 7:42 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
btrfs_next_leaf() can return -errno, and we should propagate
it to userspace.
This also simplifies how we walk the btree path.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/xattr.c | 33 ++++++++++++---------------------
1 files changed, 12 insertions(+), 21 deletions(-)
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index e5d22f2..07b9bc3 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -180,11 +180,10 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
struct btrfs_path *path;
struct extent_buffer *leaf;
struct btrfs_dir_item *di;
- int ret = 0, slot, advance;
+ int ret = 0, slot;
size_t total_size = 0, size_left = size;
unsigned long name_ptr;
size_t name_len;
- u32 nritems;
/*
* ok we want all objects associated with this id.
@@ -204,34 +203,24 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
goto err;
- advance = 0;
+
while (1) {
leaf = path->nodes[0];
- nritems = btrfs_header_nritems(leaf);
slot = path->slots[0];
/* this is where we start walking through the path */
- if (advance || slot >= nritems) {
+ if (slot >= btrfs_header_nritems(leaf)) {
/*
* if we've reached the last slot in this leaf we need
* to go to the next leaf and reset everything
*/
- if (slot >= nritems-1) {
- ret = btrfs_next_leaf(root, path);
- if (ret)
- break;
- leaf = path->nodes[0];
- nritems = btrfs_header_nritems(leaf);
- slot = path->slots[0];
- } else {
- /*
- * just walking through the slots on this leaf
- */
- slot++;
- path->slots[0]++;
- }
+ ret = btrfs_next_leaf(root, path);
+ if (ret < 0)
+ goto err;
+ else if (ret > 0)
+ break;
+ continue;
}
- advance = 1;
btrfs_item_key_to_cpu(leaf, &found_key, slot);
@@ -250,7 +239,7 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
/* we are just looking for how big our buffer needs to be */
if (!size)
- continue;
+ goto next;
if (!buffer || (name_len + 1) > size_left) {
ret = -ERANGE;
@@ -263,6 +252,8 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size)
size_left -= name_len + 1;
buffer += name_len + 1;
+next:
+ path->slots[0]++;
}
ret = total_size;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] Btrfs: Check if btrfs_next_leaf() returns error in btrfs_real_readdir()
2011-04-13 7:42 [PATCH 0/4] Btrfs: A few small bug fixes Li Zefan
2011-04-13 7:42 ` [PATCH 1/4] Btrfs: Check if btrfs_next_leaf() returns error in btrfs_listxattr() Li Zefan
@ 2011-04-13 7:42 ` Li Zefan
2011-04-13 7:43 ` [PATCH 3/4] Btrfs: Fix incorrect inode nlink in btrfs_link() Li Zefan
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Li Zefan @ 2011-04-13 7:42 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
btrfs_next_leaf() can return -errno, and we should propagate
it to userspace.
This also simplifies how we walk the btree path.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/inode.c | 28 ++++++++++------------------
1 files changed, 10 insertions(+), 18 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 55a6a0b..b9f7f52 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4221,10 +4221,8 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
struct btrfs_key found_key;
struct btrfs_path *path;
int ret;
- u32 nritems;
struct extent_buffer *leaf;
int slot;
- int advance;
unsigned char d_type;
int over = 0;
u32 di_cur;
@@ -4267,27 +4265,19 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
goto err;
- advance = 0;
while (1) {
leaf = path->nodes[0];
- nritems = btrfs_header_nritems(leaf);
slot = path->slots[0];
- if (advance || slot >= nritems) {
- if (slot >= nritems - 1) {
- ret = btrfs_next_leaf(root, path);
- if (ret)
- break;
- leaf = path->nodes[0];
- nritems = btrfs_header_nritems(leaf);
- slot = path->slots[0];
- } else {
- slot++;
- path->slots[0]++;
- }
+ if (slot >= btrfs_header_nritems(leaf)) {
+ ret = btrfs_next_leaf(root, path);
+ if (ret < 0)
+ goto err;
+ else if (ret > 0)
+ break;
+ continue;
}
- advance = 1;
item = btrfs_item_nr(leaf, slot);
btrfs_item_key_to_cpu(leaf, &found_key, slot);
@@ -4296,7 +4286,7 @@ static int btrfs_real_readdir(struct file *filp, void *dirent,
if (btrfs_key_type(&found_key) != key_type)
break;
if (found_key.offset < filp->f_pos)
- continue;
+ goto next;
filp->f_pos = found_key.offset;
@@ -4349,6 +4339,8 @@ skip:
di_cur += di_len;
di = (struct btrfs_dir_item *)((char *)di + di_len);
}
+next:
+ path->slots[0]++;
}
/* Reached end of directory/root. Bump pos past the last item. */
--
1.7.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] Btrfs: Fix incorrect inode nlink in btrfs_link()
2011-04-13 7:42 [PATCH 0/4] Btrfs: A few small bug fixes Li Zefan
2011-04-13 7:42 ` [PATCH 1/4] Btrfs: Check if btrfs_next_leaf() returns error in btrfs_listxattr() Li Zefan
2011-04-13 7:42 ` [PATCH 2/4] Btrfs: Check if btrfs_next_leaf() returns error in btrfs_real_readdir() Li Zefan
@ 2011-04-13 7:43 ` Li Zefan
2011-04-13 7:43 ` [PATCH 4/4] Btrfs: Check validity before setting an acl Li Zefan
2011-04-13 11:30 ` [PATCH 0/4] Btrfs: A few small bug fixes Chris Mason
4 siblings, 0 replies; 6+ messages in thread
From: Li Zefan @ 2011-04-13 7:43 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
From: Miao Xie <miaox@cn.fujitsu.com>
Link count of the inode is not decreased if btrfs_set_inode_index()
fails.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Singed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/inode.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index b9f7f52..a4157cf 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -4846,9 +4846,6 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
if (inode->i_nlink == ~0U)
return -EMLINK;
- btrfs_inc_nlink(inode);
- inode->i_ctime = CURRENT_TIME;
-
err = btrfs_set_inode_index(dir, &index);
if (err)
goto fail;
@@ -4864,6 +4861,9 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
goto fail;
}
+ btrfs_inc_nlink(inode);
+ inode->i_ctime = CURRENT_TIME;
+
btrfs_set_trans_block_group(trans, dir);
ihold(inode);
--
1.7.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] Btrfs: Check validity before setting an acl
2011-04-13 7:42 [PATCH 0/4] Btrfs: A few small bug fixes Li Zefan
` (2 preceding siblings ...)
2011-04-13 7:43 ` [PATCH 3/4] Btrfs: Fix incorrect inode nlink in btrfs_link() Li Zefan
@ 2011-04-13 7:43 ` Li Zefan
2011-04-13 11:30 ` [PATCH 0/4] Btrfs: A few small bug fixes Chris Mason
4 siblings, 0 replies; 6+ messages in thread
From: Li Zefan @ 2011-04-13 7:43 UTC (permalink / raw)
To: Chris Mason; +Cc: linux-btrfs@vger.kernel.org
From: Miao Xie <miaox@cn.fujitsu.com>
Call posix_acl_valid() to check if an acl is valid or not.
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
fs/btrfs/acl.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 9c94934..a892bc2 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -178,16 +178,17 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
if (value) {
acl = posix_acl_from_xattr(value, size);
- if (acl == NULL) {
- value = NULL;
- size = 0;
+ if (acl) {
+ ret = posix_acl_valid(acl);
+ if (ret)
+ goto out;
} else if (IS_ERR(acl)) {
return PTR_ERR(acl);
}
}
ret = btrfs_set_acl(NULL, dentry->d_inode, acl, type);
-
+out:
posix_acl_release(acl);
return ret;
--
1.7.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] Btrfs: A few small bug fixes
2011-04-13 7:42 [PATCH 0/4] Btrfs: A few small bug fixes Li Zefan
` (3 preceding siblings ...)
2011-04-13 7:43 ` [PATCH 4/4] Btrfs: Check validity before setting an acl Li Zefan
@ 2011-04-13 11:30 ` Chris Mason
4 siblings, 0 replies; 6+ messages in thread
From: Chris Mason @ 2011-04-13 11:30 UTC (permalink / raw)
To: Li Zefan; +Cc: linux-btrfs@vger.kernel.org
Excerpts from Li Zefan's message of 2011-04-13 03:42:01 -0400:
> Hi Chris,
>
> Those bugs are small, and the fixes are simple and straitforward.
>
> You can pull from:
>
> git://repo.or.cz/linux-btrfs-devel.git for-chris
Thanks these are now in my master branch.
-chris
^ permalink raw reply [flat|nested] 6+ messages in thread