Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus-4.7-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs

Pull btrfs fixes part 2 from Chris Mason:
"This has one patch from Omar to bring iterate_shared back to btrfs.

We have a tree of work we queue up for directory items and it doesn't
lend itself well to shared access. While we're cleaning it up, Omar
has changed things to use an exclusive lock when there are delayed
items"

* 'for-linus-4.7-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: fix ->iterate_shared() by upgrading i_rwsem for delayed nodes

+34 -13
+22 -5
fs/btrfs/delayed-inode.c
··· 1606 1606 return 0; 1607 1607 } 1608 1608 1609 - void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list, 1610 - struct list_head *del_list) 1609 + bool btrfs_readdir_get_delayed_items(struct inode *inode, 1610 + struct list_head *ins_list, 1611 + struct list_head *del_list) 1611 1612 { 1612 1613 struct btrfs_delayed_node *delayed_node; 1613 1614 struct btrfs_delayed_item *item; 1614 1615 1615 1616 delayed_node = btrfs_get_delayed_node(inode); 1616 1617 if (!delayed_node) 1617 - return; 1618 + return false; 1619 + 1620 + /* 1621 + * We can only do one readdir with delayed items at a time because of 1622 + * item->readdir_list. 1623 + */ 1624 + inode_unlock_shared(inode); 1625 + inode_lock(inode); 1618 1626 1619 1627 mutex_lock(&delayed_node->mutex); 1620 1628 item = __btrfs_first_delayed_insertion_item(delayed_node); ··· 1649 1641 * requeue or dequeue this delayed node. 1650 1642 */ 1651 1643 atomic_dec(&delayed_node->refs); 1644 + 1645 + return true; 1652 1646 } 1653 1647 1654 - void btrfs_put_delayed_items(struct list_head *ins_list, 1655 - struct list_head *del_list) 1648 + void btrfs_readdir_put_delayed_items(struct inode *inode, 1649 + struct list_head *ins_list, 1650 + struct list_head *del_list) 1656 1651 { 1657 1652 struct btrfs_delayed_item *curr, *next; 1658 1653 ··· 1670 1659 if (atomic_dec_and_test(&curr->refs)) 1671 1660 kfree(curr); 1672 1661 } 1662 + 1663 + /* 1664 + * The VFS is going to do up_read(), so we need to downgrade back to a 1665 + * read lock. 1666 + */ 1667 + downgrade_write(&inode->i_rwsem); 1673 1668 } 1674 1669 1675 1670 int btrfs_should_delete_dir_index(struct list_head *del_list,
+6 -4
fs/btrfs/delayed-inode.h
··· 137 137 void btrfs_destroy_delayed_inodes(struct btrfs_root *root); 138 138 139 139 /* Used for readdir() */ 140 - void btrfs_get_delayed_items(struct inode *inode, struct list_head *ins_list, 141 - struct list_head *del_list); 142 - void btrfs_put_delayed_items(struct list_head *ins_list, 143 - struct list_head *del_list); 140 + bool btrfs_readdir_get_delayed_items(struct inode *inode, 141 + struct list_head *ins_list, 142 + struct list_head *del_list); 143 + void btrfs_readdir_put_delayed_items(struct inode *inode, 144 + struct list_head *ins_list, 145 + struct list_head *del_list); 144 146 int btrfs_should_delete_dir_index(struct list_head *del_list, 145 147 u64 index); 146 148 int btrfs_readdir_delayed_dir_index(struct dir_context *ctx,
+6 -4
fs/btrfs/inode.c
··· 5758 5758 int name_len; 5759 5759 int is_curr = 0; /* ctx->pos points to the current index? */ 5760 5760 bool emitted; 5761 + bool put = false; 5761 5762 5762 5763 /* FIXME, use a real flag for deciding about the key type */ 5763 5764 if (root->fs_info->tree_root == root) ··· 5776 5775 if (key_type == BTRFS_DIR_INDEX_KEY) { 5777 5776 INIT_LIST_HEAD(&ins_list); 5778 5777 INIT_LIST_HEAD(&del_list); 5779 - btrfs_get_delayed_items(inode, &ins_list, &del_list); 5778 + put = btrfs_readdir_get_delayed_items(inode, &ins_list, 5779 + &del_list); 5780 5780 } 5781 5781 5782 5782 key.type = key_type; ··· 5924 5922 nopos: 5925 5923 ret = 0; 5926 5924 err: 5927 - if (key_type == BTRFS_DIR_INDEX_KEY) 5928 - btrfs_put_delayed_items(&ins_list, &del_list); 5925 + if (put) 5926 + btrfs_readdir_put_delayed_items(inode, &ins_list, &del_list); 5929 5927 btrfs_free_path(path); 5930 5928 return ret; 5931 5929 } ··· 10537 10535 static const struct file_operations btrfs_dir_file_operations = { 10538 10536 .llseek = generic_file_llseek, 10539 10537 .read = generic_read_dir, 10540 - .iterate = btrfs_real_readdir, 10538 + .iterate_shared = btrfs_real_readdir, 10541 10539 .unlocked_ioctl = btrfs_ioctl, 10542 10540 #ifdef CONFIG_COMPAT 10543 10541 .compat_ioctl = btrfs_compat_ioctl,