diff options
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 14 |
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, | |||
199 | btrfs_init_path(&path); | 199 | btrfs_init_path(&path); |
200 | ret = btrfs_lookup_dir_item(NULL, root, &path, dir->i_ino, name, | 200 | ret = btrfs_lookup_dir_item(NULL, root, &path, dir->i_ino, name, |
201 | namelen, 0); | 201 | namelen, 0); |
202 | if (ret) { | 202 | if (ret || !btrfs_match_dir_item_name(root, &path, name, namelen)) { |
203 | *ino = 0; | 203 | *ino = 0; |
204 | goto out; | 204 | goto out; |
205 | } | 205 | } |
@@ -247,7 +247,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
247 | int slot; | 247 | int slot; |
248 | int advance; | 248 | int advance; |
249 | unsigned char d_type = DT_UNKNOWN; | 249 | unsigned char d_type = DT_UNKNOWN; |
250 | int over; | 250 | int over = 0; |
251 | 251 | ||
252 | key.objectid = inode->i_ino; | 252 | key.objectid = inode->i_ino; |
253 | key.flags = 0; | 253 | key.flags = 0; |
@@ -258,7 +258,7 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
258 | if (ret < 0) { | 258 | if (ret < 0) { |
259 | goto err; | 259 | goto err; |
260 | } | 260 | } |
261 | advance = filp->f_pos > 0 && ret != 0; | 261 | advance = 0; |
262 | while(1) { | 262 | while(1) { |
263 | leaf = btrfs_buffer_leaf(path.nodes[0]); | 263 | leaf = btrfs_buffer_leaf(path.nodes[0]); |
264 | nritems = btrfs_header_nritems(&leaf->header); | 264 | nritems = btrfs_header_nritems(&leaf->header); |
@@ -282,13 +282,17 @@ static int btrfs_readdir(struct file *filp, void *dirent, filldir_t filldir) | |||
282 | break; | 282 | break; |
283 | if (btrfs_disk_key_type(&item->key) != BTRFS_DIR_ITEM_KEY) | 283 | if (btrfs_disk_key_type(&item->key) != BTRFS_DIR_ITEM_KEY) |
284 | continue; | 284 | continue; |
285 | if (btrfs_disk_key_offset(&item->key) < filp->f_pos) | ||
286 | continue; | ||
285 | di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item); | 287 | di = btrfs_item_ptr(leaf, slot, struct btrfs_dir_item); |
286 | over = filldir(dirent, (const char *)(di + 1), | 288 | over = filldir(dirent, (const char *)(di + 1), |
287 | btrfs_dir_name_len(di), | 289 | btrfs_dir_name_len(di), |
288 | btrfs_disk_key_offset(&item->key), | 290 | btrfs_disk_key_offset(&item->key), |
289 | btrfs_dir_objectid(di), d_type); | 291 | btrfs_dir_objectid(di), d_type); |
290 | if (over) | 292 | if (over) { |
293 | filp->f_pos = btrfs_disk_key_offset(&item->key); | ||
291 | break; | 294 | break; |
295 | } | ||
292 | filp->f_pos = btrfs_disk_key_offset(&item->key) + 1; | 296 | filp->f_pos = btrfs_disk_key_offset(&item->key) + 1; |
293 | } | 297 | } |
294 | ret = 0; | 298 | ret = 0; |
@@ -425,7 +429,6 @@ static int btrfs_add_link(struct btrfs_trans_handle *trans, | |||
425 | dentry->d_name.name, dentry->d_name.len, | 429 | dentry->d_name.name, dentry->d_name.len, |
426 | dentry->d_parent->d_inode->i_ino, | 430 | dentry->d_parent->d_inode->i_ino, |
427 | inode->i_ino, 0); | 431 | inode->i_ino, 0); |
428 | BUG_ON(ret); | ||
429 | return ret; | 432 | return ret; |
430 | } | 433 | } |
431 | 434 | ||
@@ -466,6 +469,7 @@ static void btrfs_write_super(struct super_block *sb) | |||
466 | { | 469 | { |
467 | sb->s_dirt = 0; | 470 | sb->s_dirt = 0; |
468 | printk("btrfs write_super!\n"); | 471 | printk("btrfs write_super!\n"); |
472 | filemap_flush(sb->s_bdev->bd_inode->i_mapping); | ||
469 | } | 473 | } |
470 | 474 | ||
471 | static int btrfs_sync_fs(struct super_block *sb, int wait) | 475 | static int btrfs_sync_fs(struct super_block *sb, int wait) |