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 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2

* 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2:
ocfs2: Set i_nlink properly during reflink.
ocfs2: Add reflinked file's inode to inode hash eariler.
ocfs2: refcounttree.c cleanup.
ocfs2: Find proper end cpos for a leaf refcount block.

+131 -39
+5 -5
fs/ocfs2/alloc.c
··· 1765 1765 * 1766 1766 * The array index of the subtree root is passed back. 1767 1767 */ 1768 - static int ocfs2_find_subtree_root(struct ocfs2_extent_tree *et, 1769 - struct ocfs2_path *left, 1770 - struct ocfs2_path *right) 1768 + int ocfs2_find_subtree_root(struct ocfs2_extent_tree *et, 1769 + struct ocfs2_path *left, 1770 + struct ocfs2_path *right) 1771 1771 { 1772 1772 int i = 0; 1773 1773 ··· 2872 2872 * This looks similar, but is subtly different to 2873 2873 * ocfs2_find_cpos_for_left_leaf(). 2874 2874 */ 2875 - static int ocfs2_find_cpos_for_right_leaf(struct super_block *sb, 2876 - struct ocfs2_path *path, u32 *cpos) 2875 + int ocfs2_find_cpos_for_right_leaf(struct super_block *sb, 2876 + struct ocfs2_path *path, u32 *cpos) 2877 2877 { 2878 2878 int i, j, ret = 0; 2879 2879 u64 blkno;
+5
fs/ocfs2/alloc.h
··· 317 317 int ocfs2_journal_access_path(struct ocfs2_caching_info *ci, 318 318 handle_t *handle, 319 319 struct ocfs2_path *path); 320 + int ocfs2_find_cpos_for_right_leaf(struct super_block *sb, 321 + struct ocfs2_path *path, u32 *cpos); 322 + int ocfs2_find_subtree_root(struct ocfs2_extent_tree *et, 323 + struct ocfs2_path *left, 324 + struct ocfs2_path *right); 320 325 #endif /* OCFS2_ALLOC_H */
+4 -1
fs/ocfs2/namei.c
··· 2108 2108 } 2109 2109 did_quota_inode = 1; 2110 2110 2111 + inode->i_nlink = 0; 2111 2112 /* do the real work now. */ 2112 2113 status = ocfs2_mknod_locked(osb, dir, inode, 2113 2114 0, &new_di_bh, parent_di_bh, handle, ··· 2137 2136 if (status < 0) 2138 2137 mlog_errno(status); 2139 2138 2139 + insert_inode_hash(inode); 2140 2140 leave: 2141 2141 if (status < 0 && did_quota_inode) 2142 2142 vfs_dq_free_inode(inode); ··· 2269 2267 di = (struct ocfs2_dinode *)di_bh->b_data; 2270 2268 le32_add_cpu(&di->i_flags, -OCFS2_ORPHANED_FL); 2271 2269 di->i_orphaned_slot = 0; 2270 + inode->i_nlink = 1; 2271 + ocfs2_set_links_count(di, inode->i_nlink); 2272 2272 ocfs2_journal_dirty(handle, di_bh); 2273 2273 2274 2274 status = ocfs2_add_entry(handle, dentry, inode, ··· 2288 2284 goto out_commit; 2289 2285 } 2290 2286 2291 - insert_inode_hash(inode); 2292 2287 dentry->d_op = &ocfs2_dentry_ops; 2293 2288 d_instantiate(dentry, inode); 2294 2289 status = 0;
+117 -33
fs/ocfs2/refcounttree.c
··· 276 276 spin_unlock(&osb->osb_lock); 277 277 } 278 278 279 - void ocfs2_kref_remove_refcount_tree(struct kref *kref) 279 + static void ocfs2_kref_remove_refcount_tree(struct kref *kref) 280 280 { 281 281 struct ocfs2_refcount_tree *tree = 282 282 container_of(kref, struct ocfs2_refcount_tree, rf_getcnt); ··· 522 522 out: 523 523 brelse(ref_root_bh); 524 524 return ret; 525 - } 526 - 527 - int ocfs2_lock_refcount_tree_by_inode(struct inode *inode, int rw, 528 - struct ocfs2_refcount_tree **ret_tree, 529 - struct buffer_head **ref_bh) 530 - { 531 - int ret; 532 - u64 ref_blkno; 533 - 534 - ret = ocfs2_get_refcount_block(inode, &ref_blkno); 535 - if (ret) { 536 - mlog_errno(ret); 537 - return ret; 538 - } 539 - 540 - return ocfs2_lock_refcount_tree(OCFS2_SB(inode->i_sb), ref_blkno, 541 - rw, ret_tree, ref_bh); 542 525 } 543 526 544 527 void ocfs2_unlock_refcount_tree(struct ocfs2_super *osb, ··· 952 969 } 953 970 954 971 /* 972 + * Find the end range for a leaf refcount block indicated by 973 + * el->l_recs[index].e_blkno. 974 + */ 975 + static int ocfs2_get_refcount_cpos_end(struct ocfs2_caching_info *ci, 976 + struct buffer_head *ref_root_bh, 977 + struct ocfs2_extent_block *eb, 978 + struct ocfs2_extent_list *el, 979 + int index, u32 *cpos_end) 980 + { 981 + int ret, i, subtree_root; 982 + u32 cpos; 983 + u64 blkno; 984 + struct super_block *sb = ocfs2_metadata_cache_get_super(ci); 985 + struct ocfs2_path *left_path = NULL, *right_path = NULL; 986 + struct ocfs2_extent_tree et; 987 + struct ocfs2_extent_list *tmp_el; 988 + 989 + if (index < le16_to_cpu(el->l_next_free_rec) - 1) { 990 + /* 991 + * We have a extent rec after index, so just use the e_cpos 992 + * of the next extent rec. 993 + */ 994 + *cpos_end = le32_to_cpu(el->l_recs[index+1].e_cpos); 995 + return 0; 996 + } 997 + 998 + if (!eb || (eb && !eb->h_next_leaf_blk)) { 999 + /* 1000 + * We are the last extent rec, so any high cpos should 1001 + * be stored in this leaf refcount block. 1002 + */ 1003 + *cpos_end = UINT_MAX; 1004 + return 0; 1005 + } 1006 + 1007 + /* 1008 + * If the extent block isn't the last one, we have to find 1009 + * the subtree root between this extent block and the next 1010 + * leaf extent block and get the corresponding e_cpos from 1011 + * the subroot. Otherwise we may corrupt the b-tree. 1012 + */ 1013 + ocfs2_init_refcount_extent_tree(&et, ci, ref_root_bh); 1014 + 1015 + left_path = ocfs2_new_path_from_et(&et); 1016 + if (!left_path) { 1017 + ret = -ENOMEM; 1018 + mlog_errno(ret); 1019 + goto out; 1020 + } 1021 + 1022 + cpos = le32_to_cpu(eb->h_list.l_recs[index].e_cpos); 1023 + ret = ocfs2_find_path(ci, left_path, cpos); 1024 + if (ret) { 1025 + mlog_errno(ret); 1026 + goto out; 1027 + } 1028 + 1029 + right_path = ocfs2_new_path_from_path(left_path); 1030 + if (!right_path) { 1031 + ret = -ENOMEM; 1032 + mlog_errno(ret); 1033 + goto out; 1034 + } 1035 + 1036 + ret = ocfs2_find_cpos_for_right_leaf(sb, left_path, &cpos); 1037 + if (ret) { 1038 + mlog_errno(ret); 1039 + goto out; 1040 + } 1041 + 1042 + ret = ocfs2_find_path(ci, right_path, cpos); 1043 + if (ret) { 1044 + mlog_errno(ret); 1045 + goto out; 1046 + } 1047 + 1048 + subtree_root = ocfs2_find_subtree_root(&et, left_path, 1049 + right_path); 1050 + 1051 + tmp_el = left_path->p_node[subtree_root].el; 1052 + blkno = left_path->p_node[subtree_root+1].bh->b_blocknr; 1053 + for (i = 0; i < le32_to_cpu(tmp_el->l_next_free_rec); i++) { 1054 + if (le64_to_cpu(tmp_el->l_recs[i].e_blkno) == blkno) { 1055 + *cpos_end = le32_to_cpu(tmp_el->l_recs[i+1].e_cpos); 1056 + break; 1057 + } 1058 + } 1059 + 1060 + BUG_ON(i == le32_to_cpu(tmp_el->l_next_free_rec)); 1061 + 1062 + out: 1063 + ocfs2_free_path(left_path); 1064 + ocfs2_free_path(right_path); 1065 + return ret; 1066 + } 1067 + 1068 + /* 955 1069 * Given a cpos and len, try to find the refcount record which contains cpos. 956 1070 * 1. If cpos can be found in one refcount record, return the record. 957 1071 * 2. If cpos can't be found, return a fake record which start from cpos ··· 1063 983 struct buffer_head **ret_bh) 1064 984 { 1065 985 int ret = 0, i, found; 1066 - u32 low_cpos; 986 + u32 low_cpos, uninitialized_var(cpos_end); 1067 987 struct ocfs2_extent_list *el; 1068 - struct ocfs2_extent_rec *tmp, *rec = NULL; 1069 - struct ocfs2_extent_block *eb; 988 + struct ocfs2_extent_rec *rec = NULL; 989 + struct ocfs2_extent_block *eb = NULL; 1070 990 struct buffer_head *eb_bh = NULL, *ref_leaf_bh = NULL; 1071 991 struct super_block *sb = ocfs2_metadata_cache_get_super(ci); 1072 992 struct ocfs2_refcount_block *rb = ··· 1114 1034 } 1115 1035 } 1116 1036 1117 - /* adjust len when we have ocfs2_extent_rec after it. */ 1118 - if (found && i < le16_to_cpu(el->l_next_free_rec) - 1) { 1119 - tmp = &el->l_recs[i+1]; 1037 + if (found) { 1038 + ret = ocfs2_get_refcount_cpos_end(ci, ref_root_bh, 1039 + eb, el, i, &cpos_end); 1040 + if (ret) { 1041 + mlog_errno(ret); 1042 + goto out; 1043 + } 1120 1044 1121 - if (le32_to_cpu(tmp->e_cpos) < cpos + len) 1122 - len = le32_to_cpu(tmp->e_cpos) - cpos; 1045 + if (cpos_end < low_cpos + len) 1046 + len = cpos_end - low_cpos; 1123 1047 } 1124 1048 1125 1049 ret = ocfs2_read_refcount_block(ci, le64_to_cpu(rec->e_blkno), ··· 1502 1418 1503 1419 /* change old and new rl_used accordingly. */ 1504 1420 le16_add_cpu(&rl->rl_used, -num_moved); 1505 - new_rl->rl_used = cpu_to_le32(num_moved); 1421 + new_rl->rl_used = cpu_to_le16(num_moved); 1506 1422 1507 1423 sort(&rl->rl_recs, le16_to_cpu(rl->rl_used), 1508 1424 sizeof(struct ocfs2_refcount_rec), ··· 1881 1797 recs_need++; 1882 1798 1883 1799 /* If the leaf block don't have enough record, expand it. */ 1884 - if (le16_to_cpu(rf_list->rl_used) + recs_need > rf_list->rl_count) { 1800 + if (le16_to_cpu(rf_list->rl_used) + recs_need > 1801 + le16_to_cpu(rf_list->rl_count)) { 1885 1802 struct ocfs2_refcount_rec tmp_rec; 1886 1803 u64 cpos = le64_to_cpu(orig_rec->r_cpos); 1887 1804 len = le32_to_cpu(orig_rec->r_clusters); ··· 1944 1859 memcpy(tail_rec, orig_rec, sizeof(struct ocfs2_refcount_rec)); 1945 1860 le64_add_cpu(&tail_rec->r_cpos, 1946 1861 le32_to_cpu(tail_rec->r_clusters) - len); 1947 - tail_rec->r_clusters = le32_to_cpu(len); 1862 + tail_rec->r_clusters = cpu_to_le32(len); 1948 1863 } 1949 1864 1950 1865 /* ··· 3925 3840 } 3926 3841 3927 3842 ret = ocfs2_insert_extent(handle, et, cpos, 3928 - cpu_to_le64(ocfs2_clusters_to_blocks(inode->i_sb, 3929 - p_cluster)), 3843 + ocfs2_clusters_to_blocks(inode->i_sb, p_cluster), 3930 3844 num_clusters, ext_flags, meta_ac); 3931 3845 if (ret) { 3932 3846 mlog_errno(ret); ··· 4337 4253 * @new_dentry: target dentry 4338 4254 * @preserve: if true, preserve all file attributes 4339 4255 */ 4340 - int ocfs2_vfs_reflink(struct dentry *old_dentry, struct inode *dir, 4341 - struct dentry *new_dentry, bool preserve) 4256 + static int ocfs2_vfs_reflink(struct dentry *old_dentry, struct inode *dir, 4257 + struct dentry *new_dentry, bool preserve) 4342 4258 { 4343 4259 struct inode *inode = old_dentry->d_inode; 4344 4260 int error;