summaryrefslogtreecommitdiff
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-23 15:56:19 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-23 15:56:19 -0400
commit7f5c15160e1436a53d01f9190db11c2a3a4d788a (patch)
treeae9894ab743aca4ff4c1f50ada5a5ed665a88c21 /fs/btrfs/super.c
parentdf2ce34c8801af8e00c7f82435fcb1e4b45a2759 (diff)
downloadlwn-7f5c15160e1436a53d01f9190db11c2a3a4d788a.tar.gz
lwn-7f5c15160e1436a53d01f9190db11c2a3a4d788a.zip
Add generation number to btrfs_header, readdir fixes, hash collision fixes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 8970e9a82156..a2db05594695 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -199,7 +199,7 @@ static int btrfs_inode_by_name(struct inode *dir, struct dentry *dentry,
btrfs_init_path(&path);
ret = btrfs_lookup_dir_item(NULL, root, &path, dir->i_ino, name,
namelen, 0);
- if (ret) {
+ if (ret || !btrfs_match_dir_item_name(root, &path, name, namelen)) {
*ino = 0;
goto out;
}
@@ -247,7 +247,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
int slot;
int advance;
unsigned char d_type = DT_UNKNOWN;
- int over;
+ int over = 0;
key.objectid = inode->i_ino;
key.flags = 0;
@@ -258,7 +258,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
if (ret < 0) {
goto err;
}
- advance = filp->f_pos > 0 && ret != 0;
+ advance = 0;
while(1) {
leaf = btrfs_buffer_leaf(path.nodes[0]);
nritems = btrfs_header_nritems(&leaf->header);
@@ -282,13 +282,17 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
break;
if (btrfs_disk_key_type(&item->key) != BTRFS_DIR_ITEM_KEY)
continue;
+ if (btrfs_disk_key_offset(&item->key) < filp->f_pos)
+ continue;
di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item);
over = filldir(dirent, (const char *)(di + 1),
btrfs_dir_name_len(di),
btrfs_disk_key_offset(&item->key),
btrfs_dir_objectid(di), d_type);
- if (over)
+ if (over) {
+ filp->f_pos = btrfs_disk_key_offset(&item->key);
break;
+ }
filp->f_pos = btrfs_disk_key_offset(&item->key) + 1;
}
ret = 0;
@@ -425,7 +429,6 @@ static int btrfs_add_link(struct btrfs_trans_handle *trans,
dentry->d_name.name, dentry->d_name.len,
dentry->d_parent->d_inode->i_ino,
inode->i_ino, 0);
- BUG_ON(ret);
return ret;
}
@@ -466,6 +469,7 @@ static void btrfs_write_super(struct super_block *sb)
{
sb->s_dirt = 0;
printk("btrfs write_super!\n");
+ filemap_flush(sb->s_bdev->bd_inode->i_mapping);
}
static int btrfs_sync_fs(struct super_block *sb, int wait)