suballoc.c (d6b32bbb3eae3fb787f1c33bf9f767ca1ddeb208) | suballoc.c (13723d00e374c2a6d6ccb5af6de965e89c3e1b01) |
---|---|
1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * suballoc.c 5 * 6 * metadata alloc and free 7 * Inspired by ext3 block groups. 8 * --- 247 unchanged lines hidden (view full) --- 256 BUG_ON(!buffer_uptodate(bh)); 257 258 /* 259 * If the ecc fails, we return the error but otherwise 260 * leave the filesystem running. We know any error is 261 * local to this block. 262 */ 263 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &gd->bg_check); | 1/* -*- mode: c; c-basic-offset: 8; -*- 2 * vim: noexpandtab sw=8 ts=8 sts=0: 3 * 4 * suballoc.c 5 * 6 * metadata alloc and free 7 * Inspired by ext3 block groups. 8 * --- 247 unchanged lines hidden (view full) --- 256 BUG_ON(!buffer_uptodate(bh)); 257 258 /* 259 * If the ecc fails, we return the error but otherwise 260 * leave the filesystem running. We know any error is 261 * local to this block. 262 */ 263 rc = ocfs2_validate_meta_ecc(sb, bh->b_data, &gd->bg_check); |
264 if (!rc) | 264 if (rc) { 265 mlog(ML_ERROR, 266 "Checksum failed for group descriptor %llu\n", 267 (unsigned long long)bh->b_blocknr); 268 } else |
265 rc = ocfs2_validate_gd_self(sb, bh, 1); 266 if (!rc) 267 rc = ocfs2_validate_gd_parent(sb, di, bh, 1); 268 269 return rc; 270} 271 272static int ocfs2_validate_group_descriptor(struct super_block *sb, --- 65 unchanged lines hidden (view full) --- 338 ocfs2_error(alloc_inode->i_sb, "group block (%llu) != " 339 "b_blocknr (%llu)", 340 (unsigned long long)group_blkno, 341 (unsigned long long) bg_bh->b_blocknr); 342 status = -EIO; 343 goto bail; 344 } 345 | 269 rc = ocfs2_validate_gd_self(sb, bh, 1); 270 if (!rc) 271 rc = ocfs2_validate_gd_parent(sb, di, bh, 1); 272 273 return rc; 274} 275 276static int ocfs2_validate_group_descriptor(struct super_block *sb, --- 65 unchanged lines hidden (view full) --- 342 ocfs2_error(alloc_inode->i_sb, "group block (%llu) != " 343 "b_blocknr (%llu)", 344 (unsigned long long)group_blkno, 345 (unsigned long long) bg_bh->b_blocknr); 346 status = -EIO; 347 goto bail; 348 } 349 |
346 status = ocfs2_journal_access(handle, 347 alloc_inode, 348 bg_bh, 349 OCFS2_JOURNAL_ACCESS_CREATE); | 350 status = ocfs2_journal_access_gd(handle, 351 alloc_inode, 352 bg_bh, 353 OCFS2_JOURNAL_ACCESS_CREATE); |
350 if (status < 0) { 351 mlog_errno(status); 352 goto bail; 353 } 354 355 memset(bg, 0, sb->s_blocksize); 356 strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); 357 bg->bg_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation); --- 113 unchanged lines hidden (view full) --- 471 cl); 472 if (status < 0) { 473 mlog_errno(status); 474 goto bail; 475 } 476 477 bg = (struct ocfs2_group_desc *) bg_bh->b_data; 478 | 354 if (status < 0) { 355 mlog_errno(status); 356 goto bail; 357 } 358 359 memset(bg, 0, sb->s_blocksize); 360 strcpy(bg->bg_signature, OCFS2_GROUP_DESC_SIGNATURE); 361 bg->bg_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation); --- 113 unchanged lines hidden (view full) --- 475 cl); 476 if (status < 0) { 477 mlog_errno(status); 478 goto bail; 479 } 480 481 bg = (struct ocfs2_group_desc *) bg_bh->b_data; 482 |
479 status = ocfs2_journal_access(handle, alloc_inode, 480 bh, OCFS2_JOURNAL_ACCESS_WRITE); | 483 status = ocfs2_journal_access_di(handle, alloc_inode, 484 bh, OCFS2_JOURNAL_ACCESS_WRITE); |
481 if (status < 0) { 482 mlog_errno(status); 483 goto bail; 484 } 485 486 le32_add_cpu(&cl->cl_recs[alloc_rec].c_free, 487 le16_to_cpu(bg->bg_free_bits_count)); 488 le32_add_cpu(&cl->cl_recs[alloc_rec].c_total, le16_to_cpu(bg->bg_bits)); --- 492 unchanged lines hidden (view full) --- 981 BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); 982 983 mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off, 984 num_bits); 985 986 if (ocfs2_is_cluster_bitmap(alloc_inode)) 987 journal_type = OCFS2_JOURNAL_ACCESS_UNDO; 988 | 485 if (status < 0) { 486 mlog_errno(status); 487 goto bail; 488 } 489 490 le32_add_cpu(&cl->cl_recs[alloc_rec].c_free, 491 le16_to_cpu(bg->bg_free_bits_count)); 492 le32_add_cpu(&cl->cl_recs[alloc_rec].c_total, le16_to_cpu(bg->bg_bits)); --- 492 unchanged lines hidden (view full) --- 985 BUG_ON(le16_to_cpu(bg->bg_free_bits_count) < num_bits); 986 987 mlog(0, "block_group_set_bits: off = %u, num = %u\n", bit_off, 988 num_bits); 989 990 if (ocfs2_is_cluster_bitmap(alloc_inode)) 991 journal_type = OCFS2_JOURNAL_ACCESS_UNDO; 992 |
989 status = ocfs2_journal_access(handle, 990 alloc_inode, 991 group_bh, 992 journal_type); | 993 status = ocfs2_journal_access_gd(handle, 994 alloc_inode, 995 group_bh, 996 journal_type); |
993 if (status < 0) { 994 mlog_errno(status); 995 goto bail; 996 } 997 998 le16_add_cpu(&bg->bg_free_bits_count, -num_bits); 999 1000 while(num_bits--) --- 54 unchanged lines hidden (view full) --- 1055 (unsigned long long)le64_to_cpu(fe->i_blkno), chain, 1056 (unsigned long long)le64_to_cpu(bg->bg_blkno), 1057 (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); 1058 1059 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); 1060 bg_ptr = le64_to_cpu(bg->bg_next_group); 1061 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group); 1062 | 997 if (status < 0) { 998 mlog_errno(status); 999 goto bail; 1000 } 1001 1002 le16_add_cpu(&bg->bg_free_bits_count, -num_bits); 1003 1004 while(num_bits--) --- 54 unchanged lines hidden (view full) --- 1059 (unsigned long long)le64_to_cpu(fe->i_blkno), chain, 1060 (unsigned long long)le64_to_cpu(bg->bg_blkno), 1061 (unsigned long long)le64_to_cpu(prev_bg->bg_blkno)); 1062 1063 fe_ptr = le64_to_cpu(fe->id2.i_chain.cl_recs[chain].c_blkno); 1064 bg_ptr = le64_to_cpu(bg->bg_next_group); 1065 prev_bg_ptr = le64_to_cpu(prev_bg->bg_next_group); 1066 |
1063 status = ocfs2_journal_access(handle, alloc_inode, prev_bg_bh, 1064 OCFS2_JOURNAL_ACCESS_WRITE); | 1067 status = ocfs2_journal_access_gd(handle, alloc_inode, prev_bg_bh, 1068 OCFS2_JOURNAL_ACCESS_WRITE); |
1065 if (status < 0) { 1066 mlog_errno(status); 1067 goto out_rollback; 1068 } 1069 1070 prev_bg->bg_next_group = bg->bg_next_group; 1071 1072 status = ocfs2_journal_dirty(handle, prev_bg_bh); 1073 if (status < 0) { 1074 mlog_errno(status); 1075 goto out_rollback; 1076 } 1077 | 1069 if (status < 0) { 1070 mlog_errno(status); 1071 goto out_rollback; 1072 } 1073 1074 prev_bg->bg_next_group = bg->bg_next_group; 1075 1076 status = ocfs2_journal_dirty(handle, prev_bg_bh); 1077 if (status < 0) { 1078 mlog_errno(status); 1079 goto out_rollback; 1080 } 1081 |
1078 status = ocfs2_journal_access(handle, alloc_inode, bg_bh, 1079 OCFS2_JOURNAL_ACCESS_WRITE); | 1082 status = ocfs2_journal_access_gd(handle, alloc_inode, bg_bh, 1083 OCFS2_JOURNAL_ACCESS_WRITE); |
1080 if (status < 0) { 1081 mlog_errno(status); 1082 goto out_rollback; 1083 } 1084 1085 bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno; 1086 1087 status = ocfs2_journal_dirty(handle, bg_bh); 1088 if (status < 0) { 1089 mlog_errno(status); 1090 goto out_rollback; 1091 } 1092 | 1084 if (status < 0) { 1085 mlog_errno(status); 1086 goto out_rollback; 1087 } 1088 1089 bg->bg_next_group = fe->id2.i_chain.cl_recs[chain].c_blkno; 1090 1091 status = ocfs2_journal_dirty(handle, bg_bh); 1092 if (status < 0) { 1093 mlog_errno(status); 1094 goto out_rollback; 1095 } 1096 |
1093 status = ocfs2_journal_access(handle, alloc_inode, fe_bh, 1094 OCFS2_JOURNAL_ACCESS_WRITE); | 1097 status = ocfs2_journal_access_di(handle, alloc_inode, fe_bh, 1098 OCFS2_JOURNAL_ACCESS_WRITE); |
1095 if (status < 0) { 1096 mlog_errno(status); 1097 goto out_rollback; 1098 } 1099 1100 fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno; 1101 1102 status = ocfs2_journal_dirty(handle, fe_bh); --- 134 unchanged lines hidden (view full) --- 1237 u32 num_bits, 1238 u16 chain) 1239{ 1240 int ret; 1241 u32 tmp_used; 1242 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; 1243 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &di->id2.i_chain; 1244 | 1099 if (status < 0) { 1100 mlog_errno(status); 1101 goto out_rollback; 1102 } 1103 1104 fe->id2.i_chain.cl_recs[chain].c_blkno = bg->bg_blkno; 1105 1106 status = ocfs2_journal_dirty(handle, fe_bh); --- 134 unchanged lines hidden (view full) --- 1241 u32 num_bits, 1242 u16 chain) 1243{ 1244 int ret; 1245 u32 tmp_used; 1246 struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; 1247 struct ocfs2_chain_list *cl = (struct ocfs2_chain_list *) &di->id2.i_chain; 1248 |
1245 ret = ocfs2_journal_access(handle, inode, di_bh, 1246 OCFS2_JOURNAL_ACCESS_WRITE); | 1249 ret = ocfs2_journal_access_di(handle, inode, di_bh, 1250 OCFS2_JOURNAL_ACCESS_WRITE); |
1247 if (ret < 0) { 1248 mlog_errno(ret); 1249 goto out; 1250 } 1251 1252 tmp_used = le32_to_cpu(di->id1.bitmap1.i_used); 1253 di->id1.bitmap1.i_used = cpu_to_le32(num_bits + tmp_used); 1254 le32_add_cpu(&cl->cl_recs[chain].c_free, -num_bits); --- 154 unchanged lines hidden (view full) --- 1409 if (status < 0) { 1410 mlog_errno(status); 1411 goto bail; 1412 } 1413 } 1414 1415 /* Ok, claim our bits now: set the info on dinode, chainlist 1416 * and then the group */ | 1251 if (ret < 0) { 1252 mlog_errno(ret); 1253 goto out; 1254 } 1255 1256 tmp_used = le32_to_cpu(di->id1.bitmap1.i_used); 1257 di->id1.bitmap1.i_used = cpu_to_le32(num_bits + tmp_used); 1258 le32_add_cpu(&cl->cl_recs[chain].c_free, -num_bits); --- 154 unchanged lines hidden (view full) --- 1413 if (status < 0) { 1414 mlog_errno(status); 1415 goto bail; 1416 } 1417 } 1418 1419 /* Ok, claim our bits now: set the info on dinode, chainlist 1420 * and then the group */ |
1417 status = ocfs2_journal_access(handle, 1418 alloc_inode, 1419 ac->ac_bh, 1420 OCFS2_JOURNAL_ACCESS_WRITE); | 1421 status = ocfs2_journal_access_di(handle, 1422 alloc_inode, 1423 ac->ac_bh, 1424 OCFS2_JOURNAL_ACCESS_WRITE); |
1421 if (status < 0) { 1422 mlog_errno(status); 1423 goto bail; 1424 } 1425 1426 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used); 1427 fe->id1.bitmap1.i_used = cpu_to_le32(*num_bits + tmp_used); 1428 le32_add_cpu(&cl->cl_recs[chain].c_free, -(*num_bits)); --- 390 unchanged lines hidden (view full) --- 1819 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ 1820 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); 1821 1822 mlog(0, "off = %u, num = %u\n", bit_off, num_bits); 1823 1824 if (ocfs2_is_cluster_bitmap(alloc_inode)) 1825 journal_type = OCFS2_JOURNAL_ACCESS_UNDO; 1826 | 1425 if (status < 0) { 1426 mlog_errno(status); 1427 goto bail; 1428 } 1429 1430 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used); 1431 fe->id1.bitmap1.i_used = cpu_to_le32(*num_bits + tmp_used); 1432 le32_add_cpu(&cl->cl_recs[chain].c_free, -(*num_bits)); --- 390 unchanged lines hidden (view full) --- 1823 * ocfs2_read_group_descriptor(). Any corruption is a code bug. */ 1824 BUG_ON(!OCFS2_IS_VALID_GROUP_DESC(bg)); 1825 1826 mlog(0, "off = %u, num = %u\n", bit_off, num_bits); 1827 1828 if (ocfs2_is_cluster_bitmap(alloc_inode)) 1829 journal_type = OCFS2_JOURNAL_ACCESS_UNDO; 1830 |
1827 status = ocfs2_journal_access(handle, alloc_inode, group_bh, 1828 journal_type); | 1831 status = ocfs2_journal_access_gd(handle, alloc_inode, group_bh, 1832 journal_type); |
1829 if (status < 0) { 1830 mlog_errno(status); 1831 goto bail; 1832 } 1833 1834 if (ocfs2_is_cluster_bitmap(alloc_inode)) 1835 undo_bg = (struct ocfs2_group_desc *) bh2jh(group_bh)->b_committed_data; 1836 --- 58 unchanged lines hidden (view full) --- 1895 status = ocfs2_block_group_clear_bits(handle, alloc_inode, 1896 group, group_bh, 1897 start_bit, count); 1898 if (status < 0) { 1899 mlog_errno(status); 1900 goto bail; 1901 } 1902 | 1833 if (status < 0) { 1834 mlog_errno(status); 1835 goto bail; 1836 } 1837 1838 if (ocfs2_is_cluster_bitmap(alloc_inode)) 1839 undo_bg = (struct ocfs2_group_desc *) bh2jh(group_bh)->b_committed_data; 1840 --- 58 unchanged lines hidden (view full) --- 1899 status = ocfs2_block_group_clear_bits(handle, alloc_inode, 1900 group, group_bh, 1901 start_bit, count); 1902 if (status < 0) { 1903 mlog_errno(status); 1904 goto bail; 1905 } 1906 |
1903 status = ocfs2_journal_access(handle, alloc_inode, alloc_bh, 1904 OCFS2_JOURNAL_ACCESS_WRITE); | 1907 status = ocfs2_journal_access_di(handle, alloc_inode, alloc_bh, 1908 OCFS2_JOURNAL_ACCESS_WRITE); |
1905 if (status < 0) { 1906 mlog_errno(status); 1907 goto bail; 1908 } 1909 1910 le32_add_cpu(&cl->cl_recs[le16_to_cpu(group->bg_chain)].c_free, 1911 count); 1912 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used); --- 202 unchanged lines hidden --- | 1909 if (status < 0) { 1910 mlog_errno(status); 1911 goto bail; 1912 } 1913 1914 le32_add_cpu(&cl->cl_recs[le16_to_cpu(group->bg_chain)].c_free, 1915 count); 1916 tmp_used = le32_to_cpu(fe->id1.bitmap1.i_used); --- 202 unchanged lines hidden --- |