diff options
Diffstat (limited to 'fs/ocfs2')
46 files changed, 1488 insertions, 1119 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index f43bc5f18a35..f27e5378caf2 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -52,14 +52,14 @@ static int ocfs2_extent_contig(struct inode *inode, | |||
52 | u64 blkno); | 52 | u64 blkno); |
53 | 53 | ||
54 | static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, | 54 | static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, |
55 | struct ocfs2_journal_handle *handle, | 55 | handle_t *handle, |
56 | struct inode *inode, | 56 | struct inode *inode, |
57 | int wanted, | 57 | int wanted, |
58 | struct ocfs2_alloc_context *meta_ac, | 58 | struct ocfs2_alloc_context *meta_ac, |
59 | struct buffer_head *bhs[]); | 59 | struct buffer_head *bhs[]); |
60 | 60 | ||
61 | static int ocfs2_add_branch(struct ocfs2_super *osb, | 61 | static int ocfs2_add_branch(struct ocfs2_super *osb, |
62 | struct ocfs2_journal_handle *handle, | 62 | handle_t *handle, |
63 | struct inode *inode, | 63 | struct inode *inode, |
64 | struct buffer_head *fe_bh, | 64 | struct buffer_head *fe_bh, |
65 | struct buffer_head *eb_bh, | 65 | struct buffer_head *eb_bh, |
@@ -67,14 +67,14 @@ static int ocfs2_add_branch(struct ocfs2_super *osb, | |||
67 | struct ocfs2_alloc_context *meta_ac); | 67 | struct ocfs2_alloc_context *meta_ac); |
68 | 68 | ||
69 | static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | 69 | static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, |
70 | struct ocfs2_journal_handle *handle, | 70 | handle_t *handle, |
71 | struct inode *inode, | 71 | struct inode *inode, |
72 | struct buffer_head *fe_bh, | 72 | struct buffer_head *fe_bh, |
73 | struct ocfs2_alloc_context *meta_ac, | 73 | struct ocfs2_alloc_context *meta_ac, |
74 | struct buffer_head **ret_new_eb_bh); | 74 | struct buffer_head **ret_new_eb_bh); |
75 | 75 | ||
76 | static int ocfs2_do_insert_extent(struct ocfs2_super *osb, | 76 | static int ocfs2_do_insert_extent(struct ocfs2_super *osb, |
77 | struct ocfs2_journal_handle *handle, | 77 | handle_t *handle, |
78 | struct inode *inode, | 78 | struct inode *inode, |
79 | struct buffer_head *fe_bh, | 79 | struct buffer_head *fe_bh, |
80 | u64 blkno, | 80 | u64 blkno, |
@@ -152,7 +152,7 @@ bail: | |||
152 | * l_count for you | 152 | * l_count for you |
153 | */ | 153 | */ |
154 | static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, | 154 | static int ocfs2_create_new_meta_bhs(struct ocfs2_super *osb, |
155 | struct ocfs2_journal_handle *handle, | 155 | handle_t *handle, |
156 | struct inode *inode, | 156 | struct inode *inode, |
157 | int wanted, | 157 | int wanted, |
158 | struct ocfs2_alloc_context *meta_ac, | 158 | struct ocfs2_alloc_context *meta_ac, |
@@ -253,7 +253,7 @@ bail: | |||
253 | * contain a single record with e_clusters == 0. | 253 | * contain a single record with e_clusters == 0. |
254 | */ | 254 | */ |
255 | static int ocfs2_add_branch(struct ocfs2_super *osb, | 255 | static int ocfs2_add_branch(struct ocfs2_super *osb, |
256 | struct ocfs2_journal_handle *handle, | 256 | handle_t *handle, |
257 | struct inode *inode, | 257 | struct inode *inode, |
258 | struct buffer_head *fe_bh, | 258 | struct buffer_head *fe_bh, |
259 | struct buffer_head *eb_bh, | 259 | struct buffer_head *eb_bh, |
@@ -418,7 +418,7 @@ bail: | |||
418 | * after this call. | 418 | * after this call. |
419 | */ | 419 | */ |
420 | static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, | 420 | static int ocfs2_shift_tree_depth(struct ocfs2_super *osb, |
421 | struct ocfs2_journal_handle *handle, | 421 | handle_t *handle, |
422 | struct inode *inode, | 422 | struct inode *inode, |
423 | struct buffer_head *fe_bh, | 423 | struct buffer_head *fe_bh, |
424 | struct ocfs2_alloc_context *meta_ac, | 424 | struct ocfs2_alloc_context *meta_ac, |
@@ -520,7 +520,7 @@ bail: | |||
520 | * down. | 520 | * down. |
521 | */ | 521 | */ |
522 | static int ocfs2_do_insert_extent(struct ocfs2_super *osb, | 522 | static int ocfs2_do_insert_extent(struct ocfs2_super *osb, |
523 | struct ocfs2_journal_handle *handle, | 523 | handle_t *handle, |
524 | struct inode *inode, | 524 | struct inode *inode, |
525 | struct buffer_head *fe_bh, | 525 | struct buffer_head *fe_bh, |
526 | u64 start_blk, | 526 | u64 start_blk, |
@@ -809,7 +809,7 @@ bail: | |||
809 | 809 | ||
810 | /* the caller needs to update fe->i_clusters */ | 810 | /* the caller needs to update fe->i_clusters */ |
811 | int ocfs2_insert_extent(struct ocfs2_super *osb, | 811 | int ocfs2_insert_extent(struct ocfs2_super *osb, |
812 | struct ocfs2_journal_handle *handle, | 812 | handle_t *handle, |
813 | struct inode *inode, | 813 | struct inode *inode, |
814 | struct buffer_head *fe_bh, | 814 | struct buffer_head *fe_bh, |
815 | u64 start_blk, | 815 | u64 start_blk, |
@@ -951,7 +951,7 @@ static int ocfs2_truncate_log_can_coalesce(struct ocfs2_truncate_log *tl, | |||
951 | } | 951 | } |
952 | 952 | ||
953 | static int ocfs2_truncate_log_append(struct ocfs2_super *osb, | 953 | static int ocfs2_truncate_log_append(struct ocfs2_super *osb, |
954 | struct ocfs2_journal_handle *handle, | 954 | handle_t *handle, |
955 | u64 start_blk, | 955 | u64 start_blk, |
956 | unsigned int num_clusters) | 956 | unsigned int num_clusters) |
957 | { | 957 | { |
@@ -1034,7 +1034,7 @@ bail: | |||
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, | 1036 | static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, |
1037 | struct ocfs2_journal_handle *handle, | 1037 | handle_t *handle, |
1038 | struct inode *data_alloc_inode, | 1038 | struct inode *data_alloc_inode, |
1039 | struct buffer_head *data_alloc_bh) | 1039 | struct buffer_head *data_alloc_bh) |
1040 | { | 1040 | { |
@@ -1113,7 +1113,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
1113 | { | 1113 | { |
1114 | int status; | 1114 | int status; |
1115 | unsigned int num_to_flush; | 1115 | unsigned int num_to_flush; |
1116 | struct ocfs2_journal_handle *handle = NULL; | 1116 | handle_t *handle; |
1117 | struct inode *tl_inode = osb->osb_tl_inode; | 1117 | struct inode *tl_inode = osb->osb_tl_inode; |
1118 | struct inode *data_alloc_inode = NULL; | 1118 | struct inode *data_alloc_inode = NULL; |
1119 | struct buffer_head *tl_bh = osb->osb_tl_bh; | 1119 | struct buffer_head *tl_bh = osb->osb_tl_bh; |
@@ -1130,7 +1130,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
1130 | if (!OCFS2_IS_VALID_DINODE(di)) { | 1130 | if (!OCFS2_IS_VALID_DINODE(di)) { |
1131 | OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); | 1131 | OCFS2_RO_ON_INVALID_DINODE(osb->sb, di); |
1132 | status = -EIO; | 1132 | status = -EIO; |
1133 | goto bail; | 1133 | goto out; |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | num_to_flush = le16_to_cpu(tl->tl_used); | 1136 | num_to_flush = le16_to_cpu(tl->tl_used); |
@@ -1138,14 +1138,7 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
1138 | num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); | 1138 | num_to_flush, (unsigned long long)OCFS2_I(tl_inode)->ip_blkno); |
1139 | if (!num_to_flush) { | 1139 | if (!num_to_flush) { |
1140 | status = 0; | 1140 | status = 0; |
1141 | goto bail; | 1141 | goto out; |
1142 | } | ||
1143 | |||
1144 | handle = ocfs2_alloc_handle(osb); | ||
1145 | if (!handle) { | ||
1146 | status = -ENOMEM; | ||
1147 | mlog_errno(status); | ||
1148 | goto bail; | ||
1149 | } | 1142 | } |
1150 | 1143 | ||
1151 | data_alloc_inode = ocfs2_get_system_file_inode(osb, | 1144 | data_alloc_inode = ocfs2_get_system_file_inode(osb, |
@@ -1154,41 +1147,40 @@ static int __ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
1154 | if (!data_alloc_inode) { | 1147 | if (!data_alloc_inode) { |
1155 | status = -EINVAL; | 1148 | status = -EINVAL; |
1156 | mlog(ML_ERROR, "Could not get bitmap inode!\n"); | 1149 | mlog(ML_ERROR, "Could not get bitmap inode!\n"); |
1157 | goto bail; | 1150 | goto out; |
1158 | } | 1151 | } |
1159 | 1152 | ||
1160 | ocfs2_handle_add_inode(handle, data_alloc_inode); | 1153 | mutex_lock(&data_alloc_inode->i_mutex); |
1161 | status = ocfs2_meta_lock(data_alloc_inode, handle, &data_alloc_bh, 1); | 1154 | |
1155 | status = ocfs2_meta_lock(data_alloc_inode, &data_alloc_bh, 1); | ||
1162 | if (status < 0) { | 1156 | if (status < 0) { |
1163 | mlog_errno(status); | 1157 | mlog_errno(status); |
1164 | goto bail; | 1158 | goto out_mutex; |
1165 | } | 1159 | } |
1166 | 1160 | ||
1167 | handle = ocfs2_start_trans(osb, handle, OCFS2_TRUNCATE_LOG_UPDATE); | 1161 | handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE); |
1168 | if (IS_ERR(handle)) { | 1162 | if (IS_ERR(handle)) { |
1169 | status = PTR_ERR(handle); | 1163 | status = PTR_ERR(handle); |
1170 | handle = NULL; | ||
1171 | mlog_errno(status); | 1164 | mlog_errno(status); |
1172 | goto bail; | 1165 | goto out_unlock; |
1173 | } | 1166 | } |
1174 | 1167 | ||
1175 | status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode, | 1168 | status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode, |
1176 | data_alloc_bh); | 1169 | data_alloc_bh); |
1177 | if (status < 0) { | 1170 | if (status < 0) |
1178 | mlog_errno(status); | 1171 | mlog_errno(status); |
1179 | goto bail; | ||
1180 | } | ||
1181 | 1172 | ||
1182 | bail: | 1173 | ocfs2_commit_trans(osb, handle); |
1183 | if (handle) | ||
1184 | ocfs2_commit_trans(handle); | ||
1185 | 1174 | ||
1186 | if (data_alloc_inode) | 1175 | out_unlock: |
1187 | iput(data_alloc_inode); | 1176 | brelse(data_alloc_bh); |
1177 | ocfs2_meta_unlock(data_alloc_inode, 1); | ||
1188 | 1178 | ||
1189 | if (data_alloc_bh) | 1179 | out_mutex: |
1190 | brelse(data_alloc_bh); | 1180 | mutex_unlock(&data_alloc_inode->i_mutex); |
1181 | iput(data_alloc_inode); | ||
1191 | 1182 | ||
1183 | out: | ||
1192 | mlog_exit(status); | 1184 | mlog_exit(status); |
1193 | return status; | 1185 | return status; |
1194 | } | 1186 | } |
@@ -1205,10 +1197,12 @@ int ocfs2_flush_truncate_log(struct ocfs2_super *osb) | |||
1205 | return status; | 1197 | return status; |
1206 | } | 1198 | } |
1207 | 1199 | ||
1208 | static void ocfs2_truncate_log_worker(void *data) | 1200 | static void ocfs2_truncate_log_worker(struct work_struct *work) |
1209 | { | 1201 | { |
1210 | int status; | 1202 | int status; |
1211 | struct ocfs2_super *osb = data; | 1203 | struct ocfs2_super *osb = |
1204 | container_of(work, struct ocfs2_super, | ||
1205 | osb_truncate_log_wq.work); | ||
1212 | 1206 | ||
1213 | mlog_entry_void(); | 1207 | mlog_entry_void(); |
1214 | 1208 | ||
@@ -1347,7 +1341,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
1347 | int i; | 1341 | int i; |
1348 | unsigned int clusters, num_recs, start_cluster; | 1342 | unsigned int clusters, num_recs, start_cluster; |
1349 | u64 start_blk; | 1343 | u64 start_blk; |
1350 | struct ocfs2_journal_handle *handle; | 1344 | handle_t *handle; |
1351 | struct inode *tl_inode = osb->osb_tl_inode; | 1345 | struct inode *tl_inode = osb->osb_tl_inode; |
1352 | struct ocfs2_truncate_log *tl; | 1346 | struct ocfs2_truncate_log *tl; |
1353 | 1347 | ||
@@ -1373,8 +1367,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
1373 | } | 1367 | } |
1374 | } | 1368 | } |
1375 | 1369 | ||
1376 | handle = ocfs2_start_trans(osb, NULL, | 1370 | handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE); |
1377 | OCFS2_TRUNCATE_LOG_UPDATE); | ||
1378 | if (IS_ERR(handle)) { | 1371 | if (IS_ERR(handle)) { |
1379 | status = PTR_ERR(handle); | 1372 | status = PTR_ERR(handle); |
1380 | mlog_errno(status); | 1373 | mlog_errno(status); |
@@ -1387,7 +1380,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
1387 | 1380 | ||
1388 | status = ocfs2_truncate_log_append(osb, handle, | 1381 | status = ocfs2_truncate_log_append(osb, handle, |
1389 | start_blk, clusters); | 1382 | start_blk, clusters); |
1390 | ocfs2_commit_trans(handle); | 1383 | ocfs2_commit_trans(osb, handle); |
1391 | if (status < 0) { | 1384 | if (status < 0) { |
1392 | mlog_errno(status); | 1385 | mlog_errno(status); |
1393 | goto bail_up; | 1386 | goto bail_up; |
@@ -1441,7 +1434,8 @@ int ocfs2_truncate_log_init(struct ocfs2_super *osb) | |||
1441 | /* ocfs2_truncate_log_shutdown keys on the existence of | 1434 | /* ocfs2_truncate_log_shutdown keys on the existence of |
1442 | * osb->osb_tl_inode so we don't set any of the osb variables | 1435 | * osb->osb_tl_inode so we don't set any of the osb variables |
1443 | * until we're sure all is well. */ | 1436 | * until we're sure all is well. */ |
1444 | INIT_WORK(&osb->osb_truncate_log_wq, ocfs2_truncate_log_worker, osb); | 1437 | INIT_DELAYED_WORK(&osb->osb_truncate_log_wq, |
1438 | ocfs2_truncate_log_worker); | ||
1445 | osb->osb_tl_bh = tl_bh; | 1439 | osb->osb_tl_bh = tl_bh; |
1446 | osb->osb_tl_inode = tl_inode; | 1440 | osb->osb_tl_inode = tl_inode; |
1447 | 1441 | ||
@@ -1543,7 +1537,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb, | |||
1543 | struct inode *inode, | 1537 | struct inode *inode, |
1544 | struct buffer_head *fe_bh, | 1538 | struct buffer_head *fe_bh, |
1545 | struct buffer_head *old_last_eb_bh, | 1539 | struct buffer_head *old_last_eb_bh, |
1546 | struct ocfs2_journal_handle *handle, | 1540 | handle_t *handle, |
1547 | struct ocfs2_truncate_context *tc) | 1541 | struct ocfs2_truncate_context *tc) |
1548 | { | 1542 | { |
1549 | int status, i, depth; | 1543 | int status, i, depth; |
@@ -1782,7 +1776,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
1782 | struct ocfs2_extent_block *eb; | 1776 | struct ocfs2_extent_block *eb; |
1783 | struct ocfs2_extent_list *el; | 1777 | struct ocfs2_extent_list *el; |
1784 | struct buffer_head *last_eb_bh; | 1778 | struct buffer_head *last_eb_bh; |
1785 | struct ocfs2_journal_handle *handle = NULL; | 1779 | handle_t *handle = NULL; |
1786 | struct inode *tl_inode = osb->osb_tl_inode; | 1780 | struct inode *tl_inode = osb->osb_tl_inode; |
1787 | 1781 | ||
1788 | mlog_entry_void(); | 1782 | mlog_entry_void(); |
@@ -1868,7 +1862,7 @@ start: | |||
1868 | 1862 | ||
1869 | credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, | 1863 | credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, |
1870 | fe, el); | 1864 | fe, el); |
1871 | handle = ocfs2_start_trans(osb, NULL, credits); | 1865 | handle = ocfs2_start_trans(osb, credits); |
1872 | if (IS_ERR(handle)) { | 1866 | if (IS_ERR(handle)) { |
1873 | status = PTR_ERR(handle); | 1867 | status = PTR_ERR(handle); |
1874 | handle = NULL; | 1868 | handle = NULL; |
@@ -1891,7 +1885,7 @@ start: | |||
1891 | mutex_unlock(&tl_inode->i_mutex); | 1885 | mutex_unlock(&tl_inode->i_mutex); |
1892 | tl_sem = 0; | 1886 | tl_sem = 0; |
1893 | 1887 | ||
1894 | ocfs2_commit_trans(handle); | 1888 | ocfs2_commit_trans(osb, handle); |
1895 | handle = NULL; | 1889 | handle = NULL; |
1896 | 1890 | ||
1897 | BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters); | 1891 | BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters); |
@@ -1906,7 +1900,7 @@ bail: | |||
1906 | mutex_unlock(&tl_inode->i_mutex); | 1900 | mutex_unlock(&tl_inode->i_mutex); |
1907 | 1901 | ||
1908 | if (handle) | 1902 | if (handle) |
1909 | ocfs2_commit_trans(handle); | 1903 | ocfs2_commit_trans(osb, handle); |
1910 | 1904 | ||
1911 | if (last_eb_bh) | 1905 | if (last_eb_bh) |
1912 | brelse(last_eb_bh); | 1906 | brelse(last_eb_bh); |
@@ -1965,7 +1959,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb, | |||
1965 | goto bail; | 1959 | goto bail; |
1966 | } | 1960 | } |
1967 | 1961 | ||
1968 | *tc = kcalloc(1, sizeof(struct ocfs2_truncate_context), GFP_KERNEL); | 1962 | *tc = kzalloc(sizeof(struct ocfs2_truncate_context), GFP_KERNEL); |
1969 | if (!(*tc)) { | 1963 | if (!(*tc)) { |
1970 | status = -ENOMEM; | 1964 | status = -ENOMEM; |
1971 | mlog_errno(status); | 1965 | mlog_errno(status); |
@@ -2011,10 +2005,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb, | |||
2011 | mutex_lock(&ext_alloc_inode->i_mutex); | 2005 | mutex_lock(&ext_alloc_inode->i_mutex); |
2012 | (*tc)->tc_ext_alloc_inode = ext_alloc_inode; | 2006 | (*tc)->tc_ext_alloc_inode = ext_alloc_inode; |
2013 | 2007 | ||
2014 | status = ocfs2_meta_lock(ext_alloc_inode, | 2008 | status = ocfs2_meta_lock(ext_alloc_inode, &ext_alloc_bh, 1); |
2015 | NULL, | ||
2016 | &ext_alloc_bh, | ||
2017 | 1); | ||
2018 | if (status < 0) { | 2009 | if (status < 0) { |
2019 | mlog_errno(status); | 2010 | mlog_errno(status); |
2020 | goto bail; | 2011 | goto bail; |
diff --git a/fs/ocfs2/alloc.h b/fs/ocfs2/alloc.h index 12ba897743f4..0b82e8044325 100644 --- a/fs/ocfs2/alloc.h +++ b/fs/ocfs2/alloc.h | |||
@@ -28,7 +28,7 @@ | |||
28 | 28 | ||
29 | struct ocfs2_alloc_context; | 29 | struct ocfs2_alloc_context; |
30 | int ocfs2_insert_extent(struct ocfs2_super *osb, | 30 | int ocfs2_insert_extent(struct ocfs2_super *osb, |
31 | struct ocfs2_journal_handle *handle, | 31 | handle_t *handle, |
32 | struct inode *inode, | 32 | struct inode *inode, |
33 | struct buffer_head *fe_bh, | 33 | struct buffer_head *fe_bh, |
34 | u64 blkno, | 34 | u64 blkno, |
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c index 3d7c082a8f58..93628b02ef5d 100644 --- a/fs/ocfs2/aops.c +++ b/fs/ocfs2/aops.c | |||
@@ -200,7 +200,7 @@ static int ocfs2_readpage(struct file *file, struct page *page) | |||
200 | 200 | ||
201 | mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0)); | 201 | mlog_entry("(0x%p, %lu)\n", file, (page ? page->index : 0)); |
202 | 202 | ||
203 | ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); | 203 | ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); |
204 | if (ret != 0) { | 204 | if (ret != 0) { |
205 | if (ret == AOP_TRUNCATED_PAGE) | 205 | if (ret == AOP_TRUNCATED_PAGE) |
206 | unlock = 0; | 206 | unlock = 0; |
@@ -305,7 +305,7 @@ static int ocfs2_prepare_write(struct file *file, struct page *page, | |||
305 | 305 | ||
306 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); | 306 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); |
307 | 307 | ||
308 | ret = ocfs2_meta_lock_with_page(inode, NULL, NULL, 0, page); | 308 | ret = ocfs2_meta_lock_with_page(inode, NULL, 0, page); |
309 | if (ret != 0) { | 309 | if (ret != 0) { |
310 | mlog_errno(ret); | 310 | mlog_errno(ret); |
311 | goto out; | 311 | goto out; |
@@ -355,16 +355,16 @@ static int walk_page_buffers( handle_t *handle, | |||
355 | return ret; | 355 | return ret; |
356 | } | 356 | } |
357 | 357 | ||
358 | struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, | 358 | handle_t *ocfs2_start_walk_page_trans(struct inode *inode, |
359 | struct page *page, | 359 | struct page *page, |
360 | unsigned from, | 360 | unsigned from, |
361 | unsigned to) | 361 | unsigned to) |
362 | { | 362 | { |
363 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 363 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
364 | struct ocfs2_journal_handle *handle = NULL; | 364 | handle_t *handle = NULL; |
365 | int ret = 0; | 365 | int ret = 0; |
366 | 366 | ||
367 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 367 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
368 | if (!handle) { | 368 | if (!handle) { |
369 | ret = -ENOMEM; | 369 | ret = -ENOMEM; |
370 | mlog_errno(ret); | 370 | mlog_errno(ret); |
@@ -372,7 +372,7 @@ struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, | |||
372 | } | 372 | } |
373 | 373 | ||
374 | if (ocfs2_should_order_data(inode)) { | 374 | if (ocfs2_should_order_data(inode)) { |
375 | ret = walk_page_buffers(handle->k_handle, | 375 | ret = walk_page_buffers(handle, |
376 | page_buffers(page), | 376 | page_buffers(page), |
377 | from, to, NULL, | 377 | from, to, NULL, |
378 | ocfs2_journal_dirty_data); | 378 | ocfs2_journal_dirty_data); |
@@ -382,7 +382,7 @@ struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, | |||
382 | out: | 382 | out: |
383 | if (ret) { | 383 | if (ret) { |
384 | if (handle) | 384 | if (handle) |
385 | ocfs2_commit_trans(handle); | 385 | ocfs2_commit_trans(osb, handle); |
386 | handle = ERR_PTR(ret); | 386 | handle = ERR_PTR(ret); |
387 | } | 387 | } |
388 | return handle; | 388 | return handle; |
@@ -394,7 +394,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page, | |||
394 | int ret; | 394 | int ret; |
395 | struct buffer_head *di_bh = NULL; | 395 | struct buffer_head *di_bh = NULL; |
396 | struct inode *inode = page->mapping->host; | 396 | struct inode *inode = page->mapping->host; |
397 | struct ocfs2_journal_handle *handle = NULL; | 397 | handle_t *handle = NULL; |
398 | struct ocfs2_dinode *di; | 398 | struct ocfs2_dinode *di; |
399 | 399 | ||
400 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); | 400 | mlog_entry("(0x%p, 0x%p, %u, %u)\n", file, page, from, to); |
@@ -412,7 +412,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page, | |||
412 | * stale inode allocation image (i_size, i_clusters, etc). | 412 | * stale inode allocation image (i_size, i_clusters, etc). |
413 | */ | 413 | */ |
414 | 414 | ||
415 | ret = ocfs2_meta_lock_with_page(inode, NULL, &di_bh, 1, page); | 415 | ret = ocfs2_meta_lock_with_page(inode, &di_bh, 1, page); |
416 | if (ret != 0) { | 416 | if (ret != 0) { |
417 | mlog_errno(ret); | 417 | mlog_errno(ret); |
418 | goto out; | 418 | goto out; |
@@ -464,7 +464,7 @@ static int ocfs2_commit_write(struct file *file, struct page *page, | |||
464 | } | 464 | } |
465 | 465 | ||
466 | out_commit: | 466 | out_commit: |
467 | ocfs2_commit_trans(handle); | 467 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); |
468 | out_unlock_data: | 468 | out_unlock_data: |
469 | ocfs2_data_unlock(inode, 1); | 469 | ocfs2_data_unlock(inode, 1); |
470 | out_unlock_meta: | 470 | out_unlock_meta: |
@@ -490,7 +490,7 @@ static sector_t ocfs2_bmap(struct address_space *mapping, sector_t block) | |||
490 | * accessed concurrently from multiple nodes. | 490 | * accessed concurrently from multiple nodes. |
491 | */ | 491 | */ |
492 | if (!INODE_JOURNAL(inode)) { | 492 | if (!INODE_JOURNAL(inode)) { |
493 | err = ocfs2_meta_lock(inode, NULL, NULL, 0); | 493 | err = ocfs2_meta_lock(inode, NULL, 0); |
494 | if (err) { | 494 | if (err) { |
495 | if (err != -ENOENT) | 495 | if (err != -ENOENT) |
496 | mlog_errno(err); | 496 | mlog_errno(err); |
@@ -540,8 +540,7 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
540 | struct buffer_head *bh_result, int create) | 540 | struct buffer_head *bh_result, int create) |
541 | { | 541 | { |
542 | int ret; | 542 | int ret; |
543 | u64 vbo_max; /* file offset, max_blocks from iblock */ | 543 | u64 p_blkno, inode_blocks; |
544 | u64 p_blkno; | ||
545 | int contig_blocks; | 544 | int contig_blocks; |
546 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; | 545 | unsigned char blocksize_bits = inode->i_sb->s_blocksize_bits; |
547 | unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; | 546 | unsigned long max_blocks = bh_result->b_size >> inode->i_blkbits; |
@@ -550,12 +549,23 @@ static int ocfs2_direct_IO_get_blocks(struct inode *inode, sector_t iblock, | |||
550 | * nicely aligned and of the right size, so there's no need | 549 | * nicely aligned and of the right size, so there's no need |
551 | * for us to check any of that. */ | 550 | * for us to check any of that. */ |
552 | 551 | ||
553 | vbo_max = ((u64)iblock + max_blocks) << blocksize_bits; | ||
554 | |||
555 | spin_lock(&OCFS2_I(inode)->ip_lock); | 552 | spin_lock(&OCFS2_I(inode)->ip_lock); |
556 | if ((iblock + max_blocks) > | 553 | inode_blocks = ocfs2_clusters_to_blocks(inode->i_sb, |
557 | ocfs2_clusters_to_blocks(inode->i_sb, | 554 | OCFS2_I(inode)->ip_clusters); |
558 | OCFS2_I(inode)->ip_clusters)) { | 555 | |
556 | /* | ||
557 | * For a read which begins past the end of file, we return a hole. | ||
558 | */ | ||
559 | if (!create && (iblock >= inode_blocks)) { | ||
560 | spin_unlock(&OCFS2_I(inode)->ip_lock); | ||
561 | ret = 0; | ||
562 | goto bail; | ||
563 | } | ||
564 | |||
565 | /* | ||
566 | * Any write past EOF is not allowed because we'd be extending. | ||
567 | */ | ||
568 | if (create && (iblock + max_blocks) > inode_blocks) { | ||
559 | spin_unlock(&OCFS2_I(inode)->ip_lock); | 569 | spin_unlock(&OCFS2_I(inode)->ip_lock); |
560 | ret = -EIO; | 570 | ret = -EIO; |
561 | goto bail; | 571 | goto bail; |
@@ -595,7 +605,7 @@ static void ocfs2_dio_end_io(struct kiocb *iocb, | |||
595 | ssize_t bytes, | 605 | ssize_t bytes, |
596 | void *private) | 606 | void *private) |
597 | { | 607 | { |
598 | struct inode *inode = iocb->ki_filp->f_dentry->d_inode; | 608 | struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; |
599 | 609 | ||
600 | /* this io's submitter should not have unlocked this before we could */ | 610 | /* this io's submitter should not have unlocked this before we could */ |
601 | BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); | 611 | BUG_ON(!ocfs2_iocb_is_rw_locked(iocb)); |
@@ -611,7 +621,7 @@ static ssize_t ocfs2_direct_IO(int rw, | |||
611 | unsigned long nr_segs) | 621 | unsigned long nr_segs) |
612 | { | 622 | { |
613 | struct file *file = iocb->ki_filp; | 623 | struct file *file = iocb->ki_filp; |
614 | struct inode *inode = file->f_dentry->d_inode->i_mapping->host; | 624 | struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host; |
615 | int ret; | 625 | int ret; |
616 | 626 | ||
617 | mlog_entry_void(); | 627 | mlog_entry_void(); |
diff --git a/fs/ocfs2/aops.h b/fs/ocfs2/aops.h index e88c3f0b8fa9..f446a15eab88 100644 --- a/fs/ocfs2/aops.h +++ b/fs/ocfs2/aops.h | |||
@@ -25,7 +25,7 @@ | |||
25 | int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page, | 25 | int ocfs2_prepare_write_nolock(struct inode *inode, struct page *page, |
26 | unsigned from, unsigned to); | 26 | unsigned from, unsigned to); |
27 | 27 | ||
28 | struct ocfs2_journal_handle *ocfs2_start_walk_page_trans(struct inode *inode, | 28 | handle_t *ocfs2_start_walk_page_trans(struct inode *inode, |
29 | struct page *page, | 29 | struct page *page, |
30 | unsigned from, | 30 | unsigned from, |
31 | unsigned to); | 31 | unsigned to); |
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index 305cba3681fe..277ca67a2ad6 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -141,7 +141,7 @@ struct o2hb_region { | |||
141 | * recognizes a node going up and down in one iteration */ | 141 | * recognizes a node going up and down in one iteration */ |
142 | u64 hr_generation; | 142 | u64 hr_generation; |
143 | 143 | ||
144 | struct work_struct hr_write_timeout_work; | 144 | struct delayed_work hr_write_timeout_work; |
145 | unsigned long hr_last_timeout_start; | 145 | unsigned long hr_last_timeout_start; |
146 | 146 | ||
147 | /* Used during o2hb_check_slot to hold a copy of the block | 147 | /* Used during o2hb_check_slot to hold a copy of the block |
@@ -156,9 +156,11 @@ struct o2hb_bio_wait_ctxt { | |||
156 | int wc_error; | 156 | int wc_error; |
157 | }; | 157 | }; |
158 | 158 | ||
159 | static void o2hb_write_timeout(void *arg) | 159 | static void o2hb_write_timeout(struct work_struct *work) |
160 | { | 160 | { |
161 | struct o2hb_region *reg = arg; | 161 | struct o2hb_region *reg = |
162 | container_of(work, struct o2hb_region, | ||
163 | hr_write_timeout_work.work); | ||
162 | 164 | ||
163 | mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u " | 165 | mlog(ML_ERROR, "Heartbeat write timeout to device %s after %u " |
164 | "milliseconds\n", reg->hr_dev_name, | 166 | "milliseconds\n", reg->hr_dev_name, |
@@ -1404,7 +1406,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg, | |||
1404 | goto out; | 1406 | goto out; |
1405 | } | 1407 | } |
1406 | 1408 | ||
1407 | INIT_WORK(®->hr_write_timeout_work, o2hb_write_timeout, reg); | 1409 | INIT_DELAYED_WORK(®->hr_write_timeout_work, o2hb_write_timeout); |
1408 | 1410 | ||
1409 | /* | 1411 | /* |
1410 | * A node is considered live after it has beat LIVE_THRESHOLD | 1412 | * A node is considered live after it has beat LIVE_THRESHOLD |
@@ -1445,6 +1447,15 @@ out: | |||
1445 | return ret; | 1447 | return ret; |
1446 | } | 1448 | } |
1447 | 1449 | ||
1450 | static ssize_t o2hb_region_pid_read(struct o2hb_region *reg, | ||
1451 | char *page) | ||
1452 | { | ||
1453 | if (!reg->hr_task) | ||
1454 | return 0; | ||
1455 | |||
1456 | return sprintf(page, "%u\n", reg->hr_task->pid); | ||
1457 | } | ||
1458 | |||
1448 | struct o2hb_region_attribute { | 1459 | struct o2hb_region_attribute { |
1449 | struct configfs_attribute attr; | 1460 | struct configfs_attribute attr; |
1450 | ssize_t (*show)(struct o2hb_region *, char *); | 1461 | ssize_t (*show)(struct o2hb_region *, char *); |
@@ -1483,11 +1494,19 @@ static struct o2hb_region_attribute o2hb_region_attr_dev = { | |||
1483 | .store = o2hb_region_dev_write, | 1494 | .store = o2hb_region_dev_write, |
1484 | }; | 1495 | }; |
1485 | 1496 | ||
1497 | static struct o2hb_region_attribute o2hb_region_attr_pid = { | ||
1498 | .attr = { .ca_owner = THIS_MODULE, | ||
1499 | .ca_name = "pid", | ||
1500 | .ca_mode = S_IRUGO | S_IRUSR }, | ||
1501 | .show = o2hb_region_pid_read, | ||
1502 | }; | ||
1503 | |||
1486 | static struct configfs_attribute *o2hb_region_attrs[] = { | 1504 | static struct configfs_attribute *o2hb_region_attrs[] = { |
1487 | &o2hb_region_attr_block_bytes.attr, | 1505 | &o2hb_region_attr_block_bytes.attr, |
1488 | &o2hb_region_attr_start_block.attr, | 1506 | &o2hb_region_attr_start_block.attr, |
1489 | &o2hb_region_attr_blocks.attr, | 1507 | &o2hb_region_attr_blocks.attr, |
1490 | &o2hb_region_attr_dev.attr, | 1508 | &o2hb_region_attr_dev.attr, |
1509 | &o2hb_region_attr_pid.attr, | ||
1491 | NULL, | 1510 | NULL, |
1492 | }; | 1511 | }; |
1493 | 1512 | ||
@@ -1551,7 +1570,7 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g | |||
1551 | struct o2hb_region *reg = NULL; | 1570 | struct o2hb_region *reg = NULL; |
1552 | struct config_item *ret = NULL; | 1571 | struct config_item *ret = NULL; |
1553 | 1572 | ||
1554 | reg = kcalloc(1, sizeof(struct o2hb_region), GFP_KERNEL); | 1573 | reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); |
1555 | if (reg == NULL) | 1574 | if (reg == NULL) |
1556 | goto out; /* ENOMEM */ | 1575 | goto out; /* ENOMEM */ |
1557 | 1576 | ||
@@ -1677,7 +1696,7 @@ struct config_group *o2hb_alloc_hb_set(void) | |||
1677 | struct o2hb_heartbeat_group *hs = NULL; | 1696 | struct o2hb_heartbeat_group *hs = NULL; |
1678 | struct config_group *ret = NULL; | 1697 | struct config_group *ret = NULL; |
1679 | 1698 | ||
1680 | hs = kcalloc(1, sizeof(struct o2hb_heartbeat_group), GFP_KERNEL); | 1699 | hs = kzalloc(sizeof(struct o2hb_heartbeat_group), GFP_KERNEL); |
1681 | if (hs == NULL) | 1700 | if (hs == NULL) |
1682 | goto out; | 1701 | goto out; |
1683 | 1702 | ||
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c index d11753c50bc1..b17333a0606b 100644 --- a/fs/ocfs2/cluster/nodemanager.c +++ b/fs/ocfs2/cluster/nodemanager.c | |||
@@ -35,7 +35,7 @@ | |||
35 | /* for now we operate under the assertion that there can be only one | 35 | /* for now we operate under the assertion that there can be only one |
36 | * cluster active at a time. Changing this will require trickling | 36 | * cluster active at a time. Changing this will require trickling |
37 | * cluster references throughout where nodes are looked up */ | 37 | * cluster references throughout where nodes are looked up */ |
38 | static struct o2nm_cluster *o2nm_single_cluster = NULL; | 38 | struct o2nm_cluster *o2nm_single_cluster = NULL; |
39 | 39 | ||
40 | #define OCFS2_MAX_HB_CTL_PATH 256 | 40 | #define OCFS2_MAX_HB_CTL_PATH 256 |
41 | static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; | 41 | static char ocfs2_hb_ctl_path[OCFS2_MAX_HB_CTL_PATH] = "/sbin/ocfs2_hb_ctl"; |
@@ -97,17 +97,6 @@ const char *o2nm_get_hb_ctl_path(void) | |||
97 | } | 97 | } |
98 | EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path); | 98 | EXPORT_SYMBOL_GPL(o2nm_get_hb_ctl_path); |
99 | 99 | ||
100 | struct o2nm_cluster { | ||
101 | struct config_group cl_group; | ||
102 | unsigned cl_has_local:1; | ||
103 | u8 cl_local_node; | ||
104 | rwlock_t cl_nodes_lock; | ||
105 | struct o2nm_node *cl_nodes[O2NM_MAX_NODES]; | ||
106 | struct rb_root cl_node_ip_tree; | ||
107 | /* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */ | ||
108 | unsigned long cl_nodes_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; | ||
109 | }; | ||
110 | |||
111 | struct o2nm_node *o2nm_get_node_by_num(u8 node_num) | 100 | struct o2nm_node *o2nm_get_node_by_num(u8 node_num) |
112 | { | 101 | { |
113 | struct o2nm_node *node = NULL; | 102 | struct o2nm_node *node = NULL; |
@@ -543,6 +532,179 @@ static struct o2nm_node_group *to_o2nm_node_group(struct config_group *group) | |||
543 | } | 532 | } |
544 | #endif | 533 | #endif |
545 | 534 | ||
535 | struct o2nm_cluster_attribute { | ||
536 | struct configfs_attribute attr; | ||
537 | ssize_t (*show)(struct o2nm_cluster *, char *); | ||
538 | ssize_t (*store)(struct o2nm_cluster *, const char *, size_t); | ||
539 | }; | ||
540 | |||
541 | static ssize_t o2nm_cluster_attr_write(const char *page, ssize_t count, | ||
542 | unsigned int *val) | ||
543 | { | ||
544 | unsigned long tmp; | ||
545 | char *p = (char *)page; | ||
546 | |||
547 | tmp = simple_strtoul(p, &p, 0); | ||
548 | if (!p || (*p && (*p != '\n'))) | ||
549 | return -EINVAL; | ||
550 | |||
551 | if (tmp == 0) | ||
552 | return -EINVAL; | ||
553 | if (tmp >= (u32)-1) | ||
554 | return -ERANGE; | ||
555 | |||
556 | *val = tmp; | ||
557 | |||
558 | return count; | ||
559 | } | ||
560 | |||
561 | static ssize_t o2nm_cluster_attr_idle_timeout_ms_read( | ||
562 | struct o2nm_cluster *cluster, char *page) | ||
563 | { | ||
564 | return sprintf(page, "%u\n", cluster->cl_idle_timeout_ms); | ||
565 | } | ||
566 | |||
567 | static ssize_t o2nm_cluster_attr_idle_timeout_ms_write( | ||
568 | struct o2nm_cluster *cluster, const char *page, size_t count) | ||
569 | { | ||
570 | ssize_t ret; | ||
571 | unsigned int val; | ||
572 | |||
573 | ret = o2nm_cluster_attr_write(page, count, &val); | ||
574 | |||
575 | if (ret > 0) { | ||
576 | if (cluster->cl_idle_timeout_ms != val | ||
577 | && o2net_num_connected_peers()) { | ||
578 | mlog(ML_NOTICE, | ||
579 | "o2net: cannot change idle timeout after " | ||
580 | "the first peer has agreed to it." | ||
581 | " %d connected peers\n", | ||
582 | o2net_num_connected_peers()); | ||
583 | ret = -EINVAL; | ||
584 | } else if (val <= cluster->cl_keepalive_delay_ms) { | ||
585 | mlog(ML_NOTICE, "o2net: idle timeout must be larger " | ||
586 | "than keepalive delay\n"); | ||
587 | ret = -EINVAL; | ||
588 | } else { | ||
589 | cluster->cl_idle_timeout_ms = val; | ||
590 | } | ||
591 | } | ||
592 | |||
593 | return ret; | ||
594 | } | ||
595 | |||
596 | static ssize_t o2nm_cluster_attr_keepalive_delay_ms_read( | ||
597 | struct o2nm_cluster *cluster, char *page) | ||
598 | { | ||
599 | return sprintf(page, "%u\n", cluster->cl_keepalive_delay_ms); | ||
600 | } | ||
601 | |||
602 | static ssize_t o2nm_cluster_attr_keepalive_delay_ms_write( | ||
603 | struct o2nm_cluster *cluster, const char *page, size_t count) | ||
604 | { | ||
605 | ssize_t ret; | ||
606 | unsigned int val; | ||
607 | |||
608 | ret = o2nm_cluster_attr_write(page, count, &val); | ||
609 | |||
610 | if (ret > 0) { | ||
611 | if (cluster->cl_keepalive_delay_ms != val | ||
612 | && o2net_num_connected_peers()) { | ||
613 | mlog(ML_NOTICE, | ||
614 | "o2net: cannot change keepalive delay after" | ||
615 | " the first peer has agreed to it." | ||
616 | " %d connected peers\n", | ||
617 | o2net_num_connected_peers()); | ||
618 | ret = -EINVAL; | ||
619 | } else if (val >= cluster->cl_idle_timeout_ms) { | ||
620 | mlog(ML_NOTICE, "o2net: keepalive delay must be " | ||
621 | "smaller than idle timeout\n"); | ||
622 | ret = -EINVAL; | ||
623 | } else { | ||
624 | cluster->cl_keepalive_delay_ms = val; | ||
625 | } | ||
626 | } | ||
627 | |||
628 | return ret; | ||
629 | } | ||
630 | |||
631 | static ssize_t o2nm_cluster_attr_reconnect_delay_ms_read( | ||
632 | struct o2nm_cluster *cluster, char *page) | ||
633 | { | ||
634 | return sprintf(page, "%u\n", cluster->cl_reconnect_delay_ms); | ||
635 | } | ||
636 | |||
637 | static ssize_t o2nm_cluster_attr_reconnect_delay_ms_write( | ||
638 | struct o2nm_cluster *cluster, const char *page, size_t count) | ||
639 | { | ||
640 | return o2nm_cluster_attr_write(page, count, | ||
641 | &cluster->cl_reconnect_delay_ms); | ||
642 | } | ||
643 | static struct o2nm_cluster_attribute o2nm_cluster_attr_idle_timeout_ms = { | ||
644 | .attr = { .ca_owner = THIS_MODULE, | ||
645 | .ca_name = "idle_timeout_ms", | ||
646 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
647 | .show = o2nm_cluster_attr_idle_timeout_ms_read, | ||
648 | .store = o2nm_cluster_attr_idle_timeout_ms_write, | ||
649 | }; | ||
650 | |||
651 | static struct o2nm_cluster_attribute o2nm_cluster_attr_keepalive_delay_ms = { | ||
652 | .attr = { .ca_owner = THIS_MODULE, | ||
653 | .ca_name = "keepalive_delay_ms", | ||
654 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
655 | .show = o2nm_cluster_attr_keepalive_delay_ms_read, | ||
656 | .store = o2nm_cluster_attr_keepalive_delay_ms_write, | ||
657 | }; | ||
658 | |||
659 | static struct o2nm_cluster_attribute o2nm_cluster_attr_reconnect_delay_ms = { | ||
660 | .attr = { .ca_owner = THIS_MODULE, | ||
661 | .ca_name = "reconnect_delay_ms", | ||
662 | .ca_mode = S_IRUGO | S_IWUSR }, | ||
663 | .show = o2nm_cluster_attr_reconnect_delay_ms_read, | ||
664 | .store = o2nm_cluster_attr_reconnect_delay_ms_write, | ||
665 | }; | ||
666 | |||
667 | static struct configfs_attribute *o2nm_cluster_attrs[] = { | ||
668 | &o2nm_cluster_attr_idle_timeout_ms.attr, | ||
669 | &o2nm_cluster_attr_keepalive_delay_ms.attr, | ||
670 | &o2nm_cluster_attr_reconnect_delay_ms.attr, | ||
671 | NULL, | ||
672 | }; | ||
673 | static ssize_t o2nm_cluster_show(struct config_item *item, | ||
674 | struct configfs_attribute *attr, | ||
675 | char *page) | ||
676 | { | ||
677 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | ||
678 | struct o2nm_cluster_attribute *o2nm_cluster_attr = | ||
679 | container_of(attr, struct o2nm_cluster_attribute, attr); | ||
680 | ssize_t ret = 0; | ||
681 | |||
682 | if (o2nm_cluster_attr->show) | ||
683 | ret = o2nm_cluster_attr->show(cluster, page); | ||
684 | return ret; | ||
685 | } | ||
686 | |||
687 | static ssize_t o2nm_cluster_store(struct config_item *item, | ||
688 | struct configfs_attribute *attr, | ||
689 | const char *page, size_t count) | ||
690 | { | ||
691 | struct o2nm_cluster *cluster = to_o2nm_cluster(item); | ||
692 | struct o2nm_cluster_attribute *o2nm_cluster_attr = | ||
693 | container_of(attr, struct o2nm_cluster_attribute, attr); | ||
694 | ssize_t ret; | ||
695 | |||
696 | if (o2nm_cluster_attr->store == NULL) { | ||
697 | ret = -EINVAL; | ||
698 | goto out; | ||
699 | } | ||
700 | |||
701 | ret = o2nm_cluster_attr->store(cluster, page, count); | ||
702 | if (ret < count) | ||
703 | goto out; | ||
704 | out: | ||
705 | return ret; | ||
706 | } | ||
707 | |||
546 | static struct config_item *o2nm_node_group_make_item(struct config_group *group, | 708 | static struct config_item *o2nm_node_group_make_item(struct config_group *group, |
547 | const char *name) | 709 | const char *name) |
548 | { | 710 | { |
@@ -552,7 +714,7 @@ static struct config_item *o2nm_node_group_make_item(struct config_group *group, | |||
552 | if (strlen(name) > O2NM_MAX_NAME_LEN) | 714 | if (strlen(name) > O2NM_MAX_NAME_LEN) |
553 | goto out; /* ENAMETOOLONG */ | 715 | goto out; /* ENAMETOOLONG */ |
554 | 716 | ||
555 | node = kcalloc(1, sizeof(struct o2nm_node), GFP_KERNEL); | 717 | node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); |
556 | if (node == NULL) | 718 | if (node == NULL) |
557 | goto out; /* ENOMEM */ | 719 | goto out; /* ENOMEM */ |
558 | 720 | ||
@@ -624,10 +786,13 @@ static void o2nm_cluster_release(struct config_item *item) | |||
624 | 786 | ||
625 | static struct configfs_item_operations o2nm_cluster_item_ops = { | 787 | static struct configfs_item_operations o2nm_cluster_item_ops = { |
626 | .release = o2nm_cluster_release, | 788 | .release = o2nm_cluster_release, |
789 | .show_attribute = o2nm_cluster_show, | ||
790 | .store_attribute = o2nm_cluster_store, | ||
627 | }; | 791 | }; |
628 | 792 | ||
629 | static struct config_item_type o2nm_cluster_type = { | 793 | static struct config_item_type o2nm_cluster_type = { |
630 | .ct_item_ops = &o2nm_cluster_item_ops, | 794 | .ct_item_ops = &o2nm_cluster_item_ops, |
795 | .ct_attrs = o2nm_cluster_attrs, | ||
631 | .ct_owner = THIS_MODULE, | 796 | .ct_owner = THIS_MODULE, |
632 | }; | 797 | }; |
633 | 798 | ||
@@ -660,8 +825,8 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g | |||
660 | if (o2nm_single_cluster) | 825 | if (o2nm_single_cluster) |
661 | goto out; /* ENOSPC */ | 826 | goto out; /* ENOSPC */ |
662 | 827 | ||
663 | cluster = kcalloc(1, sizeof(struct o2nm_cluster), GFP_KERNEL); | 828 | cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); |
664 | ns = kcalloc(1, sizeof(struct o2nm_node_group), GFP_KERNEL); | 829 | ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); |
665 | defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); | 830 | defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); |
666 | o2hb_group = o2hb_alloc_hb_set(); | 831 | o2hb_group = o2hb_alloc_hb_set(); |
667 | if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) | 832 | if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) |
@@ -678,6 +843,9 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g | |||
678 | cluster->cl_group.default_groups[2] = NULL; | 843 | cluster->cl_group.default_groups[2] = NULL; |
679 | rwlock_init(&cluster->cl_nodes_lock); | 844 | rwlock_init(&cluster->cl_nodes_lock); |
680 | cluster->cl_node_ip_tree = RB_ROOT; | 845 | cluster->cl_node_ip_tree = RB_ROOT; |
846 | cluster->cl_reconnect_delay_ms = O2NET_RECONNECT_DELAY_MS_DEFAULT; | ||
847 | cluster->cl_idle_timeout_ms = O2NET_IDLE_TIMEOUT_MS_DEFAULT; | ||
848 | cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT; | ||
681 | 849 | ||
682 | ret = &cluster->cl_group; | 850 | ret = &cluster->cl_group; |
683 | o2nm_single_cluster = cluster; | 851 | o2nm_single_cluster = cluster; |
diff --git a/fs/ocfs2/cluster/nodemanager.h b/fs/ocfs2/cluster/nodemanager.h index fce8033c310f..8fb23cacc2f5 100644 --- a/fs/ocfs2/cluster/nodemanager.h +++ b/fs/ocfs2/cluster/nodemanager.h | |||
@@ -53,6 +53,23 @@ struct o2nm_node { | |||
53 | unsigned long nd_set_attributes; | 53 | unsigned long nd_set_attributes; |
54 | }; | 54 | }; |
55 | 55 | ||
56 | struct o2nm_cluster { | ||
57 | struct config_group cl_group; | ||
58 | unsigned cl_has_local:1; | ||
59 | u8 cl_local_node; | ||
60 | rwlock_t cl_nodes_lock; | ||
61 | struct o2nm_node *cl_nodes[O2NM_MAX_NODES]; | ||
62 | struct rb_root cl_node_ip_tree; | ||
63 | unsigned int cl_idle_timeout_ms; | ||
64 | unsigned int cl_keepalive_delay_ms; | ||
65 | unsigned int cl_reconnect_delay_ms; | ||
66 | |||
67 | /* this bitmap is part of a hack for disk bitmap.. will go eventually. - zab */ | ||
68 | unsigned long cl_nodes_bitmap[BITS_TO_LONGS(O2NM_MAX_NODES)]; | ||
69 | }; | ||
70 | |||
71 | extern struct o2nm_cluster *o2nm_single_cluster; | ||
72 | |||
56 | u8 o2nm_this_node(void); | 73 | u8 o2nm_this_node(void); |
57 | 74 | ||
58 | int o2nm_configured_node_map(unsigned long *map, unsigned bytes); | 75 | int o2nm_configured_node_map(unsigned long *map, unsigned bytes); |
diff --git a/fs/ocfs2/cluster/quorum.c b/fs/ocfs2/cluster/quorum.c index 7bba98fbfc15..4705d659fe57 100644 --- a/fs/ocfs2/cluster/quorum.c +++ b/fs/ocfs2/cluster/quorum.c | |||
@@ -88,7 +88,7 @@ void o2quo_disk_timeout(void) | |||
88 | o2quo_fence_self(); | 88 | o2quo_fence_self(); |
89 | } | 89 | } |
90 | 90 | ||
91 | static void o2quo_make_decision(void *arg) | 91 | static void o2quo_make_decision(struct work_struct *work) |
92 | { | 92 | { |
93 | int quorum; | 93 | int quorum; |
94 | int lowest_hb, lowest_reachable = 0, fence = 0; | 94 | int lowest_hb, lowest_reachable = 0, fence = 0; |
@@ -306,7 +306,7 @@ void o2quo_init(void) | |||
306 | struct o2quo_state *qs = &o2quo_state; | 306 | struct o2quo_state *qs = &o2quo_state; |
307 | 307 | ||
308 | spin_lock_init(&qs->qs_lock); | 308 | spin_lock_init(&qs->qs_lock); |
309 | INIT_WORK(&qs->qs_work, o2quo_make_decision, NULL); | 309 | INIT_WORK(&qs->qs_work, o2quo_make_decision); |
310 | } | 310 | } |
311 | 311 | ||
312 | void o2quo_exit(void) | 312 | void o2quo_exit(void) |
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index b650efa8c8be..ae4ff4a6636b 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
@@ -140,13 +140,35 @@ static int o2net_sys_err_translations[O2NET_ERR_MAX] = | |||
140 | [O2NET_ERR_DIED] = -EHOSTDOWN,}; | 140 | [O2NET_ERR_DIED] = -EHOSTDOWN,}; |
141 | 141 | ||
142 | /* can't quite avoid *all* internal declarations :/ */ | 142 | /* can't quite avoid *all* internal declarations :/ */ |
143 | static void o2net_sc_connect_completed(void *arg); | 143 | static void o2net_sc_connect_completed(struct work_struct *work); |
144 | static void o2net_rx_until_empty(void *arg); | 144 | static void o2net_rx_until_empty(struct work_struct *work); |
145 | static void o2net_shutdown_sc(void *arg); | 145 | static void o2net_shutdown_sc(struct work_struct *work); |
146 | static void o2net_listen_data_ready(struct sock *sk, int bytes); | 146 | static void o2net_listen_data_ready(struct sock *sk, int bytes); |
147 | static void o2net_sc_send_keep_req(void *arg); | 147 | static void o2net_sc_send_keep_req(struct work_struct *work); |
148 | static void o2net_idle_timer(unsigned long data); | 148 | static void o2net_idle_timer(unsigned long data); |
149 | static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); | 149 | static void o2net_sc_postpone_idle(struct o2net_sock_container *sc); |
150 | static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc); | ||
151 | |||
152 | /* | ||
153 | * FIXME: These should use to_o2nm_cluster_from_node(), but we end up | ||
154 | * losing our parent link to the cluster during shutdown. This can be | ||
155 | * solved by adding a pre-removal callback to configfs, or passing | ||
156 | * around the cluster with the node. -jeffm | ||
157 | */ | ||
158 | static inline int o2net_reconnect_delay(struct o2nm_node *node) | ||
159 | { | ||
160 | return o2nm_single_cluster->cl_reconnect_delay_ms; | ||
161 | } | ||
162 | |||
163 | static inline int o2net_keepalive_delay(struct o2nm_node *node) | ||
164 | { | ||
165 | return o2nm_single_cluster->cl_keepalive_delay_ms; | ||
166 | } | ||
167 | |||
168 | static inline int o2net_idle_timeout(struct o2nm_node *node) | ||
169 | { | ||
170 | return o2nm_single_cluster->cl_idle_timeout_ms; | ||
171 | } | ||
150 | 172 | ||
151 | static inline int o2net_sys_err_to_errno(enum o2net_system_error err) | 173 | static inline int o2net_sys_err_to_errno(enum o2net_system_error err) |
152 | { | 174 | { |
@@ -271,6 +293,8 @@ static void sc_kref_release(struct kref *kref) | |||
271 | { | 293 | { |
272 | struct o2net_sock_container *sc = container_of(kref, | 294 | struct o2net_sock_container *sc = container_of(kref, |
273 | struct o2net_sock_container, sc_kref); | 295 | struct o2net_sock_container, sc_kref); |
296 | BUG_ON(timer_pending(&sc->sc_idle_timeout)); | ||
297 | |||
274 | sclog(sc, "releasing\n"); | 298 | sclog(sc, "releasing\n"); |
275 | 299 | ||
276 | if (sc->sc_sock) { | 300 | if (sc->sc_sock) { |
@@ -300,7 +324,7 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node) | |||
300 | struct page *page = NULL; | 324 | struct page *page = NULL; |
301 | 325 | ||
302 | page = alloc_page(GFP_NOFS); | 326 | page = alloc_page(GFP_NOFS); |
303 | sc = kcalloc(1, sizeof(*sc), GFP_NOFS); | 327 | sc = kzalloc(sizeof(*sc), GFP_NOFS); |
304 | if (sc == NULL || page == NULL) | 328 | if (sc == NULL || page == NULL) |
305 | goto out; | 329 | goto out; |
306 | 330 | ||
@@ -308,10 +332,10 @@ static struct o2net_sock_container *sc_alloc(struct o2nm_node *node) | |||
308 | o2nm_node_get(node); | 332 | o2nm_node_get(node); |
309 | sc->sc_node = node; | 333 | sc->sc_node = node; |
310 | 334 | ||
311 | INIT_WORK(&sc->sc_connect_work, o2net_sc_connect_completed, sc); | 335 | INIT_WORK(&sc->sc_connect_work, o2net_sc_connect_completed); |
312 | INIT_WORK(&sc->sc_rx_work, o2net_rx_until_empty, sc); | 336 | INIT_WORK(&sc->sc_rx_work, o2net_rx_until_empty); |
313 | INIT_WORK(&sc->sc_shutdown_work, o2net_shutdown_sc, sc); | 337 | INIT_WORK(&sc->sc_shutdown_work, o2net_shutdown_sc); |
314 | INIT_WORK(&sc->sc_keepalive_work, o2net_sc_send_keep_req, sc); | 338 | INIT_DELAYED_WORK(&sc->sc_keepalive_work, o2net_sc_send_keep_req); |
315 | 339 | ||
316 | init_timer(&sc->sc_idle_timeout); | 340 | init_timer(&sc->sc_idle_timeout); |
317 | sc->sc_idle_timeout.function = o2net_idle_timer; | 341 | sc->sc_idle_timeout.function = o2net_idle_timer; |
@@ -342,7 +366,7 @@ static void o2net_sc_queue_work(struct o2net_sock_container *sc, | |||
342 | sc_put(sc); | 366 | sc_put(sc); |
343 | } | 367 | } |
344 | static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc, | 368 | static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc, |
345 | struct work_struct *work, | 369 | struct delayed_work *work, |
346 | int delay) | 370 | int delay) |
347 | { | 371 | { |
348 | sc_get(sc); | 372 | sc_get(sc); |
@@ -350,12 +374,19 @@ static void o2net_sc_queue_delayed_work(struct o2net_sock_container *sc, | |||
350 | sc_put(sc); | 374 | sc_put(sc); |
351 | } | 375 | } |
352 | static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc, | 376 | static void o2net_sc_cancel_delayed_work(struct o2net_sock_container *sc, |
353 | struct work_struct *work) | 377 | struct delayed_work *work) |
354 | { | 378 | { |
355 | if (cancel_delayed_work(work)) | 379 | if (cancel_delayed_work(work)) |
356 | sc_put(sc); | 380 | sc_put(sc); |
357 | } | 381 | } |
358 | 382 | ||
383 | static atomic_t o2net_connected_peers = ATOMIC_INIT(0); | ||
384 | |||
385 | int o2net_num_connected_peers(void) | ||
386 | { | ||
387 | return atomic_read(&o2net_connected_peers); | ||
388 | } | ||
389 | |||
359 | static void o2net_set_nn_state(struct o2net_node *nn, | 390 | static void o2net_set_nn_state(struct o2net_node *nn, |
360 | struct o2net_sock_container *sc, | 391 | struct o2net_sock_container *sc, |
361 | unsigned valid, int err) | 392 | unsigned valid, int err) |
@@ -366,6 +397,11 @@ static void o2net_set_nn_state(struct o2net_node *nn, | |||
366 | 397 | ||
367 | assert_spin_locked(&nn->nn_lock); | 398 | assert_spin_locked(&nn->nn_lock); |
368 | 399 | ||
400 | if (old_sc && !sc) | ||
401 | atomic_dec(&o2net_connected_peers); | ||
402 | else if (!old_sc && sc) | ||
403 | atomic_inc(&o2net_connected_peers); | ||
404 | |||
369 | /* the node num comparison and single connect/accept path should stop | 405 | /* the node num comparison and single connect/accept path should stop |
370 | * an non-null sc from being overwritten with another */ | 406 | * an non-null sc from being overwritten with another */ |
371 | BUG_ON(sc && nn->nn_sc && nn->nn_sc != sc); | 407 | BUG_ON(sc && nn->nn_sc && nn->nn_sc != sc); |
@@ -424,9 +460,9 @@ static void o2net_set_nn_state(struct o2net_node *nn, | |||
424 | /* delay if we're withing a RECONNECT_DELAY of the | 460 | /* delay if we're withing a RECONNECT_DELAY of the |
425 | * last attempt */ | 461 | * last attempt */ |
426 | delay = (nn->nn_last_connect_attempt + | 462 | delay = (nn->nn_last_connect_attempt + |
427 | msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS)) | 463 | msecs_to_jiffies(o2net_reconnect_delay(sc->sc_node))) |
428 | - jiffies; | 464 | - jiffies; |
429 | if (delay > msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS)) | 465 | if (delay > msecs_to_jiffies(o2net_reconnect_delay(sc->sc_node))) |
430 | delay = 0; | 466 | delay = 0; |
431 | mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay); | 467 | mlog(ML_CONN, "queueing conn attempt in %lu jiffies\n", delay); |
432 | queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay); | 468 | queue_delayed_work(o2net_wq, &nn->nn_connect_work, delay); |
@@ -564,9 +600,11 @@ static void o2net_ensure_shutdown(struct o2net_node *nn, | |||
564 | * ourselves as state_change couldn't get the nn_lock and call set_nn_state | 600 | * ourselves as state_change couldn't get the nn_lock and call set_nn_state |
565 | * itself. | 601 | * itself. |
566 | */ | 602 | */ |
567 | static void o2net_shutdown_sc(void *arg) | 603 | static void o2net_shutdown_sc(struct work_struct *work) |
568 | { | 604 | { |
569 | struct o2net_sock_container *sc = arg; | 605 | struct o2net_sock_container *sc = |
606 | container_of(work, struct o2net_sock_container, | ||
607 | sc_shutdown_work); | ||
570 | struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); | 608 | struct o2net_node *nn = o2net_nn_from_num(sc->sc_node->nd_num); |
571 | 609 | ||
572 | sclog(sc, "shutting down\n"); | 610 | sclog(sc, "shutting down\n"); |
@@ -676,7 +714,7 @@ int o2net_register_handler(u32 msg_type, u32 key, u32 max_len, | |||
676 | goto out; | 714 | goto out; |
677 | } | 715 | } |
678 | 716 | ||
679 | nmh = kcalloc(1, sizeof(struct o2net_msg_handler), GFP_NOFS); | 717 | nmh = kzalloc(sizeof(struct o2net_msg_handler), GFP_NOFS); |
680 | if (nmh == NULL) { | 718 | if (nmh == NULL) { |
681 | ret = -ENOMEM; | 719 | ret = -ENOMEM; |
682 | goto out; | 720 | goto out; |
@@ -1097,13 +1135,51 @@ static int o2net_check_handshake(struct o2net_sock_container *sc) | |||
1097 | return -1; | 1135 | return -1; |
1098 | } | 1136 | } |
1099 | 1137 | ||
1138 | /* | ||
1139 | * Ensure timeouts are consistent with other nodes, otherwise | ||
1140 | * we can end up with one node thinking that the other must be down, | ||
1141 | * but isn't. This can ultimately cause corruption. | ||
1142 | */ | ||
1143 | if (be32_to_cpu(hand->o2net_idle_timeout_ms) != | ||
1144 | o2net_idle_timeout(sc->sc_node)) { | ||
1145 | mlog(ML_NOTICE, SC_NODEF_FMT " uses a network idle timeout of " | ||
1146 | "%u ms, but we use %u ms locally. disconnecting\n", | ||
1147 | SC_NODEF_ARGS(sc), | ||
1148 | be32_to_cpu(hand->o2net_idle_timeout_ms), | ||
1149 | o2net_idle_timeout(sc->sc_node)); | ||
1150 | o2net_ensure_shutdown(nn, sc, -ENOTCONN); | ||
1151 | return -1; | ||
1152 | } | ||
1153 | |||
1154 | if (be32_to_cpu(hand->o2net_keepalive_delay_ms) != | ||
1155 | o2net_keepalive_delay(sc->sc_node)) { | ||
1156 | mlog(ML_NOTICE, SC_NODEF_FMT " uses a keepalive delay of " | ||
1157 | "%u ms, but we use %u ms locally. disconnecting\n", | ||
1158 | SC_NODEF_ARGS(sc), | ||
1159 | be32_to_cpu(hand->o2net_keepalive_delay_ms), | ||
1160 | o2net_keepalive_delay(sc->sc_node)); | ||
1161 | o2net_ensure_shutdown(nn, sc, -ENOTCONN); | ||
1162 | return -1; | ||
1163 | } | ||
1164 | |||
1165 | if (be32_to_cpu(hand->o2hb_heartbeat_timeout_ms) != | ||
1166 | O2HB_MAX_WRITE_TIMEOUT_MS) { | ||
1167 | mlog(ML_NOTICE, SC_NODEF_FMT " uses a heartbeat timeout of " | ||
1168 | "%u ms, but we use %u ms locally. disconnecting\n", | ||
1169 | SC_NODEF_ARGS(sc), | ||
1170 | be32_to_cpu(hand->o2hb_heartbeat_timeout_ms), | ||
1171 | O2HB_MAX_WRITE_TIMEOUT_MS); | ||
1172 | o2net_ensure_shutdown(nn, sc, -ENOTCONN); | ||
1173 | return -1; | ||
1174 | } | ||
1175 | |||
1100 | sc->sc_handshake_ok = 1; | 1176 | sc->sc_handshake_ok = 1; |
1101 | 1177 | ||
1102 | spin_lock(&nn->nn_lock); | 1178 | spin_lock(&nn->nn_lock); |
1103 | /* set valid and queue the idle timers only if it hasn't been | 1179 | /* set valid and queue the idle timers only if it hasn't been |
1104 | * shut down already */ | 1180 | * shut down already */ |
1105 | if (nn->nn_sc == sc) { | 1181 | if (nn->nn_sc == sc) { |
1106 | o2net_sc_postpone_idle(sc); | 1182 | o2net_sc_reset_idle_timer(sc); |
1107 | o2net_set_nn_state(nn, sc, 1, 0); | 1183 | o2net_set_nn_state(nn, sc, 1, 0); |
1108 | } | 1184 | } |
1109 | spin_unlock(&nn->nn_lock); | 1185 | spin_unlock(&nn->nn_lock); |
@@ -1129,6 +1205,23 @@ static int o2net_advance_rx(struct o2net_sock_container *sc) | |||
1129 | sclog(sc, "receiving\n"); | 1205 | sclog(sc, "receiving\n"); |
1130 | do_gettimeofday(&sc->sc_tv_advance_start); | 1206 | do_gettimeofday(&sc->sc_tv_advance_start); |
1131 | 1207 | ||
1208 | if (unlikely(sc->sc_handshake_ok == 0)) { | ||
1209 | if(sc->sc_page_off < sizeof(struct o2net_handshake)) { | ||
1210 | data = page_address(sc->sc_page) + sc->sc_page_off; | ||
1211 | datalen = sizeof(struct o2net_handshake) - sc->sc_page_off; | ||
1212 | ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen); | ||
1213 | if (ret > 0) | ||
1214 | sc->sc_page_off += ret; | ||
1215 | } | ||
1216 | |||
1217 | if (sc->sc_page_off == sizeof(struct o2net_handshake)) { | ||
1218 | o2net_check_handshake(sc); | ||
1219 | if (unlikely(sc->sc_handshake_ok == 0)) | ||
1220 | ret = -EPROTO; | ||
1221 | } | ||
1222 | goto out; | ||
1223 | } | ||
1224 | |||
1132 | /* do we need more header? */ | 1225 | /* do we need more header? */ |
1133 | if (sc->sc_page_off < sizeof(struct o2net_msg)) { | 1226 | if (sc->sc_page_off < sizeof(struct o2net_msg)) { |
1134 | data = page_address(sc->sc_page) + sc->sc_page_off; | 1227 | data = page_address(sc->sc_page) + sc->sc_page_off; |
@@ -1136,15 +1229,6 @@ static int o2net_advance_rx(struct o2net_sock_container *sc) | |||
1136 | ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen); | 1229 | ret = o2net_recv_tcp_msg(sc->sc_sock, data, datalen); |
1137 | if (ret > 0) { | 1230 | if (ret > 0) { |
1138 | sc->sc_page_off += ret; | 1231 | sc->sc_page_off += ret; |
1139 | |||
1140 | /* this working relies on the handshake being | ||
1141 | * smaller than the normal message header */ | ||
1142 | if (sc->sc_page_off >= sizeof(struct o2net_handshake)&& | ||
1143 | !sc->sc_handshake_ok && o2net_check_handshake(sc)) { | ||
1144 | ret = -EPROTO; | ||
1145 | goto out; | ||
1146 | } | ||
1147 | |||
1148 | /* only swab incoming here.. we can | 1232 | /* only swab incoming here.. we can |
1149 | * only get here once as we cross from | 1233 | * only get here once as we cross from |
1150 | * being under to over */ | 1234 | * being under to over */ |
@@ -1201,9 +1285,10 @@ out: | |||
1201 | /* this work func is triggerd by data ready. it reads until it can read no | 1285 | /* this work func is triggerd by data ready. it reads until it can read no |
1202 | * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing | 1286 | * more. it interprets 0, eof, as fatal. if data_ready hits while we're doing |
1203 | * our work the work struct will be marked and we'll be called again. */ | 1287 | * our work the work struct will be marked and we'll be called again. */ |
1204 | static void o2net_rx_until_empty(void *arg) | 1288 | static void o2net_rx_until_empty(struct work_struct *work) |
1205 | { | 1289 | { |
1206 | struct o2net_sock_container *sc = arg; | 1290 | struct o2net_sock_container *sc = |
1291 | container_of(work, struct o2net_sock_container, sc_rx_work); | ||
1207 | int ret; | 1292 | int ret; |
1208 | 1293 | ||
1209 | do { | 1294 | do { |
@@ -1245,26 +1330,43 @@ static int o2net_set_nodelay(struct socket *sock) | |||
1245 | return ret; | 1330 | return ret; |
1246 | } | 1331 | } |
1247 | 1332 | ||
1333 | static void o2net_initialize_handshake(void) | ||
1334 | { | ||
1335 | o2net_hand->o2hb_heartbeat_timeout_ms = cpu_to_be32( | ||
1336 | O2HB_MAX_WRITE_TIMEOUT_MS); | ||
1337 | o2net_hand->o2net_idle_timeout_ms = cpu_to_be32( | ||
1338 | o2net_idle_timeout(NULL)); | ||
1339 | o2net_hand->o2net_keepalive_delay_ms = cpu_to_be32( | ||
1340 | o2net_keepalive_delay(NULL)); | ||
1341 | o2net_hand->o2net_reconnect_delay_ms = cpu_to_be32( | ||
1342 | o2net_reconnect_delay(NULL)); | ||
1343 | } | ||
1344 | |||
1248 | /* ------------------------------------------------------------ */ | 1345 | /* ------------------------------------------------------------ */ |
1249 | 1346 | ||
1250 | /* called when a connect completes and after a sock is accepted. the | 1347 | /* called when a connect completes and after a sock is accepted. the |
1251 | * rx path will see the response and mark the sc valid */ | 1348 | * rx path will see the response and mark the sc valid */ |
1252 | static void o2net_sc_connect_completed(void *arg) | 1349 | static void o2net_sc_connect_completed(struct work_struct *work) |
1253 | { | 1350 | { |
1254 | struct o2net_sock_container *sc = arg; | 1351 | struct o2net_sock_container *sc = |
1352 | container_of(work, struct o2net_sock_container, | ||
1353 | sc_connect_work); | ||
1255 | 1354 | ||
1256 | mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n", | 1355 | mlog(ML_MSG, "sc sending handshake with ver %llu id %llx\n", |
1257 | (unsigned long long)O2NET_PROTOCOL_VERSION, | 1356 | (unsigned long long)O2NET_PROTOCOL_VERSION, |
1258 | (unsigned long long)be64_to_cpu(o2net_hand->connector_id)); | 1357 | (unsigned long long)be64_to_cpu(o2net_hand->connector_id)); |
1259 | 1358 | ||
1359 | o2net_initialize_handshake(); | ||
1260 | o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); | 1360 | o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); |
1261 | sc_put(sc); | 1361 | sc_put(sc); |
1262 | } | 1362 | } |
1263 | 1363 | ||
1264 | /* this is called as a work_struct func. */ | 1364 | /* this is called as a work_struct func. */ |
1265 | static void o2net_sc_send_keep_req(void *arg) | 1365 | static void o2net_sc_send_keep_req(struct work_struct *work) |
1266 | { | 1366 | { |
1267 | struct o2net_sock_container *sc = arg; | 1367 | struct o2net_sock_container *sc = |
1368 | container_of(work, struct o2net_sock_container, | ||
1369 | sc_keepalive_work.work); | ||
1268 | 1370 | ||
1269 | o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req)); | 1371 | o2net_sendpage(sc, o2net_keep_req, sizeof(*o2net_keep_req)); |
1270 | sc_put(sc); | 1372 | sc_put(sc); |
@@ -1280,8 +1382,10 @@ static void o2net_idle_timer(unsigned long data) | |||
1280 | 1382 | ||
1281 | do_gettimeofday(&now); | 1383 | do_gettimeofday(&now); |
1282 | 1384 | ||
1283 | printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT " has been idle for 10 " | 1385 | printk(KERN_INFO "o2net: connection to " SC_NODEF_FMT " has been idle for %u.%u " |
1284 | "seconds, shutting it down.\n", SC_NODEF_ARGS(sc)); | 1386 | "seconds, shutting it down.\n", SC_NODEF_ARGS(sc), |
1387 | o2net_idle_timeout(sc->sc_node) / 1000, | ||
1388 | o2net_idle_timeout(sc->sc_node) % 1000); | ||
1285 | mlog(ML_NOTICE, "here are some times that might help debug the " | 1389 | mlog(ML_NOTICE, "here are some times that might help debug the " |
1286 | "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv " | 1390 | "situation: (tmr %ld.%ld now %ld.%ld dr %ld.%ld adv " |
1287 | "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n", | 1391 | "%ld.%ld:%ld.%ld func (%08x:%u) %ld.%ld:%ld.%ld)\n", |
@@ -1299,14 +1403,21 @@ static void o2net_idle_timer(unsigned long data) | |||
1299 | o2net_sc_queue_work(sc, &sc->sc_shutdown_work); | 1403 | o2net_sc_queue_work(sc, &sc->sc_shutdown_work); |
1300 | } | 1404 | } |
1301 | 1405 | ||
1302 | static void o2net_sc_postpone_idle(struct o2net_sock_container *sc) | 1406 | static void o2net_sc_reset_idle_timer(struct o2net_sock_container *sc) |
1303 | { | 1407 | { |
1304 | o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); | 1408 | o2net_sc_cancel_delayed_work(sc, &sc->sc_keepalive_work); |
1305 | o2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work, | 1409 | o2net_sc_queue_delayed_work(sc, &sc->sc_keepalive_work, |
1306 | O2NET_KEEPALIVE_DELAY_SECS * HZ); | 1410 | msecs_to_jiffies(o2net_keepalive_delay(sc->sc_node))); |
1307 | do_gettimeofday(&sc->sc_tv_timer); | 1411 | do_gettimeofday(&sc->sc_tv_timer); |
1308 | mod_timer(&sc->sc_idle_timeout, | 1412 | mod_timer(&sc->sc_idle_timeout, |
1309 | jiffies + (O2NET_IDLE_TIMEOUT_SECS * HZ)); | 1413 | jiffies + msecs_to_jiffies(o2net_idle_timeout(sc->sc_node))); |
1414 | } | ||
1415 | |||
1416 | static void o2net_sc_postpone_idle(struct o2net_sock_container *sc) | ||
1417 | { | ||
1418 | /* Only push out an existing timer */ | ||
1419 | if (timer_pending(&sc->sc_idle_timeout)) | ||
1420 | o2net_sc_reset_idle_timer(sc); | ||
1310 | } | 1421 | } |
1311 | 1422 | ||
1312 | /* this work func is kicked whenever a path sets the nn state which doesn't | 1423 | /* this work func is kicked whenever a path sets the nn state which doesn't |
@@ -1314,14 +1425,15 @@ static void o2net_sc_postpone_idle(struct o2net_sock_container *sc) | |||
1314 | * having a connect attempt fail, etc. This centralizes the logic which decides | 1425 | * having a connect attempt fail, etc. This centralizes the logic which decides |
1315 | * if a connect attempt should be made or if we should give up and all future | 1426 | * if a connect attempt should be made or if we should give up and all future |
1316 | * transmit attempts should fail */ | 1427 | * transmit attempts should fail */ |
1317 | static void o2net_start_connect(void *arg) | 1428 | static void o2net_start_connect(struct work_struct *work) |
1318 | { | 1429 | { |
1319 | struct o2net_node *nn = arg; | 1430 | struct o2net_node *nn = |
1431 | container_of(work, struct o2net_node, nn_connect_work.work); | ||
1320 | struct o2net_sock_container *sc = NULL; | 1432 | struct o2net_sock_container *sc = NULL; |
1321 | struct o2nm_node *node = NULL, *mynode = NULL; | 1433 | struct o2nm_node *node = NULL, *mynode = NULL; |
1322 | struct socket *sock = NULL; | 1434 | struct socket *sock = NULL; |
1323 | struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; | 1435 | struct sockaddr_in myaddr = {0, }, remoteaddr = {0, }; |
1324 | int ret = 0; | 1436 | int ret = 0, stop; |
1325 | 1437 | ||
1326 | /* if we're greater we initiate tx, otherwise we accept */ | 1438 | /* if we're greater we initiate tx, otherwise we accept */ |
1327 | if (o2nm_this_node() <= o2net_num_from_nn(nn)) | 1439 | if (o2nm_this_node() <= o2net_num_from_nn(nn)) |
@@ -1342,10 +1454,9 @@ static void o2net_start_connect(void *arg) | |||
1342 | 1454 | ||
1343 | spin_lock(&nn->nn_lock); | 1455 | spin_lock(&nn->nn_lock); |
1344 | /* see if we already have one pending or have given up */ | 1456 | /* see if we already have one pending or have given up */ |
1345 | if (nn->nn_sc || nn->nn_persistent_error) | 1457 | stop = (nn->nn_sc || nn->nn_persistent_error); |
1346 | arg = NULL; | ||
1347 | spin_unlock(&nn->nn_lock); | 1458 | spin_unlock(&nn->nn_lock); |
1348 | if (arg == NULL) /* *shrug*, needed some indicator */ | 1459 | if (stop) |
1349 | goto out; | 1460 | goto out; |
1350 | 1461 | ||
1351 | nn->nn_last_connect_attempt = jiffies; | 1462 | nn->nn_last_connect_attempt = jiffies; |
@@ -1421,24 +1532,29 @@ out: | |||
1421 | return; | 1532 | return; |
1422 | } | 1533 | } |
1423 | 1534 | ||
1424 | static void o2net_connect_expired(void *arg) | 1535 | static void o2net_connect_expired(struct work_struct *work) |
1425 | { | 1536 | { |
1426 | struct o2net_node *nn = arg; | 1537 | struct o2net_node *nn = |
1538 | container_of(work, struct o2net_node, nn_connect_expired.work); | ||
1427 | 1539 | ||
1428 | spin_lock(&nn->nn_lock); | 1540 | spin_lock(&nn->nn_lock); |
1429 | if (!nn->nn_sc_valid) { | 1541 | if (!nn->nn_sc_valid) { |
1542 | struct o2nm_node *node = nn->nn_sc->sc_node; | ||
1430 | mlog(ML_ERROR, "no connection established with node %u after " | 1543 | mlog(ML_ERROR, "no connection established with node %u after " |
1431 | "%u seconds, giving up and returning errors.\n", | 1544 | "%u.%u seconds, giving up and returning errors.\n", |
1432 | o2net_num_from_nn(nn), O2NET_IDLE_TIMEOUT_SECS); | 1545 | o2net_num_from_nn(nn), |
1546 | o2net_idle_timeout(node) / 1000, | ||
1547 | o2net_idle_timeout(node) % 1000); | ||
1433 | 1548 | ||
1434 | o2net_set_nn_state(nn, NULL, 0, -ENOTCONN); | 1549 | o2net_set_nn_state(nn, NULL, 0, -ENOTCONN); |
1435 | } | 1550 | } |
1436 | spin_unlock(&nn->nn_lock); | 1551 | spin_unlock(&nn->nn_lock); |
1437 | } | 1552 | } |
1438 | 1553 | ||
1439 | static void o2net_still_up(void *arg) | 1554 | static void o2net_still_up(struct work_struct *work) |
1440 | { | 1555 | { |
1441 | struct o2net_node *nn = arg; | 1556 | struct o2net_node *nn = |
1557 | container_of(work, struct o2net_node, nn_still_up.work); | ||
1442 | 1558 | ||
1443 | o2quo_hb_still_up(o2net_num_from_nn(nn)); | 1559 | o2quo_hb_still_up(o2net_num_from_nn(nn)); |
1444 | } | 1560 | } |
@@ -1469,6 +1585,8 @@ static void o2net_hb_node_down_cb(struct o2nm_node *node, int node_num, | |||
1469 | 1585 | ||
1470 | if (node_num != o2nm_this_node()) | 1586 | if (node_num != o2nm_this_node()) |
1471 | o2net_disconnect_node(node); | 1587 | o2net_disconnect_node(node); |
1588 | |||
1589 | BUG_ON(atomic_read(&o2net_connected_peers) < 0); | ||
1472 | } | 1590 | } |
1473 | 1591 | ||
1474 | static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num, | 1592 | static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num, |
@@ -1480,14 +1598,14 @@ static void o2net_hb_node_up_cb(struct o2nm_node *node, int node_num, | |||
1480 | 1598 | ||
1481 | /* ensure an immediate connect attempt */ | 1599 | /* ensure an immediate connect attempt */ |
1482 | nn->nn_last_connect_attempt = jiffies - | 1600 | nn->nn_last_connect_attempt = jiffies - |
1483 | (msecs_to_jiffies(O2NET_RECONNECT_DELAY_MS) + 1); | 1601 | (msecs_to_jiffies(o2net_reconnect_delay(node)) + 1); |
1484 | 1602 | ||
1485 | if (node_num != o2nm_this_node()) { | 1603 | if (node_num != o2nm_this_node()) { |
1486 | /* heartbeat doesn't work unless a local node number is | 1604 | /* heartbeat doesn't work unless a local node number is |
1487 | * configured and doing so brings up the o2net_wq, so we can | 1605 | * configured and doing so brings up the o2net_wq, so we can |
1488 | * use it.. */ | 1606 | * use it.. */ |
1489 | queue_delayed_work(o2net_wq, &nn->nn_connect_expired, | 1607 | queue_delayed_work(o2net_wq, &nn->nn_connect_expired, |
1490 | O2NET_IDLE_TIMEOUT_SECS * HZ); | 1608 | msecs_to_jiffies(o2net_idle_timeout(node))); |
1491 | 1609 | ||
1492 | /* believe it or not, accept and node hearbeating testing | 1610 | /* believe it or not, accept and node hearbeating testing |
1493 | * can succeed for this node before we got here.. so | 1611 | * can succeed for this node before we got here.. so |
@@ -1632,6 +1750,7 @@ static int o2net_accept_one(struct socket *sock) | |||
1632 | o2net_register_callbacks(sc->sc_sock->sk, sc); | 1750 | o2net_register_callbacks(sc->sc_sock->sk, sc); |
1633 | o2net_sc_queue_work(sc, &sc->sc_rx_work); | 1751 | o2net_sc_queue_work(sc, &sc->sc_rx_work); |
1634 | 1752 | ||
1753 | o2net_initialize_handshake(); | ||
1635 | o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); | 1754 | o2net_sendpage(sc, o2net_hand, sizeof(*o2net_hand)); |
1636 | 1755 | ||
1637 | out: | 1756 | out: |
@@ -1644,9 +1763,9 @@ out: | |||
1644 | return ret; | 1763 | return ret; |
1645 | } | 1764 | } |
1646 | 1765 | ||
1647 | static void o2net_accept_many(void *arg) | 1766 | static void o2net_accept_many(struct work_struct *work) |
1648 | { | 1767 | { |
1649 | struct socket *sock = arg; | 1768 | struct socket *sock = o2net_listen_sock; |
1650 | while (o2net_accept_one(sock) == 0) | 1769 | while (o2net_accept_one(sock) == 0) |
1651 | cond_resched(); | 1770 | cond_resched(); |
1652 | } | 1771 | } |
@@ -1700,7 +1819,7 @@ static int o2net_open_listening_sock(__be16 port) | |||
1700 | write_unlock_bh(&sock->sk->sk_callback_lock); | 1819 | write_unlock_bh(&sock->sk->sk_callback_lock); |
1701 | 1820 | ||
1702 | o2net_listen_sock = sock; | 1821 | o2net_listen_sock = sock; |
1703 | INIT_WORK(&o2net_listen_work, o2net_accept_many, sock); | 1822 | INIT_WORK(&o2net_listen_work, o2net_accept_many); |
1704 | 1823 | ||
1705 | sock->sk->sk_reuse = 1; | 1824 | sock->sk->sk_reuse = 1; |
1706 | ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); | 1825 | ret = sock->ops->bind(sock, (struct sockaddr *)&sin, sizeof(sin)); |
@@ -1799,9 +1918,9 @@ int o2net_init(void) | |||
1799 | 1918 | ||
1800 | o2quo_init(); | 1919 | o2quo_init(); |
1801 | 1920 | ||
1802 | o2net_hand = kcalloc(1, sizeof(struct o2net_handshake), GFP_KERNEL); | 1921 | o2net_hand = kzalloc(sizeof(struct o2net_handshake), GFP_KERNEL); |
1803 | o2net_keep_req = kcalloc(1, sizeof(struct o2net_msg), GFP_KERNEL); | 1922 | o2net_keep_req = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); |
1804 | o2net_keep_resp = kcalloc(1, sizeof(struct o2net_msg), GFP_KERNEL); | 1923 | o2net_keep_resp = kzalloc(sizeof(struct o2net_msg), GFP_KERNEL); |
1805 | if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) { | 1924 | if (!o2net_hand || !o2net_keep_req || !o2net_keep_resp) { |
1806 | kfree(o2net_hand); | 1925 | kfree(o2net_hand); |
1807 | kfree(o2net_keep_req); | 1926 | kfree(o2net_keep_req); |
@@ -1819,9 +1938,10 @@ int o2net_init(void) | |||
1819 | struct o2net_node *nn = o2net_nn_from_num(i); | 1938 | struct o2net_node *nn = o2net_nn_from_num(i); |
1820 | 1939 | ||
1821 | spin_lock_init(&nn->nn_lock); | 1940 | spin_lock_init(&nn->nn_lock); |
1822 | INIT_WORK(&nn->nn_connect_work, o2net_start_connect, nn); | 1941 | INIT_DELAYED_WORK(&nn->nn_connect_work, o2net_start_connect); |
1823 | INIT_WORK(&nn->nn_connect_expired, o2net_connect_expired, nn); | 1942 | INIT_DELAYED_WORK(&nn->nn_connect_expired, |
1824 | INIT_WORK(&nn->nn_still_up, o2net_still_up, nn); | 1943 | o2net_connect_expired); |
1944 | INIT_DELAYED_WORK(&nn->nn_still_up, o2net_still_up); | ||
1825 | /* until we see hb from a node we'll return einval */ | 1945 | /* until we see hb from a node we'll return einval */ |
1826 | nn->nn_persistent_error = -ENOTCONN; | 1946 | nn->nn_persistent_error = -ENOTCONN; |
1827 | init_waitqueue_head(&nn->nn_sc_wq); | 1947 | init_waitqueue_head(&nn->nn_sc_wq); |
diff --git a/fs/ocfs2/cluster/tcp.h b/fs/ocfs2/cluster/tcp.h index 616ff2b8434a..21a4e43df836 100644 --- a/fs/ocfs2/cluster/tcp.h +++ b/fs/ocfs2/cluster/tcp.h | |||
@@ -54,6 +54,13 @@ typedef int (o2net_msg_handler_func)(struct o2net_msg *msg, u32 len, void *data) | |||
54 | 54 | ||
55 | #define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg)) | 55 | #define O2NET_MAX_PAYLOAD_BYTES (4096 - sizeof(struct o2net_msg)) |
56 | 56 | ||
57 | /* same as hb delay, we're waiting for another node to recognize our hb */ | ||
58 | #define O2NET_RECONNECT_DELAY_MS_DEFAULT 2000 | ||
59 | |||
60 | #define O2NET_KEEPALIVE_DELAY_MS_DEFAULT 5000 | ||
61 | #define O2NET_IDLE_TIMEOUT_MS_DEFAULT 10000 | ||
62 | |||
63 | |||
57 | /* TODO: figure this out.... */ | 64 | /* TODO: figure this out.... */ |
58 | static inline int o2net_link_down(int err, struct socket *sock) | 65 | static inline int o2net_link_down(int err, struct socket *sock) |
59 | { | 66 | { |
@@ -101,6 +108,7 @@ void o2net_unregister_hb_callbacks(void); | |||
101 | int o2net_start_listening(struct o2nm_node *node); | 108 | int o2net_start_listening(struct o2nm_node *node); |
102 | void o2net_stop_listening(struct o2nm_node *node); | 109 | void o2net_stop_listening(struct o2nm_node *node); |
103 | void o2net_disconnect_node(struct o2nm_node *node); | 110 | void o2net_disconnect_node(struct o2nm_node *node); |
111 | int o2net_num_connected_peers(void); | ||
104 | 112 | ||
105 | int o2net_init(void); | 113 | int o2net_init(void); |
106 | void o2net_exit(void); | 114 | void o2net_exit(void); |
diff --git a/fs/ocfs2/cluster/tcp_internal.h b/fs/ocfs2/cluster/tcp_internal.h index 4b46aac7d243..b700dc9624d1 100644 --- a/fs/ocfs2/cluster/tcp_internal.h +++ b/fs/ocfs2/cluster/tcp_internal.h | |||
@@ -27,23 +27,20 @@ | |||
27 | #define O2NET_MSG_KEEP_REQ_MAGIC ((u16)0xfa57) | 27 | #define O2NET_MSG_KEEP_REQ_MAGIC ((u16)0xfa57) |
28 | #define O2NET_MSG_KEEP_RESP_MAGIC ((u16)0xfa58) | 28 | #define O2NET_MSG_KEEP_RESP_MAGIC ((u16)0xfa58) |
29 | 29 | ||
30 | /* same as hb delay, we're waiting for another node to recognize our hb */ | ||
31 | #define O2NET_RECONNECT_DELAY_MS O2HB_REGION_TIMEOUT_MS | ||
32 | |||
33 | /* we're delaying our quorum decision so that heartbeat will have timed | 30 | /* we're delaying our quorum decision so that heartbeat will have timed |
34 | * out truly dead nodes by the time we come around to making decisions | 31 | * out truly dead nodes by the time we come around to making decisions |
35 | * on their number */ | 32 | * on their number */ |
36 | #define O2NET_QUORUM_DELAY_MS ((o2hb_dead_threshold + 2) * O2HB_REGION_TIMEOUT_MS) | 33 | #define O2NET_QUORUM_DELAY_MS ((o2hb_dead_threshold + 2) * O2HB_REGION_TIMEOUT_MS) |
37 | 34 | ||
38 | #define O2NET_KEEPALIVE_DELAY_SECS 5 | ||
39 | #define O2NET_IDLE_TIMEOUT_SECS 10 | ||
40 | |||
41 | /* | 35 | /* |
42 | * This version number represents quite a lot, unfortunately. It not | 36 | * This version number represents quite a lot, unfortunately. It not |
43 | * only represents the raw network message protocol on the wire but also | 37 | * only represents the raw network message protocol on the wire but also |
44 | * locking semantics of the file system using the protocol. It should | 38 | * locking semantics of the file system using the protocol. It should |
45 | * be somewhere else, I'm sure, but right now it isn't. | 39 | * be somewhere else, I'm sure, but right now it isn't. |
46 | * | 40 | * |
41 | * New in version 5: | ||
42 | * - Network timeout checking protocol | ||
43 | * | ||
47 | * New in version 4: | 44 | * New in version 4: |
48 | * - Remove i_generation from lock names for better stat performance. | 45 | * - Remove i_generation from lock names for better stat performance. |
49 | * | 46 | * |
@@ -54,10 +51,14 @@ | |||
54 | * - full 64 bit i_size in the metadata lock lvbs | 51 | * - full 64 bit i_size in the metadata lock lvbs |
55 | * - introduction of "rw" lock and pushing meta/data locking down | 52 | * - introduction of "rw" lock and pushing meta/data locking down |
56 | */ | 53 | */ |
57 | #define O2NET_PROTOCOL_VERSION 4ULL | 54 | #define O2NET_PROTOCOL_VERSION 5ULL |
58 | struct o2net_handshake { | 55 | struct o2net_handshake { |
59 | __be64 protocol_version; | 56 | __be64 protocol_version; |
60 | __be64 connector_id; | 57 | __be64 connector_id; |
58 | __be32 o2hb_heartbeat_timeout_ms; | ||
59 | __be32 o2net_idle_timeout_ms; | ||
60 | __be32 o2net_keepalive_delay_ms; | ||
61 | __be32 o2net_reconnect_delay_ms; | ||
61 | }; | 62 | }; |
62 | 63 | ||
63 | struct o2net_node { | 64 | struct o2net_node { |
@@ -86,18 +87,18 @@ struct o2net_node { | |||
86 | * connect attempt fails and so can be self-arming. shutdown is | 87 | * connect attempt fails and so can be self-arming. shutdown is |
87 | * careful to first mark the nn such that no connects will be attempted | 88 | * careful to first mark the nn such that no connects will be attempted |
88 | * before canceling delayed connect work and flushing the queue. */ | 89 | * before canceling delayed connect work and flushing the queue. */ |
89 | struct work_struct nn_connect_work; | 90 | struct delayed_work nn_connect_work; |
90 | unsigned long nn_last_connect_attempt; | 91 | unsigned long nn_last_connect_attempt; |
91 | 92 | ||
92 | /* this is queued as nodes come up and is canceled when a connection is | 93 | /* this is queued as nodes come up and is canceled when a connection is |
93 | * established. this expiring gives up on the node and errors out | 94 | * established. this expiring gives up on the node and errors out |
94 | * transmits */ | 95 | * transmits */ |
95 | struct work_struct nn_connect_expired; | 96 | struct delayed_work nn_connect_expired; |
96 | 97 | ||
97 | /* after we give up on a socket we wait a while before deciding | 98 | /* after we give up on a socket we wait a while before deciding |
98 | * that it is still heartbeating and that we should do some | 99 | * that it is still heartbeating and that we should do some |
99 | * quorum work */ | 100 | * quorum work */ |
100 | struct work_struct nn_still_up; | 101 | struct delayed_work nn_still_up; |
101 | }; | 102 | }; |
102 | 103 | ||
103 | struct o2net_sock_container { | 104 | struct o2net_sock_container { |
@@ -129,7 +130,7 @@ struct o2net_sock_container { | |||
129 | struct work_struct sc_shutdown_work; | 130 | struct work_struct sc_shutdown_work; |
130 | 131 | ||
131 | struct timer_list sc_idle_timeout; | 132 | struct timer_list sc_idle_timeout; |
132 | struct work_struct sc_keepalive_work; | 133 | struct delayed_work sc_keepalive_work; |
133 | 134 | ||
134 | unsigned sc_handshake_ok:1; | 135 | unsigned sc_handshake_ok:1; |
135 | 136 | ||
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index 04e01915b86e..66821e178167 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -79,9 +79,10 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
79 | struct buffer_head * bh, * tmp; | 79 | struct buffer_head * bh, * tmp; |
80 | struct ocfs2_dir_entry * de; | 80 | struct ocfs2_dir_entry * de; |
81 | int err; | 81 | int err; |
82 | struct inode *inode = filp->f_dentry->d_inode; | 82 | struct inode *inode = filp->f_path.dentry->d_inode; |
83 | struct super_block * sb = inode->i_sb; | 83 | struct super_block * sb = inode->i_sb; |
84 | unsigned int ra_sectors = 16; | 84 | unsigned int ra_sectors = 16; |
85 | int lock_level = 0; | ||
85 | 86 | ||
86 | mlog_entry("dirino=%llu\n", | 87 | mlog_entry("dirino=%llu\n", |
87 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 88 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
@@ -89,7 +90,15 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
89 | stored = 0; | 90 | stored = 0; |
90 | bh = NULL; | 91 | bh = NULL; |
91 | 92 | ||
92 | error = ocfs2_meta_lock(inode, NULL, NULL, 0); | 93 | error = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level); |
94 | if (lock_level && error >= 0) { | ||
95 | /* We release EX lock which used to update atime | ||
96 | * and get PR lock again to reduce contention | ||
97 | * on commonly accessed directories. */ | ||
98 | ocfs2_meta_unlock(inode, 1); | ||
99 | lock_level = 0; | ||
100 | error = ocfs2_meta_lock(inode, NULL, 0); | ||
101 | } | ||
93 | if (error < 0) { | 102 | if (error < 0) { |
94 | if (error != -ENOENT) | 103 | if (error != -ENOENT) |
95 | mlog_errno(error); | 104 | mlog_errno(error); |
@@ -198,7 +207,7 @@ revalidate: | |||
198 | 207 | ||
199 | stored = 0; | 208 | stored = 0; |
200 | bail: | 209 | bail: |
201 | ocfs2_meta_unlock(inode, 0); | 210 | ocfs2_meta_unlock(inode, lock_level); |
202 | 211 | ||
203 | bail_nolock: | 212 | bail_nolock: |
204 | mlog_exit(stored); | 213 | mlog_exit(stored); |
@@ -340,7 +349,7 @@ int ocfs2_empty_dir(struct inode *inode) | |||
340 | 349 | ||
341 | /* returns a bh of the 1st new block in the allocation. */ | 350 | /* returns a bh of the 1st new block in the allocation. */ |
342 | int ocfs2_do_extend_dir(struct super_block *sb, | 351 | int ocfs2_do_extend_dir(struct super_block *sb, |
343 | struct ocfs2_journal_handle *handle, | 352 | handle_t *handle, |
344 | struct inode *dir, | 353 | struct inode *dir, |
345 | struct buffer_head *parent_fe_bh, | 354 | struct buffer_head *parent_fe_bh, |
346 | struct ocfs2_alloc_context *data_ac, | 355 | struct ocfs2_alloc_context *data_ac, |
@@ -398,7 +407,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
398 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data; | 407 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) parent_fe_bh->b_data; |
399 | struct ocfs2_alloc_context *data_ac = NULL; | 408 | struct ocfs2_alloc_context *data_ac = NULL; |
400 | struct ocfs2_alloc_context *meta_ac = NULL; | 409 | struct ocfs2_alloc_context *meta_ac = NULL; |
401 | struct ocfs2_journal_handle *handle = NULL; | 410 | handle_t *handle = NULL; |
402 | struct buffer_head *new_bh = NULL; | 411 | struct buffer_head *new_bh = NULL; |
403 | struct ocfs2_dir_entry * de; | 412 | struct ocfs2_dir_entry * de; |
404 | struct super_block *sb = osb->sb; | 413 | struct super_block *sb = osb->sb; |
@@ -409,13 +418,6 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
409 | mlog(0, "extending dir %llu (i_size = %lld)\n", | 418 | mlog(0, "extending dir %llu (i_size = %lld)\n", |
410 | (unsigned long long)OCFS2_I(dir)->ip_blkno, dir_i_size); | 419 | (unsigned long long)OCFS2_I(dir)->ip_blkno, dir_i_size); |
411 | 420 | ||
412 | handle = ocfs2_alloc_handle(osb); | ||
413 | if (handle == NULL) { | ||
414 | status = -ENOMEM; | ||
415 | mlog_errno(status); | ||
416 | goto bail; | ||
417 | } | ||
418 | |||
419 | /* dir->i_size is always block aligned. */ | 421 | /* dir->i_size is always block aligned. */ |
420 | spin_lock(&OCFS2_I(dir)->ip_lock); | 422 | spin_lock(&OCFS2_I(dir)->ip_lock); |
421 | if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { | 423 | if (dir_i_size == ocfs2_clusters_to_bytes(sb, OCFS2_I(dir)->ip_clusters)) { |
@@ -428,8 +430,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
428 | } | 430 | } |
429 | 431 | ||
430 | if (!num_free_extents) { | 432 | if (!num_free_extents) { |
431 | status = ocfs2_reserve_new_metadata(osb, handle, | 433 | status = ocfs2_reserve_new_metadata(osb, fe, &meta_ac); |
432 | fe, &meta_ac); | ||
433 | if (status < 0) { | 434 | if (status < 0) { |
434 | if (status != -ENOSPC) | 435 | if (status != -ENOSPC) |
435 | mlog_errno(status); | 436 | mlog_errno(status); |
@@ -437,7 +438,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
437 | } | 438 | } |
438 | } | 439 | } |
439 | 440 | ||
440 | status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); | 441 | status = ocfs2_reserve_clusters(osb, 1, &data_ac); |
441 | if (status < 0) { | 442 | if (status < 0) { |
442 | if (status != -ENOSPC) | 443 | if (status != -ENOSPC) |
443 | mlog_errno(status); | 444 | mlog_errno(status); |
@@ -450,7 +451,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
450 | credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS; | 451 | credits = OCFS2_SIMPLE_DIR_EXTEND_CREDITS; |
451 | } | 452 | } |
452 | 453 | ||
453 | handle = ocfs2_start_trans(osb, handle, credits); | 454 | handle = ocfs2_start_trans(osb, credits); |
454 | if (IS_ERR(handle)) { | 455 | if (IS_ERR(handle)) { |
455 | status = PTR_ERR(handle); | 456 | status = PTR_ERR(handle); |
456 | handle = NULL; | 457 | handle = NULL; |
@@ -496,7 +497,7 @@ static int ocfs2_extend_dir(struct ocfs2_super *osb, | |||
496 | get_bh(*new_de_bh); | 497 | get_bh(*new_de_bh); |
497 | bail: | 498 | bail: |
498 | if (handle) | 499 | if (handle) |
499 | ocfs2_commit_trans(handle); | 500 | ocfs2_commit_trans(osb, handle); |
500 | 501 | ||
501 | if (data_ac) | 502 | if (data_ac) |
502 | ocfs2_free_alloc_context(data_ac); | 503 | ocfs2_free_alloc_context(data_ac); |
diff --git a/fs/ocfs2/dir.h b/fs/ocfs2/dir.h index 5f614ec9649c..3f67e146864a 100644 --- a/fs/ocfs2/dir.h +++ b/fs/ocfs2/dir.h | |||
@@ -45,7 +45,7 @@ int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb, | |||
45 | struct buffer_head **ret_de_bh); | 45 | struct buffer_head **ret_de_bh); |
46 | struct ocfs2_alloc_context; | 46 | struct ocfs2_alloc_context; |
47 | int ocfs2_do_extend_dir(struct super_block *sb, | 47 | int ocfs2_do_extend_dir(struct super_block *sb, |
48 | struct ocfs2_journal_handle *handle, | 48 | handle_t *handle, |
49 | struct inode *dir, | 49 | struct inode *dir, |
50 | struct buffer_head *parent_fe_bh, | 50 | struct buffer_head *parent_fe_bh, |
51 | struct ocfs2_alloc_context *data_ac, | 51 | struct ocfs2_alloc_context *data_ac, |
diff --git a/fs/ocfs2/dlm/dlmcommon.h b/fs/ocfs2/dlm/dlmcommon.h index fa968180b072..6b6ff76538c5 100644 --- a/fs/ocfs2/dlm/dlmcommon.h +++ b/fs/ocfs2/dlm/dlmcommon.h | |||
@@ -153,7 +153,7 @@ static inline struct hlist_head *dlm_lockres_hash(struct dlm_ctxt *dlm, unsigned | |||
153 | * called functions that cannot be directly called from the | 153 | * called functions that cannot be directly called from the |
154 | * net message handlers for some reason, usually because | 154 | * net message handlers for some reason, usually because |
155 | * they need to send net messages of their own. */ | 155 | * they need to send net messages of their own. */ |
156 | void dlm_dispatch_work(void *data); | 156 | void dlm_dispatch_work(struct work_struct *work); |
157 | 157 | ||
158 | struct dlm_lock_resource; | 158 | struct dlm_lock_resource; |
159 | struct dlm_work_item; | 159 | struct dlm_work_item; |
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 8d1065f8b3bd..f0b25f2dd205 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
@@ -68,7 +68,8 @@ static void **dlm_alloc_pagevec(int pages) | |||
68 | goto out_free; | 68 | goto out_free; |
69 | 69 | ||
70 | mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n", | 70 | mlog(0, "Allocated DLM hash pagevec; %d pages (%lu expected), %lu buckets per page\n", |
71 | pages, DLM_HASH_PAGES, (unsigned long)DLM_BUCKETS_PER_PAGE); | 71 | pages, (unsigned long)DLM_HASH_PAGES, |
72 | (unsigned long)DLM_BUCKETS_PER_PAGE); | ||
72 | return vec; | 73 | return vec; |
73 | out_free: | 74 | out_free: |
74 | dlm_free_pagevec(vec, i); | 75 | dlm_free_pagevec(vec, i); |
@@ -919,7 +920,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm) | |||
919 | 920 | ||
920 | mlog_entry("%p", dlm); | 921 | mlog_entry("%p", dlm); |
921 | 922 | ||
922 | ctxt = kcalloc(1, sizeof(*ctxt), GFP_KERNEL); | 923 | ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL); |
923 | if (!ctxt) { | 924 | if (!ctxt) { |
924 | status = -ENOMEM; | 925 | status = -ENOMEM; |
925 | mlog_errno(status); | 926 | mlog_errno(status); |
@@ -1222,7 +1223,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain, | |||
1222 | int i; | 1223 | int i; |
1223 | struct dlm_ctxt *dlm = NULL; | 1224 | struct dlm_ctxt *dlm = NULL; |
1224 | 1225 | ||
1225 | dlm = kcalloc(1, sizeof(*dlm), GFP_KERNEL); | 1226 | dlm = kzalloc(sizeof(*dlm), GFP_KERNEL); |
1226 | if (!dlm) { | 1227 | if (!dlm) { |
1227 | mlog_errno(-ENOMEM); | 1228 | mlog_errno(-ENOMEM); |
1228 | goto leave; | 1229 | goto leave; |
@@ -1296,7 +1297,7 @@ static struct dlm_ctxt *dlm_alloc_ctxt(const char *domain, | |||
1296 | 1297 | ||
1297 | spin_lock_init(&dlm->work_lock); | 1298 | spin_lock_init(&dlm->work_lock); |
1298 | INIT_LIST_HEAD(&dlm->work_list); | 1299 | INIT_LIST_HEAD(&dlm->work_list); |
1299 | INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work, dlm); | 1300 | INIT_WORK(&dlm->dispatched_work, dlm_dispatch_work); |
1300 | 1301 | ||
1301 | kref_init(&dlm->dlm_refs); | 1302 | kref_init(&dlm->dlm_refs); |
1302 | dlm->dlm_state = DLM_CTXT_NEW; | 1303 | dlm->dlm_state = DLM_CTXT_NEW; |
diff --git a/fs/ocfs2/dlm/dlmfs.c b/fs/ocfs2/dlm/dlmfs.c index 16b8d1ba7066..b7f0ba97a1a2 100644 --- a/fs/ocfs2/dlm/dlmfs.c +++ b/fs/ocfs2/dlm/dlmfs.c | |||
@@ -66,7 +66,7 @@ static struct file_operations dlmfs_file_operations; | |||
66 | static struct inode_operations dlmfs_dir_inode_operations; | 66 | static struct inode_operations dlmfs_dir_inode_operations; |
67 | static struct inode_operations dlmfs_root_inode_operations; | 67 | static struct inode_operations dlmfs_root_inode_operations; |
68 | static struct inode_operations dlmfs_file_inode_operations; | 68 | static struct inode_operations dlmfs_file_inode_operations; |
69 | static kmem_cache_t *dlmfs_inode_cache; | 69 | static struct kmem_cache *dlmfs_inode_cache; |
70 | 70 | ||
71 | struct workqueue_struct *user_dlm_worker; | 71 | struct workqueue_struct *user_dlm_worker; |
72 | 72 | ||
@@ -176,7 +176,7 @@ static ssize_t dlmfs_file_read(struct file *filp, | |||
176 | int bytes_left; | 176 | int bytes_left; |
177 | ssize_t readlen; | 177 | ssize_t readlen; |
178 | char *lvb_buf; | 178 | char *lvb_buf; |
179 | struct inode *inode = filp->f_dentry->d_inode; | 179 | struct inode *inode = filp->f_path.dentry->d_inode; |
180 | 180 | ||
181 | mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", | 181 | mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", |
182 | inode->i_ino, count, *ppos); | 182 | inode->i_ino, count, *ppos); |
@@ -220,7 +220,7 @@ static ssize_t dlmfs_file_write(struct file *filp, | |||
220 | int bytes_left; | 220 | int bytes_left; |
221 | ssize_t writelen; | 221 | ssize_t writelen; |
222 | char *lvb_buf; | 222 | char *lvb_buf; |
223 | struct inode *inode = filp->f_dentry->d_inode; | 223 | struct inode *inode = filp->f_path.dentry->d_inode; |
224 | 224 | ||
225 | mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", | 225 | mlog(0, "inode %lu, count = %zu, *ppos = %llu\n", |
226 | inode->i_ino, count, *ppos); | 226 | inode->i_ino, count, *ppos); |
@@ -257,7 +257,7 @@ static ssize_t dlmfs_file_write(struct file *filp, | |||
257 | } | 257 | } |
258 | 258 | ||
259 | static void dlmfs_init_once(void *foo, | 259 | static void dlmfs_init_once(void *foo, |
260 | kmem_cache_t *cachep, | 260 | struct kmem_cache *cachep, |
261 | unsigned long flags) | 261 | unsigned long flags) |
262 | { | 262 | { |
263 | struct dlmfs_inode_private *ip = | 263 | struct dlmfs_inode_private *ip = |
@@ -276,7 +276,7 @@ static struct inode *dlmfs_alloc_inode(struct super_block *sb) | |||
276 | { | 276 | { |
277 | struct dlmfs_inode_private *ip; | 277 | struct dlmfs_inode_private *ip; |
278 | 278 | ||
279 | ip = kmem_cache_alloc(dlmfs_inode_cache, SLAB_NOFS); | 279 | ip = kmem_cache_alloc(dlmfs_inode_cache, GFP_NOFS); |
280 | if (!ip) | 280 | if (!ip) |
281 | return NULL; | 281 | return NULL; |
282 | 282 | ||
diff --git a/fs/ocfs2/dlm/dlmlock.c b/fs/ocfs2/dlm/dlmlock.c index 42a1b91979b5..e5ca3db197f6 100644 --- a/fs/ocfs2/dlm/dlmlock.c +++ b/fs/ocfs2/dlm/dlmlock.c | |||
@@ -408,13 +408,13 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie, | |||
408 | struct dlm_lock *lock; | 408 | struct dlm_lock *lock; |
409 | int kernel_allocated = 0; | 409 | int kernel_allocated = 0; |
410 | 410 | ||
411 | lock = kcalloc(1, sizeof(*lock), GFP_NOFS); | 411 | lock = kzalloc(sizeof(*lock), GFP_NOFS); |
412 | if (!lock) | 412 | if (!lock) |
413 | return NULL; | 413 | return NULL; |
414 | 414 | ||
415 | if (!lksb) { | 415 | if (!lksb) { |
416 | /* zero memory only if kernel-allocated */ | 416 | /* zero memory only if kernel-allocated */ |
417 | lksb = kcalloc(1, sizeof(*lksb), GFP_NOFS); | 417 | lksb = kzalloc(sizeof(*lksb), GFP_NOFS); |
418 | if (!lksb) { | 418 | if (!lksb) { |
419 | kfree(lock); | 419 | kfree(lock); |
420 | return NULL; | 420 | return NULL; |
diff --git a/fs/ocfs2/dlm/dlmmaster.c b/fs/ocfs2/dlm/dlmmaster.c index f784177b6241..0ad872055cb3 100644 --- a/fs/ocfs2/dlm/dlmmaster.c +++ b/fs/ocfs2/dlm/dlmmaster.c | |||
@@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(dlm_dump_all_mles); | |||
221 | #endif /* 0 */ | 221 | #endif /* 0 */ |
222 | 222 | ||
223 | 223 | ||
224 | static kmem_cache_t *dlm_mle_cache = NULL; | 224 | static struct kmem_cache *dlm_mle_cache = NULL; |
225 | 225 | ||
226 | 226 | ||
227 | static void dlm_mle_release(struct kref *kref); | 227 | static void dlm_mle_release(struct kref *kref); |
@@ -1939,7 +1939,7 @@ int dlm_dispatch_assert_master(struct dlm_ctxt *dlm, | |||
1939 | int ignore_higher, u8 request_from, u32 flags) | 1939 | int ignore_higher, u8 request_from, u32 flags) |
1940 | { | 1940 | { |
1941 | struct dlm_work_item *item; | 1941 | struct dlm_work_item *item; |
1942 | item = kcalloc(1, sizeof(*item), GFP_NOFS); | 1942 | item = kzalloc(sizeof(*item), GFP_NOFS); |
1943 | if (!item) | 1943 | if (!item) |
1944 | return -ENOMEM; | 1944 | return -ENOMEM; |
1945 | 1945 | ||
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c index 9d950d7cea38..367a11e9e2ed 100644 --- a/fs/ocfs2/dlm/dlmrecovery.c +++ b/fs/ocfs2/dlm/dlmrecovery.c | |||
@@ -153,9 +153,10 @@ static inline void dlm_reset_recovery(struct dlm_ctxt *dlm) | |||
153 | } | 153 | } |
154 | 154 | ||
155 | /* Worker function used during recovery. */ | 155 | /* Worker function used during recovery. */ |
156 | void dlm_dispatch_work(void *data) | 156 | void dlm_dispatch_work(struct work_struct *work) |
157 | { | 157 | { |
158 | struct dlm_ctxt *dlm = (struct dlm_ctxt *)data; | 158 | struct dlm_ctxt *dlm = |
159 | container_of(work, struct dlm_ctxt, dispatched_work); | ||
159 | LIST_HEAD(tmp_list); | 160 | LIST_HEAD(tmp_list); |
160 | struct list_head *iter, *iter2; | 161 | struct list_head *iter, *iter2; |
161 | struct dlm_work_item *item; | 162 | struct dlm_work_item *item; |
@@ -756,7 +757,7 @@ static int dlm_init_recovery_area(struct dlm_ctxt *dlm, u8 dead_node) | |||
756 | } | 757 | } |
757 | BUG_ON(num == dead_node); | 758 | BUG_ON(num == dead_node); |
758 | 759 | ||
759 | ndata = kcalloc(1, sizeof(*ndata), GFP_NOFS); | 760 | ndata = kzalloc(sizeof(*ndata), GFP_NOFS); |
760 | if (!ndata) { | 761 | if (!ndata) { |
761 | dlm_destroy_recovery_area(dlm, dead_node); | 762 | dlm_destroy_recovery_area(dlm, dead_node); |
762 | return -ENOMEM; | 763 | return -ENOMEM; |
@@ -841,7 +842,7 @@ int dlm_request_all_locks_handler(struct o2net_msg *msg, u32 len, void *data) | |||
841 | } | 842 | } |
842 | BUG_ON(lr->dead_node != dlm->reco.dead_node); | 843 | BUG_ON(lr->dead_node != dlm->reco.dead_node); |
843 | 844 | ||
844 | item = kcalloc(1, sizeof(*item), GFP_NOFS); | 845 | item = kzalloc(sizeof(*item), GFP_NOFS); |
845 | if (!item) { | 846 | if (!item) { |
846 | dlm_put(dlm); | 847 | dlm_put(dlm); |
847 | return -ENOMEM; | 848 | return -ENOMEM; |
@@ -1322,7 +1323,7 @@ int dlm_mig_lockres_handler(struct o2net_msg *msg, u32 len, void *data) | |||
1322 | 1323 | ||
1323 | ret = -ENOMEM; | 1324 | ret = -ENOMEM; |
1324 | buf = kmalloc(be16_to_cpu(msg->data_len), GFP_NOFS); | 1325 | buf = kmalloc(be16_to_cpu(msg->data_len), GFP_NOFS); |
1325 | item = kcalloc(1, sizeof(*item), GFP_NOFS); | 1326 | item = kzalloc(sizeof(*item), GFP_NOFS); |
1326 | if (!buf || !item) | 1327 | if (!buf || !item) |
1327 | goto leave; | 1328 | goto leave; |
1328 | 1329 | ||
diff --git a/fs/ocfs2/dlm/userdlm.c b/fs/ocfs2/dlm/userdlm.c index eead48bbfac6..7d2f578b267d 100644 --- a/fs/ocfs2/dlm/userdlm.c +++ b/fs/ocfs2/dlm/userdlm.c | |||
@@ -171,15 +171,14 @@ static inline void user_dlm_grab_inode_ref(struct user_lock_res *lockres) | |||
171 | BUG(); | 171 | BUG(); |
172 | } | 172 | } |
173 | 173 | ||
174 | static void user_dlm_unblock_lock(void *opaque); | 174 | static void user_dlm_unblock_lock(struct work_struct *work); |
175 | 175 | ||
176 | static void __user_dlm_queue_lockres(struct user_lock_res *lockres) | 176 | static void __user_dlm_queue_lockres(struct user_lock_res *lockres) |
177 | { | 177 | { |
178 | if (!(lockres->l_flags & USER_LOCK_QUEUED)) { | 178 | if (!(lockres->l_flags & USER_LOCK_QUEUED)) { |
179 | user_dlm_grab_inode_ref(lockres); | 179 | user_dlm_grab_inode_ref(lockres); |
180 | 180 | ||
181 | INIT_WORK(&lockres->l_work, user_dlm_unblock_lock, | 181 | INIT_WORK(&lockres->l_work, user_dlm_unblock_lock); |
182 | lockres); | ||
183 | 182 | ||
184 | queue_work(user_dlm_worker, &lockres->l_work); | 183 | queue_work(user_dlm_worker, &lockres->l_work); |
185 | lockres->l_flags |= USER_LOCK_QUEUED; | 184 | lockres->l_flags |= USER_LOCK_QUEUED; |
@@ -279,10 +278,11 @@ static inline void user_dlm_drop_inode_ref(struct user_lock_res *lockres) | |||
279 | iput(inode); | 278 | iput(inode); |
280 | } | 279 | } |
281 | 280 | ||
282 | static void user_dlm_unblock_lock(void *opaque) | 281 | static void user_dlm_unblock_lock(struct work_struct *work) |
283 | { | 282 | { |
284 | int new_level, status; | 283 | int new_level, status; |
285 | struct user_lock_res *lockres = (struct user_lock_res *) opaque; | 284 | struct user_lock_res *lockres = |
285 | container_of(work, struct user_lock_res, l_work); | ||
286 | struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); | 286 | struct dlm_ctxt *dlm = dlm_ctxt_from_user_lockres(lockres); |
287 | 287 | ||
288 | mlog(0, "processing lockres %.*s\n", lockres->l_namelen, | 288 | mlog(0, "processing lockres %.*s\n", lockres->l_namelen, |
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 8801e41afe80..e335541727f9 100644 --- a/fs/ocfs2/dlmglue.c +++ b/fs/ocfs2/dlmglue.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include "dcache.h" | 49 | #include "dcache.h" |
50 | #include "dlmglue.h" | 50 | #include "dlmglue.h" |
51 | #include "extent_map.h" | 51 | #include "extent_map.h" |
52 | #include "file.h" | ||
52 | #include "heartbeat.h" | 53 | #include "heartbeat.h" |
53 | #include "inode.h" | 54 | #include "inode.h" |
54 | #include "journal.h" | 55 | #include "journal.h" |
@@ -769,7 +770,7 @@ static int ocfs2_lock_create(struct ocfs2_super *osb, | |||
769 | int dlm_flags) | 770 | int dlm_flags) |
770 | { | 771 | { |
771 | int ret = 0; | 772 | int ret = 0; |
772 | enum dlm_status status; | 773 | enum dlm_status status = DLM_NORMAL; |
773 | unsigned long flags; | 774 | unsigned long flags; |
774 | 775 | ||
775 | mlog_entry_void(); | 776 | mlog_entry_void(); |
@@ -1063,10 +1064,10 @@ static void ocfs2_cluster_unlock(struct ocfs2_super *osb, | |||
1063 | mlog_exit_void(); | 1064 | mlog_exit_void(); |
1064 | } | 1065 | } |
1065 | 1066 | ||
1066 | int ocfs2_create_new_lock(struct ocfs2_super *osb, | 1067 | static int ocfs2_create_new_lock(struct ocfs2_super *osb, |
1067 | struct ocfs2_lock_res *lockres, | 1068 | struct ocfs2_lock_res *lockres, |
1068 | int ex, | 1069 | int ex, |
1069 | int local) | 1070 | int local) |
1070 | { | 1071 | { |
1071 | int level = ex ? LKM_EXMODE : LKM_PRMODE; | 1072 | int level = ex ? LKM_EXMODE : LKM_PRMODE; |
1072 | unsigned long flags; | 1073 | unsigned long flags; |
@@ -1137,6 +1138,7 @@ int ocfs2_rw_lock(struct inode *inode, int write) | |||
1137 | { | 1138 | { |
1138 | int status, level; | 1139 | int status, level; |
1139 | struct ocfs2_lock_res *lockres; | 1140 | struct ocfs2_lock_res *lockres; |
1141 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1140 | 1142 | ||
1141 | BUG_ON(!inode); | 1143 | BUG_ON(!inode); |
1142 | 1144 | ||
@@ -1146,6 +1148,9 @@ int ocfs2_rw_lock(struct inode *inode, int write) | |||
1146 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 1148 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
1147 | write ? "EXMODE" : "PRMODE"); | 1149 | write ? "EXMODE" : "PRMODE"); |
1148 | 1150 | ||
1151 | if (ocfs2_mount_local(osb)) | ||
1152 | return 0; | ||
1153 | |||
1149 | lockres = &OCFS2_I(inode)->ip_rw_lockres; | 1154 | lockres = &OCFS2_I(inode)->ip_rw_lockres; |
1150 | 1155 | ||
1151 | level = write ? LKM_EXMODE : LKM_PRMODE; | 1156 | level = write ? LKM_EXMODE : LKM_PRMODE; |
@@ -1163,6 +1168,7 @@ void ocfs2_rw_unlock(struct inode *inode, int write) | |||
1163 | { | 1168 | { |
1164 | int level = write ? LKM_EXMODE : LKM_PRMODE; | 1169 | int level = write ? LKM_EXMODE : LKM_PRMODE; |
1165 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; | 1170 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_rw_lockres; |
1171 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1166 | 1172 | ||
1167 | mlog_entry_void(); | 1173 | mlog_entry_void(); |
1168 | 1174 | ||
@@ -1170,7 +1176,8 @@ void ocfs2_rw_unlock(struct inode *inode, int write) | |||
1170 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 1176 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
1171 | write ? "EXMODE" : "PRMODE"); | 1177 | write ? "EXMODE" : "PRMODE"); |
1172 | 1178 | ||
1173 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); | 1179 | if (!ocfs2_mount_local(osb)) |
1180 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); | ||
1174 | 1181 | ||
1175 | mlog_exit_void(); | 1182 | mlog_exit_void(); |
1176 | } | 1183 | } |
@@ -1181,6 +1188,7 @@ int ocfs2_data_lock_full(struct inode *inode, | |||
1181 | { | 1188 | { |
1182 | int status = 0, level; | 1189 | int status = 0, level; |
1183 | struct ocfs2_lock_res *lockres; | 1190 | struct ocfs2_lock_res *lockres; |
1191 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1184 | 1192 | ||
1185 | BUG_ON(!inode); | 1193 | BUG_ON(!inode); |
1186 | 1194 | ||
@@ -1200,6 +1208,9 @@ int ocfs2_data_lock_full(struct inode *inode, | |||
1200 | goto out; | 1208 | goto out; |
1201 | } | 1209 | } |
1202 | 1210 | ||
1211 | if (ocfs2_mount_local(osb)) | ||
1212 | goto out; | ||
1213 | |||
1203 | lockres = &OCFS2_I(inode)->ip_data_lockres; | 1214 | lockres = &OCFS2_I(inode)->ip_data_lockres; |
1204 | 1215 | ||
1205 | level = write ? LKM_EXMODE : LKM_PRMODE; | 1216 | level = write ? LKM_EXMODE : LKM_PRMODE; |
@@ -1268,6 +1279,7 @@ void ocfs2_data_unlock(struct inode *inode, | |||
1268 | { | 1279 | { |
1269 | int level = write ? LKM_EXMODE : LKM_PRMODE; | 1280 | int level = write ? LKM_EXMODE : LKM_PRMODE; |
1270 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres; | 1281 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_data_lockres; |
1282 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1271 | 1283 | ||
1272 | mlog_entry_void(); | 1284 | mlog_entry_void(); |
1273 | 1285 | ||
@@ -1275,7 +1287,8 @@ void ocfs2_data_unlock(struct inode *inode, | |||
1275 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 1287 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
1276 | write ? "EXMODE" : "PRMODE"); | 1288 | write ? "EXMODE" : "PRMODE"); |
1277 | 1289 | ||
1278 | if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) | 1290 | if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) && |
1291 | !ocfs2_mount_local(osb)) | ||
1279 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); | 1292 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); |
1280 | 1293 | ||
1281 | mlog_exit_void(); | 1294 | mlog_exit_void(); |
@@ -1466,8 +1479,9 @@ static int ocfs2_meta_lock_update(struct inode *inode, | |||
1466 | { | 1479 | { |
1467 | int status = 0; | 1480 | int status = 0; |
1468 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 1481 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
1469 | struct ocfs2_lock_res *lockres; | 1482 | struct ocfs2_lock_res *lockres = NULL; |
1470 | struct ocfs2_dinode *fe; | 1483 | struct ocfs2_dinode *fe; |
1484 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1471 | 1485 | ||
1472 | mlog_entry_void(); | 1486 | mlog_entry_void(); |
1473 | 1487 | ||
@@ -1482,10 +1496,12 @@ static int ocfs2_meta_lock_update(struct inode *inode, | |||
1482 | } | 1496 | } |
1483 | spin_unlock(&oi->ip_lock); | 1497 | spin_unlock(&oi->ip_lock); |
1484 | 1498 | ||
1485 | lockres = &oi->ip_meta_lockres; | 1499 | if (!ocfs2_mount_local(osb)) { |
1500 | lockres = &oi->ip_meta_lockres; | ||
1486 | 1501 | ||
1487 | if (!ocfs2_should_refresh_lock_res(lockres)) | 1502 | if (!ocfs2_should_refresh_lock_res(lockres)) |
1488 | goto bail; | 1503 | goto bail; |
1504 | } | ||
1489 | 1505 | ||
1490 | /* This will discard any caching information we might have had | 1506 | /* This will discard any caching information we might have had |
1491 | * for the inode metadata. */ | 1507 | * for the inode metadata. */ |
@@ -1495,7 +1511,7 @@ static int ocfs2_meta_lock_update(struct inode *inode, | |||
1495 | * map (directories, bitmap files, etc) */ | 1511 | * map (directories, bitmap files, etc) */ |
1496 | ocfs2_extent_map_trunc(inode, 0); | 1512 | ocfs2_extent_map_trunc(inode, 0); |
1497 | 1513 | ||
1498 | if (ocfs2_meta_lvb_is_trustable(inode, lockres)) { | 1514 | if (lockres && ocfs2_meta_lvb_is_trustable(inode, lockres)) { |
1499 | mlog(0, "Trusting LVB on inode %llu\n", | 1515 | mlog(0, "Trusting LVB on inode %llu\n", |
1500 | (unsigned long long)oi->ip_blkno); | 1516 | (unsigned long long)oi->ip_blkno); |
1501 | ocfs2_refresh_inode_from_lvb(inode); | 1517 | ocfs2_refresh_inode_from_lvb(inode); |
@@ -1542,7 +1558,8 @@ static int ocfs2_meta_lock_update(struct inode *inode, | |||
1542 | 1558 | ||
1543 | status = 0; | 1559 | status = 0; |
1544 | bail_refresh: | 1560 | bail_refresh: |
1545 | ocfs2_complete_lock_res_refresh(lockres, status); | 1561 | if (lockres) |
1562 | ocfs2_complete_lock_res_refresh(lockres, status); | ||
1546 | bail: | 1563 | bail: |
1547 | mlog_exit(status); | 1564 | mlog_exit(status); |
1548 | return status; | 1565 | return status; |
@@ -1579,13 +1596,12 @@ static int ocfs2_assign_bh(struct inode *inode, | |||
1579 | * the result of the lock will be communicated via the callback. | 1596 | * the result of the lock will be communicated via the callback. |
1580 | */ | 1597 | */ |
1581 | int ocfs2_meta_lock_full(struct inode *inode, | 1598 | int ocfs2_meta_lock_full(struct inode *inode, |
1582 | struct ocfs2_journal_handle *handle, | ||
1583 | struct buffer_head **ret_bh, | 1599 | struct buffer_head **ret_bh, |
1584 | int ex, | 1600 | int ex, |
1585 | int arg_flags) | 1601 | int arg_flags) |
1586 | { | 1602 | { |
1587 | int status, level, dlm_flags, acquired; | 1603 | int status, level, dlm_flags, acquired; |
1588 | struct ocfs2_lock_res *lockres; | 1604 | struct ocfs2_lock_res *lockres = NULL; |
1589 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 1605 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
1590 | struct buffer_head *local_bh = NULL; | 1606 | struct buffer_head *local_bh = NULL; |
1591 | 1607 | ||
@@ -1607,6 +1623,9 @@ int ocfs2_meta_lock_full(struct inode *inode, | |||
1607 | goto bail; | 1623 | goto bail; |
1608 | } | 1624 | } |
1609 | 1625 | ||
1626 | if (ocfs2_mount_local(osb)) | ||
1627 | goto local; | ||
1628 | |||
1610 | if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) | 1629 | if (!(arg_flags & OCFS2_META_LOCK_RECOVERY)) |
1611 | wait_event(osb->recovery_event, | 1630 | wait_event(osb->recovery_event, |
1612 | ocfs2_node_map_is_empty(osb, &osb->recovery_map)); | 1631 | ocfs2_node_map_is_empty(osb, &osb->recovery_map)); |
@@ -1636,6 +1655,7 @@ int ocfs2_meta_lock_full(struct inode *inode, | |||
1636 | wait_event(osb->recovery_event, | 1655 | wait_event(osb->recovery_event, |
1637 | ocfs2_node_map_is_empty(osb, &osb->recovery_map)); | 1656 | ocfs2_node_map_is_empty(osb, &osb->recovery_map)); |
1638 | 1657 | ||
1658 | local: | ||
1639 | /* | 1659 | /* |
1640 | * We only see this flag if we're being called from | 1660 | * We only see this flag if we're being called from |
1641 | * ocfs2_read_locked_inode(). It means we're locking an inode | 1661 | * ocfs2_read_locked_inode(). It means we're locking an inode |
@@ -1644,7 +1664,8 @@ int ocfs2_meta_lock_full(struct inode *inode, | |||
1644 | */ | 1664 | */ |
1645 | if (inode->i_state & I_NEW) { | 1665 | if (inode->i_state & I_NEW) { |
1646 | status = 0; | 1666 | status = 0; |
1647 | ocfs2_complete_lock_res_refresh(lockres, 0); | 1667 | if (lockres) |
1668 | ocfs2_complete_lock_res_refresh(lockres, 0); | ||
1648 | goto bail; | 1669 | goto bail; |
1649 | } | 1670 | } |
1650 | 1671 | ||
@@ -1668,12 +1689,6 @@ int ocfs2_meta_lock_full(struct inode *inode, | |||
1668 | } | 1689 | } |
1669 | } | 1690 | } |
1670 | 1691 | ||
1671 | if (handle) { | ||
1672 | status = ocfs2_handle_add_lock(handle, inode); | ||
1673 | if (status < 0) | ||
1674 | mlog_errno(status); | ||
1675 | } | ||
1676 | |||
1677 | bail: | 1692 | bail: |
1678 | if (status < 0) { | 1693 | if (status < 0) { |
1679 | if (ret_bh && (*ret_bh)) { | 1694 | if (ret_bh && (*ret_bh)) { |
@@ -1713,18 +1728,16 @@ bail: | |||
1713 | * the lock inversion simply. | 1728 | * the lock inversion simply. |
1714 | */ | 1729 | */ |
1715 | int ocfs2_meta_lock_with_page(struct inode *inode, | 1730 | int ocfs2_meta_lock_with_page(struct inode *inode, |
1716 | struct ocfs2_journal_handle *handle, | ||
1717 | struct buffer_head **ret_bh, | 1731 | struct buffer_head **ret_bh, |
1718 | int ex, | 1732 | int ex, |
1719 | struct page *page) | 1733 | struct page *page) |
1720 | { | 1734 | { |
1721 | int ret; | 1735 | int ret; |
1722 | 1736 | ||
1723 | ret = ocfs2_meta_lock_full(inode, handle, ret_bh, ex, | 1737 | ret = ocfs2_meta_lock_full(inode, ret_bh, ex, OCFS2_LOCK_NONBLOCK); |
1724 | OCFS2_LOCK_NONBLOCK); | ||
1725 | if (ret == -EAGAIN) { | 1738 | if (ret == -EAGAIN) { |
1726 | unlock_page(page); | 1739 | unlock_page(page); |
1727 | if (ocfs2_meta_lock(inode, handle, ret_bh, ex) == 0) | 1740 | if (ocfs2_meta_lock(inode, ret_bh, ex) == 0) |
1728 | ocfs2_meta_unlock(inode, ex); | 1741 | ocfs2_meta_unlock(inode, ex); |
1729 | ret = AOP_TRUNCATED_PAGE; | 1742 | ret = AOP_TRUNCATED_PAGE; |
1730 | } | 1743 | } |
@@ -1732,11 +1745,50 @@ int ocfs2_meta_lock_with_page(struct inode *inode, | |||
1732 | return ret; | 1745 | return ret; |
1733 | } | 1746 | } |
1734 | 1747 | ||
1748 | int ocfs2_meta_lock_atime(struct inode *inode, | ||
1749 | struct vfsmount *vfsmnt, | ||
1750 | int *level) | ||
1751 | { | ||
1752 | int ret; | ||
1753 | |||
1754 | mlog_entry_void(); | ||
1755 | ret = ocfs2_meta_lock(inode, NULL, 0); | ||
1756 | if (ret < 0) { | ||
1757 | mlog_errno(ret); | ||
1758 | return ret; | ||
1759 | } | ||
1760 | |||
1761 | /* | ||
1762 | * If we should update atime, we will get EX lock, | ||
1763 | * otherwise we just get PR lock. | ||
1764 | */ | ||
1765 | if (ocfs2_should_update_atime(inode, vfsmnt)) { | ||
1766 | struct buffer_head *bh = NULL; | ||
1767 | |||
1768 | ocfs2_meta_unlock(inode, 0); | ||
1769 | ret = ocfs2_meta_lock(inode, &bh, 1); | ||
1770 | if (ret < 0) { | ||
1771 | mlog_errno(ret); | ||
1772 | return ret; | ||
1773 | } | ||
1774 | *level = 1; | ||
1775 | if (ocfs2_should_update_atime(inode, vfsmnt)) | ||
1776 | ocfs2_update_inode_atime(inode, bh); | ||
1777 | if (bh) | ||
1778 | brelse(bh); | ||
1779 | } else | ||
1780 | *level = 0; | ||
1781 | |||
1782 | mlog_exit(ret); | ||
1783 | return ret; | ||
1784 | } | ||
1785 | |||
1735 | void ocfs2_meta_unlock(struct inode *inode, | 1786 | void ocfs2_meta_unlock(struct inode *inode, |
1736 | int ex) | 1787 | int ex) |
1737 | { | 1788 | { |
1738 | int level = ex ? LKM_EXMODE : LKM_PRMODE; | 1789 | int level = ex ? LKM_EXMODE : LKM_PRMODE; |
1739 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; | 1790 | struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_meta_lockres; |
1791 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
1740 | 1792 | ||
1741 | mlog_entry_void(); | 1793 | mlog_entry_void(); |
1742 | 1794 | ||
@@ -1744,7 +1796,8 @@ void ocfs2_meta_unlock(struct inode *inode, | |||
1744 | (unsigned long long)OCFS2_I(inode)->ip_blkno, | 1796 | (unsigned long long)OCFS2_I(inode)->ip_blkno, |
1745 | ex ? "EXMODE" : "PRMODE"); | 1797 | ex ? "EXMODE" : "PRMODE"); |
1746 | 1798 | ||
1747 | if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb))) | 1799 | if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) && |
1800 | !ocfs2_mount_local(osb)) | ||
1748 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); | 1801 | ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level); |
1749 | 1802 | ||
1750 | mlog_exit_void(); | 1803 | mlog_exit_void(); |
@@ -1753,7 +1806,7 @@ void ocfs2_meta_unlock(struct inode *inode, | |||
1753 | int ocfs2_super_lock(struct ocfs2_super *osb, | 1806 | int ocfs2_super_lock(struct ocfs2_super *osb, |
1754 | int ex) | 1807 | int ex) |
1755 | { | 1808 | { |
1756 | int status; | 1809 | int status = 0; |
1757 | int level = ex ? LKM_EXMODE : LKM_PRMODE; | 1810 | int level = ex ? LKM_EXMODE : LKM_PRMODE; |
1758 | struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; | 1811 | struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; |
1759 | struct buffer_head *bh; | 1812 | struct buffer_head *bh; |
@@ -1764,6 +1817,9 @@ int ocfs2_super_lock(struct ocfs2_super *osb, | |||
1764 | if (ocfs2_is_hard_readonly(osb)) | 1817 | if (ocfs2_is_hard_readonly(osb)) |
1765 | return -EROFS; | 1818 | return -EROFS; |
1766 | 1819 | ||
1820 | if (ocfs2_mount_local(osb)) | ||
1821 | goto bail; | ||
1822 | |||
1767 | status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); | 1823 | status = ocfs2_cluster_lock(osb, lockres, level, 0, 0); |
1768 | if (status < 0) { | 1824 | if (status < 0) { |
1769 | mlog_errno(status); | 1825 | mlog_errno(status); |
@@ -1802,7 +1858,8 @@ void ocfs2_super_unlock(struct ocfs2_super *osb, | |||
1802 | int level = ex ? LKM_EXMODE : LKM_PRMODE; | 1858 | int level = ex ? LKM_EXMODE : LKM_PRMODE; |
1803 | struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; | 1859 | struct ocfs2_lock_res *lockres = &osb->osb_super_lockres; |
1804 | 1860 | ||
1805 | ocfs2_cluster_unlock(osb, lockres, level); | 1861 | if (!ocfs2_mount_local(osb)) |
1862 | ocfs2_cluster_unlock(osb, lockres, level); | ||
1806 | } | 1863 | } |
1807 | 1864 | ||
1808 | int ocfs2_rename_lock(struct ocfs2_super *osb) | 1865 | int ocfs2_rename_lock(struct ocfs2_super *osb) |
@@ -1813,6 +1870,9 @@ int ocfs2_rename_lock(struct ocfs2_super *osb) | |||
1813 | if (ocfs2_is_hard_readonly(osb)) | 1870 | if (ocfs2_is_hard_readonly(osb)) |
1814 | return -EROFS; | 1871 | return -EROFS; |
1815 | 1872 | ||
1873 | if (ocfs2_mount_local(osb)) | ||
1874 | return 0; | ||
1875 | |||
1816 | status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0); | 1876 | status = ocfs2_cluster_lock(osb, lockres, LKM_EXMODE, 0, 0); |
1817 | if (status < 0) | 1877 | if (status < 0) |
1818 | mlog_errno(status); | 1878 | mlog_errno(status); |
@@ -1824,7 +1884,8 @@ void ocfs2_rename_unlock(struct ocfs2_super *osb) | |||
1824 | { | 1884 | { |
1825 | struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; | 1885 | struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres; |
1826 | 1886 | ||
1827 | ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE); | 1887 | if (!ocfs2_mount_local(osb)) |
1888 | ocfs2_cluster_unlock(osb, lockres, LKM_EXMODE); | ||
1828 | } | 1889 | } |
1829 | 1890 | ||
1830 | int ocfs2_dentry_lock(struct dentry *dentry, int ex) | 1891 | int ocfs2_dentry_lock(struct dentry *dentry, int ex) |
@@ -1839,6 +1900,9 @@ int ocfs2_dentry_lock(struct dentry *dentry, int ex) | |||
1839 | if (ocfs2_is_hard_readonly(osb)) | 1900 | if (ocfs2_is_hard_readonly(osb)) |
1840 | return -EROFS; | 1901 | return -EROFS; |
1841 | 1902 | ||
1903 | if (ocfs2_mount_local(osb)) | ||
1904 | return 0; | ||
1905 | |||
1842 | ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0); | 1906 | ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0); |
1843 | if (ret < 0) | 1907 | if (ret < 0) |
1844 | mlog_errno(ret); | 1908 | mlog_errno(ret); |
@@ -1852,7 +1916,8 @@ void ocfs2_dentry_unlock(struct dentry *dentry, int ex) | |||
1852 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; | 1916 | struct ocfs2_dentry_lock *dl = dentry->d_fsdata; |
1853 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); | 1917 | struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb); |
1854 | 1918 | ||
1855 | ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); | 1919 | if (!ocfs2_mount_local(osb)) |
1920 | ocfs2_cluster_unlock(osb, &dl->dl_lockres, level); | ||
1856 | } | 1921 | } |
1857 | 1922 | ||
1858 | /* Reference counting of the dlm debug structure. We want this because | 1923 | /* Reference counting of the dlm debug structure. We want this because |
@@ -2115,12 +2180,15 @@ static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb) | |||
2115 | 2180 | ||
2116 | int ocfs2_dlm_init(struct ocfs2_super *osb) | 2181 | int ocfs2_dlm_init(struct ocfs2_super *osb) |
2117 | { | 2182 | { |
2118 | int status; | 2183 | int status = 0; |
2119 | u32 dlm_key; | 2184 | u32 dlm_key; |
2120 | struct dlm_ctxt *dlm; | 2185 | struct dlm_ctxt *dlm = NULL; |
2121 | 2186 | ||
2122 | mlog_entry_void(); | 2187 | mlog_entry_void(); |
2123 | 2188 | ||
2189 | if (ocfs2_mount_local(osb)) | ||
2190 | goto local; | ||
2191 | |||
2124 | status = ocfs2_dlm_init_debug(osb); | 2192 | status = ocfs2_dlm_init_debug(osb); |
2125 | if (status < 0) { | 2193 | if (status < 0) { |
2126 | mlog_errno(status); | 2194 | mlog_errno(status); |
@@ -2148,11 +2216,12 @@ int ocfs2_dlm_init(struct ocfs2_super *osb) | |||
2148 | goto bail; | 2216 | goto bail; |
2149 | } | 2217 | } |
2150 | 2218 | ||
2219 | dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb); | ||
2220 | |||
2221 | local: | ||
2151 | ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); | 2222 | ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb); |
2152 | ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); | 2223 | ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb); |
2153 | 2224 | ||
2154 | dlm_register_eviction_cb(dlm, &osb->osb_eviction_cb); | ||
2155 | |||
2156 | osb->dlm = dlm; | 2225 | osb->dlm = dlm; |
2157 | 2226 | ||
2158 | status = 0; | 2227 | status = 0; |
@@ -2649,6 +2718,15 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, | |||
2649 | inode = ocfs2_lock_res_inode(lockres); | 2718 | inode = ocfs2_lock_res_inode(lockres); |
2650 | mapping = inode->i_mapping; | 2719 | mapping = inode->i_mapping; |
2651 | 2720 | ||
2721 | /* | ||
2722 | * We need this before the filemap_fdatawrite() so that it can | ||
2723 | * transfer the dirty bit from the PTE to the | ||
2724 | * page. Unfortunately this means that even for EX->PR | ||
2725 | * downconverts, we'll lose our mappings and have to build | ||
2726 | * them up again. | ||
2727 | */ | ||
2728 | unmap_mapping_range(mapping, 0, 0, 0); | ||
2729 | |||
2652 | if (filemap_fdatawrite(mapping)) { | 2730 | if (filemap_fdatawrite(mapping)) { |
2653 | mlog(ML_ERROR, "Could not sync inode %llu for downconvert!", | 2731 | mlog(ML_ERROR, "Could not sync inode %llu for downconvert!", |
2654 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | 2732 | (unsigned long long)OCFS2_I(inode)->ip_blkno); |
@@ -2656,7 +2734,6 @@ static int ocfs2_data_convert_worker(struct ocfs2_lock_res *lockres, | |||
2656 | sync_mapping_buffers(mapping); | 2734 | sync_mapping_buffers(mapping); |
2657 | if (blocking == LKM_EXMODE) { | 2735 | if (blocking == LKM_EXMODE) { |
2658 | truncate_inode_pages(mapping, 0); | 2736 | truncate_inode_pages(mapping, 0); |
2659 | unmap_mapping_range(mapping, 0, 0, 0); | ||
2660 | } else { | 2737 | } else { |
2661 | /* We only need to wait on the I/O if we're not also | 2738 | /* We only need to wait on the I/O if we're not also |
2662 | * truncating pages because truncate_inode_pages waits | 2739 | * truncating pages because truncate_inode_pages waits |
diff --git a/fs/ocfs2/dlmglue.h b/fs/ocfs2/dlmglue.h index 4a2769387229..c343fca68cf1 100644 --- a/fs/ocfs2/dlmglue.h +++ b/fs/ocfs2/dlmglue.h | |||
@@ -68,8 +68,6 @@ void ocfs2_dentry_lock_res_init(struct ocfs2_dentry_lock *dl, | |||
68 | u64 parent, struct inode *inode); | 68 | u64 parent, struct inode *inode); |
69 | void ocfs2_lock_res_free(struct ocfs2_lock_res *res); | 69 | void ocfs2_lock_res_free(struct ocfs2_lock_res *res); |
70 | int ocfs2_create_new_inode_locks(struct inode *inode); | 70 | int ocfs2_create_new_inode_locks(struct inode *inode); |
71 | int ocfs2_create_new_lock(struct ocfs2_super *osb, | ||
72 | struct ocfs2_lock_res *lockres, int ex, int local); | ||
73 | int ocfs2_drop_inode_locks(struct inode *inode); | 71 | int ocfs2_drop_inode_locks(struct inode *inode); |
74 | int ocfs2_data_lock_full(struct inode *inode, | 72 | int ocfs2_data_lock_full(struct inode *inode, |
75 | int write, | 73 | int write, |
@@ -82,19 +80,20 @@ void ocfs2_data_unlock(struct inode *inode, | |||
82 | int write); | 80 | int write); |
83 | int ocfs2_rw_lock(struct inode *inode, int write); | 81 | int ocfs2_rw_lock(struct inode *inode, int write); |
84 | void ocfs2_rw_unlock(struct inode *inode, int write); | 82 | void ocfs2_rw_unlock(struct inode *inode, int write); |
83 | int ocfs2_meta_lock_atime(struct inode *inode, | ||
84 | struct vfsmount *vfsmnt, | ||
85 | int *level); | ||
85 | int ocfs2_meta_lock_full(struct inode *inode, | 86 | int ocfs2_meta_lock_full(struct inode *inode, |
86 | struct ocfs2_journal_handle *handle, | ||
87 | struct buffer_head **ret_bh, | 87 | struct buffer_head **ret_bh, |
88 | int ex, | 88 | int ex, |
89 | int arg_flags); | 89 | int arg_flags); |
90 | int ocfs2_meta_lock_with_page(struct inode *inode, | 90 | int ocfs2_meta_lock_with_page(struct inode *inode, |
91 | struct ocfs2_journal_handle *handle, | ||
92 | struct buffer_head **ret_bh, | 91 | struct buffer_head **ret_bh, |
93 | int ex, | 92 | int ex, |
94 | struct page *page); | 93 | struct page *page); |
95 | /* 99% of the time we don't want to supply any additional flags -- | 94 | /* 99% of the time we don't want to supply any additional flags -- |
96 | * those are for very specific cases only. */ | 95 | * those are for very specific cases only. */ |
97 | #define ocfs2_meta_lock(i, h, b, e) ocfs2_meta_lock_full(i, h, b, e, 0) | 96 | #define ocfs2_meta_lock(i, b, e) ocfs2_meta_lock_full(i, b, e, 0) |
98 | void ocfs2_meta_unlock(struct inode *inode, | 97 | void ocfs2_meta_unlock(struct inode *inode, |
99 | int ex); | 98 | int ex); |
100 | int ocfs2_super_lock(struct ocfs2_super *osb, | 99 | int ocfs2_super_lock(struct ocfs2_super *osb, |
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index fb91089a60a7..06be6e774cf9 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c | |||
@@ -100,7 +100,7 @@ static struct dentry *ocfs2_get_parent(struct dentry *child) | |||
100 | mlog(0, "find parent of directory %llu\n", | 100 | mlog(0, "find parent of directory %llu\n", |
101 | (unsigned long long)OCFS2_I(dir)->ip_blkno); | 101 | (unsigned long long)OCFS2_I(dir)->ip_blkno); |
102 | 102 | ||
103 | status = ocfs2_meta_lock(dir, NULL, NULL, 0); | 103 | status = ocfs2_meta_lock(dir, NULL, 0); |
104 | if (status < 0) { | 104 | if (status < 0) { |
105 | if (status != -ENOENT) | 105 | if (status != -ENOENT) |
106 | mlog_errno(status); | 106 | mlog_errno(status); |
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index fcd4475d1f89..80ac69f11d9f 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c | |||
@@ -61,7 +61,7 @@ struct ocfs2_em_insert_context { | |||
61 | struct ocfs2_extent_map_entry *right_ent; | 61 | struct ocfs2_extent_map_entry *right_ent; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | static kmem_cache_t *ocfs2_em_ent_cachep = NULL; | 64 | static struct kmem_cache *ocfs2_em_ent_cachep = NULL; |
65 | 65 | ||
66 | 66 | ||
67 | static struct ocfs2_extent_map_entry * | 67 | static struct ocfs2_extent_map_entry * |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 1be74c4e7814..10953a508f2f 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -31,6 +31,8 @@ | |||
31 | #include <linux/pagemap.h> | 31 | #include <linux/pagemap.h> |
32 | #include <linux/uio.h> | 32 | #include <linux/uio.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/pipe_fs_i.h> | ||
35 | #include <linux/mount.h> | ||
34 | 36 | ||
35 | #define MLOG_MASK_PREFIX ML_INODE | 37 | #define MLOG_MASK_PREFIX ML_INODE |
36 | #include <cluster/masklog.h> | 38 | #include <cluster/masklog.h> |
@@ -66,7 +68,7 @@ static int ocfs2_file_open(struct inode *inode, struct file *file) | |||
66 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 68 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
67 | 69 | ||
68 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, | 70 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, |
69 | file->f_dentry->d_name.len, file->f_dentry->d_name.name); | 71 | file->f_path.dentry->d_name.len, file->f_path.dentry->d_name.name); |
70 | 72 | ||
71 | spin_lock(&oi->ip_lock); | 73 | spin_lock(&oi->ip_lock); |
72 | 74 | ||
@@ -96,8 +98,8 @@ static int ocfs2_file_release(struct inode *inode, struct file *file) | |||
96 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 98 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
97 | 99 | ||
98 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, | 100 | mlog_entry("(0x%p, 0x%p, '%.*s')\n", inode, file, |
99 | file->f_dentry->d_name.len, | 101 | file->f_path.dentry->d_name.len, |
100 | file->f_dentry->d_name.name); | 102 | file->f_path.dentry->d_name.name); |
101 | 103 | ||
102 | spin_lock(&oi->ip_lock); | 104 | spin_lock(&oi->ip_lock); |
103 | if (!--oi->ip_open_count) | 105 | if (!--oi->ip_open_count) |
@@ -134,7 +136,77 @@ bail: | |||
134 | return (err < 0) ? -EIO : 0; | 136 | return (err < 0) ? -EIO : 0; |
135 | } | 137 | } |
136 | 138 | ||
137 | int ocfs2_set_inode_size(struct ocfs2_journal_handle *handle, | 139 | int ocfs2_should_update_atime(struct inode *inode, |
140 | struct vfsmount *vfsmnt) | ||
141 | { | ||
142 | struct timespec now; | ||
143 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
144 | |||
145 | if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) | ||
146 | return 0; | ||
147 | |||
148 | if ((inode->i_flags & S_NOATIME) || | ||
149 | ((inode->i_sb->s_flags & MS_NODIRATIME) && S_ISDIR(inode->i_mode))) | ||
150 | return 0; | ||
151 | |||
152 | /* | ||
153 | * We can be called with no vfsmnt structure - NFSD will | ||
154 | * sometimes do this. | ||
155 | * | ||
156 | * Note that our action here is different than touch_atime() - | ||
157 | * if we can't tell whether this is a noatime mount, then we | ||
158 | * don't know whether to trust the value of s_atime_quantum. | ||
159 | */ | ||
160 | if (vfsmnt == NULL) | ||
161 | return 0; | ||
162 | |||
163 | if ((vfsmnt->mnt_flags & MNT_NOATIME) || | ||
164 | ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))) | ||
165 | return 0; | ||
166 | |||
167 | if (vfsmnt->mnt_flags & MNT_RELATIME) { | ||
168 | if ((timespec_compare(&inode->i_atime, &inode->i_mtime) <= 0) || | ||
169 | (timespec_compare(&inode->i_atime, &inode->i_ctime) <= 0)) | ||
170 | return 1; | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | now = CURRENT_TIME; | ||
176 | if ((now.tv_sec - inode->i_atime.tv_sec <= osb->s_atime_quantum)) | ||
177 | return 0; | ||
178 | else | ||
179 | return 1; | ||
180 | } | ||
181 | |||
182 | int ocfs2_update_inode_atime(struct inode *inode, | ||
183 | struct buffer_head *bh) | ||
184 | { | ||
185 | int ret; | ||
186 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
187 | handle_t *handle; | ||
188 | |||
189 | mlog_entry_void(); | ||
190 | |||
191 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | ||
192 | if (handle == NULL) { | ||
193 | ret = -ENOMEM; | ||
194 | mlog_errno(ret); | ||
195 | goto out; | ||
196 | } | ||
197 | |||
198 | inode->i_atime = CURRENT_TIME; | ||
199 | ret = ocfs2_mark_inode_dirty(handle, inode, bh); | ||
200 | if (ret < 0) | ||
201 | mlog_errno(ret); | ||
202 | |||
203 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); | ||
204 | out: | ||
205 | mlog_exit(ret); | ||
206 | return ret; | ||
207 | } | ||
208 | |||
209 | int ocfs2_set_inode_size(handle_t *handle, | ||
138 | struct inode *inode, | 210 | struct inode *inode, |
139 | struct buffer_head *fe_bh, | 211 | struct buffer_head *fe_bh, |
140 | u64 new_i_size) | 212 | u64 new_i_size) |
@@ -163,10 +235,9 @@ static int ocfs2_simple_size_update(struct inode *inode, | |||
163 | { | 235 | { |
164 | int ret; | 236 | int ret; |
165 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 237 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
166 | struct ocfs2_journal_handle *handle = NULL; | 238 | handle_t *handle = NULL; |
167 | 239 | ||
168 | handle = ocfs2_start_trans(osb, NULL, | 240 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
169 | OCFS2_INODE_UPDATE_CREDITS); | ||
170 | if (handle == NULL) { | 241 | if (handle == NULL) { |
171 | ret = -ENOMEM; | 242 | ret = -ENOMEM; |
172 | mlog_errno(ret); | 243 | mlog_errno(ret); |
@@ -178,7 +249,7 @@ static int ocfs2_simple_size_update(struct inode *inode, | |||
178 | if (ret < 0) | 249 | if (ret < 0) |
179 | mlog_errno(ret); | 250 | mlog_errno(ret); |
180 | 251 | ||
181 | ocfs2_commit_trans(handle); | 252 | ocfs2_commit_trans(osb, handle); |
182 | out: | 253 | out: |
183 | return ret; | 254 | return ret; |
184 | } | 255 | } |
@@ -189,14 +260,14 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb, | |||
189 | u64 new_i_size) | 260 | u64 new_i_size) |
190 | { | 261 | { |
191 | int status; | 262 | int status; |
192 | struct ocfs2_journal_handle *handle; | 263 | handle_t *handle; |
193 | 264 | ||
194 | mlog_entry_void(); | 265 | mlog_entry_void(); |
195 | 266 | ||
196 | /* TODO: This needs to actually orphan the inode in this | 267 | /* TODO: This needs to actually orphan the inode in this |
197 | * transaction. */ | 268 | * transaction. */ |
198 | 269 | ||
199 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 270 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
200 | if (IS_ERR(handle)) { | 271 | if (IS_ERR(handle)) { |
201 | status = PTR_ERR(handle); | 272 | status = PTR_ERR(handle); |
202 | mlog_errno(status); | 273 | mlog_errno(status); |
@@ -207,7 +278,7 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb, | |||
207 | if (status < 0) | 278 | if (status < 0) |
208 | mlog_errno(status); | 279 | mlog_errno(status); |
209 | 280 | ||
210 | ocfs2_commit_trans(handle); | 281 | ocfs2_commit_trans(osb, handle); |
211 | out: | 282 | out: |
212 | mlog_exit(status); | 283 | mlog_exit(status); |
213 | return status; | 284 | return status; |
@@ -328,7 +399,7 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb, | |||
328 | struct inode *inode, | 399 | struct inode *inode, |
329 | u32 clusters_to_add, | 400 | u32 clusters_to_add, |
330 | struct buffer_head *fe_bh, | 401 | struct buffer_head *fe_bh, |
331 | struct ocfs2_journal_handle *handle, | 402 | handle_t *handle, |
332 | struct ocfs2_alloc_context *data_ac, | 403 | struct ocfs2_alloc_context *data_ac, |
333 | struct ocfs2_alloc_context *meta_ac, | 404 | struct ocfs2_alloc_context *meta_ac, |
334 | enum ocfs2_alloc_restarted *reason_ret) | 405 | enum ocfs2_alloc_restarted *reason_ret) |
@@ -433,7 +504,7 @@ static int ocfs2_extend_allocation(struct inode *inode, | |||
433 | u32 prev_clusters; | 504 | u32 prev_clusters; |
434 | struct buffer_head *bh = NULL; | 505 | struct buffer_head *bh = NULL; |
435 | struct ocfs2_dinode *fe = NULL; | 506 | struct ocfs2_dinode *fe = NULL; |
436 | struct ocfs2_journal_handle *handle = NULL; | 507 | handle_t *handle = NULL; |
437 | struct ocfs2_alloc_context *data_ac = NULL; | 508 | struct ocfs2_alloc_context *data_ac = NULL; |
438 | struct ocfs2_alloc_context *meta_ac = NULL; | 509 | struct ocfs2_alloc_context *meta_ac = NULL; |
439 | enum ocfs2_alloc_restarted why; | 510 | enum ocfs2_alloc_restarted why; |
@@ -463,13 +534,6 @@ restart_all: | |||
463 | (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode), | 534 | (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode), |
464 | fe->i_clusters, clusters_to_add); | 535 | fe->i_clusters, clusters_to_add); |
465 | 536 | ||
466 | handle = ocfs2_alloc_handle(osb); | ||
467 | if (handle == NULL) { | ||
468 | status = -ENOMEM; | ||
469 | mlog_errno(status); | ||
470 | goto leave; | ||
471 | } | ||
472 | |||
473 | num_free_extents = ocfs2_num_free_extents(osb, | 537 | num_free_extents = ocfs2_num_free_extents(osb, |
474 | inode, | 538 | inode, |
475 | fe); | 539 | fe); |
@@ -480,10 +544,7 @@ restart_all: | |||
480 | } | 544 | } |
481 | 545 | ||
482 | if (!num_free_extents) { | 546 | if (!num_free_extents) { |
483 | status = ocfs2_reserve_new_metadata(osb, | 547 | status = ocfs2_reserve_new_metadata(osb, fe, &meta_ac); |
484 | handle, | ||
485 | fe, | ||
486 | &meta_ac); | ||
487 | if (status < 0) { | 548 | if (status < 0) { |
488 | if (status != -ENOSPC) | 549 | if (status != -ENOSPC) |
489 | mlog_errno(status); | 550 | mlog_errno(status); |
@@ -491,10 +552,7 @@ restart_all: | |||
491 | } | 552 | } |
492 | } | 553 | } |
493 | 554 | ||
494 | status = ocfs2_reserve_clusters(osb, | 555 | status = ocfs2_reserve_clusters(osb, clusters_to_add, &data_ac); |
495 | handle, | ||
496 | clusters_to_add, | ||
497 | &data_ac); | ||
498 | if (status < 0) { | 556 | if (status < 0) { |
499 | if (status != -ENOSPC) | 557 | if (status != -ENOSPC) |
500 | mlog_errno(status); | 558 | mlog_errno(status); |
@@ -509,7 +567,7 @@ restart_all: | |||
509 | drop_alloc_sem = 1; | 567 | drop_alloc_sem = 1; |
510 | 568 | ||
511 | credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add); | 569 | credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add); |
512 | handle = ocfs2_start_trans(osb, handle, credits); | 570 | handle = ocfs2_start_trans(osb, credits); |
513 | if (IS_ERR(handle)) { | 571 | if (IS_ERR(handle)) { |
514 | status = PTR_ERR(handle); | 572 | status = PTR_ERR(handle); |
515 | handle = NULL; | 573 | handle = NULL; |
@@ -589,7 +647,7 @@ leave: | |||
589 | drop_alloc_sem = 0; | 647 | drop_alloc_sem = 0; |
590 | } | 648 | } |
591 | if (handle) { | 649 | if (handle) { |
592 | ocfs2_commit_trans(handle); | 650 | ocfs2_commit_trans(osb, handle); |
593 | handle = NULL; | 651 | handle = NULL; |
594 | } | 652 | } |
595 | if (data_ac) { | 653 | if (data_ac) { |
@@ -624,7 +682,7 @@ static int ocfs2_write_zero_page(struct inode *inode, | |||
624 | struct page *page; | 682 | struct page *page; |
625 | unsigned long index; | 683 | unsigned long index; |
626 | unsigned int offset; | 684 | unsigned int offset; |
627 | struct ocfs2_journal_handle *handle = NULL; | 685 | handle_t *handle = NULL; |
628 | int ret; | 686 | int ret; |
629 | 687 | ||
630 | offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */ | 688 | offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */ |
@@ -668,7 +726,7 @@ static int ocfs2_write_zero_page(struct inode *inode, | |||
668 | ret = 0; | 726 | ret = 0; |
669 | 727 | ||
670 | if (handle) | 728 | if (handle) |
671 | ocfs2_commit_trans(handle); | 729 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); |
672 | out_unlock: | 730 | out_unlock: |
673 | unlock_page(page); | 731 | unlock_page(page); |
674 | page_cache_release(page); | 732 | page_cache_release(page); |
@@ -789,7 +847,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
789 | struct super_block *sb = inode->i_sb; | 847 | struct super_block *sb = inode->i_sb; |
790 | struct ocfs2_super *osb = OCFS2_SB(sb); | 848 | struct ocfs2_super *osb = OCFS2_SB(sb); |
791 | struct buffer_head *bh = NULL; | 849 | struct buffer_head *bh = NULL; |
792 | struct ocfs2_journal_handle *handle = NULL; | 850 | handle_t *handle = NULL; |
793 | 851 | ||
794 | mlog_entry("(0x%p, '%.*s')\n", dentry, | 852 | mlog_entry("(0x%p, '%.*s')\n", dentry, |
795 | dentry->d_name.len, dentry->d_name.name); | 853 | dentry->d_name.len, dentry->d_name.name); |
@@ -825,7 +883,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
825 | } | 883 | } |
826 | } | 884 | } |
827 | 885 | ||
828 | status = ocfs2_meta_lock(inode, NULL, &bh, 1); | 886 | status = ocfs2_meta_lock(inode, &bh, 1); |
829 | if (status < 0) { | 887 | if (status < 0) { |
830 | if (status != -ENOENT) | 888 | if (status != -ENOENT) |
831 | mlog_errno(status); | 889 | mlog_errno(status); |
@@ -845,7 +903,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
845 | } | 903 | } |
846 | } | 904 | } |
847 | 905 | ||
848 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 906 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
849 | if (IS_ERR(handle)) { | 907 | if (IS_ERR(handle)) { |
850 | status = PTR_ERR(handle); | 908 | status = PTR_ERR(handle); |
851 | mlog_errno(status); | 909 | mlog_errno(status); |
@@ -863,7 +921,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
863 | mlog_errno(status); | 921 | mlog_errno(status); |
864 | 922 | ||
865 | bail_commit: | 923 | bail_commit: |
866 | ocfs2_commit_trans(handle); | 924 | ocfs2_commit_trans(osb, handle); |
867 | bail_unlock: | 925 | bail_unlock: |
868 | ocfs2_meta_unlock(inode, 1); | 926 | ocfs2_meta_unlock(inode, 1); |
869 | bail_unlock_rw: | 927 | bail_unlock_rw: |
@@ -906,19 +964,39 @@ bail: | |||
906 | return err; | 964 | return err; |
907 | } | 965 | } |
908 | 966 | ||
967 | int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd) | ||
968 | { | ||
969 | int ret; | ||
970 | |||
971 | mlog_entry_void(); | ||
972 | |||
973 | ret = ocfs2_meta_lock(inode, NULL, 0); | ||
974 | if (ret) { | ||
975 | mlog_errno(ret); | ||
976 | goto out; | ||
977 | } | ||
978 | |||
979 | ret = generic_permission(inode, mask, NULL); | ||
980 | |||
981 | ocfs2_meta_unlock(inode, 0); | ||
982 | out: | ||
983 | mlog_exit(ret); | ||
984 | return ret; | ||
985 | } | ||
986 | |||
909 | static int ocfs2_write_remove_suid(struct inode *inode) | 987 | static int ocfs2_write_remove_suid(struct inode *inode) |
910 | { | 988 | { |
911 | int ret; | 989 | int ret; |
912 | struct buffer_head *bh = NULL; | 990 | struct buffer_head *bh = NULL; |
913 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 991 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
914 | struct ocfs2_journal_handle *handle; | 992 | handle_t *handle; |
915 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 993 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
916 | struct ocfs2_dinode *di; | 994 | struct ocfs2_dinode *di; |
917 | 995 | ||
918 | mlog_entry("(Inode %llu, mode 0%o)\n", | 996 | mlog_entry("(Inode %llu, mode 0%o)\n", |
919 | (unsigned long long)oi->ip_blkno, inode->i_mode); | 997 | (unsigned long long)oi->ip_blkno, inode->i_mode); |
920 | 998 | ||
921 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 999 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
922 | if (handle == NULL) { | 1000 | if (handle == NULL) { |
923 | ret = -ENOMEM; | 1001 | ret = -ENOMEM; |
924 | mlog_errno(ret); | 1002 | mlog_errno(ret); |
@@ -951,75 +1029,29 @@ static int ocfs2_write_remove_suid(struct inode *inode) | |||
951 | out_bh: | 1029 | out_bh: |
952 | brelse(bh); | 1030 | brelse(bh); |
953 | out_trans: | 1031 | out_trans: |
954 | ocfs2_commit_trans(handle); | 1032 | ocfs2_commit_trans(osb, handle); |
955 | out: | 1033 | out: |
956 | mlog_exit(ret); | 1034 | mlog_exit(ret); |
957 | return ret; | 1035 | return ret; |
958 | } | 1036 | } |
959 | 1037 | ||
960 | static inline int ocfs2_write_should_remove_suid(struct inode *inode) | 1038 | static int ocfs2_prepare_inode_for_write(struct dentry *dentry, |
961 | { | 1039 | loff_t *ppos, |
962 | mode_t mode = inode->i_mode; | 1040 | size_t count, |
963 | 1041 | int appending) | |
964 | if (!capable(CAP_FSETID)) { | ||
965 | if (unlikely(mode & S_ISUID)) | ||
966 | return 1; | ||
967 | |||
968 | if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) | ||
969 | return 1; | ||
970 | } | ||
971 | return 0; | ||
972 | } | ||
973 | |||
974 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | ||
975 | const struct iovec *iov, | ||
976 | unsigned long nr_segs, | ||
977 | loff_t pos) | ||
978 | { | 1042 | { |
979 | int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; | 1043 | int ret = 0, meta_level = appending; |
1044 | struct inode *inode = dentry->d_inode; | ||
980 | u32 clusters; | 1045 | u32 clusters; |
981 | struct file *filp = iocb->ki_filp; | ||
982 | struct inode *inode = filp->f_dentry->d_inode; | ||
983 | loff_t newsize, saved_pos; | 1046 | loff_t newsize, saved_pos; |
984 | 1047 | ||
985 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, | ||
986 | (unsigned int)nr_segs, | ||
987 | filp->f_dentry->d_name.len, | ||
988 | filp->f_dentry->d_name.name); | ||
989 | |||
990 | /* happy write of zero bytes */ | ||
991 | if (iocb->ki_left == 0) | ||
992 | return 0; | ||
993 | |||
994 | if (!inode) { | ||
995 | mlog(0, "bad inode\n"); | ||
996 | return -EIO; | ||
997 | } | ||
998 | |||
999 | mutex_lock(&inode->i_mutex); | ||
1000 | /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ | ||
1001 | if (filp->f_flags & O_DIRECT) { | ||
1002 | have_alloc_sem = 1; | ||
1003 | down_read(&inode->i_alloc_sem); | ||
1004 | } | ||
1005 | |||
1006 | /* concurrent O_DIRECT writes are allowed */ | ||
1007 | rw_level = (filp->f_flags & O_DIRECT) ? 0 : 1; | ||
1008 | ret = ocfs2_rw_lock(inode, rw_level); | ||
1009 | if (ret < 0) { | ||
1010 | rw_level = -1; | ||
1011 | mlog_errno(ret); | ||
1012 | goto out; | ||
1013 | } | ||
1014 | |||
1015 | /* | 1048 | /* |
1016 | * We sample i_size under a read level meta lock to see if our write | 1049 | * We sample i_size under a read level meta lock to see if our write |
1017 | * is extending the file, if it is we back off and get a write level | 1050 | * is extending the file, if it is we back off and get a write level |
1018 | * meta lock. | 1051 | * meta lock. |
1019 | */ | 1052 | */ |
1020 | meta_level = (filp->f_flags & O_APPEND) ? 1 : 0; | ||
1021 | for(;;) { | 1053 | for(;;) { |
1022 | ret = ocfs2_meta_lock(inode, NULL, NULL, meta_level); | 1054 | ret = ocfs2_meta_lock(inode, NULL, meta_level); |
1023 | if (ret < 0) { | 1055 | if (ret < 0) { |
1024 | meta_level = -1; | 1056 | meta_level = -1; |
1025 | mlog_errno(ret); | 1057 | mlog_errno(ret); |
@@ -1035,7 +1067,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1035 | * inode. There's also the dinode i_size state which | 1067 | * inode. There's also the dinode i_size state which |
1036 | * can be lost via setattr during extending writes (we | 1068 | * can be lost via setattr during extending writes (we |
1037 | * set inode->i_size at the end of a write. */ | 1069 | * set inode->i_size at the end of a write. */ |
1038 | if (ocfs2_write_should_remove_suid(inode)) { | 1070 | if (should_remove_suid(dentry)) { |
1039 | if (meta_level == 0) { | 1071 | if (meta_level == 0) { |
1040 | ocfs2_meta_unlock(inode, meta_level); | 1072 | ocfs2_meta_unlock(inode, meta_level); |
1041 | meta_level = 1; | 1073 | meta_level = 1; |
@@ -1045,19 +1077,19 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1045 | ret = ocfs2_write_remove_suid(inode); | 1077 | ret = ocfs2_write_remove_suid(inode); |
1046 | if (ret < 0) { | 1078 | if (ret < 0) { |
1047 | mlog_errno(ret); | 1079 | mlog_errno(ret); |
1048 | goto out; | 1080 | goto out_unlock; |
1049 | } | 1081 | } |
1050 | } | 1082 | } |
1051 | 1083 | ||
1052 | /* work on a copy of ppos until we're sure that we won't have | 1084 | /* work on a copy of ppos until we're sure that we won't have |
1053 | * to recalculate it due to relocking. */ | 1085 | * to recalculate it due to relocking. */ |
1054 | if (filp->f_flags & O_APPEND) { | 1086 | if (appending) { |
1055 | saved_pos = i_size_read(inode); | 1087 | saved_pos = i_size_read(inode); |
1056 | mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); | 1088 | mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); |
1057 | } else { | 1089 | } else { |
1058 | saved_pos = iocb->ki_pos; | 1090 | saved_pos = *ppos; |
1059 | } | 1091 | } |
1060 | newsize = iocb->ki_left + saved_pos; | 1092 | newsize = count + saved_pos; |
1061 | 1093 | ||
1062 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", | 1094 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", |
1063 | (long long) saved_pos, (long long) newsize, | 1095 | (long long) saved_pos, (long long) newsize, |
@@ -1090,19 +1122,66 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1090 | if (!clusters) | 1122 | if (!clusters) |
1091 | break; | 1123 | break; |
1092 | 1124 | ||
1093 | ret = ocfs2_extend_file(inode, NULL, newsize, iocb->ki_left); | 1125 | ret = ocfs2_extend_file(inode, NULL, newsize, count); |
1094 | if (ret < 0) { | 1126 | if (ret < 0) { |
1095 | if (ret != -ENOSPC) | 1127 | if (ret != -ENOSPC) |
1096 | mlog_errno(ret); | 1128 | mlog_errno(ret); |
1097 | goto out; | 1129 | goto out_unlock; |
1098 | } | 1130 | } |
1099 | break; | 1131 | break; |
1100 | } | 1132 | } |
1101 | 1133 | ||
1102 | /* ok, we're done with i_size and alloc work */ | 1134 | if (appending) |
1103 | iocb->ki_pos = saved_pos; | 1135 | *ppos = saved_pos; |
1136 | |||
1137 | out_unlock: | ||
1104 | ocfs2_meta_unlock(inode, meta_level); | 1138 | ocfs2_meta_unlock(inode, meta_level); |
1105 | meta_level = -1; | 1139 | |
1140 | out: | ||
1141 | return ret; | ||
1142 | } | ||
1143 | |||
1144 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | ||
1145 | const struct iovec *iov, | ||
1146 | unsigned long nr_segs, | ||
1147 | loff_t pos) | ||
1148 | { | ||
1149 | int ret, rw_level, have_alloc_sem = 0; | ||
1150 | struct file *filp = iocb->ki_filp; | ||
1151 | struct inode *inode = filp->f_path.dentry->d_inode; | ||
1152 | int appending = filp->f_flags & O_APPEND ? 1 : 0; | ||
1153 | |||
1154 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, | ||
1155 | (unsigned int)nr_segs, | ||
1156 | filp->f_path.dentry->d_name.len, | ||
1157 | filp->f_path.dentry->d_name.name); | ||
1158 | |||
1159 | /* happy write of zero bytes */ | ||
1160 | if (iocb->ki_left == 0) | ||
1161 | return 0; | ||
1162 | |||
1163 | mutex_lock(&inode->i_mutex); | ||
1164 | /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ | ||
1165 | if (filp->f_flags & O_DIRECT) { | ||
1166 | have_alloc_sem = 1; | ||
1167 | down_read(&inode->i_alloc_sem); | ||
1168 | } | ||
1169 | |||
1170 | /* concurrent O_DIRECT writes are allowed */ | ||
1171 | rw_level = (filp->f_flags & O_DIRECT) ? 0 : 1; | ||
1172 | ret = ocfs2_rw_lock(inode, rw_level); | ||
1173 | if (ret < 0) { | ||
1174 | rw_level = -1; | ||
1175 | mlog_errno(ret); | ||
1176 | goto out; | ||
1177 | } | ||
1178 | |||
1179 | ret = ocfs2_prepare_inode_for_write(filp->f_path.dentry, &iocb->ki_pos, | ||
1180 | iocb->ki_left, appending); | ||
1181 | if (ret < 0) { | ||
1182 | mlog_errno(ret); | ||
1183 | goto out; | ||
1184 | } | ||
1106 | 1185 | ||
1107 | /* communicate with ocfs2_dio_end_io */ | 1186 | /* communicate with ocfs2_dio_end_io */ |
1108 | ocfs2_iocb_set_rw_locked(iocb); | 1187 | ocfs2_iocb_set_rw_locked(iocb); |
@@ -1128,8 +1207,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1128 | } | 1207 | } |
1129 | 1208 | ||
1130 | out: | 1209 | out: |
1131 | if (meta_level != -1) | ||
1132 | ocfs2_meta_unlock(inode, meta_level); | ||
1133 | if (have_alloc_sem) | 1210 | if (have_alloc_sem) |
1134 | up_read(&inode->i_alloc_sem); | 1211 | up_read(&inode->i_alloc_sem); |
1135 | if (rw_level != -1) | 1212 | if (rw_level != -1) |
@@ -1140,19 +1217,90 @@ out: | |||
1140 | return ret; | 1217 | return ret; |
1141 | } | 1218 | } |
1142 | 1219 | ||
1220 | static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, | ||
1221 | struct file *out, | ||
1222 | loff_t *ppos, | ||
1223 | size_t len, | ||
1224 | unsigned int flags) | ||
1225 | { | ||
1226 | int ret; | ||
1227 | struct inode *inode = out->f_path.dentry->d_inode; | ||
1228 | |||
1229 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", out, pipe, | ||
1230 | (unsigned int)len, | ||
1231 | out->f_path.dentry->d_name.len, | ||
1232 | out->f_path.dentry->d_name.name); | ||
1233 | |||
1234 | inode_double_lock(inode, pipe->inode); | ||
1235 | |||
1236 | ret = ocfs2_rw_lock(inode, 1); | ||
1237 | if (ret < 0) { | ||
1238 | mlog_errno(ret); | ||
1239 | goto out; | ||
1240 | } | ||
1241 | |||
1242 | ret = ocfs2_prepare_inode_for_write(out->f_path.dentry, ppos, len, 0); | ||
1243 | if (ret < 0) { | ||
1244 | mlog_errno(ret); | ||
1245 | goto out_unlock; | ||
1246 | } | ||
1247 | |||
1248 | /* ok, we're done with i_size and alloc work */ | ||
1249 | ret = generic_file_splice_write_nolock(pipe, out, ppos, len, flags); | ||
1250 | |||
1251 | out_unlock: | ||
1252 | ocfs2_rw_unlock(inode, 1); | ||
1253 | out: | ||
1254 | inode_double_unlock(inode, pipe->inode); | ||
1255 | |||
1256 | mlog_exit(ret); | ||
1257 | return ret; | ||
1258 | } | ||
1259 | |||
1260 | static ssize_t ocfs2_file_splice_read(struct file *in, | ||
1261 | loff_t *ppos, | ||
1262 | struct pipe_inode_info *pipe, | ||
1263 | size_t len, | ||
1264 | unsigned int flags) | ||
1265 | { | ||
1266 | int ret = 0; | ||
1267 | struct inode *inode = in->f_path.dentry->d_inode; | ||
1268 | |||
1269 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", in, pipe, | ||
1270 | (unsigned int)len, | ||
1271 | in->f_path.dentry->d_name.len, | ||
1272 | in->f_path.dentry->d_name.name); | ||
1273 | |||
1274 | /* | ||
1275 | * See the comment in ocfs2_file_aio_read() | ||
1276 | */ | ||
1277 | ret = ocfs2_meta_lock(inode, NULL, 0); | ||
1278 | if (ret < 0) { | ||
1279 | mlog_errno(ret); | ||
1280 | goto bail; | ||
1281 | } | ||
1282 | ocfs2_meta_unlock(inode, 0); | ||
1283 | |||
1284 | ret = generic_file_splice_read(in, ppos, pipe, len, flags); | ||
1285 | |||
1286 | bail: | ||
1287 | mlog_exit(ret); | ||
1288 | return ret; | ||
1289 | } | ||
1290 | |||
1143 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | 1291 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, |
1144 | const struct iovec *iov, | 1292 | const struct iovec *iov, |
1145 | unsigned long nr_segs, | 1293 | unsigned long nr_segs, |
1146 | loff_t pos) | 1294 | loff_t pos) |
1147 | { | 1295 | { |
1148 | int ret = 0, rw_level = -1, have_alloc_sem = 0; | 1296 | int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0; |
1149 | struct file *filp = iocb->ki_filp; | 1297 | struct file *filp = iocb->ki_filp; |
1150 | struct inode *inode = filp->f_dentry->d_inode; | 1298 | struct inode *inode = filp->f_path.dentry->d_inode; |
1151 | 1299 | ||
1152 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, | 1300 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, |
1153 | (unsigned int)nr_segs, | 1301 | (unsigned int)nr_segs, |
1154 | filp->f_dentry->d_name.len, | 1302 | filp->f_path.dentry->d_name.len, |
1155 | filp->f_dentry->d_name.name); | 1303 | filp->f_path.dentry->d_name.name); |
1156 | 1304 | ||
1157 | if (!inode) { | 1305 | if (!inode) { |
1158 | ret = -EINVAL; | 1306 | ret = -EINVAL; |
@@ -1187,12 +1335,12 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
1187 | * like i_size. This allows the checks down below | 1335 | * like i_size. This allows the checks down below |
1188 | * generic_file_aio_read() a chance of actually working. | 1336 | * generic_file_aio_read() a chance of actually working. |
1189 | */ | 1337 | */ |
1190 | ret = ocfs2_meta_lock(inode, NULL, NULL, 0); | 1338 | ret = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level); |
1191 | if (ret < 0) { | 1339 | if (ret < 0) { |
1192 | mlog_errno(ret); | 1340 | mlog_errno(ret); |
1193 | goto bail; | 1341 | goto bail; |
1194 | } | 1342 | } |
1195 | ocfs2_meta_unlock(inode, 0); | 1343 | ocfs2_meta_unlock(inode, lock_level); |
1196 | 1344 | ||
1197 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); | 1345 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); |
1198 | if (ret == -EINVAL) | 1346 | if (ret == -EINVAL) |
@@ -1220,11 +1368,13 @@ bail: | |||
1220 | struct inode_operations ocfs2_file_iops = { | 1368 | struct inode_operations ocfs2_file_iops = { |
1221 | .setattr = ocfs2_setattr, | 1369 | .setattr = ocfs2_setattr, |
1222 | .getattr = ocfs2_getattr, | 1370 | .getattr = ocfs2_getattr, |
1371 | .permission = ocfs2_permission, | ||
1223 | }; | 1372 | }; |
1224 | 1373 | ||
1225 | struct inode_operations ocfs2_special_file_iops = { | 1374 | struct inode_operations ocfs2_special_file_iops = { |
1226 | .setattr = ocfs2_setattr, | 1375 | .setattr = ocfs2_setattr, |
1227 | .getattr = ocfs2_getattr, | 1376 | .getattr = ocfs2_getattr, |
1377 | .permission = ocfs2_permission, | ||
1228 | }; | 1378 | }; |
1229 | 1379 | ||
1230 | const struct file_operations ocfs2_fops = { | 1380 | const struct file_operations ocfs2_fops = { |
@@ -1238,6 +1388,8 @@ const struct file_operations ocfs2_fops = { | |||
1238 | .aio_read = ocfs2_file_aio_read, | 1388 | .aio_read = ocfs2_file_aio_read, |
1239 | .aio_write = ocfs2_file_aio_write, | 1389 | .aio_write = ocfs2_file_aio_write, |
1240 | .ioctl = ocfs2_ioctl, | 1390 | .ioctl = ocfs2_ioctl, |
1391 | .splice_read = ocfs2_file_splice_read, | ||
1392 | .splice_write = ocfs2_file_splice_write, | ||
1241 | }; | 1393 | }; |
1242 | 1394 | ||
1243 | const struct file_operations ocfs2_dops = { | 1395 | const struct file_operations ocfs2_dops = { |
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h index 740c9e7ca599..601a453f18a8 100644 --- a/fs/ocfs2/file.h +++ b/fs/ocfs2/file.h | |||
@@ -41,17 +41,24 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb, | |||
41 | struct inode *inode, | 41 | struct inode *inode, |
42 | u32 clusters_to_add, | 42 | u32 clusters_to_add, |
43 | struct buffer_head *fe_bh, | 43 | struct buffer_head *fe_bh, |
44 | struct ocfs2_journal_handle *handle, | 44 | handle_t *handle, |
45 | struct ocfs2_alloc_context *data_ac, | 45 | struct ocfs2_alloc_context *data_ac, |
46 | struct ocfs2_alloc_context *meta_ac, | 46 | struct ocfs2_alloc_context *meta_ac, |
47 | enum ocfs2_alloc_restarted *reason); | 47 | enum ocfs2_alloc_restarted *reason); |
48 | int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); | 48 | int ocfs2_setattr(struct dentry *dentry, struct iattr *attr); |
49 | int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, | 49 | int ocfs2_getattr(struct vfsmount *mnt, struct dentry *dentry, |
50 | struct kstat *stat); | 50 | struct kstat *stat); |
51 | int ocfs2_permission(struct inode *inode, int mask, | ||
52 | struct nameidata *nd); | ||
51 | 53 | ||
52 | int ocfs2_set_inode_size(struct ocfs2_journal_handle *handle, | 54 | int ocfs2_set_inode_size(handle_t *handle, |
53 | struct inode *inode, | 55 | struct inode *inode, |
54 | struct buffer_head *fe_bh, | 56 | struct buffer_head *fe_bh, |
55 | u64 new_i_size); | 57 | u64 new_i_size); |
56 | 58 | ||
59 | int ocfs2_should_update_atime(struct inode *inode, | ||
60 | struct vfsmount *vfsmnt); | ||
61 | int ocfs2_update_inode_atime(struct inode *inode, | ||
62 | struct buffer_head *bh); | ||
63 | |||
57 | #endif /* OCFS2_FILE_H */ | 64 | #endif /* OCFS2_FILE_H */ |
diff --git a/fs/ocfs2/heartbeat.c b/fs/ocfs2/heartbeat.c index cbfd45a97a63..8fc52d6d0ce7 100644 --- a/fs/ocfs2/heartbeat.c +++ b/fs/ocfs2/heartbeat.c | |||
@@ -154,6 +154,9 @@ int ocfs2_register_hb_callbacks(struct ocfs2_super *osb) | |||
154 | { | 154 | { |
155 | int status; | 155 | int status; |
156 | 156 | ||
157 | if (ocfs2_mount_local(osb)) | ||
158 | return 0; | ||
159 | |||
157 | status = o2hb_register_callback(&osb->osb_hb_down); | 160 | status = o2hb_register_callback(&osb->osb_hb_down); |
158 | if (status < 0) { | 161 | if (status < 0) { |
159 | mlog_errno(status); | 162 | mlog_errno(status); |
@@ -172,6 +175,9 @@ void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb) | |||
172 | { | 175 | { |
173 | int status; | 176 | int status; |
174 | 177 | ||
178 | if (ocfs2_mount_local(osb)) | ||
179 | return; | ||
180 | |||
175 | status = o2hb_unregister_callback(&osb->osb_hb_down); | 181 | status = o2hb_unregister_callback(&osb->osb_hb_down); |
176 | if (status < 0) | 182 | if (status < 0) |
177 | mlog_errno(status); | 183 | mlog_errno(status); |
@@ -186,6 +192,9 @@ void ocfs2_stop_heartbeat(struct ocfs2_super *osb) | |||
186 | int ret; | 192 | int ret; |
187 | char *argv[5], *envp[3]; | 193 | char *argv[5], *envp[3]; |
188 | 194 | ||
195 | if (ocfs2_mount_local(osb)) | ||
196 | return; | ||
197 | |||
189 | if (!osb->uuid_str) { | 198 | if (!osb->uuid_str) { |
190 | /* This can happen if we don't get far enough in mount... */ | 199 | /* This can happen if we don't get far enough in mount... */ |
191 | mlog(0, "No UUID with which to stop heartbeat!\n\n"); | 200 | mlog(0, "No UUID with which to stop heartbeat!\n\n"); |
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c index 16e8e74dc966..e4d91493d7d7 100644 --- a/fs/ocfs2/inode.c +++ b/fs/ocfs2/inode.c | |||
@@ -360,7 +360,6 @@ int ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe, | |||
360 | inode); | 360 | inode); |
361 | 361 | ||
362 | ocfs2_set_inode_flags(inode); | 362 | ocfs2_set_inode_flags(inode); |
363 | inode->i_flags |= S_NOATIME; | ||
364 | 363 | ||
365 | status = 0; | 364 | status = 0; |
366 | bail: | 365 | bail: |
@@ -424,7 +423,8 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
424 | * cluster lock before trusting anything anyway. | 423 | * cluster lock before trusting anything anyway. |
425 | */ | 424 | */ |
426 | can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE) | 425 | can_lock = !(args->fi_flags & OCFS2_FI_FLAG_SYSFILE) |
427 | && !(args->fi_flags & OCFS2_FI_FLAG_NOLOCK); | 426 | && !(args->fi_flags & OCFS2_FI_FLAG_NOLOCK) |
427 | && !ocfs2_mount_local(osb); | ||
428 | 428 | ||
429 | /* | 429 | /* |
430 | * To maintain backwards compatibility with older versions of | 430 | * To maintain backwards compatibility with older versions of |
@@ -441,7 +441,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
441 | generation, inode); | 441 | generation, inode); |
442 | 442 | ||
443 | if (can_lock) { | 443 | if (can_lock) { |
444 | status = ocfs2_meta_lock(inode, NULL, NULL, 0); | 444 | status = ocfs2_meta_lock(inode, NULL, 0); |
445 | if (status) { | 445 | if (status) { |
446 | make_bad_inode(inode); | 446 | make_bad_inode(inode); |
447 | mlog_errno(status); | 447 | mlog_errno(status); |
@@ -512,7 +512,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
512 | struct buffer_head *fe_bh) | 512 | struct buffer_head *fe_bh) |
513 | { | 513 | { |
514 | int status = 0; | 514 | int status = 0; |
515 | struct ocfs2_journal_handle *handle = NULL; | 515 | handle_t *handle = NULL; |
516 | struct ocfs2_truncate_context *tc = NULL; | 516 | struct ocfs2_truncate_context *tc = NULL; |
517 | struct ocfs2_dinode *fe; | 517 | struct ocfs2_dinode *fe; |
518 | 518 | ||
@@ -524,7 +524,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
524 | if (!fe->i_clusters) | 524 | if (!fe->i_clusters) |
525 | goto bail; | 525 | goto bail; |
526 | 526 | ||
527 | handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS); | 527 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
528 | if (IS_ERR(handle)) { | 528 | if (IS_ERR(handle)) { |
529 | status = PTR_ERR(handle); | 529 | status = PTR_ERR(handle); |
530 | handle = NULL; | 530 | handle = NULL; |
@@ -538,7 +538,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
538 | goto bail; | 538 | goto bail; |
539 | } | 539 | } |
540 | 540 | ||
541 | ocfs2_commit_trans(handle); | 541 | ocfs2_commit_trans(osb, handle); |
542 | handle = NULL; | 542 | handle = NULL; |
543 | 543 | ||
544 | status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc); | 544 | status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc); |
@@ -554,7 +554,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
554 | } | 554 | } |
555 | bail: | 555 | bail: |
556 | if (handle) | 556 | if (handle) |
557 | ocfs2_commit_trans(handle); | 557 | ocfs2_commit_trans(osb, handle); |
558 | 558 | ||
559 | mlog_exit(status); | 559 | mlog_exit(status); |
560 | return status; | 560 | return status; |
@@ -568,7 +568,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
568 | int status; | 568 | int status; |
569 | struct inode *inode_alloc_inode = NULL; | 569 | struct inode *inode_alloc_inode = NULL; |
570 | struct buffer_head *inode_alloc_bh = NULL; | 570 | struct buffer_head *inode_alloc_bh = NULL; |
571 | struct ocfs2_journal_handle *handle; | 571 | handle_t *handle; |
572 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 572 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
573 | struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; | 573 | struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; |
574 | 574 | ||
@@ -582,7 +582,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
582 | } | 582 | } |
583 | 583 | ||
584 | mutex_lock(&inode_alloc_inode->i_mutex); | 584 | mutex_lock(&inode_alloc_inode->i_mutex); |
585 | status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1); | 585 | status = ocfs2_meta_lock(inode_alloc_inode, &inode_alloc_bh, 1); |
586 | if (status < 0) { | 586 | if (status < 0) { |
587 | mutex_unlock(&inode_alloc_inode->i_mutex); | 587 | mutex_unlock(&inode_alloc_inode->i_mutex); |
588 | 588 | ||
@@ -590,7 +590,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
590 | goto bail; | 590 | goto bail; |
591 | } | 591 | } |
592 | 592 | ||
593 | handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS); | 593 | handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS); |
594 | if (IS_ERR(handle)) { | 594 | if (IS_ERR(handle)) { |
595 | status = PTR_ERR(handle); | 595 | status = PTR_ERR(handle); |
596 | mlog_errno(status); | 596 | mlog_errno(status); |
@@ -629,7 +629,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
629 | mlog_errno(status); | 629 | mlog_errno(status); |
630 | 630 | ||
631 | bail_commit: | 631 | bail_commit: |
632 | ocfs2_commit_trans(handle); | 632 | ocfs2_commit_trans(osb, handle); |
633 | bail_unlock: | 633 | bail_unlock: |
634 | ocfs2_meta_unlock(inode_alloc_inode, 1); | 634 | ocfs2_meta_unlock(inode_alloc_inode, 1); |
635 | mutex_unlock(&inode_alloc_inode->i_mutex); | 635 | mutex_unlock(&inode_alloc_inode->i_mutex); |
@@ -705,7 +705,7 @@ static int ocfs2_wipe_inode(struct inode *inode, | |||
705 | * delete_inode operation. We do this now to avoid races with | 705 | * delete_inode operation. We do this now to avoid races with |
706 | * recovery completion on other nodes. */ | 706 | * recovery completion on other nodes. */ |
707 | mutex_lock(&orphan_dir_inode->i_mutex); | 707 | mutex_lock(&orphan_dir_inode->i_mutex); |
708 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1); | 708 | status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1); |
709 | if (status < 0) { | 709 | if (status < 0) { |
710 | mutex_unlock(&orphan_dir_inode->i_mutex); | 710 | mutex_unlock(&orphan_dir_inode->i_mutex); |
711 | 711 | ||
@@ -933,7 +933,7 @@ void ocfs2_delete_inode(struct inode *inode) | |||
933 | * allocation lock here as it won't be needed - nobody will | 933 | * allocation lock here as it won't be needed - nobody will |
934 | * have the file open. | 934 | * have the file open. |
935 | */ | 935 | */ |
936 | status = ocfs2_meta_lock(inode, NULL, &di_bh, 1); | 936 | status = ocfs2_meta_lock(inode, &di_bh, 1); |
937 | if (status < 0) { | 937 | if (status < 0) { |
938 | if (status != -ENOENT) | 938 | if (status != -ENOENT) |
939 | mlog_errno(status); | 939 | mlog_errno(status); |
@@ -1067,12 +1067,6 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1067 | mlog_bug_on_msg(oi->ip_open_count, | 1067 | mlog_bug_on_msg(oi->ip_open_count, |
1068 | "Clear inode of %llu has open count %d\n", | 1068 | "Clear inode of %llu has open count %d\n", |
1069 | (unsigned long long)oi->ip_blkno, oi->ip_open_count); | 1069 | (unsigned long long)oi->ip_blkno, oi->ip_open_count); |
1070 | mlog_bug_on_msg(!list_empty(&oi->ip_handle_list), | ||
1071 | "Clear inode of %llu has non empty handle list\n", | ||
1072 | (unsigned long long)oi->ip_blkno); | ||
1073 | mlog_bug_on_msg(oi->ip_handle, | ||
1074 | "Clear inode of %llu has non empty handle pointer\n", | ||
1075 | (unsigned long long)oi->ip_blkno); | ||
1076 | 1070 | ||
1077 | /* Clear all other flags. */ | 1071 | /* Clear all other flags. */ |
1078 | oi->ip_flags = OCFS2_INODE_CACHE_INLINE; | 1072 | oi->ip_flags = OCFS2_INODE_CACHE_INLINE; |
@@ -1186,7 +1180,7 @@ int ocfs2_inode_revalidate(struct dentry *dentry) | |||
1186 | 1180 | ||
1187 | /* Let ocfs2_meta_lock do the work of updating our struct | 1181 | /* Let ocfs2_meta_lock do the work of updating our struct |
1188 | * inode for us. */ | 1182 | * inode for us. */ |
1189 | status = ocfs2_meta_lock(inode, NULL, NULL, 0); | 1183 | status = ocfs2_meta_lock(inode, NULL, 0); |
1190 | if (status < 0) { | 1184 | if (status < 0) { |
1191 | if (status != -ENOENT) | 1185 | if (status != -ENOENT) |
1192 | mlog_errno(status); | 1186 | mlog_errno(status); |
@@ -1204,7 +1198,7 @@ bail: | |||
1204 | * struct inode. | 1198 | * struct inode. |
1205 | * Only takes ip_lock. | 1199 | * Only takes ip_lock. |
1206 | */ | 1200 | */ |
1207 | int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle, | 1201 | int ocfs2_mark_inode_dirty(handle_t *handle, |
1208 | struct inode *inode, | 1202 | struct inode *inode, |
1209 | struct buffer_head *bh) | 1203 | struct buffer_head *bh) |
1210 | { | 1204 | { |
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h index 9957810fdf85..1a7dd2945b34 100644 --- a/fs/ocfs2/inode.h +++ b/fs/ocfs2/inode.h | |||
@@ -48,13 +48,6 @@ struct ocfs2_inode_info | |||
48 | 48 | ||
49 | struct mutex ip_io_mutex; | 49 | struct mutex ip_io_mutex; |
50 | 50 | ||
51 | /* Used by the journalling code to attach an inode to a | ||
52 | * handle. These are protected by ip_io_mutex in order to lock | ||
53 | * out other I/O to the inode until we either commit or | ||
54 | * abort. */ | ||
55 | struct list_head ip_handle_list; | ||
56 | struct ocfs2_journal_handle *ip_handle; | ||
57 | |||
58 | u32 ip_flags; /* see below */ | 51 | u32 ip_flags; /* see below */ |
59 | u32 ip_attr; /* inode attributes */ | 52 | u32 ip_attr; /* inode attributes */ |
60 | 53 | ||
@@ -113,7 +106,7 @@ static inline struct ocfs2_inode_info *OCFS2_I(struct inode *inode) | |||
113 | #define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL) | 106 | #define INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags & OCFS2_INODE_JOURNAL) |
114 | #define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL) | 107 | #define SET_INODE_JOURNAL(i) (OCFS2_I(i)->ip_flags |= OCFS2_INODE_JOURNAL) |
115 | 108 | ||
116 | extern kmem_cache_t *ocfs2_inode_cache; | 109 | extern struct kmem_cache *ocfs2_inode_cache; |
117 | 110 | ||
118 | extern const struct address_space_operations ocfs2_aops; | 111 | extern const struct address_space_operations ocfs2_aops; |
119 | 112 | ||
@@ -143,7 +136,7 @@ ssize_t ocfs2_rw_direct(int rw, struct file *filp, char *buf, | |||
143 | void ocfs2_sync_blockdev(struct super_block *sb); | 136 | void ocfs2_sync_blockdev(struct super_block *sb); |
144 | void ocfs2_refresh_inode(struct inode *inode, | 137 | void ocfs2_refresh_inode(struct inode *inode, |
145 | struct ocfs2_dinode *fe); | 138 | struct ocfs2_dinode *fe); |
146 | int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle, | 139 | int ocfs2_mark_inode_dirty(handle_t *handle, |
147 | struct inode *inode, | 140 | struct inode *inode, |
148 | struct buffer_head *bh); | 141 | struct buffer_head *bh); |
149 | int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb); | 142 | int ocfs2_aio_read(struct file *file, struct kiocb *req, struct iocb *iocb); |
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c index 3663cef80689..4768be5f3086 100644 --- a/fs/ocfs2/ioctl.c +++ b/fs/ocfs2/ioctl.c | |||
@@ -26,7 +26,7 @@ static int ocfs2_get_inode_attr(struct inode *inode, unsigned *flags) | |||
26 | { | 26 | { |
27 | int status; | 27 | int status; |
28 | 28 | ||
29 | status = ocfs2_meta_lock(inode, NULL, NULL, 0); | 29 | status = ocfs2_meta_lock(inode, NULL, 0); |
30 | if (status < 0) { | 30 | if (status < 0) { |
31 | mlog_errno(status); | 31 | mlog_errno(status); |
32 | return status; | 32 | return status; |
@@ -43,14 +43,14 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags, | |||
43 | { | 43 | { |
44 | struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode); | 44 | struct ocfs2_inode_info *ocfs2_inode = OCFS2_I(inode); |
45 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 45 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
46 | struct ocfs2_journal_handle *handle = NULL; | 46 | handle_t *handle = NULL; |
47 | struct buffer_head *bh = NULL; | 47 | struct buffer_head *bh = NULL; |
48 | unsigned oldflags; | 48 | unsigned oldflags; |
49 | int status; | 49 | int status; |
50 | 50 | ||
51 | mutex_lock(&inode->i_mutex); | 51 | mutex_lock(&inode->i_mutex); |
52 | 52 | ||
53 | status = ocfs2_meta_lock(inode, NULL, &bh, 1); | 53 | status = ocfs2_meta_lock(inode, &bh, 1); |
54 | if (status < 0) { | 54 | if (status < 0) { |
55 | mlog_errno(status); | 55 | mlog_errno(status); |
56 | goto bail; | 56 | goto bail; |
@@ -67,7 +67,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags, | |||
67 | if (!S_ISDIR(inode->i_mode)) | 67 | if (!S_ISDIR(inode->i_mode)) |
68 | flags &= ~OCFS2_DIRSYNC_FL; | 68 | flags &= ~OCFS2_DIRSYNC_FL; |
69 | 69 | ||
70 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 70 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
71 | if (IS_ERR(handle)) { | 71 | if (IS_ERR(handle)) { |
72 | status = PTR_ERR(handle); | 72 | status = PTR_ERR(handle); |
73 | mlog_errno(status); | 73 | mlog_errno(status); |
@@ -96,7 +96,7 @@ static int ocfs2_set_inode_attr(struct inode *inode, unsigned flags, | |||
96 | if (status < 0) | 96 | if (status < 0) |
97 | mlog_errno(status); | 97 | mlog_errno(status); |
98 | 98 | ||
99 | ocfs2_commit_trans(handle); | 99 | ocfs2_commit_trans(osb, handle); |
100 | bail_unlock: | 100 | bail_unlock: |
101 | ocfs2_meta_unlock(inode, 1); | 101 | ocfs2_meta_unlock(inode, 1); |
102 | bail: | 102 | bail: |
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index fd9734def551..825cb0ae1b4c 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
@@ -57,9 +57,6 @@ static int ocfs2_recover_node(struct ocfs2_super *osb, | |||
57 | static int __ocfs2_recovery_thread(void *arg); | 57 | static int __ocfs2_recovery_thread(void *arg); |
58 | static int ocfs2_commit_cache(struct ocfs2_super *osb); | 58 | static int ocfs2_commit_cache(struct ocfs2_super *osb); |
59 | static int ocfs2_wait_on_mount(struct ocfs2_super *osb); | 59 | static int ocfs2_wait_on_mount(struct ocfs2_super *osb); |
60 | static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal, | ||
61 | struct ocfs2_journal_handle *handle); | ||
62 | static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle); | ||
63 | static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, | 60 | static int ocfs2_journal_toggle_dirty(struct ocfs2_super *osb, |
64 | int dirty); | 61 | int dirty); |
65 | static int ocfs2_trylock_journal(struct ocfs2_super *osb, | 62 | static int ocfs2_trylock_journal(struct ocfs2_super *osb, |
@@ -113,46 +110,18 @@ finally: | |||
113 | return status; | 110 | return status; |
114 | } | 111 | } |
115 | 112 | ||
116 | struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb) | ||
117 | { | ||
118 | struct ocfs2_journal_handle *retval = NULL; | ||
119 | |||
120 | retval = kcalloc(1, sizeof(*retval), GFP_NOFS); | ||
121 | if (!retval) { | ||
122 | mlog(ML_ERROR, "Failed to allocate memory for journal " | ||
123 | "handle!\n"); | ||
124 | return NULL; | ||
125 | } | ||
126 | |||
127 | retval->max_buffs = 0; | ||
128 | retval->num_locks = 0; | ||
129 | retval->k_handle = NULL; | ||
130 | |||
131 | INIT_LIST_HEAD(&retval->locks); | ||
132 | INIT_LIST_HEAD(&retval->inode_list); | ||
133 | retval->journal = osb->journal; | ||
134 | |||
135 | return retval; | ||
136 | } | ||
137 | |||
138 | /* pass it NULL and it will allocate a new handle object for you. If | 113 | /* pass it NULL and it will allocate a new handle object for you. If |
139 | * you pass it a handle however, it may still return error, in which | 114 | * you pass it a handle however, it may still return error, in which |
140 | * case it has free'd the passed handle for you. */ | 115 | * case it has free'd the passed handle for you. */ |
141 | struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, | 116 | handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs) |
142 | struct ocfs2_journal_handle *handle, | ||
143 | int max_buffs) | ||
144 | { | 117 | { |
145 | int ret; | ||
146 | journal_t *journal = osb->journal->j_journal; | 118 | journal_t *journal = osb->journal->j_journal; |
147 | 119 | handle_t *handle; | |
148 | mlog_entry("(max_buffs = %d)\n", max_buffs); | ||
149 | 120 | ||
150 | BUG_ON(!osb || !osb->journal->j_journal); | 121 | BUG_ON(!osb || !osb->journal->j_journal); |
151 | 122 | ||
152 | if (ocfs2_is_hard_readonly(osb)) { | 123 | if (ocfs2_is_hard_readonly(osb)) |
153 | ret = -EROFS; | 124 | return ERR_PTR(-EROFS); |
154 | goto done_free; | ||
155 | } | ||
156 | 125 | ||
157 | BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); | 126 | BUG_ON(osb->journal->j_state == OCFS2_JOURNAL_FREE); |
158 | BUG_ON(max_buffs <= 0); | 127 | BUG_ON(max_buffs <= 0); |
@@ -163,154 +132,41 @@ struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, | |||
163 | BUG(); | 132 | BUG(); |
164 | } | 133 | } |
165 | 134 | ||
166 | if (!handle) | ||
167 | handle = ocfs2_alloc_handle(osb); | ||
168 | if (!handle) { | ||
169 | ret = -ENOMEM; | ||
170 | mlog(ML_ERROR, "Failed to allocate memory for journal " | ||
171 | "handle!\n"); | ||
172 | goto done_free; | ||
173 | } | ||
174 | |||
175 | handle->max_buffs = max_buffs; | ||
176 | |||
177 | down_read(&osb->journal->j_trans_barrier); | 135 | down_read(&osb->journal->j_trans_barrier); |
178 | 136 | ||
179 | /* actually start the transaction now */ | 137 | handle = journal_start(journal, max_buffs); |
180 | handle->k_handle = journal_start(journal, max_buffs); | 138 | if (IS_ERR(handle)) { |
181 | if (IS_ERR(handle->k_handle)) { | ||
182 | up_read(&osb->journal->j_trans_barrier); | 139 | up_read(&osb->journal->j_trans_barrier); |
183 | 140 | ||
184 | ret = PTR_ERR(handle->k_handle); | 141 | mlog_errno(PTR_ERR(handle)); |
185 | handle->k_handle = NULL; | ||
186 | mlog_errno(ret); | ||
187 | 142 | ||
188 | if (is_journal_aborted(journal)) { | 143 | if (is_journal_aborted(journal)) { |
189 | ocfs2_abort(osb->sb, "Detected aborted journal"); | 144 | ocfs2_abort(osb->sb, "Detected aborted journal"); |
190 | ret = -EROFS; | 145 | handle = ERR_PTR(-EROFS); |
191 | } | 146 | } |
192 | goto done_free; | 147 | } else { |
148 | if (!ocfs2_mount_local(osb)) | ||
149 | atomic_inc(&(osb->journal->j_num_trans)); | ||
193 | } | 150 | } |
194 | 151 | ||
195 | atomic_inc(&(osb->journal->j_num_trans)); | ||
196 | handle->flags |= OCFS2_HANDLE_STARTED; | ||
197 | |||
198 | mlog_exit_ptr(handle); | ||
199 | return handle; | 152 | return handle; |
200 | |||
201 | done_free: | ||
202 | if (handle) | ||
203 | ocfs2_commit_unstarted_handle(handle); /* will kfree handle */ | ||
204 | |||
205 | mlog_exit(ret); | ||
206 | return ERR_PTR(ret); | ||
207 | } | ||
208 | |||
209 | void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle, | ||
210 | struct inode *inode) | ||
211 | { | ||
212 | BUG_ON(!handle); | ||
213 | BUG_ON(!inode); | ||
214 | |||
215 | atomic_inc(&inode->i_count); | ||
216 | |||
217 | /* we're obviously changing it... */ | ||
218 | mutex_lock(&inode->i_mutex); | ||
219 | |||
220 | /* sanity check */ | ||
221 | BUG_ON(OCFS2_I(inode)->ip_handle); | ||
222 | BUG_ON(!list_empty(&OCFS2_I(inode)->ip_handle_list)); | ||
223 | |||
224 | OCFS2_I(inode)->ip_handle = handle; | ||
225 | list_move_tail(&(OCFS2_I(inode)->ip_handle_list), &(handle->inode_list)); | ||
226 | } | ||
227 | |||
228 | static void ocfs2_handle_unlock_inodes(struct ocfs2_journal_handle *handle) | ||
229 | { | ||
230 | struct list_head *p, *n; | ||
231 | struct inode *inode; | ||
232 | struct ocfs2_inode_info *oi; | ||
233 | |||
234 | list_for_each_safe(p, n, &handle->inode_list) { | ||
235 | oi = list_entry(p, struct ocfs2_inode_info, | ||
236 | ip_handle_list); | ||
237 | inode = &oi->vfs_inode; | ||
238 | |||
239 | OCFS2_I(inode)->ip_handle = NULL; | ||
240 | list_del_init(&OCFS2_I(inode)->ip_handle_list); | ||
241 | |||
242 | mutex_unlock(&inode->i_mutex); | ||
243 | iput(inode); | ||
244 | } | ||
245 | } | 153 | } |
246 | 154 | ||
247 | /* This is trivial so we do it out of the main commit | 155 | int ocfs2_commit_trans(struct ocfs2_super *osb, |
248 | * paths. Beware, it can be called from start_trans too! */ | 156 | handle_t *handle) |
249 | static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle) | ||
250 | { | 157 | { |
251 | mlog_entry_void(); | 158 | int ret; |
252 | 159 | struct ocfs2_journal *journal = osb->journal; | |
253 | BUG_ON(handle->flags & OCFS2_HANDLE_STARTED); | ||
254 | |||
255 | ocfs2_handle_unlock_inodes(handle); | ||
256 | /* You are allowed to add journal locks before the transaction | ||
257 | * has started. */ | ||
258 | ocfs2_handle_cleanup_locks(handle->journal, handle); | ||
259 | |||
260 | kfree(handle); | ||
261 | |||
262 | mlog_exit_void(); | ||
263 | } | ||
264 | |||
265 | void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) | ||
266 | { | ||
267 | handle_t *jbd_handle; | ||
268 | int retval; | ||
269 | struct ocfs2_journal *journal = handle->journal; | ||
270 | |||
271 | mlog_entry_void(); | ||
272 | 160 | ||
273 | BUG_ON(!handle); | 161 | BUG_ON(!handle); |
274 | 162 | ||
275 | if (!(handle->flags & OCFS2_HANDLE_STARTED)) { | 163 | ret = journal_stop(handle); |
276 | ocfs2_commit_unstarted_handle(handle); | 164 | if (ret < 0) |
277 | mlog_exit_void(); | 165 | mlog_errno(ret); |
278 | return; | ||
279 | } | ||
280 | |||
281 | /* release inode semaphores we took during this transaction */ | ||
282 | ocfs2_handle_unlock_inodes(handle); | ||
283 | |||
284 | /* ocfs2_extend_trans may have had to call journal_restart | ||
285 | * which will always commit the transaction, but may return | ||
286 | * error for any number of reasons. If this is the case, we | ||
287 | * clear k_handle as it's not valid any more. */ | ||
288 | if (handle->k_handle) { | ||
289 | jbd_handle = handle->k_handle; | ||
290 | |||
291 | if (handle->flags & OCFS2_HANDLE_SYNC) | ||
292 | jbd_handle->h_sync = 1; | ||
293 | else | ||
294 | jbd_handle->h_sync = 0; | ||
295 | |||
296 | /* actually stop the transaction. if we've set h_sync, | ||
297 | * it'll have been committed when we return */ | ||
298 | retval = journal_stop(jbd_handle); | ||
299 | if (retval < 0) { | ||
300 | mlog_errno(retval); | ||
301 | mlog(ML_ERROR, "Could not commit transaction\n"); | ||
302 | BUG(); | ||
303 | } | ||
304 | |||
305 | handle->k_handle = NULL; /* it's been free'd in journal_stop */ | ||
306 | } | ||
307 | |||
308 | ocfs2_handle_cleanup_locks(journal, handle); | ||
309 | 166 | ||
310 | up_read(&journal->j_trans_barrier); | 167 | up_read(&journal->j_trans_barrier); |
311 | 168 | ||
312 | kfree(handle); | 169 | return ret; |
313 | mlog_exit_void(); | ||
314 | } | 170 | } |
315 | 171 | ||
316 | /* | 172 | /* |
@@ -326,20 +182,18 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) | |||
326 | * good because transaction ids haven't yet been recorded on the | 182 | * good because transaction ids haven't yet been recorded on the |
327 | * cluster locks associated with this handle. | 183 | * cluster locks associated with this handle. |
328 | */ | 184 | */ |
329 | int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | 185 | int ocfs2_extend_trans(handle_t *handle, int nblocks) |
330 | int nblocks) | ||
331 | { | 186 | { |
332 | int status; | 187 | int status; |
333 | 188 | ||
334 | BUG_ON(!handle); | 189 | BUG_ON(!handle); |
335 | BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); | ||
336 | BUG_ON(!nblocks); | 190 | BUG_ON(!nblocks); |
337 | 191 | ||
338 | mlog_entry_void(); | 192 | mlog_entry_void(); |
339 | 193 | ||
340 | mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); | 194 | mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); |
341 | 195 | ||
342 | status = journal_extend(handle->k_handle, nblocks); | 196 | status = journal_extend(handle, nblocks); |
343 | if (status < 0) { | 197 | if (status < 0) { |
344 | mlog_errno(status); | 198 | mlog_errno(status); |
345 | goto bail; | 199 | goto bail; |
@@ -347,15 +201,12 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | |||
347 | 201 | ||
348 | if (status > 0) { | 202 | if (status > 0) { |
349 | mlog(0, "journal_extend failed, trying journal_restart\n"); | 203 | mlog(0, "journal_extend failed, trying journal_restart\n"); |
350 | status = journal_restart(handle->k_handle, nblocks); | 204 | status = journal_restart(handle, nblocks); |
351 | if (status < 0) { | 205 | if (status < 0) { |
352 | handle->k_handle = NULL; | ||
353 | mlog_errno(status); | 206 | mlog_errno(status); |
354 | goto bail; | 207 | goto bail; |
355 | } | 208 | } |
356 | handle->max_buffs = nblocks; | 209 | } |
357 | } else | ||
358 | handle->max_buffs += nblocks; | ||
359 | 210 | ||
360 | status = 0; | 211 | status = 0; |
361 | bail: | 212 | bail: |
@@ -364,7 +215,7 @@ bail: | |||
364 | return status; | 215 | return status; |
365 | } | 216 | } |
366 | 217 | ||
367 | int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | 218 | int ocfs2_journal_access(handle_t *handle, |
368 | struct inode *inode, | 219 | struct inode *inode, |
369 | struct buffer_head *bh, | 220 | struct buffer_head *bh, |
370 | int type) | 221 | int type) |
@@ -374,7 +225,6 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
374 | BUG_ON(!inode); | 225 | BUG_ON(!inode); |
375 | BUG_ON(!handle); | 226 | BUG_ON(!handle); |
376 | BUG_ON(!bh); | 227 | BUG_ON(!bh); |
377 | BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); | ||
378 | 228 | ||
379 | mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n", | 229 | mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n", |
380 | (unsigned long long)bh->b_blocknr, type, | 230 | (unsigned long long)bh->b_blocknr, type, |
@@ -403,11 +253,11 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
403 | switch (type) { | 253 | switch (type) { |
404 | case OCFS2_JOURNAL_ACCESS_CREATE: | 254 | case OCFS2_JOURNAL_ACCESS_CREATE: |
405 | case OCFS2_JOURNAL_ACCESS_WRITE: | 255 | case OCFS2_JOURNAL_ACCESS_WRITE: |
406 | status = journal_get_write_access(handle->k_handle, bh); | 256 | status = journal_get_write_access(handle, bh); |
407 | break; | 257 | break; |
408 | 258 | ||
409 | case OCFS2_JOURNAL_ACCESS_UNDO: | 259 | case OCFS2_JOURNAL_ACCESS_UNDO: |
410 | status = journal_get_undo_access(handle->k_handle, bh); | 260 | status = journal_get_undo_access(handle, bh); |
411 | break; | 261 | break; |
412 | 262 | ||
413 | default: | 263 | default: |
@@ -424,17 +274,15 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
424 | return status; | 274 | return status; |
425 | } | 275 | } |
426 | 276 | ||
427 | int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, | 277 | int ocfs2_journal_dirty(handle_t *handle, |
428 | struct buffer_head *bh) | 278 | struct buffer_head *bh) |
429 | { | 279 | { |
430 | int status; | 280 | int status; |
431 | 281 | ||
432 | BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); | ||
433 | |||
434 | mlog_entry("(bh->b_blocknr=%llu)\n", | 282 | mlog_entry("(bh->b_blocknr=%llu)\n", |
435 | (unsigned long long)bh->b_blocknr); | 283 | (unsigned long long)bh->b_blocknr); |
436 | 284 | ||
437 | status = journal_dirty_metadata(handle->k_handle, bh); | 285 | status = journal_dirty_metadata(handle, bh); |
438 | if (status < 0) | 286 | if (status < 0) |
439 | mlog(ML_ERROR, "Could not dirty metadata buffer. " | 287 | mlog(ML_ERROR, "Could not dirty metadata buffer. " |
440 | "(bh->b_blocknr=%llu)\n", | 288 | "(bh->b_blocknr=%llu)\n", |
@@ -456,59 +304,6 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
456 | return err; | 304 | return err; |
457 | } | 305 | } |
458 | 306 | ||
459 | /* We always assume you're adding a metadata lock at level 'ex' */ | ||
460 | int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle, | ||
461 | struct inode *inode) | ||
462 | { | ||
463 | int status; | ||
464 | struct ocfs2_journal_lock *lock; | ||
465 | |||
466 | BUG_ON(!inode); | ||
467 | |||
468 | lock = kmem_cache_alloc(ocfs2_lock_cache, GFP_NOFS); | ||
469 | if (!lock) { | ||
470 | status = -ENOMEM; | ||
471 | mlog_errno(-ENOMEM); | ||
472 | goto bail; | ||
473 | } | ||
474 | |||
475 | if (!igrab(inode)) | ||
476 | BUG(); | ||
477 | lock->jl_inode = inode; | ||
478 | |||
479 | list_add_tail(&(lock->jl_lock_list), &(handle->locks)); | ||
480 | handle->num_locks++; | ||
481 | |||
482 | status = 0; | ||
483 | bail: | ||
484 | mlog_exit(status); | ||
485 | return status; | ||
486 | } | ||
487 | |||
488 | static void ocfs2_handle_cleanup_locks(struct ocfs2_journal *journal, | ||
489 | struct ocfs2_journal_handle *handle) | ||
490 | { | ||
491 | struct list_head *p, *n; | ||
492 | struct ocfs2_journal_lock *lock; | ||
493 | struct inode *inode; | ||
494 | |||
495 | list_for_each_safe(p, n, &(handle->locks)) { | ||
496 | lock = list_entry(p, struct ocfs2_journal_lock, | ||
497 | jl_lock_list); | ||
498 | list_del(&lock->jl_lock_list); | ||
499 | handle->num_locks--; | ||
500 | |||
501 | inode = lock->jl_inode; | ||
502 | ocfs2_meta_unlock(inode, 1); | ||
503 | if (atomic_read(&inode->i_count) == 1) | ||
504 | mlog(ML_ERROR, | ||
505 | "Inode %llu, I'm doing a last iput for!", | ||
506 | (unsigned long long)OCFS2_I(inode)->ip_blkno); | ||
507 | iput(inode); | ||
508 | kmem_cache_free(ocfs2_lock_cache, lock); | ||
509 | } | ||
510 | } | ||
511 | |||
512 | #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) | 307 | #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) |
513 | 308 | ||
514 | void ocfs2_set_journal_params(struct ocfs2_super *osb) | 309 | void ocfs2_set_journal_params(struct ocfs2_super *osb) |
@@ -562,8 +357,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty) | |||
562 | /* Skip recovery waits here - journal inode metadata never | 357 | /* Skip recovery waits here - journal inode metadata never |
563 | * changes in a live cluster so it can be considered an | 358 | * changes in a live cluster so it can be considered an |
564 | * exception to the rule. */ | 359 | * exception to the rule. */ |
565 | status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, | 360 | status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); |
566 | OCFS2_META_LOCK_RECOVERY); | ||
567 | if (status < 0) { | 361 | if (status < 0) { |
568 | if (status != -ERESTARTSYS) | 362 | if (status != -ERESTARTSYS) |
569 | mlog(ML_ERROR, "Could not get lock on journal!\n"); | 363 | mlog(ML_ERROR, "Could not get lock on journal!\n"); |
@@ -715,9 +509,23 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb) | |||
715 | 509 | ||
716 | BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); | 510 | BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); |
717 | 511 | ||
718 | status = ocfs2_journal_toggle_dirty(osb, 0); | 512 | if (ocfs2_mount_local(osb)) { |
719 | if (status < 0) | 513 | journal_lock_updates(journal->j_journal); |
720 | mlog_errno(status); | 514 | status = journal_flush(journal->j_journal); |
515 | journal_unlock_updates(journal->j_journal); | ||
516 | if (status < 0) | ||
517 | mlog_errno(status); | ||
518 | } | ||
519 | |||
520 | if (status == 0) { | ||
521 | /* | ||
522 | * Do not toggle if flush was unsuccessful otherwise | ||
523 | * will leave dirty metadata in a "clean" journal | ||
524 | */ | ||
525 | status = ocfs2_journal_toggle_dirty(osb, 0); | ||
526 | if (status < 0) | ||
527 | mlog_errno(status); | ||
528 | } | ||
721 | 529 | ||
722 | /* Shutdown the kernel journal system */ | 530 | /* Shutdown the kernel journal system */ |
723 | journal_destroy(journal->j_journal); | 531 | journal_destroy(journal->j_journal); |
@@ -757,7 +565,7 @@ static void ocfs2_clear_journal_error(struct super_block *sb, | |||
757 | } | 565 | } |
758 | } | 566 | } |
759 | 567 | ||
760 | int ocfs2_journal_load(struct ocfs2_journal *journal) | 568 | int ocfs2_journal_load(struct ocfs2_journal *journal, int local) |
761 | { | 569 | { |
762 | int status = 0; | 570 | int status = 0; |
763 | struct ocfs2_super *osb; | 571 | struct ocfs2_super *osb; |
@@ -784,14 +592,18 @@ int ocfs2_journal_load(struct ocfs2_journal *journal) | |||
784 | } | 592 | } |
785 | 593 | ||
786 | /* Launch the commit thread */ | 594 | /* Launch the commit thread */ |
787 | osb->commit_task = kthread_run(ocfs2_commit_thread, osb, "ocfs2cmt"); | 595 | if (!local) { |
788 | if (IS_ERR(osb->commit_task)) { | 596 | osb->commit_task = kthread_run(ocfs2_commit_thread, osb, |
789 | status = PTR_ERR(osb->commit_task); | 597 | "ocfs2cmt"); |
598 | if (IS_ERR(osb->commit_task)) { | ||
599 | status = PTR_ERR(osb->commit_task); | ||
600 | osb->commit_task = NULL; | ||
601 | mlog(ML_ERROR, "unable to launch ocfs2commit thread, " | ||
602 | "error=%d", status); | ||
603 | goto done; | ||
604 | } | ||
605 | } else | ||
790 | osb->commit_task = NULL; | 606 | osb->commit_task = NULL; |
791 | mlog(ML_ERROR, "unable to launch ocfs2commit thread, error=%d", | ||
792 | status); | ||
793 | goto done; | ||
794 | } | ||
795 | 607 | ||
796 | done: | 608 | done: |
797 | mlog_exit(status); | 609 | mlog_exit(status); |
@@ -911,11 +723,12 @@ struct ocfs2_la_recovery_item { | |||
911 | * NOTE: This function can and will sleep on recovery of other nodes | 723 | * NOTE: This function can and will sleep on recovery of other nodes |
912 | * during cluster locking, just like any other ocfs2 process. | 724 | * during cluster locking, just like any other ocfs2 process. |
913 | */ | 725 | */ |
914 | void ocfs2_complete_recovery(void *data) | 726 | void ocfs2_complete_recovery(struct work_struct *work) |
915 | { | 727 | { |
916 | int ret; | 728 | int ret; |
917 | struct ocfs2_super *osb = data; | 729 | struct ocfs2_journal *journal = |
918 | struct ocfs2_journal *journal = osb->journal; | 730 | container_of(work, struct ocfs2_journal, j_recovery_work); |
731 | struct ocfs2_super *osb = journal->j_osb; | ||
919 | struct ocfs2_dinode *la_dinode, *tl_dinode; | 732 | struct ocfs2_dinode *la_dinode, *tl_dinode; |
920 | struct ocfs2_la_recovery_item *item; | 733 | struct ocfs2_la_recovery_item *item; |
921 | struct list_head *p, *n; | 734 | struct list_head *p, *n; |
@@ -1160,8 +973,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
1160 | } | 973 | } |
1161 | SET_INODE_JOURNAL(inode); | 974 | SET_INODE_JOURNAL(inode); |
1162 | 975 | ||
1163 | status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, | 976 | status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); |
1164 | OCFS2_META_LOCK_RECOVERY); | ||
1165 | if (status < 0) { | 977 | if (status < 0) { |
1166 | mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); | 978 | mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); |
1167 | if (status != -ERESTARTSYS) | 979 | if (status != -ERESTARTSYS) |
@@ -1350,7 +1162,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb, | |||
1350 | SET_INODE_JOURNAL(inode); | 1162 | SET_INODE_JOURNAL(inode); |
1351 | 1163 | ||
1352 | flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; | 1164 | flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; |
1353 | status = ocfs2_meta_lock_full(inode, NULL, NULL, 1, flags); | 1165 | status = ocfs2_meta_lock_full(inode, NULL, 1, flags); |
1354 | if (status < 0) { | 1166 | if (status < 0) { |
1355 | if (status != -EAGAIN) | 1167 | if (status != -EAGAIN) |
1356 | mlog_errno(status); | 1168 | mlog_errno(status); |
@@ -1433,7 +1245,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb, | |||
1433 | } | 1245 | } |
1434 | 1246 | ||
1435 | mutex_lock(&orphan_dir_inode->i_mutex); | 1247 | mutex_lock(&orphan_dir_inode->i_mutex); |
1436 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); | 1248 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, 0); |
1437 | if (status < 0) { | 1249 | if (status < 0) { |
1438 | mlog_errno(status); | 1250 | mlog_errno(status); |
1439 | goto out; | 1251 | goto out; |
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h index 2f3a6acdac45..e1216364d191 100644 --- a/fs/ocfs2/journal.h +++ b/fs/ocfs2/journal.h | |||
@@ -37,7 +37,6 @@ enum ocfs2_journal_state { | |||
37 | 37 | ||
38 | struct ocfs2_super; | 38 | struct ocfs2_super; |
39 | struct ocfs2_dinode; | 39 | struct ocfs2_dinode; |
40 | struct ocfs2_journal_handle; | ||
41 | 40 | ||
42 | struct ocfs2_journal { | 41 | struct ocfs2_journal { |
43 | enum ocfs2_journal_state j_state; /* Journals current state */ | 42 | enum ocfs2_journal_state j_state; /* Journals current state */ |
@@ -133,46 +132,8 @@ static inline void ocfs2_inode_set_new(struct ocfs2_super *osb, | |||
133 | spin_unlock(&trans_inc_lock); | 132 | spin_unlock(&trans_inc_lock); |
134 | } | 133 | } |
135 | 134 | ||
136 | extern kmem_cache_t *ocfs2_lock_cache; | ||
137 | |||
138 | struct ocfs2_journal_lock { | ||
139 | struct inode *jl_inode; | ||
140 | struct list_head jl_lock_list; | ||
141 | }; | ||
142 | |||
143 | struct ocfs2_journal_handle { | ||
144 | handle_t *k_handle; /* kernel handle. */ | ||
145 | struct ocfs2_journal *journal; | ||
146 | u32 flags; /* see flags below. */ | ||
147 | int max_buffs; /* Buffs reserved by this handle */ | ||
148 | |||
149 | /* The following two fields are for ocfs2_handle_add_lock */ | ||
150 | int num_locks; | ||
151 | struct list_head locks; /* A bunch of locks to | ||
152 | * release on commit. This | ||
153 | * should be a list_head */ | ||
154 | |||
155 | struct list_head inode_list; | ||
156 | }; | ||
157 | |||
158 | #define OCFS2_HANDLE_STARTED 1 | ||
159 | /* should we sync-commit this handle? */ | ||
160 | #define OCFS2_HANDLE_SYNC 2 | ||
161 | static inline int ocfs2_handle_started(struct ocfs2_journal_handle *handle) | ||
162 | { | ||
163 | return handle->flags & OCFS2_HANDLE_STARTED; | ||
164 | } | ||
165 | |||
166 | static inline void ocfs2_handle_set_sync(struct ocfs2_journal_handle *handle, int sync) | ||
167 | { | ||
168 | if (sync) | ||
169 | handle->flags |= OCFS2_HANDLE_SYNC; | ||
170 | else | ||
171 | handle->flags &= ~OCFS2_HANDLE_SYNC; | ||
172 | } | ||
173 | |||
174 | /* Exported only for the journal struct init code in super.c. Do not call. */ | 135 | /* Exported only for the journal struct init code in super.c. Do not call. */ |
175 | void ocfs2_complete_recovery(void *data); | 136 | void ocfs2_complete_recovery(struct work_struct *work); |
176 | 137 | ||
177 | /* | 138 | /* |
178 | * Journal Control: | 139 | * Journal Control: |
@@ -196,7 +157,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, | |||
196 | void ocfs2_journal_shutdown(struct ocfs2_super *osb); | 157 | void ocfs2_journal_shutdown(struct ocfs2_super *osb); |
197 | int ocfs2_journal_wipe(struct ocfs2_journal *journal, | 158 | int ocfs2_journal_wipe(struct ocfs2_journal *journal, |
198 | int full); | 159 | int full); |
199 | int ocfs2_journal_load(struct ocfs2_journal *journal); | 160 | int ocfs2_journal_load(struct ocfs2_journal *journal, int local); |
200 | int ocfs2_check_journals_nolocks(struct ocfs2_super *osb); | 161 | int ocfs2_check_journals_nolocks(struct ocfs2_super *osb); |
201 | void ocfs2_recovery_thread(struct ocfs2_super *osb, | 162 | void ocfs2_recovery_thread(struct ocfs2_super *osb, |
202 | int node_num); | 163 | int node_num); |
@@ -213,6 +174,9 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode) | |||
213 | { | 174 | { |
214 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 175 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
215 | 176 | ||
177 | if (ocfs2_mount_local(osb)) | ||
178 | return; | ||
179 | |||
216 | if (!ocfs2_inode_fully_checkpointed(inode)) { | 180 | if (!ocfs2_inode_fully_checkpointed(inode)) { |
217 | /* WARNING: This only kicks off a single | 181 | /* WARNING: This only kicks off a single |
218 | * checkpoint. If someone races you and adds more | 182 | * checkpoint. If someone races you and adds more |
@@ -231,15 +195,14 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode) | |||
231 | * Transaction Handling: | 195 | * Transaction Handling: |
232 | * Manage the lifetime of a transaction handle. | 196 | * Manage the lifetime of a transaction handle. |
233 | * | 197 | * |
234 | * ocfs2_alloc_handle - Only allocate a handle so we can start putting | ||
235 | * cluster locks on it. To actually change blocks, | ||
236 | * call ocfs2_start_trans with the handle returned | ||
237 | * from this function. You may call ocfs2_commit_trans | ||
238 | * at any time in the lifetime of a handle. | ||
239 | * ocfs2_start_trans - Begin a transaction. Give it an upper estimate of | 198 | * ocfs2_start_trans - Begin a transaction. Give it an upper estimate of |
240 | * the number of blocks that will be changed during | 199 | * the number of blocks that will be changed during |
241 | * this handle. | 200 | * this handle. |
242 | * ocfs2_commit_trans - Complete a handle. | 201 | * ocfs2_commit_trans - Complete a handle. It might return -EIO if |
202 | * the journal was aborted. The majority of paths don't | ||
203 | * check the return value as an error there comes too | ||
204 | * late to do anything (and will be picked up in a | ||
205 | * later transaction). | ||
243 | * ocfs2_extend_trans - Extend a handle by nblocks credits. This may | 206 | * ocfs2_extend_trans - Extend a handle by nblocks credits. This may |
244 | * commit the handle to disk in the process, but will | 207 | * commit the handle to disk in the process, but will |
245 | * not release any locks taken during the transaction. | 208 | * not release any locks taken during the transaction. |
@@ -249,24 +212,16 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode) | |||
249 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. | 212 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. |
250 | * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before | 213 | * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before |
251 | * the current handle commits. | 214 | * the current handle commits. |
252 | * ocfs2_handle_add_lock - Sometimes we need to delay lock release | ||
253 | * until after a transaction has been completed. Use | ||
254 | * ocfs2_handle_add_lock to indicate that a lock needs | ||
255 | * to be released at the end of that handle. Locks | ||
256 | * will be released in the order that they are added. | ||
257 | * ocfs2_handle_add_inode - Add a locked inode to a transaction. | ||
258 | */ | 215 | */ |
259 | 216 | ||
260 | /* You must always start_trans with a number of buffs > 0, but it's | 217 | /* You must always start_trans with a number of buffs > 0, but it's |
261 | * perfectly legal to go through an entire transaction without having | 218 | * perfectly legal to go through an entire transaction without having |
262 | * dirtied any buffers. */ | 219 | * dirtied any buffers. */ |
263 | struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb); | 220 | handle_t *ocfs2_start_trans(struct ocfs2_super *osb, |
264 | struct ocfs2_journal_handle *ocfs2_start_trans(struct ocfs2_super *osb, | ||
265 | struct ocfs2_journal_handle *handle, | ||
266 | int max_buffs); | 221 | int max_buffs); |
267 | void ocfs2_commit_trans(struct ocfs2_journal_handle *handle); | 222 | int ocfs2_commit_trans(struct ocfs2_super *osb, |
268 | int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | 223 | handle_t *handle); |
269 | int nblocks); | 224 | int ocfs2_extend_trans(handle_t *handle, int nblocks); |
270 | 225 | ||
271 | /* | 226 | /* |
272 | * Create access is for when we get a newly created buffer and we're | 227 | * Create access is for when we get a newly created buffer and we're |
@@ -283,7 +238,7 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | |||
283 | #define OCFS2_JOURNAL_ACCESS_WRITE 1 | 238 | #define OCFS2_JOURNAL_ACCESS_WRITE 1 |
284 | #define OCFS2_JOURNAL_ACCESS_UNDO 2 | 239 | #define OCFS2_JOURNAL_ACCESS_UNDO 2 |
285 | 240 | ||
286 | int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | 241 | int ocfs2_journal_access(handle_t *handle, |
287 | struct inode *inode, | 242 | struct inode *inode, |
288 | struct buffer_head *bh, | 243 | struct buffer_head *bh, |
289 | int type); | 244 | int type); |
@@ -306,18 +261,10 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
306 | * <modify the bh> | 261 | * <modify the bh> |
307 | * ocfs2_journal_dirty(handle, bh); | 262 | * ocfs2_journal_dirty(handle, bh); |
308 | */ | 263 | */ |
309 | int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, | 264 | int ocfs2_journal_dirty(handle_t *handle, |
310 | struct buffer_head *bh); | 265 | struct buffer_head *bh); |
311 | int ocfs2_journal_dirty_data(handle_t *handle, | 266 | int ocfs2_journal_dirty_data(handle_t *handle, |
312 | struct buffer_head *bh); | 267 | struct buffer_head *bh); |
313 | int ocfs2_handle_add_lock(struct ocfs2_journal_handle *handle, | ||
314 | struct inode *inode); | ||
315 | /* | ||
316 | * Use this to protect from other processes reading buffer state while | ||
317 | * it's in flight. | ||
318 | */ | ||
319 | void ocfs2_handle_add_inode(struct ocfs2_journal_handle *handle, | ||
320 | struct inode *inode); | ||
321 | 268 | ||
322 | /* | 269 | /* |
323 | * Credit Macros: | 270 | * Credit Macros: |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 1f17a4d08287..4dedd9789108 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -58,19 +58,18 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, | |||
58 | static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc); | 58 | static void ocfs2_clear_local_alloc(struct ocfs2_dinode *alloc); |
59 | 59 | ||
60 | static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | 60 | static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, |
61 | struct ocfs2_journal_handle *handle, | 61 | handle_t *handle, |
62 | struct ocfs2_dinode *alloc, | 62 | struct ocfs2_dinode *alloc, |
63 | struct inode *main_bm_inode, | 63 | struct inode *main_bm_inode, |
64 | struct buffer_head *main_bm_bh); | 64 | struct buffer_head *main_bm_bh); |
65 | 65 | ||
66 | static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, | 66 | static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, |
67 | struct ocfs2_journal_handle *handle, | ||
68 | struct ocfs2_alloc_context **ac, | 67 | struct ocfs2_alloc_context **ac, |
69 | struct inode **bitmap_inode, | 68 | struct inode **bitmap_inode, |
70 | struct buffer_head **bitmap_bh); | 69 | struct buffer_head **bitmap_bh); |
71 | 70 | ||
72 | static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, | 71 | static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, |
73 | struct ocfs2_journal_handle *handle, | 72 | handle_t *handle, |
74 | struct ocfs2_alloc_context *ac); | 73 | struct ocfs2_alloc_context *ac); |
75 | 74 | ||
76 | static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | 75 | static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, |
@@ -196,7 +195,7 @@ bail: | |||
196 | void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | 195 | void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) |
197 | { | 196 | { |
198 | int status; | 197 | int status; |
199 | struct ocfs2_journal_handle *handle = NULL; | 198 | handle_t *handle; |
200 | struct inode *local_alloc_inode = NULL; | 199 | struct inode *local_alloc_inode = NULL; |
201 | struct buffer_head *bh = NULL; | 200 | struct buffer_head *bh = NULL; |
202 | struct buffer_head *main_bm_bh = NULL; | 201 | struct buffer_head *main_bm_bh = NULL; |
@@ -207,7 +206,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
207 | mlog_entry_void(); | 206 | mlog_entry_void(); |
208 | 207 | ||
209 | if (osb->local_alloc_state == OCFS2_LA_UNUSED) | 208 | if (osb->local_alloc_state == OCFS2_LA_UNUSED) |
210 | goto bail; | 209 | goto out; |
211 | 210 | ||
212 | local_alloc_inode = | 211 | local_alloc_inode = |
213 | ocfs2_get_system_file_inode(osb, | 212 | ocfs2_get_system_file_inode(osb, |
@@ -216,40 +215,34 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
216 | if (!local_alloc_inode) { | 215 | if (!local_alloc_inode) { |
217 | status = -ENOENT; | 216 | status = -ENOENT; |
218 | mlog_errno(status); | 217 | mlog_errno(status); |
219 | goto bail; | 218 | goto out; |
220 | } | 219 | } |
221 | 220 | ||
222 | osb->local_alloc_state = OCFS2_LA_DISABLED; | 221 | osb->local_alloc_state = OCFS2_LA_DISABLED; |
223 | 222 | ||
224 | handle = ocfs2_alloc_handle(osb); | ||
225 | if (!handle) { | ||
226 | status = -ENOMEM; | ||
227 | mlog_errno(status); | ||
228 | goto bail; | ||
229 | } | ||
230 | |||
231 | main_bm_inode = ocfs2_get_system_file_inode(osb, | 223 | main_bm_inode = ocfs2_get_system_file_inode(osb, |
232 | GLOBAL_BITMAP_SYSTEM_INODE, | 224 | GLOBAL_BITMAP_SYSTEM_INODE, |
233 | OCFS2_INVALID_SLOT); | 225 | OCFS2_INVALID_SLOT); |
234 | if (!main_bm_inode) { | 226 | if (!main_bm_inode) { |
235 | status = -EINVAL; | 227 | status = -EINVAL; |
236 | mlog_errno(status); | 228 | mlog_errno(status); |
237 | goto bail; | 229 | goto out; |
238 | } | 230 | } |
239 | 231 | ||
240 | ocfs2_handle_add_inode(handle, main_bm_inode); | 232 | mutex_lock(&main_bm_inode->i_mutex); |
241 | status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); | 233 | |
234 | status = ocfs2_meta_lock(main_bm_inode, &main_bm_bh, 1); | ||
242 | if (status < 0) { | 235 | if (status < 0) { |
243 | mlog_errno(status); | 236 | mlog_errno(status); |
244 | goto bail; | 237 | goto out_mutex; |
245 | } | 238 | } |
246 | 239 | ||
247 | /* WINDOW_MOVE_CREDITS is a bit heavy... */ | 240 | /* WINDOW_MOVE_CREDITS is a bit heavy... */ |
248 | handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); | 241 | handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); |
249 | if (IS_ERR(handle)) { | 242 | if (IS_ERR(handle)) { |
250 | mlog_errno(PTR_ERR(handle)); | 243 | mlog_errno(PTR_ERR(handle)); |
251 | handle = NULL; | 244 | handle = NULL; |
252 | goto bail; | 245 | goto out_unlock; |
253 | } | 246 | } |
254 | 247 | ||
255 | bh = osb->local_alloc_bh; | 248 | bh = osb->local_alloc_bh; |
@@ -258,7 +251,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
258 | alloc_copy = kmalloc(bh->b_size, GFP_KERNEL); | 251 | alloc_copy = kmalloc(bh->b_size, GFP_KERNEL); |
259 | if (!alloc_copy) { | 252 | if (!alloc_copy) { |
260 | status = -ENOMEM; | 253 | status = -ENOMEM; |
261 | goto bail; | 254 | goto out_commit; |
262 | } | 255 | } |
263 | memcpy(alloc_copy, alloc, bh->b_size); | 256 | memcpy(alloc_copy, alloc, bh->b_size); |
264 | 257 | ||
@@ -266,7 +259,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
266 | OCFS2_JOURNAL_ACCESS_WRITE); | 259 | OCFS2_JOURNAL_ACCESS_WRITE); |
267 | if (status < 0) { | 260 | if (status < 0) { |
268 | mlog_errno(status); | 261 | mlog_errno(status); |
269 | goto bail; | 262 | goto out_commit; |
270 | } | 263 | } |
271 | 264 | ||
272 | ocfs2_clear_local_alloc(alloc); | 265 | ocfs2_clear_local_alloc(alloc); |
@@ -274,7 +267,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
274 | status = ocfs2_journal_dirty(handle, bh); | 267 | status = ocfs2_journal_dirty(handle, bh); |
275 | if (status < 0) { | 268 | if (status < 0) { |
276 | mlog_errno(status); | 269 | mlog_errno(status); |
277 | goto bail; | 270 | goto out_commit; |
278 | } | 271 | } |
279 | 272 | ||
280 | brelse(bh); | 273 | brelse(bh); |
@@ -286,16 +279,20 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) | |||
286 | if (status < 0) | 279 | if (status < 0) |
287 | mlog_errno(status); | 280 | mlog_errno(status); |
288 | 281 | ||
289 | bail: | 282 | out_commit: |
290 | if (handle) | 283 | ocfs2_commit_trans(osb, handle); |
291 | ocfs2_commit_trans(handle); | ||
292 | 284 | ||
285 | out_unlock: | ||
293 | if (main_bm_bh) | 286 | if (main_bm_bh) |
294 | brelse(main_bm_bh); | 287 | brelse(main_bm_bh); |
295 | 288 | ||
296 | if (main_bm_inode) | 289 | ocfs2_meta_unlock(main_bm_inode, 1); |
297 | iput(main_bm_inode); | ||
298 | 290 | ||
291 | out_mutex: | ||
292 | mutex_unlock(&main_bm_inode->i_mutex); | ||
293 | iput(main_bm_inode); | ||
294 | |||
295 | out: | ||
299 | if (local_alloc_inode) | 296 | if (local_alloc_inode) |
300 | iput(local_alloc_inode); | 297 | iput(local_alloc_inode); |
301 | 298 | ||
@@ -385,61 +382,59 @@ int ocfs2_complete_local_alloc_recovery(struct ocfs2_super *osb, | |||
385 | struct ocfs2_dinode *alloc) | 382 | struct ocfs2_dinode *alloc) |
386 | { | 383 | { |
387 | int status; | 384 | int status; |
388 | struct ocfs2_journal_handle *handle = NULL; | 385 | handle_t *handle; |
389 | struct buffer_head *main_bm_bh = NULL; | 386 | struct buffer_head *main_bm_bh = NULL; |
390 | struct inode *main_bm_inode = NULL; | 387 | struct inode *main_bm_inode; |
391 | 388 | ||
392 | mlog_entry_void(); | 389 | mlog_entry_void(); |
393 | 390 | ||
394 | handle = ocfs2_alloc_handle(osb); | ||
395 | if (!handle) { | ||
396 | status = -ENOMEM; | ||
397 | mlog_errno(status); | ||
398 | goto bail; | ||
399 | } | ||
400 | |||
401 | main_bm_inode = ocfs2_get_system_file_inode(osb, | 391 | main_bm_inode = ocfs2_get_system_file_inode(osb, |
402 | GLOBAL_BITMAP_SYSTEM_INODE, | 392 | GLOBAL_BITMAP_SYSTEM_INODE, |
403 | OCFS2_INVALID_SLOT); | 393 | OCFS2_INVALID_SLOT); |
404 | if (!main_bm_inode) { | 394 | if (!main_bm_inode) { |
405 | status = -EINVAL; | 395 | status = -EINVAL; |
406 | mlog_errno(status); | 396 | mlog_errno(status); |
407 | goto bail; | 397 | goto out; |
408 | } | 398 | } |
409 | 399 | ||
410 | ocfs2_handle_add_inode(handle, main_bm_inode); | 400 | mutex_lock(&main_bm_inode->i_mutex); |
411 | status = ocfs2_meta_lock(main_bm_inode, handle, &main_bm_bh, 1); | 401 | |
402 | status = ocfs2_meta_lock(main_bm_inode, &main_bm_bh, 1); | ||
412 | if (status < 0) { | 403 | if (status < 0) { |
413 | mlog_errno(status); | 404 | mlog_errno(status); |
414 | goto bail; | 405 | goto out_mutex; |
415 | } | 406 | } |
416 | 407 | ||
417 | handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); | 408 | handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); |
418 | if (IS_ERR(handle)) { | 409 | if (IS_ERR(handle)) { |
419 | status = PTR_ERR(handle); | 410 | status = PTR_ERR(handle); |
420 | handle = NULL; | 411 | handle = NULL; |
421 | mlog_errno(status); | 412 | mlog_errno(status); |
422 | goto bail; | 413 | goto out_unlock; |
423 | } | 414 | } |
424 | 415 | ||
425 | /* we want the bitmap change to be recorded on disk asap */ | 416 | /* we want the bitmap change to be recorded on disk asap */ |
426 | ocfs2_handle_set_sync(handle, 1); | 417 | handle->h_sync = 1; |
427 | 418 | ||
428 | status = ocfs2_sync_local_to_main(osb, handle, alloc, | 419 | status = ocfs2_sync_local_to_main(osb, handle, alloc, |
429 | main_bm_inode, main_bm_bh); | 420 | main_bm_inode, main_bm_bh); |
430 | if (status < 0) | 421 | if (status < 0) |
431 | mlog_errno(status); | 422 | mlog_errno(status); |
432 | 423 | ||
433 | bail: | 424 | ocfs2_commit_trans(osb, handle); |
434 | if (handle) | 425 | |
435 | ocfs2_commit_trans(handle); | 426 | out_unlock: |
427 | ocfs2_meta_unlock(main_bm_inode, 1); | ||
428 | |||
429 | out_mutex: | ||
430 | mutex_unlock(&main_bm_inode->i_mutex); | ||
436 | 431 | ||
437 | if (main_bm_bh) | 432 | if (main_bm_bh) |
438 | brelse(main_bm_bh); | 433 | brelse(main_bm_bh); |
439 | 434 | ||
440 | if (main_bm_inode) | 435 | iput(main_bm_inode); |
441 | iput(main_bm_inode); | ||
442 | 436 | ||
437 | out: | ||
443 | mlog_exit(status); | 438 | mlog_exit(status); |
444 | return status; | 439 | return status; |
445 | } | 440 | } |
@@ -452,7 +447,6 @@ bail: | |||
452 | * our own in order to shift windows. | 447 | * our own in order to shift windows. |
453 | */ | 448 | */ |
454 | int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | 449 | int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, |
455 | struct ocfs2_journal_handle *passed_handle, | ||
456 | u32 bits_wanted, | 450 | u32 bits_wanted, |
457 | struct ocfs2_alloc_context *ac) | 451 | struct ocfs2_alloc_context *ac) |
458 | { | 452 | { |
@@ -463,9 +457,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
463 | 457 | ||
464 | mlog_entry_void(); | 458 | mlog_entry_void(); |
465 | 459 | ||
466 | BUG_ON(!passed_handle); | ||
467 | BUG_ON(!ac); | 460 | BUG_ON(!ac); |
468 | BUG_ON(passed_handle->flags & OCFS2_HANDLE_STARTED); | ||
469 | 461 | ||
470 | local_alloc_inode = | 462 | local_alloc_inode = |
471 | ocfs2_get_system_file_inode(osb, | 463 | ocfs2_get_system_file_inode(osb, |
@@ -476,7 +468,11 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
476 | mlog_errno(status); | 468 | mlog_errno(status); |
477 | goto bail; | 469 | goto bail; |
478 | } | 470 | } |
479 | ocfs2_handle_add_inode(passed_handle, local_alloc_inode); | 471 | |
472 | mutex_lock(&local_alloc_inode->i_mutex); | ||
473 | |||
474 | ac->ac_inode = local_alloc_inode; | ||
475 | ac->ac_which = OCFS2_AC_USE_LOCAL; | ||
480 | 476 | ||
481 | if (osb->local_alloc_state != OCFS2_LA_ENABLED) { | 477 | if (osb->local_alloc_state != OCFS2_LA_ENABLED) { |
482 | status = -ENOSPC; | 478 | status = -ENOSPC; |
@@ -515,21 +511,17 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | |||
515 | } | 511 | } |
516 | } | 512 | } |
517 | 513 | ||
518 | ac->ac_inode = igrab(local_alloc_inode); | ||
519 | get_bh(osb->local_alloc_bh); | 514 | get_bh(osb->local_alloc_bh); |
520 | ac->ac_bh = osb->local_alloc_bh; | 515 | ac->ac_bh = osb->local_alloc_bh; |
521 | ac->ac_which = OCFS2_AC_USE_LOCAL; | ||
522 | status = 0; | 516 | status = 0; |
523 | bail: | 517 | bail: |
524 | if (local_alloc_inode) | ||
525 | iput(local_alloc_inode); | ||
526 | 518 | ||
527 | mlog_exit(status); | 519 | mlog_exit(status); |
528 | return status; | 520 | return status; |
529 | } | 521 | } |
530 | 522 | ||
531 | int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, | 523 | int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, |
532 | struct ocfs2_journal_handle *handle, | 524 | handle_t *handle, |
533 | struct ocfs2_alloc_context *ac, | 525 | struct ocfs2_alloc_context *ac, |
534 | u32 min_bits, | 526 | u32 min_bits, |
535 | u32 *bit_off, | 527 | u32 *bit_off, |
@@ -707,7 +699,7 @@ static void ocfs2_verify_zero_bits(unsigned long *bitmap, | |||
707 | * passed is used for caching. | 699 | * passed is used for caching. |
708 | */ | 700 | */ |
709 | static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, | 701 | static int ocfs2_sync_local_to_main(struct ocfs2_super *osb, |
710 | struct ocfs2_journal_handle *handle, | 702 | handle_t *handle, |
711 | struct ocfs2_dinode *alloc, | 703 | struct ocfs2_dinode *alloc, |
712 | struct inode *main_bm_inode, | 704 | struct inode *main_bm_inode, |
713 | struct buffer_head *main_bm_bh) | 705 | struct buffer_head *main_bm_bh) |
@@ -778,21 +770,19 @@ bail: | |||
778 | } | 770 | } |
779 | 771 | ||
780 | static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, | 772 | static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, |
781 | struct ocfs2_journal_handle *handle, | ||
782 | struct ocfs2_alloc_context **ac, | 773 | struct ocfs2_alloc_context **ac, |
783 | struct inode **bitmap_inode, | 774 | struct inode **bitmap_inode, |
784 | struct buffer_head **bitmap_bh) | 775 | struct buffer_head **bitmap_bh) |
785 | { | 776 | { |
786 | int status; | 777 | int status; |
787 | 778 | ||
788 | *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); | 779 | *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
789 | if (!(*ac)) { | 780 | if (!(*ac)) { |
790 | status = -ENOMEM; | 781 | status = -ENOMEM; |
791 | mlog_errno(status); | 782 | mlog_errno(status); |
792 | goto bail; | 783 | goto bail; |
793 | } | 784 | } |
794 | 785 | ||
795 | (*ac)->ac_handle = handle; | ||
796 | (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb); | 786 | (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb); |
797 | 787 | ||
798 | status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); | 788 | status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); |
@@ -821,7 +811,7 @@ bail: | |||
821 | * pass it the bitmap lock in lock_bh if you have it. | 811 | * pass it the bitmap lock in lock_bh if you have it. |
822 | */ | 812 | */ |
823 | static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, | 813 | static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, |
824 | struct ocfs2_journal_handle *handle, | 814 | handle_t *handle, |
825 | struct ocfs2_alloc_context *ac) | 815 | struct ocfs2_alloc_context *ac) |
826 | { | 816 | { |
827 | int status = 0; | 817 | int status = 0; |
@@ -888,23 +878,15 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | |||
888 | int status = 0; | 878 | int status = 0; |
889 | struct buffer_head *main_bm_bh = NULL; | 879 | struct buffer_head *main_bm_bh = NULL; |
890 | struct inode *main_bm_inode = NULL; | 880 | struct inode *main_bm_inode = NULL; |
891 | struct ocfs2_journal_handle *handle = NULL; | 881 | handle_t *handle = NULL; |
892 | struct ocfs2_dinode *alloc; | 882 | struct ocfs2_dinode *alloc; |
893 | struct ocfs2_dinode *alloc_copy = NULL; | 883 | struct ocfs2_dinode *alloc_copy = NULL; |
894 | struct ocfs2_alloc_context *ac = NULL; | 884 | struct ocfs2_alloc_context *ac = NULL; |
895 | 885 | ||
896 | mlog_entry_void(); | 886 | mlog_entry_void(); |
897 | 887 | ||
898 | handle = ocfs2_alloc_handle(osb); | ||
899 | if (!handle) { | ||
900 | status = -ENOMEM; | ||
901 | mlog_errno(status); | ||
902 | goto bail; | ||
903 | } | ||
904 | |||
905 | /* This will lock the main bitmap for us. */ | 888 | /* This will lock the main bitmap for us. */ |
906 | status = ocfs2_local_alloc_reserve_for_window(osb, | 889 | status = ocfs2_local_alloc_reserve_for_window(osb, |
907 | handle, | ||
908 | &ac, | 890 | &ac, |
909 | &main_bm_inode, | 891 | &main_bm_inode, |
910 | &main_bm_bh); | 892 | &main_bm_bh); |
@@ -914,7 +896,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | |||
914 | goto bail; | 896 | goto bail; |
915 | } | 897 | } |
916 | 898 | ||
917 | handle = ocfs2_start_trans(osb, handle, OCFS2_WINDOW_MOVE_CREDITS); | 899 | handle = ocfs2_start_trans(osb, OCFS2_WINDOW_MOVE_CREDITS); |
918 | if (IS_ERR(handle)) { | 900 | if (IS_ERR(handle)) { |
919 | status = PTR_ERR(handle); | 901 | status = PTR_ERR(handle); |
920 | handle = NULL; | 902 | handle = NULL; |
@@ -972,7 +954,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | |||
972 | status = 0; | 954 | status = 0; |
973 | bail: | 955 | bail: |
974 | if (handle) | 956 | if (handle) |
975 | ocfs2_commit_trans(handle); | 957 | ocfs2_commit_trans(osb, handle); |
976 | 958 | ||
977 | if (main_bm_bh) | 959 | if (main_bm_bh) |
978 | brelse(main_bm_bh); | 960 | brelse(main_bm_bh); |
diff --git a/fs/ocfs2/localalloc.h b/fs/ocfs2/localalloc.h index 30f88ce14e46..385a10152f9c 100644 --- a/fs/ocfs2/localalloc.h +++ b/fs/ocfs2/localalloc.h | |||
@@ -42,12 +42,11 @@ int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, | |||
42 | 42 | ||
43 | struct ocfs2_alloc_context; | 43 | struct ocfs2_alloc_context; |
44 | int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, | 44 | int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb, |
45 | struct ocfs2_journal_handle *passed_handle, | ||
46 | u32 bits_wanted, | 45 | u32 bits_wanted, |
47 | struct ocfs2_alloc_context *ac); | 46 | struct ocfs2_alloc_context *ac); |
48 | 47 | ||
49 | int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, | 48 | int ocfs2_claim_local_alloc_bits(struct ocfs2_super *osb, |
50 | struct ocfs2_journal_handle *handle, | 49 | handle_t *handle, |
51 | struct ocfs2_alloc_context *ac, | 50 | struct ocfs2_alloc_context *ac, |
52 | u32 min_bits, | 51 | u32 min_bits, |
53 | u32 *bit_off, | 52 | u32 *bit_off, |
diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index 83934e33e5b0..51b020447683 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c | |||
@@ -82,16 +82,27 @@ static struct vm_operations_struct ocfs2_file_vm_ops = { | |||
82 | 82 | ||
83 | int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) | 83 | int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) |
84 | { | 84 | { |
85 | int ret = 0, lock_level = 0; | ||
86 | struct ocfs2_super *osb = OCFS2_SB(file->f_dentry->d_inode->i_sb); | ||
87 | |||
85 | /* We don't want to support shared writable mappings yet. */ | 88 | /* We don't want to support shared writable mappings yet. */ |
86 | if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) | 89 | if (!ocfs2_mount_local(osb) && |
87 | && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { | 90 | ((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) && |
91 | ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { | ||
88 | mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags); | 92 | mlog(0, "disallow shared writable mmaps %lx\n", vma->vm_flags); |
89 | /* This is -EINVAL because generic_file_readonly_mmap | 93 | /* This is -EINVAL because generic_file_readonly_mmap |
90 | * returns it in a similar situation. */ | 94 | * returns it in a similar situation. */ |
91 | return -EINVAL; | 95 | return -EINVAL; |
92 | } | 96 | } |
93 | 97 | ||
94 | file_accessed(file); | 98 | ret = ocfs2_meta_lock_atime(file->f_dentry->d_inode, |
99 | file->f_vfsmnt, &lock_level); | ||
100 | if (ret < 0) { | ||
101 | mlog_errno(ret); | ||
102 | goto out; | ||
103 | } | ||
104 | ocfs2_meta_unlock(file->f_dentry->d_inode, lock_level); | ||
105 | out: | ||
95 | vma->vm_ops = &ocfs2_file_vm_ops; | 106 | vma->vm_ops = &ocfs2_file_vm_ops; |
96 | return 0; | 107 | return 0; |
97 | } | 108 | } |
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index a57b751d4f40..9637039c2633 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c | |||
@@ -75,12 +75,12 @@ static int inline ocfs2_search_dirblock(struct buffer_head *bh, | |||
75 | unsigned long offset, | 75 | unsigned long offset, |
76 | struct ocfs2_dir_entry **res_dir); | 76 | struct ocfs2_dir_entry **res_dir); |
77 | 77 | ||
78 | static int ocfs2_delete_entry(struct ocfs2_journal_handle *handle, | 78 | static int ocfs2_delete_entry(handle_t *handle, |
79 | struct inode *dir, | 79 | struct inode *dir, |
80 | struct ocfs2_dir_entry *de_del, | 80 | struct ocfs2_dir_entry *de_del, |
81 | struct buffer_head *bh); | 81 | struct buffer_head *bh); |
82 | 82 | ||
83 | static int __ocfs2_add_entry(struct ocfs2_journal_handle *handle, | 83 | static int __ocfs2_add_entry(handle_t *handle, |
84 | struct inode *dir, | 84 | struct inode *dir, |
85 | const char *name, int namelen, | 85 | const char *name, int namelen, |
86 | struct inode *inode, u64 blkno, | 86 | struct inode *inode, u64 blkno, |
@@ -93,43 +93,37 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
93 | dev_t dev, | 93 | dev_t dev, |
94 | struct buffer_head **new_fe_bh, | 94 | struct buffer_head **new_fe_bh, |
95 | struct buffer_head *parent_fe_bh, | 95 | struct buffer_head *parent_fe_bh, |
96 | struct ocfs2_journal_handle *handle, | 96 | handle_t *handle, |
97 | struct inode **ret_inode, | 97 | struct inode **ret_inode, |
98 | struct ocfs2_alloc_context *inode_ac); | 98 | struct ocfs2_alloc_context *inode_ac); |
99 | 99 | ||
100 | static int ocfs2_fill_new_dir(struct ocfs2_super *osb, | 100 | static int ocfs2_fill_new_dir(struct ocfs2_super *osb, |
101 | struct ocfs2_journal_handle *handle, | 101 | handle_t *handle, |
102 | struct inode *parent, | 102 | struct inode *parent, |
103 | struct inode *inode, | 103 | struct inode *inode, |
104 | struct buffer_head *fe_bh, | 104 | struct buffer_head *fe_bh, |
105 | struct ocfs2_alloc_context *data_ac); | 105 | struct ocfs2_alloc_context *data_ac); |
106 | 106 | ||
107 | static int ocfs2_double_lock(struct ocfs2_super *osb, | ||
108 | struct ocfs2_journal_handle *handle, | ||
109 | struct buffer_head **bh1, | ||
110 | struct inode *inode1, | ||
111 | struct buffer_head **bh2, | ||
112 | struct inode *inode2); | ||
113 | |||
114 | static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, | 107 | static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, |
115 | struct ocfs2_journal_handle *handle, | 108 | struct inode **ret_orphan_dir, |
116 | struct inode *inode, | 109 | struct inode *inode, |
117 | char *name, | 110 | char *name, |
118 | struct buffer_head **de_bh); | 111 | struct buffer_head **de_bh); |
119 | 112 | ||
120 | static int ocfs2_orphan_add(struct ocfs2_super *osb, | 113 | static int ocfs2_orphan_add(struct ocfs2_super *osb, |
121 | struct ocfs2_journal_handle *handle, | 114 | handle_t *handle, |
122 | struct inode *inode, | 115 | struct inode *inode, |
123 | struct ocfs2_dinode *fe, | 116 | struct ocfs2_dinode *fe, |
124 | char *name, | 117 | char *name, |
125 | struct buffer_head *de_bh); | 118 | struct buffer_head *de_bh, |
119 | struct inode *orphan_dir_inode); | ||
126 | 120 | ||
127 | static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | 121 | static int ocfs2_create_symlink_data(struct ocfs2_super *osb, |
128 | struct ocfs2_journal_handle *handle, | 122 | handle_t *handle, |
129 | struct inode *inode, | 123 | struct inode *inode, |
130 | const char *symname); | 124 | const char *symname); |
131 | 125 | ||
132 | static inline int ocfs2_add_entry(struct ocfs2_journal_handle *handle, | 126 | static inline int ocfs2_add_entry(handle_t *handle, |
133 | struct dentry *dentry, | 127 | struct dentry *dentry, |
134 | struct inode *inode, u64 blkno, | 128 | struct inode *inode, u64 blkno, |
135 | struct buffer_head *parent_fe_bh, | 129 | struct buffer_head *parent_fe_bh, |
@@ -165,7 +159,7 @@ static struct dentry *ocfs2_lookup(struct inode *dir, struct dentry *dentry, | |||
165 | mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len, | 159 | mlog(0, "find name %.*s in directory %llu\n", dentry->d_name.len, |
166 | dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno); | 160 | dentry->d_name.name, (unsigned long long)OCFS2_I(dir)->ip_blkno); |
167 | 161 | ||
168 | status = ocfs2_meta_lock(dir, NULL, NULL, 0); | 162 | status = ocfs2_meta_lock(dir, NULL, 0); |
169 | if (status < 0) { | 163 | if (status < 0) { |
170 | if (status != -ENOENT) | 164 | if (status != -ENOENT) |
171 | mlog_errno(status); | 165 | mlog_errno(status); |
@@ -242,7 +236,7 @@ bail: | |||
242 | } | 236 | } |
243 | 237 | ||
244 | static int ocfs2_fill_new_dir(struct ocfs2_super *osb, | 238 | static int ocfs2_fill_new_dir(struct ocfs2_super *osb, |
245 | struct ocfs2_journal_handle *handle, | 239 | handle_t *handle, |
246 | struct inode *parent, | 240 | struct inode *parent, |
247 | struct inode *inode, | 241 | struct inode *inode, |
248 | struct buffer_head *fe_bh, | 242 | struct buffer_head *fe_bh, |
@@ -317,7 +311,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
317 | { | 311 | { |
318 | int status = 0; | 312 | int status = 0; |
319 | struct buffer_head *parent_fe_bh = NULL; | 313 | struct buffer_head *parent_fe_bh = NULL; |
320 | struct ocfs2_journal_handle *handle = NULL; | 314 | handle_t *handle = NULL; |
321 | struct ocfs2_super *osb; | 315 | struct ocfs2_super *osb; |
322 | struct ocfs2_dinode *dirfe; | 316 | struct ocfs2_dinode *dirfe; |
323 | struct buffer_head *new_fe_bh = NULL; | 317 | struct buffer_head *new_fe_bh = NULL; |
@@ -333,18 +327,11 @@ static int ocfs2_mknod(struct inode *dir, | |||
333 | /* get our super block */ | 327 | /* get our super block */ |
334 | osb = OCFS2_SB(dir->i_sb); | 328 | osb = OCFS2_SB(dir->i_sb); |
335 | 329 | ||
336 | handle = ocfs2_alloc_handle(osb); | 330 | status = ocfs2_meta_lock(dir, &parent_fe_bh, 1); |
337 | if (handle == NULL) { | ||
338 | status = -ENOMEM; | ||
339 | mlog_errno(status); | ||
340 | goto leave; | ||
341 | } | ||
342 | |||
343 | status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); | ||
344 | if (status < 0) { | 331 | if (status < 0) { |
345 | if (status != -ENOENT) | 332 | if (status != -ENOENT) |
346 | mlog_errno(status); | 333 | mlog_errno(status); |
347 | goto leave; | 334 | return status; |
348 | } | 335 | } |
349 | 336 | ||
350 | if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) { | 337 | if (S_ISDIR(mode) && (dir->i_nlink >= OCFS2_LINK_MAX)) { |
@@ -374,7 +361,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
374 | } | 361 | } |
375 | 362 | ||
376 | /* reserve an inode spot */ | 363 | /* reserve an inode spot */ |
377 | status = ocfs2_reserve_new_inode(osb, handle, &inode_ac); | 364 | status = ocfs2_reserve_new_inode(osb, &inode_ac); |
378 | if (status < 0) { | 365 | if (status < 0) { |
379 | if (status != -ENOSPC) | 366 | if (status != -ENOSPC) |
380 | mlog_errno(status); | 367 | mlog_errno(status); |
@@ -384,7 +371,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
384 | /* are we making a directory? If so, reserve a cluster for his | 371 | /* are we making a directory? If so, reserve a cluster for his |
385 | * 1st extent. */ | 372 | * 1st extent. */ |
386 | if (S_ISDIR(mode)) { | 373 | if (S_ISDIR(mode)) { |
387 | status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); | 374 | status = ocfs2_reserve_clusters(osb, 1, &data_ac); |
388 | if (status < 0) { | 375 | if (status < 0) { |
389 | if (status != -ENOSPC) | 376 | if (status != -ENOSPC) |
390 | mlog_errno(status); | 377 | mlog_errno(status); |
@@ -392,7 +379,7 @@ static int ocfs2_mknod(struct inode *dir, | |||
392 | } | 379 | } |
393 | } | 380 | } |
394 | 381 | ||
395 | handle = ocfs2_start_trans(osb, handle, OCFS2_MKNOD_CREDITS); | 382 | handle = ocfs2_start_trans(osb, OCFS2_MKNOD_CREDITS); |
396 | if (IS_ERR(handle)) { | 383 | if (IS_ERR(handle)) { |
397 | status = PTR_ERR(handle); | 384 | status = PTR_ERR(handle); |
398 | handle = NULL; | 385 | handle = NULL; |
@@ -453,7 +440,9 @@ static int ocfs2_mknod(struct inode *dir, | |||
453 | status = 0; | 440 | status = 0; |
454 | leave: | 441 | leave: |
455 | if (handle) | 442 | if (handle) |
456 | ocfs2_commit_trans(handle); | 443 | ocfs2_commit_trans(osb, handle); |
444 | |||
445 | ocfs2_meta_unlock(dir, 1); | ||
457 | 446 | ||
458 | if (status == -ENOSPC) | 447 | if (status == -ENOSPC) |
459 | mlog(0, "Disk is full\n"); | 448 | mlog(0, "Disk is full\n"); |
@@ -487,7 +476,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
487 | dev_t dev, | 476 | dev_t dev, |
488 | struct buffer_head **new_fe_bh, | 477 | struct buffer_head **new_fe_bh, |
489 | struct buffer_head *parent_fe_bh, | 478 | struct buffer_head *parent_fe_bh, |
490 | struct ocfs2_journal_handle *handle, | 479 | handle_t *handle, |
491 | struct inode **ret_inode, | 480 | struct inode **ret_inode, |
492 | struct ocfs2_alloc_context *inode_ac) | 481 | struct ocfs2_alloc_context *inode_ac) |
493 | { | 482 | { |
@@ -598,9 +587,11 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb, | |||
598 | } | 587 | } |
599 | 588 | ||
600 | ocfs2_inode_set_new(osb, inode); | 589 | ocfs2_inode_set_new(osb, inode); |
601 | status = ocfs2_create_new_inode_locks(inode); | 590 | if (!ocfs2_mount_local(osb)) { |
602 | if (status < 0) | 591 | status = ocfs2_create_new_inode_locks(inode); |
603 | mlog_errno(status); | 592 | if (status < 0) |
593 | mlog_errno(status); | ||
594 | } | ||
604 | 595 | ||
605 | status = 0; /* error in ocfs2_create_new_inode_locks is not | 596 | status = 0; /* error in ocfs2_create_new_inode_locks is not |
606 | * critical */ | 597 | * critical */ |
@@ -653,7 +644,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
653 | struct inode *dir, | 644 | struct inode *dir, |
654 | struct dentry *dentry) | 645 | struct dentry *dentry) |
655 | { | 646 | { |
656 | struct ocfs2_journal_handle *handle = NULL; | 647 | handle_t *handle; |
657 | struct inode *inode = old_dentry->d_inode; | 648 | struct inode *inode = old_dentry->d_inode; |
658 | int err; | 649 | int err; |
659 | struct buffer_head *fe_bh = NULL; | 650 | struct buffer_head *fe_bh = NULL; |
@@ -666,68 +657,60 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
666 | old_dentry->d_name.len, old_dentry->d_name.name, | 657 | old_dentry->d_name.len, old_dentry->d_name.name, |
667 | dentry->d_name.len, dentry->d_name.name); | 658 | dentry->d_name.len, dentry->d_name.name); |
668 | 659 | ||
669 | if (S_ISDIR(inode->i_mode)) { | 660 | if (S_ISDIR(inode->i_mode)) |
670 | err = -EPERM; | 661 | return -EPERM; |
671 | goto bail; | ||
672 | } | ||
673 | |||
674 | handle = ocfs2_alloc_handle(osb); | ||
675 | if (handle == NULL) { | ||
676 | err = -ENOMEM; | ||
677 | goto bail; | ||
678 | } | ||
679 | 662 | ||
680 | err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); | 663 | err = ocfs2_meta_lock(dir, &parent_fe_bh, 1); |
681 | if (err < 0) { | 664 | if (err < 0) { |
682 | if (err != -ENOENT) | 665 | if (err != -ENOENT) |
683 | mlog_errno(err); | 666 | mlog_errno(err); |
684 | goto bail; | 667 | return err; |
685 | } | 668 | } |
686 | 669 | ||
687 | if (!dir->i_nlink) { | 670 | if (!dir->i_nlink) { |
688 | err = -ENOENT; | 671 | err = -ENOENT; |
689 | goto bail; | 672 | goto out; |
690 | } | 673 | } |
691 | 674 | ||
692 | err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, | 675 | err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, |
693 | dentry->d_name.len); | 676 | dentry->d_name.len); |
694 | if (err) | 677 | if (err) |
695 | goto bail; | 678 | goto out; |
696 | 679 | ||
697 | err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, | 680 | err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, |
698 | dentry->d_name.name, | 681 | dentry->d_name.name, |
699 | dentry->d_name.len, &de_bh); | 682 | dentry->d_name.len, &de_bh); |
700 | if (err < 0) { | 683 | if (err < 0) { |
701 | mlog_errno(err); | 684 | mlog_errno(err); |
702 | goto bail; | 685 | goto out; |
703 | } | 686 | } |
704 | 687 | ||
705 | err = ocfs2_meta_lock(inode, handle, &fe_bh, 1); | 688 | err = ocfs2_meta_lock(inode, &fe_bh, 1); |
706 | if (err < 0) { | 689 | if (err < 0) { |
707 | if (err != -ENOENT) | 690 | if (err != -ENOENT) |
708 | mlog_errno(err); | 691 | mlog_errno(err); |
709 | goto bail; | 692 | goto out; |
710 | } | 693 | } |
711 | 694 | ||
712 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | 695 | fe = (struct ocfs2_dinode *) fe_bh->b_data; |
713 | if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) { | 696 | if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) { |
714 | err = -EMLINK; | 697 | err = -EMLINK; |
715 | goto bail; | 698 | goto out_unlock_inode; |
716 | } | 699 | } |
717 | 700 | ||
718 | handle = ocfs2_start_trans(osb, handle, OCFS2_LINK_CREDITS); | 701 | handle = ocfs2_start_trans(osb, OCFS2_LINK_CREDITS); |
719 | if (IS_ERR(handle)) { | 702 | if (IS_ERR(handle)) { |
720 | err = PTR_ERR(handle); | 703 | err = PTR_ERR(handle); |
721 | handle = NULL; | 704 | handle = NULL; |
722 | mlog_errno(err); | 705 | mlog_errno(err); |
723 | goto bail; | 706 | goto out_unlock_inode; |
724 | } | 707 | } |
725 | 708 | ||
726 | err = ocfs2_journal_access(handle, inode, fe_bh, | 709 | err = ocfs2_journal_access(handle, inode, fe_bh, |
727 | OCFS2_JOURNAL_ACCESS_WRITE); | 710 | OCFS2_JOURNAL_ACCESS_WRITE); |
728 | if (err < 0) { | 711 | if (err < 0) { |
729 | mlog_errno(err); | 712 | mlog_errno(err); |
730 | goto bail; | 713 | goto out_commit; |
731 | } | 714 | } |
732 | 715 | ||
733 | inc_nlink(inode); | 716 | inc_nlink(inode); |
@@ -741,7 +724,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
741 | le16_add_cpu(&fe->i_links_count, -1); | 724 | le16_add_cpu(&fe->i_links_count, -1); |
742 | drop_nlink(inode); | 725 | drop_nlink(inode); |
743 | mlog_errno(err); | 726 | mlog_errno(err); |
744 | goto bail; | 727 | goto out_commit; |
745 | } | 728 | } |
746 | 729 | ||
747 | err = ocfs2_add_entry(handle, dentry, inode, | 730 | err = ocfs2_add_entry(handle, dentry, inode, |
@@ -751,21 +734,27 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
751 | le16_add_cpu(&fe->i_links_count, -1); | 734 | le16_add_cpu(&fe->i_links_count, -1); |
752 | drop_nlink(inode); | 735 | drop_nlink(inode); |
753 | mlog_errno(err); | 736 | mlog_errno(err); |
754 | goto bail; | 737 | goto out_commit; |
755 | } | 738 | } |
756 | 739 | ||
757 | err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); | 740 | err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); |
758 | if (err) { | 741 | if (err) { |
759 | mlog_errno(err); | 742 | mlog_errno(err); |
760 | goto bail; | 743 | goto out_commit; |
761 | } | 744 | } |
762 | 745 | ||
763 | atomic_inc(&inode->i_count); | 746 | atomic_inc(&inode->i_count); |
764 | dentry->d_op = &ocfs2_dentry_ops; | 747 | dentry->d_op = &ocfs2_dentry_ops; |
765 | d_instantiate(dentry, inode); | 748 | d_instantiate(dentry, inode); |
766 | bail: | 749 | |
767 | if (handle) | 750 | out_commit: |
768 | ocfs2_commit_trans(handle); | 751 | ocfs2_commit_trans(osb, handle); |
752 | out_unlock_inode: | ||
753 | ocfs2_meta_unlock(inode, 1); | ||
754 | |||
755 | out: | ||
756 | ocfs2_meta_unlock(dir, 1); | ||
757 | |||
769 | if (de_bh) | 758 | if (de_bh) |
770 | brelse(de_bh); | 759 | brelse(de_bh); |
771 | if (fe_bh) | 760 | if (fe_bh) |
@@ -812,13 +801,15 @@ static int ocfs2_unlink(struct inode *dir, | |||
812 | struct dentry *dentry) | 801 | struct dentry *dentry) |
813 | { | 802 | { |
814 | int status; | 803 | int status; |
804 | int child_locked = 0; | ||
815 | struct inode *inode = dentry->d_inode; | 805 | struct inode *inode = dentry->d_inode; |
806 | struct inode *orphan_dir = NULL; | ||
816 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); | 807 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
817 | u64 blkno; | 808 | u64 blkno; |
818 | struct ocfs2_dinode *fe = NULL; | 809 | struct ocfs2_dinode *fe = NULL; |
819 | struct buffer_head *fe_bh = NULL; | 810 | struct buffer_head *fe_bh = NULL; |
820 | struct buffer_head *parent_node_bh = NULL; | 811 | struct buffer_head *parent_node_bh = NULL; |
821 | struct ocfs2_journal_handle *handle = NULL; | 812 | handle_t *handle = NULL; |
822 | struct ocfs2_dir_entry *dirent = NULL; | 813 | struct ocfs2_dir_entry *dirent = NULL; |
823 | struct buffer_head *dirent_bh = NULL; | 814 | struct buffer_head *dirent_bh = NULL; |
824 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; | 815 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; |
@@ -833,22 +824,14 @@ static int ocfs2_unlink(struct inode *dir, | |||
833 | 824 | ||
834 | if (inode == osb->root_inode) { | 825 | if (inode == osb->root_inode) { |
835 | mlog(0, "Cannot delete the root directory\n"); | 826 | mlog(0, "Cannot delete the root directory\n"); |
836 | status = -EPERM; | 827 | return -EPERM; |
837 | goto leave; | ||
838 | } | ||
839 | |||
840 | handle = ocfs2_alloc_handle(osb); | ||
841 | if (handle == NULL) { | ||
842 | status = -ENOMEM; | ||
843 | mlog_errno(status); | ||
844 | goto leave; | ||
845 | } | 828 | } |
846 | 829 | ||
847 | status = ocfs2_meta_lock(dir, handle, &parent_node_bh, 1); | 830 | status = ocfs2_meta_lock(dir, &parent_node_bh, 1); |
848 | if (status < 0) { | 831 | if (status < 0) { |
849 | if (status != -ENOENT) | 832 | if (status != -ENOENT) |
850 | mlog_errno(status); | 833 | mlog_errno(status); |
851 | goto leave; | 834 | return status; |
852 | } | 835 | } |
853 | 836 | ||
854 | status = ocfs2_find_files_on_disk(dentry->d_name.name, | 837 | status = ocfs2_find_files_on_disk(dentry->d_name.name, |
@@ -869,12 +852,13 @@ static int ocfs2_unlink(struct inode *dir, | |||
869 | goto leave; | 852 | goto leave; |
870 | } | 853 | } |
871 | 854 | ||
872 | status = ocfs2_meta_lock(inode, handle, &fe_bh, 1); | 855 | status = ocfs2_meta_lock(inode, &fe_bh, 1); |
873 | if (status < 0) { | 856 | if (status < 0) { |
874 | if (status != -ENOENT) | 857 | if (status != -ENOENT) |
875 | mlog_errno(status); | 858 | mlog_errno(status); |
876 | goto leave; | 859 | goto leave; |
877 | } | 860 | } |
861 | child_locked = 1; | ||
878 | 862 | ||
879 | if (S_ISDIR(inode->i_mode)) { | 863 | if (S_ISDIR(inode->i_mode)) { |
880 | if (!ocfs2_empty_dir(inode)) { | 864 | if (!ocfs2_empty_dir(inode)) { |
@@ -895,7 +879,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
895 | } | 879 | } |
896 | 880 | ||
897 | if (inode_is_unlinkable(inode)) { | 881 | if (inode_is_unlinkable(inode)) { |
898 | status = ocfs2_prepare_orphan_dir(osb, handle, inode, | 882 | status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, inode, |
899 | orphan_name, | 883 | orphan_name, |
900 | &orphan_entry_bh); | 884 | &orphan_entry_bh); |
901 | if (status < 0) { | 885 | if (status < 0) { |
@@ -904,7 +888,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
904 | } | 888 | } |
905 | } | 889 | } |
906 | 890 | ||
907 | handle = ocfs2_start_trans(osb, handle, OCFS2_UNLINK_CREDITS); | 891 | handle = ocfs2_start_trans(osb, OCFS2_UNLINK_CREDITS); |
908 | if (IS_ERR(handle)) { | 892 | if (IS_ERR(handle)) { |
909 | status = PTR_ERR(handle); | 893 | status = PTR_ERR(handle); |
910 | handle = NULL; | 894 | handle = NULL; |
@@ -923,7 +907,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
923 | 907 | ||
924 | if (inode_is_unlinkable(inode)) { | 908 | if (inode_is_unlinkable(inode)) { |
925 | status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, | 909 | status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, |
926 | orphan_entry_bh); | 910 | orphan_entry_bh, orphan_dir); |
927 | if (status < 0) { | 911 | if (status < 0) { |
928 | mlog_errno(status); | 912 | mlog_errno(status); |
929 | goto leave; | 913 | goto leave; |
@@ -960,7 +944,19 @@ static int ocfs2_unlink(struct inode *dir, | |||
960 | 944 | ||
961 | leave: | 945 | leave: |
962 | if (handle) | 946 | if (handle) |
963 | ocfs2_commit_trans(handle); | 947 | ocfs2_commit_trans(osb, handle); |
948 | |||
949 | if (child_locked) | ||
950 | ocfs2_meta_unlock(inode, 1); | ||
951 | |||
952 | ocfs2_meta_unlock(dir, 1); | ||
953 | |||
954 | if (orphan_dir) { | ||
955 | /* This was locked for us in ocfs2_prepare_orphan_dir() */ | ||
956 | ocfs2_meta_unlock(orphan_dir, 1); | ||
957 | mutex_unlock(&orphan_dir->i_mutex); | ||
958 | iput(orphan_dir); | ||
959 | } | ||
964 | 960 | ||
965 | if (fe_bh) | 961 | if (fe_bh) |
966 | brelse(fe_bh); | 962 | brelse(fe_bh); |
@@ -984,7 +980,6 @@ leave: | |||
984 | * if they have the same id, then the 1st one is the only one locked. | 980 | * if they have the same id, then the 1st one is the only one locked. |
985 | */ | 981 | */ |
986 | static int ocfs2_double_lock(struct ocfs2_super *osb, | 982 | static int ocfs2_double_lock(struct ocfs2_super *osb, |
987 | struct ocfs2_journal_handle *handle, | ||
988 | struct buffer_head **bh1, | 983 | struct buffer_head **bh1, |
989 | struct inode *inode1, | 984 | struct inode *inode1, |
990 | struct buffer_head **bh2, | 985 | struct buffer_head **bh2, |
@@ -1000,8 +995,6 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
1000 | (unsigned long long)oi1->ip_blkno, | 995 | (unsigned long long)oi1->ip_blkno, |
1001 | (unsigned long long)oi2->ip_blkno); | 996 | (unsigned long long)oi2->ip_blkno); |
1002 | 997 | ||
1003 | BUG_ON(!handle); | ||
1004 | |||
1005 | if (*bh1) | 998 | if (*bh1) |
1006 | *bh1 = NULL; | 999 | *bh1 = NULL; |
1007 | if (*bh2) | 1000 | if (*bh2) |
@@ -1021,25 +1014,41 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
1021 | inode1 = tmpinode; | 1014 | inode1 = tmpinode; |
1022 | } | 1015 | } |
1023 | /* lock id2 */ | 1016 | /* lock id2 */ |
1024 | status = ocfs2_meta_lock(inode2, handle, bh2, 1); | 1017 | status = ocfs2_meta_lock(inode2, bh2, 1); |
1025 | if (status < 0) { | 1018 | if (status < 0) { |
1026 | if (status != -ENOENT) | 1019 | if (status != -ENOENT) |
1027 | mlog_errno(status); | 1020 | mlog_errno(status); |
1028 | goto bail; | 1021 | goto bail; |
1029 | } | 1022 | } |
1030 | } | 1023 | } |
1024 | |||
1031 | /* lock id1 */ | 1025 | /* lock id1 */ |
1032 | status = ocfs2_meta_lock(inode1, handle, bh1, 1); | 1026 | status = ocfs2_meta_lock(inode1, bh1, 1); |
1033 | if (status < 0) { | 1027 | if (status < 0) { |
1028 | /* | ||
1029 | * An error return must mean that no cluster locks | ||
1030 | * were held on function exit. | ||
1031 | */ | ||
1032 | if (oi1->ip_blkno != oi2->ip_blkno) | ||
1033 | ocfs2_meta_unlock(inode2, 1); | ||
1034 | |||
1034 | if (status != -ENOENT) | 1035 | if (status != -ENOENT) |
1035 | mlog_errno(status); | 1036 | mlog_errno(status); |
1036 | goto bail; | ||
1037 | } | 1037 | } |
1038 | |||
1038 | bail: | 1039 | bail: |
1039 | mlog_exit(status); | 1040 | mlog_exit(status); |
1040 | return status; | 1041 | return status; |
1041 | } | 1042 | } |
1042 | 1043 | ||
1044 | static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2) | ||
1045 | { | ||
1046 | ocfs2_meta_unlock(inode1, 1); | ||
1047 | |||
1048 | if (inode1 != inode2) | ||
1049 | ocfs2_meta_unlock(inode2, 1); | ||
1050 | } | ||
1051 | |||
1043 | #define PARENT_INO(buffer) \ | 1052 | #define PARENT_INO(buffer) \ |
1044 | ((struct ocfs2_dir_entry *) \ | 1053 | ((struct ocfs2_dir_entry *) \ |
1045 | ((char *)buffer + \ | 1054 | ((char *)buffer + \ |
@@ -1050,9 +1059,11 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1050 | struct inode *new_dir, | 1059 | struct inode *new_dir, |
1051 | struct dentry *new_dentry) | 1060 | struct dentry *new_dentry) |
1052 | { | 1061 | { |
1053 | int status = 0, rename_lock = 0; | 1062 | int status = 0, rename_lock = 0, parents_locked = 0; |
1063 | int old_child_locked = 0, new_child_locked = 0; | ||
1054 | struct inode *old_inode = old_dentry->d_inode; | 1064 | struct inode *old_inode = old_dentry->d_inode; |
1055 | struct inode *new_inode = new_dentry->d_inode; | 1065 | struct inode *new_inode = new_dentry->d_inode; |
1066 | struct inode *orphan_dir = NULL; | ||
1056 | struct ocfs2_dinode *newfe = NULL; | 1067 | struct ocfs2_dinode *newfe = NULL; |
1057 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; | 1068 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; |
1058 | struct buffer_head *orphan_entry_bh = NULL; | 1069 | struct buffer_head *orphan_entry_bh = NULL; |
@@ -1060,7 +1071,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1060 | struct buffer_head *insert_entry_bh = NULL; | 1071 | struct buffer_head *insert_entry_bh = NULL; |
1061 | struct ocfs2_super *osb = NULL; | 1072 | struct ocfs2_super *osb = NULL; |
1062 | u64 newfe_blkno; | 1073 | u64 newfe_blkno; |
1063 | struct ocfs2_journal_handle *handle = NULL; | 1074 | handle_t *handle = NULL; |
1064 | struct buffer_head *old_dir_bh = NULL; | 1075 | struct buffer_head *old_dir_bh = NULL; |
1065 | struct buffer_head *new_dir_bh = NULL; | 1076 | struct buffer_head *new_dir_bh = NULL; |
1066 | struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry | 1077 | struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry |
@@ -1105,21 +1116,14 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1105 | rename_lock = 1; | 1116 | rename_lock = 1; |
1106 | } | 1117 | } |
1107 | 1118 | ||
1108 | handle = ocfs2_alloc_handle(osb); | ||
1109 | if (handle == NULL) { | ||
1110 | status = -ENOMEM; | ||
1111 | mlog_errno(status); | ||
1112 | goto bail; | ||
1113 | } | ||
1114 | |||
1115 | /* if old and new are the same, this'll just do one lock. */ | 1119 | /* if old and new are the same, this'll just do one lock. */ |
1116 | status = ocfs2_double_lock(osb, handle, | 1120 | status = ocfs2_double_lock(osb, &old_dir_bh, old_dir, |
1117 | &old_dir_bh, old_dir, | 1121 | &new_dir_bh, new_dir); |
1118 | &new_dir_bh, new_dir); | ||
1119 | if (status < 0) { | 1122 | if (status < 0) { |
1120 | mlog_errno(status); | 1123 | mlog_errno(status); |
1121 | goto bail; | 1124 | goto bail; |
1122 | } | 1125 | } |
1126 | parents_locked = 1; | ||
1123 | 1127 | ||
1124 | /* make sure both dirs have bhs | 1128 | /* make sure both dirs have bhs |
1125 | * get an extra ref on old_dir_bh if old==new */ | 1129 | * get an extra ref on old_dir_bh if old==new */ |
@@ -1140,12 +1144,13 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1140 | * the vote thread on other nodes won't have to concurrently | 1144 | * the vote thread on other nodes won't have to concurrently |
1141 | * downconvert the inode and the dentry locks. | 1145 | * downconvert the inode and the dentry locks. |
1142 | */ | 1146 | */ |
1143 | status = ocfs2_meta_lock(old_inode, handle, NULL, 1); | 1147 | status = ocfs2_meta_lock(old_inode, NULL, 1); |
1144 | if (status < 0) { | 1148 | if (status < 0) { |
1145 | if (status != -ENOENT) | 1149 | if (status != -ENOENT) |
1146 | mlog_errno(status); | 1150 | mlog_errno(status); |
1147 | goto bail; | 1151 | goto bail; |
1148 | } | 1152 | } |
1153 | old_child_locked = 1; | ||
1149 | 1154 | ||
1150 | status = ocfs2_remote_dentry_delete(old_dentry); | 1155 | status = ocfs2_remote_dentry_delete(old_dentry); |
1151 | if (status < 0) { | 1156 | if (status < 0) { |
@@ -1231,12 +1236,13 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1231 | goto bail; | 1236 | goto bail; |
1232 | } | 1237 | } |
1233 | 1238 | ||
1234 | status = ocfs2_meta_lock(new_inode, handle, &newfe_bh, 1); | 1239 | status = ocfs2_meta_lock(new_inode, &newfe_bh, 1); |
1235 | if (status < 0) { | 1240 | if (status < 0) { |
1236 | if (status != -ENOENT) | 1241 | if (status != -ENOENT) |
1237 | mlog_errno(status); | 1242 | mlog_errno(status); |
1238 | goto bail; | 1243 | goto bail; |
1239 | } | 1244 | } |
1245 | new_child_locked = 1; | ||
1240 | 1246 | ||
1241 | status = ocfs2_remote_dentry_delete(new_dentry); | 1247 | status = ocfs2_remote_dentry_delete(new_dentry); |
1242 | if (status < 0) { | 1248 | if (status < 0) { |
@@ -1252,7 +1258,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1252 | (unsigned long long)newfe_bh->b_blocknr : 0ULL); | 1258 | (unsigned long long)newfe_bh->b_blocknr : 0ULL); |
1253 | 1259 | ||
1254 | if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) { | 1260 | if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) { |
1255 | status = ocfs2_prepare_orphan_dir(osb, handle, | 1261 | status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, |
1256 | new_inode, | 1262 | new_inode, |
1257 | orphan_name, | 1263 | orphan_name, |
1258 | &orphan_entry_bh); | 1264 | &orphan_entry_bh); |
@@ -1280,7 +1286,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1280 | } | 1286 | } |
1281 | } | 1287 | } |
1282 | 1288 | ||
1283 | handle = ocfs2_start_trans(osb, handle, OCFS2_RENAME_CREDITS); | 1289 | handle = ocfs2_start_trans(osb, OCFS2_RENAME_CREDITS); |
1284 | if (IS_ERR(handle)) { | 1290 | if (IS_ERR(handle)) { |
1285 | status = PTR_ERR(handle); | 1291 | status = PTR_ERR(handle); |
1286 | handle = NULL; | 1292 | handle = NULL; |
@@ -1307,7 +1313,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1307 | (newfe->i_links_count == cpu_to_le16(1))){ | 1313 | (newfe->i_links_count == cpu_to_le16(1))){ |
1308 | status = ocfs2_orphan_add(osb, handle, new_inode, | 1314 | status = ocfs2_orphan_add(osb, handle, new_inode, |
1309 | newfe, orphan_name, | 1315 | newfe, orphan_name, |
1310 | orphan_entry_bh); | 1316 | orphan_entry_bh, orphan_dir); |
1311 | if (status < 0) { | 1317 | if (status < 0) { |
1312 | mlog_errno(status); | 1318 | mlog_errno(status); |
1313 | goto bail; | 1319 | goto bail; |
@@ -1424,7 +1430,23 @@ bail: | |||
1424 | ocfs2_rename_unlock(osb); | 1430 | ocfs2_rename_unlock(osb); |
1425 | 1431 | ||
1426 | if (handle) | 1432 | if (handle) |
1427 | ocfs2_commit_trans(handle); | 1433 | ocfs2_commit_trans(osb, handle); |
1434 | |||
1435 | if (parents_locked) | ||
1436 | ocfs2_double_unlock(old_dir, new_dir); | ||
1437 | |||
1438 | if (old_child_locked) | ||
1439 | ocfs2_meta_unlock(old_inode, 1); | ||
1440 | |||
1441 | if (new_child_locked) | ||
1442 | ocfs2_meta_unlock(new_inode, 1); | ||
1443 | |||
1444 | if (orphan_dir) { | ||
1445 | /* This was locked for us in ocfs2_prepare_orphan_dir() */ | ||
1446 | ocfs2_meta_unlock(orphan_dir, 1); | ||
1447 | mutex_unlock(&orphan_dir->i_mutex); | ||
1448 | iput(orphan_dir); | ||
1449 | } | ||
1428 | 1450 | ||
1429 | if (new_inode) | 1451 | if (new_inode) |
1430 | sync_mapping_buffers(old_inode->i_mapping); | 1452 | sync_mapping_buffers(old_inode->i_mapping); |
@@ -1458,7 +1480,7 @@ bail: | |||
1458 | * data, including the null terminator. | 1480 | * data, including the null terminator. |
1459 | */ | 1481 | */ |
1460 | static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | 1482 | static int ocfs2_create_symlink_data(struct ocfs2_super *osb, |
1461 | struct ocfs2_journal_handle *handle, | 1483 | handle_t *handle, |
1462 | struct inode *inode, | 1484 | struct inode *inode, |
1463 | const char *symname) | 1485 | const char *symname) |
1464 | { | 1486 | { |
@@ -1573,7 +1595,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1573 | struct buffer_head *parent_fe_bh = NULL; | 1595 | struct buffer_head *parent_fe_bh = NULL; |
1574 | struct ocfs2_dinode *fe = NULL; | 1596 | struct ocfs2_dinode *fe = NULL; |
1575 | struct ocfs2_dinode *dirfe; | 1597 | struct ocfs2_dinode *dirfe; |
1576 | struct ocfs2_journal_handle *handle = NULL; | 1598 | handle_t *handle = NULL; |
1577 | struct ocfs2_alloc_context *inode_ac = NULL; | 1599 | struct ocfs2_alloc_context *inode_ac = NULL; |
1578 | struct ocfs2_alloc_context *data_ac = NULL; | 1600 | struct ocfs2_alloc_context *data_ac = NULL; |
1579 | 1601 | ||
@@ -1587,19 +1609,12 @@ static int ocfs2_symlink(struct inode *dir, | |||
1587 | 1609 | ||
1588 | credits = ocfs2_calc_symlink_credits(sb); | 1610 | credits = ocfs2_calc_symlink_credits(sb); |
1589 | 1611 | ||
1590 | handle = ocfs2_alloc_handle(osb); | ||
1591 | if (handle == NULL) { | ||
1592 | status = -ENOMEM; | ||
1593 | mlog_errno(status); | ||
1594 | goto bail; | ||
1595 | } | ||
1596 | |||
1597 | /* lock the parent directory */ | 1612 | /* lock the parent directory */ |
1598 | status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); | 1613 | status = ocfs2_meta_lock(dir, &parent_fe_bh, 1); |
1599 | if (status < 0) { | 1614 | if (status < 0) { |
1600 | if (status != -ENOENT) | 1615 | if (status != -ENOENT) |
1601 | mlog_errno(status); | 1616 | mlog_errno(status); |
1602 | goto bail; | 1617 | return status; |
1603 | } | 1618 | } |
1604 | 1619 | ||
1605 | dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data; | 1620 | dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data; |
@@ -1622,7 +1637,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1622 | goto bail; | 1637 | goto bail; |
1623 | } | 1638 | } |
1624 | 1639 | ||
1625 | status = ocfs2_reserve_new_inode(osb, handle, &inode_ac); | 1640 | status = ocfs2_reserve_new_inode(osb, &inode_ac); |
1626 | if (status < 0) { | 1641 | if (status < 0) { |
1627 | if (status != -ENOSPC) | 1642 | if (status != -ENOSPC) |
1628 | mlog_errno(status); | 1643 | mlog_errno(status); |
@@ -1631,7 +1646,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1631 | 1646 | ||
1632 | /* don't reserve bitmap space for fast symlinks. */ | 1647 | /* don't reserve bitmap space for fast symlinks. */ |
1633 | if (l > ocfs2_fast_symlink_chars(sb)) { | 1648 | if (l > ocfs2_fast_symlink_chars(sb)) { |
1634 | status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); | 1649 | status = ocfs2_reserve_clusters(osb, 1, &data_ac); |
1635 | if (status < 0) { | 1650 | if (status < 0) { |
1636 | if (status != -ENOSPC) | 1651 | if (status != -ENOSPC) |
1637 | mlog_errno(status); | 1652 | mlog_errno(status); |
@@ -1639,7 +1654,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1639 | } | 1654 | } |
1640 | } | 1655 | } |
1641 | 1656 | ||
1642 | handle = ocfs2_start_trans(osb, handle, credits); | 1657 | handle = ocfs2_start_trans(osb, credits); |
1643 | if (IS_ERR(handle)) { | 1658 | if (IS_ERR(handle)) { |
1644 | status = PTR_ERR(handle); | 1659 | status = PTR_ERR(handle); |
1645 | handle = NULL; | 1660 | handle = NULL; |
@@ -1717,7 +1732,10 @@ static int ocfs2_symlink(struct inode *dir, | |||
1717 | d_instantiate(dentry, inode); | 1732 | d_instantiate(dentry, inode); |
1718 | bail: | 1733 | bail: |
1719 | if (handle) | 1734 | if (handle) |
1720 | ocfs2_commit_trans(handle); | 1735 | ocfs2_commit_trans(osb, handle); |
1736 | |||
1737 | ocfs2_meta_unlock(dir, 1); | ||
1738 | |||
1721 | if (new_fe_bh) | 1739 | if (new_fe_bh) |
1722 | brelse(new_fe_bh); | 1740 | brelse(new_fe_bh); |
1723 | if (parent_fe_bh) | 1741 | if (parent_fe_bh) |
@@ -1768,7 +1786,7 @@ int ocfs2_check_dir_entry(struct inode * dir, | |||
1768 | * If you pass me insert_bh, I'll skip the search of the other dir | 1786 | * If you pass me insert_bh, I'll skip the search of the other dir |
1769 | * blocks and put the record in there. | 1787 | * blocks and put the record in there. |
1770 | */ | 1788 | */ |
1771 | static int __ocfs2_add_entry(struct ocfs2_journal_handle *handle, | 1789 | static int __ocfs2_add_entry(handle_t *handle, |
1772 | struct inode *dir, | 1790 | struct inode *dir, |
1773 | const char *name, int namelen, | 1791 | const char *name, int namelen, |
1774 | struct inode *inode, u64 blkno, | 1792 | struct inode *inode, u64 blkno, |
@@ -1854,7 +1872,7 @@ bail: | |||
1854 | * ocfs2_delete_entry deletes a directory entry by merging it with the | 1872 | * ocfs2_delete_entry deletes a directory entry by merging it with the |
1855 | * previous entry | 1873 | * previous entry |
1856 | */ | 1874 | */ |
1857 | static int ocfs2_delete_entry(struct ocfs2_journal_handle *handle, | 1875 | static int ocfs2_delete_entry(handle_t *handle, |
1858 | struct inode *dir, | 1876 | struct inode *dir, |
1859 | struct ocfs2_dir_entry *de_del, | 1877 | struct ocfs2_dir_entry *de_del, |
1860 | struct buffer_head *bh) | 1878 | struct buffer_head *bh) |
@@ -2085,19 +2103,19 @@ bail: | |||
2085 | } | 2103 | } |
2086 | 2104 | ||
2087 | static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, | 2105 | static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, |
2088 | struct ocfs2_journal_handle *handle, | 2106 | struct inode **ret_orphan_dir, |
2089 | struct inode *inode, | 2107 | struct inode *inode, |
2090 | char *name, | 2108 | char *name, |
2091 | struct buffer_head **de_bh) | 2109 | struct buffer_head **de_bh) |
2092 | { | 2110 | { |
2093 | struct inode *orphan_dir_inode = NULL; | 2111 | struct inode *orphan_dir_inode; |
2094 | struct buffer_head *orphan_dir_bh = NULL; | 2112 | struct buffer_head *orphan_dir_bh = NULL; |
2095 | int status = 0; | 2113 | int status = 0; |
2096 | 2114 | ||
2097 | status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); | 2115 | status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); |
2098 | if (status < 0) { | 2116 | if (status < 0) { |
2099 | mlog_errno(status); | 2117 | mlog_errno(status); |
2100 | goto leave; | 2118 | return status; |
2101 | } | 2119 | } |
2102 | 2120 | ||
2103 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, | 2121 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, |
@@ -2106,11 +2124,12 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, | |||
2106 | if (!orphan_dir_inode) { | 2124 | if (!orphan_dir_inode) { |
2107 | status = -ENOENT; | 2125 | status = -ENOENT; |
2108 | mlog_errno(status); | 2126 | mlog_errno(status); |
2109 | goto leave; | 2127 | return status; |
2110 | } | 2128 | } |
2111 | 2129 | ||
2112 | ocfs2_handle_add_inode(handle, orphan_dir_inode); | 2130 | mutex_lock(&orphan_dir_inode->i_mutex); |
2113 | status = ocfs2_meta_lock(orphan_dir_inode, handle, &orphan_dir_bh, 1); | 2131 | |
2132 | status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1); | ||
2114 | if (status < 0) { | 2133 | if (status < 0) { |
2115 | mlog_errno(status); | 2134 | mlog_errno(status); |
2116 | goto leave; | 2135 | goto leave; |
@@ -2120,13 +2139,19 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, | |||
2120 | orphan_dir_bh, name, | 2139 | orphan_dir_bh, name, |
2121 | OCFS2_ORPHAN_NAMELEN, de_bh); | 2140 | OCFS2_ORPHAN_NAMELEN, de_bh); |
2122 | if (status < 0) { | 2141 | if (status < 0) { |
2142 | ocfs2_meta_unlock(orphan_dir_inode, 1); | ||
2143 | |||
2123 | mlog_errno(status); | 2144 | mlog_errno(status); |
2124 | goto leave; | 2145 | goto leave; |
2125 | } | 2146 | } |
2126 | 2147 | ||
2148 | *ret_orphan_dir = orphan_dir_inode; | ||
2149 | |||
2127 | leave: | 2150 | leave: |
2128 | if (orphan_dir_inode) | 2151 | if (status) { |
2152 | mutex_unlock(&orphan_dir_inode->i_mutex); | ||
2129 | iput(orphan_dir_inode); | 2153 | iput(orphan_dir_inode); |
2154 | } | ||
2130 | 2155 | ||
2131 | if (orphan_dir_bh) | 2156 | if (orphan_dir_bh) |
2132 | brelse(orphan_dir_bh); | 2157 | brelse(orphan_dir_bh); |
@@ -2136,28 +2161,19 @@ leave: | |||
2136 | } | 2161 | } |
2137 | 2162 | ||
2138 | static int ocfs2_orphan_add(struct ocfs2_super *osb, | 2163 | static int ocfs2_orphan_add(struct ocfs2_super *osb, |
2139 | struct ocfs2_journal_handle *handle, | 2164 | handle_t *handle, |
2140 | struct inode *inode, | 2165 | struct inode *inode, |
2141 | struct ocfs2_dinode *fe, | 2166 | struct ocfs2_dinode *fe, |
2142 | char *name, | 2167 | char *name, |
2143 | struct buffer_head *de_bh) | 2168 | struct buffer_head *de_bh, |
2169 | struct inode *orphan_dir_inode) | ||
2144 | { | 2170 | { |
2145 | struct inode *orphan_dir_inode = NULL; | ||
2146 | struct buffer_head *orphan_dir_bh = NULL; | 2171 | struct buffer_head *orphan_dir_bh = NULL; |
2147 | int status = 0; | 2172 | int status = 0; |
2148 | struct ocfs2_dinode *orphan_fe; | 2173 | struct ocfs2_dinode *orphan_fe; |
2149 | 2174 | ||
2150 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); | 2175 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); |
2151 | 2176 | ||
2152 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, | ||
2153 | ORPHAN_DIR_SYSTEM_INODE, | ||
2154 | osb->slot_num); | ||
2155 | if (!orphan_dir_inode) { | ||
2156 | status = -ENOENT; | ||
2157 | mlog_errno(status); | ||
2158 | goto leave; | ||
2159 | } | ||
2160 | |||
2161 | status = ocfs2_read_block(osb, | 2177 | status = ocfs2_read_block(osb, |
2162 | OCFS2_I(orphan_dir_inode)->ip_blkno, | 2178 | OCFS2_I(orphan_dir_inode)->ip_blkno, |
2163 | &orphan_dir_bh, OCFS2_BH_CACHED, | 2179 | &orphan_dir_bh, OCFS2_BH_CACHED, |
@@ -2209,9 +2225,6 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, | |||
2209 | (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); | 2225 | (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); |
2210 | 2226 | ||
2211 | leave: | 2227 | leave: |
2212 | if (orphan_dir_inode) | ||
2213 | iput(orphan_dir_inode); | ||
2214 | |||
2215 | if (orphan_dir_bh) | 2228 | if (orphan_dir_bh) |
2216 | brelse(orphan_dir_bh); | 2229 | brelse(orphan_dir_bh); |
2217 | 2230 | ||
@@ -2221,7 +2234,7 @@ leave: | |||
2221 | 2234 | ||
2222 | /* unlike orphan_add, we expect the orphan dir to already be locked here. */ | 2235 | /* unlike orphan_add, we expect the orphan dir to already be locked here. */ |
2223 | int ocfs2_orphan_del(struct ocfs2_super *osb, | 2236 | int ocfs2_orphan_del(struct ocfs2_super *osb, |
2224 | struct ocfs2_journal_handle *handle, | 2237 | handle_t *handle, |
2225 | struct inode *orphan_dir_inode, | 2238 | struct inode *orphan_dir_inode, |
2226 | struct inode *inode, | 2239 | struct inode *inode, |
2227 | struct buffer_head *orphan_dir_bh) | 2240 | struct buffer_head *orphan_dir_bh) |
@@ -2300,4 +2313,5 @@ struct inode_operations ocfs2_dir_iops = { | |||
2300 | .rename = ocfs2_rename, | 2313 | .rename = ocfs2_rename, |
2301 | .setattr = ocfs2_setattr, | 2314 | .setattr = ocfs2_setattr, |
2302 | .getattr = ocfs2_getattr, | 2315 | .getattr = ocfs2_getattr, |
2316 | .permission = ocfs2_permission, | ||
2303 | }; | 2317 | }; |
diff --git a/fs/ocfs2/namei.h b/fs/ocfs2/namei.h index deaaa97dbf0b..8425944fcccd 100644 --- a/fs/ocfs2/namei.h +++ b/fs/ocfs2/namei.h | |||
@@ -39,7 +39,7 @@ struct buffer_head *ocfs2_find_entry(const char *name, | |||
39 | struct inode *dir, | 39 | struct inode *dir, |
40 | struct ocfs2_dir_entry **res_dir); | 40 | struct ocfs2_dir_entry **res_dir); |
41 | int ocfs2_orphan_del(struct ocfs2_super *osb, | 41 | int ocfs2_orphan_del(struct ocfs2_super *osb, |
42 | struct ocfs2_journal_handle *handle, | 42 | handle_t *handle, |
43 | struct inode *orphan_dir_inode, | 43 | struct inode *orphan_dir_inode, |
44 | struct inode *inode, | 44 | struct inode *inode, |
45 | struct buffer_head *orphan_dir_bh); | 45 | struct buffer_head *orphan_dir_bh); |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 0462a7f4e21b..db8e77cd35d3 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/workqueue.h> | 34 | #include <linux/workqueue.h> |
35 | #include <linux/kref.h> | 35 | #include <linux/kref.h> |
36 | #include <linux/mutex.h> | 36 | #include <linux/mutex.h> |
37 | #include <linux/jbd.h> | ||
37 | 38 | ||
38 | #include "cluster/nodemanager.h" | 39 | #include "cluster/nodemanager.h" |
39 | #include "cluster/heartbeat.h" | 40 | #include "cluster/heartbeat.h" |
@@ -179,9 +180,9 @@ enum ocfs2_mount_options | |||
179 | #define OCFS2_OSB_SOFT_RO 0x0001 | 180 | #define OCFS2_OSB_SOFT_RO 0x0001 |
180 | #define OCFS2_OSB_HARD_RO 0x0002 | 181 | #define OCFS2_OSB_HARD_RO 0x0002 |
181 | #define OCFS2_OSB_ERROR_FS 0x0004 | 182 | #define OCFS2_OSB_ERROR_FS 0x0004 |
183 | #define OCFS2_DEFAULT_ATIME_QUANTUM 60 | ||
182 | 184 | ||
183 | struct ocfs2_journal; | 185 | struct ocfs2_journal; |
184 | struct ocfs2_journal_handle; | ||
185 | struct ocfs2_super | 186 | struct ocfs2_super |
186 | { | 187 | { |
187 | struct task_struct *commit_task; | 188 | struct task_struct *commit_task; |
@@ -218,6 +219,7 @@ struct ocfs2_super | |||
218 | unsigned long osb_flags; | 219 | unsigned long osb_flags; |
219 | 220 | ||
220 | unsigned long s_mount_opt; | 221 | unsigned long s_mount_opt; |
222 | unsigned int s_atime_quantum; | ||
221 | 223 | ||
222 | u16 max_slots; | 224 | u16 max_slots; |
223 | s16 node_num; | 225 | s16 node_num; |
@@ -283,7 +285,7 @@ struct ocfs2_super | |||
283 | /* Truncate log info */ | 285 | /* Truncate log info */ |
284 | struct inode *osb_tl_inode; | 286 | struct inode *osb_tl_inode; |
285 | struct buffer_head *osb_tl_bh; | 287 | struct buffer_head *osb_tl_bh; |
286 | struct work_struct osb_truncate_log_wq; | 288 | struct delayed_work osb_truncate_log_wq; |
287 | 289 | ||
288 | struct ocfs2_node_map osb_recovering_orphan_dirs; | 290 | struct ocfs2_node_map osb_recovering_orphan_dirs; |
289 | unsigned int *osb_orphan_wipes; | 291 | unsigned int *osb_orphan_wipes; |
@@ -347,6 +349,11 @@ static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb) | |||
347 | return ret; | 349 | return ret; |
348 | } | 350 | } |
349 | 351 | ||
352 | static inline int ocfs2_mount_local(struct ocfs2_super *osb) | ||
353 | { | ||
354 | return (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT); | ||
355 | } | ||
356 | |||
350 | #define OCFS2_IS_VALID_DINODE(ptr) \ | 357 | #define OCFS2_IS_VALID_DINODE(ptr) \ |
351 | (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE)) | 358 | (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE)) |
352 | 359 | ||
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index 3330a5dc6be2..b5c68567077e 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -86,7 +86,7 @@ | |||
86 | OCFS2_SB(sb)->s_feature_incompat &= ~(mask) | 86 | OCFS2_SB(sb)->s_feature_incompat &= ~(mask) |
87 | 87 | ||
88 | #define OCFS2_FEATURE_COMPAT_SUPP 0 | 88 | #define OCFS2_FEATURE_COMPAT_SUPP 0 |
89 | #define OCFS2_FEATURE_INCOMPAT_SUPP 0 | 89 | #define OCFS2_FEATURE_INCOMPAT_SUPP OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT |
90 | #define OCFS2_FEATURE_RO_COMPAT_SUPP 0 | 90 | #define OCFS2_FEATURE_RO_COMPAT_SUPP 0 |
91 | 91 | ||
92 | /* | 92 | /* |
@@ -96,6 +96,18 @@ | |||
96 | */ | 96 | */ |
97 | #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 | 97 | #define OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV 0x0002 |
98 | 98 | ||
99 | /* | ||
100 | * tunefs sets this incompat flag before starting the resize and clears it | ||
101 | * at the end. This flag protects users from inadvertently mounting the fs | ||
102 | * after an aborted run without fsck-ing. | ||
103 | */ | ||
104 | #define OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG 0x0004 | ||
105 | |||
106 | /* Used to denote a non-clustered volume */ | ||
107 | #define OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT 0x0008 | ||
108 | |||
109 | /* Support for sparse allocation in b-trees */ | ||
110 | #define OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC 0x0010 | ||
99 | 111 | ||
100 | /* | 112 | /* |
101 | * Flags on ocfs2_dinode.i_flags | 113 | * Flags on ocfs2_dinode.i_flags |
diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c index aa6f5aadedc4..2d3ac32cb74e 100644 --- a/fs/ocfs2/slot_map.c +++ b/fs/ocfs2/slot_map.c | |||
@@ -175,7 +175,7 @@ int ocfs2_init_slot_info(struct ocfs2_super *osb) | |||
175 | struct buffer_head *bh = NULL; | 175 | struct buffer_head *bh = NULL; |
176 | struct ocfs2_slot_info *si; | 176 | struct ocfs2_slot_info *si; |
177 | 177 | ||
178 | si = kcalloc(1, sizeof(struct ocfs2_slot_info), GFP_KERNEL); | 178 | si = kzalloc(sizeof(struct ocfs2_slot_info), GFP_KERNEL); |
179 | if (!si) { | 179 | if (!si) { |
180 | status = -ENOMEM; | 180 | status = -ENOMEM; |
181 | mlog_errno(status); | 181 | mlog_errno(status); |
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 9d91e66f51a9..6dbb11762759 100644 --- a/fs/ocfs2/suballoc.c +++ b/fs/ocfs2/suballoc.c | |||
@@ -49,7 +49,7 @@ | |||
49 | static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); | 49 | static inline void ocfs2_debug_bg(struct ocfs2_group_desc *bg); |
50 | static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); | 50 | static inline void ocfs2_debug_suballoc_inode(struct ocfs2_dinode *fe); |
51 | static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); | 51 | static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl); |
52 | static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, | 52 | static int ocfs2_block_group_fill(handle_t *handle, |
53 | struct inode *alloc_inode, | 53 | struct inode *alloc_inode, |
54 | struct buffer_head *bg_bh, | 54 | struct buffer_head *bg_bh, |
55 | u64 group_blkno, | 55 | u64 group_blkno, |
@@ -59,9 +59,6 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
59 | struct inode *alloc_inode, | 59 | struct inode *alloc_inode, |
60 | struct buffer_head *bh); | 60 | struct buffer_head *bh); |
61 | 61 | ||
62 | static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | ||
63 | struct ocfs2_alloc_context *ac); | ||
64 | |||
65 | static int ocfs2_cluster_group_search(struct inode *inode, | 62 | static int ocfs2_cluster_group_search(struct inode *inode, |
66 | struct buffer_head *group_bh, | 63 | struct buffer_head *group_bh, |
67 | u32 bits_wanted, u32 min_bits, | 64 | u32 bits_wanted, u32 min_bits, |
@@ -72,6 +69,7 @@ static int ocfs2_block_group_search(struct inode *inode, | |||
72 | u16 *bit_off, u16 *bits_found); | 69 | u16 *bit_off, u16 *bits_found); |
73 | static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, | 70 | static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, |
74 | struct ocfs2_alloc_context *ac, | 71 | struct ocfs2_alloc_context *ac, |
72 | handle_t *handle, | ||
75 | u32 bits_wanted, | 73 | u32 bits_wanted, |
76 | u32 min_bits, | 74 | u32 min_bits, |
77 | u16 *bit_off, | 75 | u16 *bit_off, |
@@ -79,20 +77,20 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, | |||
79 | u64 *bg_blkno); | 77 | u64 *bg_blkno); |
80 | static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, | 78 | static int ocfs2_test_bg_bit_allocatable(struct buffer_head *bg_bh, |
81 | int nr); | 79 | int nr); |
82 | static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, | 80 | static inline int ocfs2_block_group_set_bits(handle_t *handle, |
83 | struct inode *alloc_inode, | 81 | struct inode *alloc_inode, |
84 | struct ocfs2_group_desc *bg, | 82 | struct ocfs2_group_desc *bg, |
85 | struct buffer_head *group_bh, | 83 | struct buffer_head *group_bh, |
86 | unsigned int bit_off, | 84 | unsigned int bit_off, |
87 | unsigned int num_bits); | 85 | unsigned int num_bits); |
88 | static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, | 86 | static inline int ocfs2_block_group_clear_bits(handle_t *handle, |
89 | struct inode *alloc_inode, | 87 | struct inode *alloc_inode, |
90 | struct ocfs2_group_desc *bg, | 88 | struct ocfs2_group_desc *bg, |
91 | struct buffer_head *group_bh, | 89 | struct buffer_head *group_bh, |
92 | unsigned int bit_off, | 90 | unsigned int bit_off, |
93 | unsigned int num_bits); | 91 | unsigned int num_bits); |
94 | 92 | ||
95 | static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, | 93 | static int ocfs2_relink_block_group(handle_t *handle, |
96 | struct inode *alloc_inode, | 94 | struct inode *alloc_inode, |
97 | struct buffer_head *fe_bh, | 95 | struct buffer_head *fe_bh, |
98 | struct buffer_head *bg_bh, | 96 | struct buffer_head *bg_bh, |
@@ -100,7 +98,7 @@ static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, | |||
100 | u16 chain); | 98 | u16 chain); |
101 | static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg, | 99 | static inline int ocfs2_block_group_reasonably_empty(struct ocfs2_group_desc *bg, |
102 | u32 wanted); | 100 | u32 wanted); |
103 | static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, | 101 | static int ocfs2_free_suballoc_bits(handle_t *handle, |
104 | struct inode *alloc_inode, | 102 | struct inode *alloc_inode, |
105 | struct buffer_head *alloc_bh, | 103 | struct buffer_head *alloc_bh, |
106 | unsigned int start_bit, | 104 | unsigned int start_bit, |
@@ -120,8 +118,16 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode, | |||
120 | 118 | ||
121 | void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) | 119 | void ocfs2_free_alloc_context(struct ocfs2_alloc_context *ac) |
122 | { | 120 | { |
123 | if (ac->ac_inode) | 121 | struct inode *inode = ac->ac_inode; |
124 | iput(ac->ac_inode); | 122 | |
123 | if (inode) { | ||
124 | if (ac->ac_which != OCFS2_AC_USE_LOCAL) | ||
125 | ocfs2_meta_unlock(inode, 1); | ||
126 | |||
127 | mutex_unlock(&inode->i_mutex); | ||
128 | |||
129 | iput(inode); | ||
130 | } | ||
125 | if (ac->ac_bh) | 131 | if (ac->ac_bh) |
126 | brelse(ac->ac_bh); | 132 | brelse(ac->ac_bh); |
127 | kfree(ac); | 133 | kfree(ac); |
@@ -190,7 +196,7 @@ static int ocfs2_check_group_descriptor(struct super_block *sb, | |||
190 | return 0; | 196 | return 0; |
191 | } | 197 | } |
192 | 198 | ||
193 | static int ocfs2_block_group_fill(struct ocfs2_journal_handle *handle, | 199 | static int ocfs2_block_group_fill(handle_t *handle, |
194 | struct inode *alloc_inode, | 200 | struct inode *alloc_inode, |
195 | struct buffer_head *bg_bh, | 201 | struct buffer_head *bg_bh, |
196 | u64 group_blkno, | 202 | u64 group_blkno, |
@@ -273,7 +279,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
273 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; | 279 | struct ocfs2_dinode *fe = (struct ocfs2_dinode *) bh->b_data; |
274 | struct ocfs2_chain_list *cl; | 280 | struct ocfs2_chain_list *cl; |
275 | struct ocfs2_alloc_context *ac = NULL; | 281 | struct ocfs2_alloc_context *ac = NULL; |
276 | struct ocfs2_journal_handle *handle = NULL; | 282 | handle_t *handle = NULL; |
277 | u32 bit_off, num_bits; | 283 | u32 bit_off, num_bits; |
278 | u16 alloc_rec; | 284 | u16 alloc_rec; |
279 | u64 bg_blkno; | 285 | u64 bg_blkno; |
@@ -284,16 +290,8 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
284 | 290 | ||
285 | mlog_entry_void(); | 291 | mlog_entry_void(); |
286 | 292 | ||
287 | handle = ocfs2_alloc_handle(osb); | ||
288 | if (!handle) { | ||
289 | status = -ENOMEM; | ||
290 | mlog_errno(status); | ||
291 | goto bail; | ||
292 | } | ||
293 | |||
294 | cl = &fe->id2.i_chain; | 293 | cl = &fe->id2.i_chain; |
295 | status = ocfs2_reserve_clusters(osb, | 294 | status = ocfs2_reserve_clusters(osb, |
296 | handle, | ||
297 | le16_to_cpu(cl->cl_cpg), | 295 | le16_to_cpu(cl->cl_cpg), |
298 | &ac); | 296 | &ac); |
299 | if (status < 0) { | 297 | if (status < 0) { |
@@ -304,7 +302,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
304 | 302 | ||
305 | credits = ocfs2_calc_group_alloc_credits(osb->sb, | 303 | credits = ocfs2_calc_group_alloc_credits(osb->sb, |
306 | le16_to_cpu(cl->cl_cpg)); | 304 | le16_to_cpu(cl->cl_cpg)); |
307 | handle = ocfs2_start_trans(osb, handle, credits); | 305 | handle = ocfs2_start_trans(osb, credits); |
308 | if (IS_ERR(handle)) { | 306 | if (IS_ERR(handle)) { |
309 | status = PTR_ERR(handle); | 307 | status = PTR_ERR(handle); |
310 | handle = NULL; | 308 | handle = NULL; |
@@ -389,7 +387,7 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb, | |||
389 | status = 0; | 387 | status = 0; |
390 | bail: | 388 | bail: |
391 | if (handle) | 389 | if (handle) |
392 | ocfs2_commit_trans(handle); | 390 | ocfs2_commit_trans(osb, handle); |
393 | 391 | ||
394 | if (ac) | 392 | if (ac) |
395 | ocfs2_free_alloc_context(ac); | 393 | ocfs2_free_alloc_context(ac); |
@@ -402,27 +400,38 @@ bail: | |||
402 | } | 400 | } |
403 | 401 | ||
404 | static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, | 402 | static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb, |
405 | struct ocfs2_alloc_context *ac) | 403 | struct ocfs2_alloc_context *ac, |
404 | int type, | ||
405 | u32 slot) | ||
406 | { | 406 | { |
407 | int status; | 407 | int status; |
408 | u32 bits_wanted = ac->ac_bits_wanted; | 408 | u32 bits_wanted = ac->ac_bits_wanted; |
409 | struct inode *alloc_inode = ac->ac_inode; | 409 | struct inode *alloc_inode; |
410 | struct buffer_head *bh = NULL; | 410 | struct buffer_head *bh = NULL; |
411 | struct ocfs2_journal_handle *handle = ac->ac_handle; | ||
412 | struct ocfs2_dinode *fe; | 411 | struct ocfs2_dinode *fe; |
413 | u32 free_bits; | 412 | u32 free_bits; |
414 | 413 | ||
415 | mlog_entry_void(); | 414 | mlog_entry_void(); |
416 | 415 | ||
417 | BUG_ON(handle->flags & OCFS2_HANDLE_STARTED); | 416 | alloc_inode = ocfs2_get_system_file_inode(osb, type, slot); |
417 | if (!alloc_inode) { | ||
418 | mlog_errno(-EINVAL); | ||
419 | return -EINVAL; | ||
420 | } | ||
418 | 421 | ||
419 | ocfs2_handle_add_inode(handle, alloc_inode); | 422 | mutex_lock(&alloc_inode->i_mutex); |
420 | status = ocfs2_meta_lock(alloc_inode, handle, &bh, 1); | 423 | |
424 | status = ocfs2_meta_lock(alloc_inode, &bh, 1); | ||
421 | if (status < 0) { | 425 | if (status < 0) { |
426 | mutex_unlock(&alloc_inode->i_mutex); | ||
427 | iput(alloc_inode); | ||
428 | |||
422 | mlog_errno(status); | 429 | mlog_errno(status); |
423 | goto bail; | 430 | return status; |
424 | } | 431 | } |
425 | 432 | ||
433 | ac->ac_inode = alloc_inode; | ||
434 | |||
426 | fe = (struct ocfs2_dinode *) bh->b_data; | 435 | fe = (struct ocfs2_dinode *) bh->b_data; |
427 | if (!OCFS2_IS_VALID_DINODE(fe)) { | 436 | if (!OCFS2_IS_VALID_DINODE(fe)) { |
428 | OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); | 437 | OCFS2_RO_ON_INVALID_DINODE(alloc_inode->i_sb, fe); |
@@ -473,14 +482,13 @@ bail: | |||
473 | } | 482 | } |
474 | 483 | ||
475 | int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, | 484 | int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, |
476 | struct ocfs2_journal_handle *handle, | ||
477 | struct ocfs2_dinode *fe, | 485 | struct ocfs2_dinode *fe, |
478 | struct ocfs2_alloc_context **ac) | 486 | struct ocfs2_alloc_context **ac) |
479 | { | 487 | { |
480 | int status; | 488 | int status; |
481 | struct inode *alloc_inode = NULL; | 489 | u32 slot; |
482 | 490 | ||
483 | *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); | 491 | *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
484 | if (!(*ac)) { | 492 | if (!(*ac)) { |
485 | status = -ENOMEM; | 493 | status = -ENOMEM; |
486 | mlog_errno(status); | 494 | mlog_errno(status); |
@@ -488,28 +496,18 @@ int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, | |||
488 | } | 496 | } |
489 | 497 | ||
490 | (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe); | 498 | (*ac)->ac_bits_wanted = ocfs2_extend_meta_needed(fe); |
491 | (*ac)->ac_handle = handle; | ||
492 | (*ac)->ac_which = OCFS2_AC_USE_META; | 499 | (*ac)->ac_which = OCFS2_AC_USE_META; |
493 | 500 | ||
494 | #ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS | 501 | #ifndef OCFS2_USE_ALL_METADATA_SUBALLOCATORS |
495 | alloc_inode = ocfs2_get_system_file_inode(osb, | 502 | slot = 0; |
496 | EXTENT_ALLOC_SYSTEM_INODE, | ||
497 | 0); | ||
498 | #else | 503 | #else |
499 | alloc_inode = ocfs2_get_system_file_inode(osb, | 504 | slot = osb->slot_num; |
500 | EXTENT_ALLOC_SYSTEM_INODE, | ||
501 | osb->slot_num); | ||
502 | #endif | 505 | #endif |
503 | if (!alloc_inode) { | ||
504 | status = -ENOMEM; | ||
505 | mlog_errno(status); | ||
506 | goto bail; | ||
507 | } | ||
508 | 506 | ||
509 | (*ac)->ac_inode = igrab(alloc_inode); | ||
510 | (*ac)->ac_group_search = ocfs2_block_group_search; | 507 | (*ac)->ac_group_search = ocfs2_block_group_search; |
511 | 508 | ||
512 | status = ocfs2_reserve_suballoc_bits(osb, (*ac)); | 509 | status = ocfs2_reserve_suballoc_bits(osb, (*ac), |
510 | EXTENT_ALLOC_SYSTEM_INODE, slot); | ||
513 | if (status < 0) { | 511 | if (status < 0) { |
514 | if (status != -ENOSPC) | 512 | if (status != -ENOSPC) |
515 | mlog_errno(status); | 513 | mlog_errno(status); |
@@ -523,21 +521,16 @@ bail: | |||
523 | *ac = NULL; | 521 | *ac = NULL; |
524 | } | 522 | } |
525 | 523 | ||
526 | if (alloc_inode) | ||
527 | iput(alloc_inode); | ||
528 | |||
529 | mlog_exit(status); | 524 | mlog_exit(status); |
530 | return status; | 525 | return status; |
531 | } | 526 | } |
532 | 527 | ||
533 | int ocfs2_reserve_new_inode(struct ocfs2_super *osb, | 528 | int ocfs2_reserve_new_inode(struct ocfs2_super *osb, |
534 | struct ocfs2_journal_handle *handle, | ||
535 | struct ocfs2_alloc_context **ac) | 529 | struct ocfs2_alloc_context **ac) |
536 | { | 530 | { |
537 | int status; | 531 | int status; |
538 | struct inode *alloc_inode = NULL; | ||
539 | 532 | ||
540 | *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); | 533 | *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
541 | if (!(*ac)) { | 534 | if (!(*ac)) { |
542 | status = -ENOMEM; | 535 | status = -ENOMEM; |
543 | mlog_errno(status); | 536 | mlog_errno(status); |
@@ -545,22 +538,13 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb, | |||
545 | } | 538 | } |
546 | 539 | ||
547 | (*ac)->ac_bits_wanted = 1; | 540 | (*ac)->ac_bits_wanted = 1; |
548 | (*ac)->ac_handle = handle; | ||
549 | (*ac)->ac_which = OCFS2_AC_USE_INODE; | 541 | (*ac)->ac_which = OCFS2_AC_USE_INODE; |
550 | 542 | ||
551 | alloc_inode = ocfs2_get_system_file_inode(osb, | ||
552 | INODE_ALLOC_SYSTEM_INODE, | ||
553 | osb->slot_num); | ||
554 | if (!alloc_inode) { | ||
555 | status = -ENOMEM; | ||
556 | mlog_errno(status); | ||
557 | goto bail; | ||
558 | } | ||
559 | |||
560 | (*ac)->ac_inode = igrab(alloc_inode); | ||
561 | (*ac)->ac_group_search = ocfs2_block_group_search; | 543 | (*ac)->ac_group_search = ocfs2_block_group_search; |
562 | 544 | ||
563 | status = ocfs2_reserve_suballoc_bits(osb, *ac); | 545 | status = ocfs2_reserve_suballoc_bits(osb, *ac, |
546 | INODE_ALLOC_SYSTEM_INODE, | ||
547 | osb->slot_num); | ||
564 | if (status < 0) { | 548 | if (status < 0) { |
565 | if (status != -ENOSPC) | 549 | if (status != -ENOSPC) |
566 | mlog_errno(status); | 550 | mlog_errno(status); |
@@ -574,9 +558,6 @@ bail: | |||
574 | *ac = NULL; | 558 | *ac = NULL; |
575 | } | 559 | } |
576 | 560 | ||
577 | if (alloc_inode) | ||
578 | iput(alloc_inode); | ||
579 | |||
580 | mlog_exit(status); | 561 | mlog_exit(status); |
581 | return status; | 562 | return status; |
582 | } | 563 | } |
@@ -588,20 +569,17 @@ int ocfs2_reserve_cluster_bitmap_bits(struct ocfs2_super *osb, | |||
588 | { | 569 | { |
589 | int status; | 570 | int status; |
590 | 571 | ||
591 | ac->ac_inode = ocfs2_get_system_file_inode(osb, | ||
592 | GLOBAL_BITMAP_SYSTEM_INODE, | ||
593 | OCFS2_INVALID_SLOT); | ||
594 | if (!ac->ac_inode) { | ||
595 | status = -EINVAL; | ||
596 | mlog(ML_ERROR, "Could not get bitmap inode!\n"); | ||
597 | goto bail; | ||
598 | } | ||
599 | ac->ac_which = OCFS2_AC_USE_MAIN; | 572 | ac->ac_which = OCFS2_AC_USE_MAIN; |
600 | ac->ac_group_search = ocfs2_cluster_group_search; | 573 | ac->ac_group_search = ocfs2_cluster_group_search; |
601 | 574 | ||
602 | status = ocfs2_reserve_suballoc_bits(osb, ac); | 575 | status = ocfs2_reserve_suballoc_bits(osb, ac, |
603 | if (status < 0 && status != -ENOSPC) | 576 | GLOBAL_BITMAP_SYSTEM_INODE, |
577 | OCFS2_INVALID_SLOT); | ||
578 | if (status < 0 && status != -ENOSPC) { | ||
604 | mlog_errno(status); | 579 | mlog_errno(status); |
580 | goto bail; | ||
581 | } | ||
582 | |||
605 | bail: | 583 | bail: |
606 | return status; | 584 | return status; |
607 | } | 585 | } |
@@ -610,7 +588,6 @@ bail: | |||
610 | * use so we figure it out for them, but unfortunately this clutters | 588 | * use so we figure it out for them, but unfortunately this clutters |
611 | * things a bit. */ | 589 | * things a bit. */ |
612 | int ocfs2_reserve_clusters(struct ocfs2_super *osb, | 590 | int ocfs2_reserve_clusters(struct ocfs2_super *osb, |
613 | struct ocfs2_journal_handle *handle, | ||
614 | u32 bits_wanted, | 591 | u32 bits_wanted, |
615 | struct ocfs2_alloc_context **ac) | 592 | struct ocfs2_alloc_context **ac) |
616 | { | 593 | { |
@@ -618,9 +595,7 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb, | |||
618 | 595 | ||
619 | mlog_entry_void(); | 596 | mlog_entry_void(); |
620 | 597 | ||
621 | BUG_ON(!handle); | 598 | *ac = kzalloc(sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
622 | |||
623 | *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); | ||
624 | if (!(*ac)) { | 599 | if (!(*ac)) { |
625 | status = -ENOMEM; | 600 | status = -ENOMEM; |
626 | mlog_errno(status); | 601 | mlog_errno(status); |
@@ -628,12 +603,10 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb, | |||
628 | } | 603 | } |
629 | 604 | ||
630 | (*ac)->ac_bits_wanted = bits_wanted; | 605 | (*ac)->ac_bits_wanted = bits_wanted; |
631 | (*ac)->ac_handle = handle; | ||
632 | 606 | ||
633 | status = -ENOSPC; | 607 | status = -ENOSPC; |
634 | if (ocfs2_alloc_should_use_local(osb, bits_wanted)) { | 608 | if (ocfs2_alloc_should_use_local(osb, bits_wanted)) { |
635 | status = ocfs2_reserve_local_alloc_bits(osb, | 609 | status = ocfs2_reserve_local_alloc_bits(osb, |
636 | handle, | ||
637 | bits_wanted, | 610 | bits_wanted, |
638 | *ac); | 611 | *ac); |
639 | if ((status < 0) && (status != -ENOSPC)) { | 612 | if ((status < 0) && (status != -ENOSPC)) { |
@@ -774,7 +747,7 @@ static int ocfs2_block_group_find_clear_bits(struct ocfs2_super *osb, | |||
774 | return status; | 747 | return status; |
775 | } | 748 | } |
776 | 749 | ||
777 | static inline int ocfs2_block_group_set_bits(struct ocfs2_journal_handle *handle, | 750 | static inline int ocfs2_block_group_set_bits(handle_t *handle, |
778 | struct inode *alloc_inode, | 751 | struct inode *alloc_inode, |
779 | struct ocfs2_group_desc *bg, | 752 | struct ocfs2_group_desc *bg, |
780 | struct buffer_head *group_bh, | 753 | struct buffer_head *group_bh, |
@@ -845,7 +818,7 @@ static inline u16 ocfs2_find_victim_chain(struct ocfs2_chain_list *cl) | |||
845 | return best; | 818 | return best; |
846 | } | 819 | } |
847 | 820 | ||
848 | static int ocfs2_relink_block_group(struct ocfs2_journal_handle *handle, | 821 | static int ocfs2_relink_block_group(handle_t *handle, |
849 | struct inode *alloc_inode, | 822 | struct inode *alloc_inode, |
850 | struct buffer_head *fe_bh, | 823 | struct buffer_head *fe_bh, |
851 | struct buffer_head *bg_bh, | 824 | struct buffer_head *bg_bh, |
@@ -1025,7 +998,7 @@ static int ocfs2_block_group_search(struct inode *inode, | |||
1025 | } | 998 | } |
1026 | 999 | ||
1027 | static int ocfs2_alloc_dinode_update_counts(struct inode *inode, | 1000 | static int ocfs2_alloc_dinode_update_counts(struct inode *inode, |
1028 | struct ocfs2_journal_handle *handle, | 1001 | handle_t *handle, |
1029 | struct buffer_head *di_bh, | 1002 | struct buffer_head *di_bh, |
1030 | u32 num_bits, | 1003 | u32 num_bits, |
1031 | u16 chain) | 1004 | u16 chain) |
@@ -1055,6 +1028,7 @@ out: | |||
1055 | } | 1028 | } |
1056 | 1029 | ||
1057 | static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, | 1030 | static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, |
1031 | handle_t *handle, | ||
1058 | u32 bits_wanted, | 1032 | u32 bits_wanted, |
1059 | u32 min_bits, | 1033 | u32 min_bits, |
1060 | u16 *bit_off, | 1034 | u16 *bit_off, |
@@ -1067,7 +1041,6 @@ static int ocfs2_search_one_group(struct ocfs2_alloc_context *ac, | |||
1067 | struct buffer_head *group_bh = NULL; | 1041 | struct buffer_head *group_bh = NULL; |
1068 | struct ocfs2_group_desc *gd; | 1042 | struct ocfs2_group_desc *gd; |
1069 | struct inode *alloc_inode = ac->ac_inode; | 1043 | struct inode *alloc_inode = ac->ac_inode; |
1070 | struct ocfs2_journal_handle *handle = ac->ac_handle; | ||
1071 | 1044 | ||
1072 | ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno, | 1045 | ret = ocfs2_read_block(OCFS2_SB(alloc_inode->i_sb), gd_blkno, |
1073 | &group_bh, OCFS2_BH_CACHED, alloc_inode); | 1046 | &group_bh, OCFS2_BH_CACHED, alloc_inode); |
@@ -1115,6 +1088,7 @@ out: | |||
1115 | } | 1088 | } |
1116 | 1089 | ||
1117 | static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | 1090 | static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, |
1091 | handle_t *handle, | ||
1118 | u32 bits_wanted, | 1092 | u32 bits_wanted, |
1119 | u32 min_bits, | 1093 | u32 min_bits, |
1120 | u16 *bit_off, | 1094 | u16 *bit_off, |
@@ -1126,7 +1100,6 @@ static int ocfs2_search_chain(struct ocfs2_alloc_context *ac, | |||
1126 | u16 chain, tmp_bits; | 1100 | u16 chain, tmp_bits; |
1127 | u32 tmp_used; | 1101 | u32 tmp_used; |
1128 | u64 next_group; | 1102 | u64 next_group; |
1129 | struct ocfs2_journal_handle *handle = ac->ac_handle; | ||
1130 | struct inode *alloc_inode = ac->ac_inode; | 1103 | struct inode *alloc_inode = ac->ac_inode; |
1131 | struct buffer_head *group_bh = NULL; | 1104 | struct buffer_head *group_bh = NULL; |
1132 | struct buffer_head *prev_group_bh = NULL; | 1105 | struct buffer_head *prev_group_bh = NULL; |
@@ -1272,6 +1245,7 @@ bail: | |||
1272 | /* will give out up to bits_wanted contiguous bits. */ | 1245 | /* will give out up to bits_wanted contiguous bits. */ |
1273 | static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, | 1246 | static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, |
1274 | struct ocfs2_alloc_context *ac, | 1247 | struct ocfs2_alloc_context *ac, |
1248 | handle_t *handle, | ||
1275 | u32 bits_wanted, | 1249 | u32 bits_wanted, |
1276 | u32 min_bits, | 1250 | u32 min_bits, |
1277 | u16 *bit_off, | 1251 | u16 *bit_off, |
@@ -1313,8 +1287,8 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, | |||
1313 | * by jumping straight to the most recently used | 1287 | * by jumping straight to the most recently used |
1314 | * allocation group. This helps us mantain some | 1288 | * allocation group. This helps us mantain some |
1315 | * contiguousness across allocations. */ | 1289 | * contiguousness across allocations. */ |
1316 | status = ocfs2_search_one_group(ac, bits_wanted, min_bits, | 1290 | status = ocfs2_search_one_group(ac, handle, bits_wanted, |
1317 | bit_off, num_bits, | 1291 | min_bits, bit_off, num_bits, |
1318 | hint_blkno, &bits_left); | 1292 | hint_blkno, &bits_left); |
1319 | if (!status) { | 1293 | if (!status) { |
1320 | /* Be careful to update *bg_blkno here as the | 1294 | /* Be careful to update *bg_blkno here as the |
@@ -1336,7 +1310,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, | |||
1336 | ac->ac_chain = victim; | 1310 | ac->ac_chain = victim; |
1337 | ac->ac_allow_chain_relink = 1; | 1311 | ac->ac_allow_chain_relink = 1; |
1338 | 1312 | ||
1339 | status = ocfs2_search_chain(ac, bits_wanted, min_bits, bit_off, | 1313 | status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, bit_off, |
1340 | num_bits, bg_blkno, &bits_left); | 1314 | num_bits, bg_blkno, &bits_left); |
1341 | if (!status) | 1315 | if (!status) |
1342 | goto set_hint; | 1316 | goto set_hint; |
@@ -1360,7 +1334,7 @@ static int ocfs2_claim_suballoc_bits(struct ocfs2_super *osb, | |||
1360 | continue; | 1334 | continue; |
1361 | 1335 | ||
1362 | ac->ac_chain = i; | 1336 | ac->ac_chain = i; |
1363 | status = ocfs2_search_chain(ac, bits_wanted, min_bits, | 1337 | status = ocfs2_search_chain(ac, handle, bits_wanted, min_bits, |
1364 | bit_off, num_bits, bg_blkno, | 1338 | bit_off, num_bits, bg_blkno, |
1365 | &bits_left); | 1339 | &bits_left); |
1366 | if (!status) | 1340 | if (!status) |
@@ -1388,7 +1362,7 @@ bail: | |||
1388 | } | 1362 | } |
1389 | 1363 | ||
1390 | int ocfs2_claim_metadata(struct ocfs2_super *osb, | 1364 | int ocfs2_claim_metadata(struct ocfs2_super *osb, |
1391 | struct ocfs2_journal_handle *handle, | 1365 | handle_t *handle, |
1392 | struct ocfs2_alloc_context *ac, | 1366 | struct ocfs2_alloc_context *ac, |
1393 | u32 bits_wanted, | 1367 | u32 bits_wanted, |
1394 | u16 *suballoc_bit_start, | 1368 | u16 *suballoc_bit_start, |
@@ -1401,10 +1375,10 @@ int ocfs2_claim_metadata(struct ocfs2_super *osb, | |||
1401 | BUG_ON(!ac); | 1375 | BUG_ON(!ac); |
1402 | BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); | 1376 | BUG_ON(ac->ac_bits_wanted < (ac->ac_bits_given + bits_wanted)); |
1403 | BUG_ON(ac->ac_which != OCFS2_AC_USE_META); | 1377 | BUG_ON(ac->ac_which != OCFS2_AC_USE_META); |
1404 | BUG_ON(ac->ac_handle != handle); | ||
1405 | 1378 | ||
1406 | status = ocfs2_claim_suballoc_bits(osb, | 1379 | status = ocfs2_claim_suballoc_bits(osb, |
1407 | ac, | 1380 | ac, |
1381 | handle, | ||
1408 | bits_wanted, | 1382 | bits_wanted, |
1409 | 1, | 1383 | 1, |
1410 | suballoc_bit_start, | 1384 | suballoc_bit_start, |
@@ -1425,7 +1399,7 @@ bail: | |||
1425 | } | 1399 | } |
1426 | 1400 | ||
1427 | int ocfs2_claim_new_inode(struct ocfs2_super *osb, | 1401 | int ocfs2_claim_new_inode(struct ocfs2_super *osb, |
1428 | struct ocfs2_journal_handle *handle, | 1402 | handle_t *handle, |
1429 | struct ocfs2_alloc_context *ac, | 1403 | struct ocfs2_alloc_context *ac, |
1430 | u16 *suballoc_bit, | 1404 | u16 *suballoc_bit, |
1431 | u64 *fe_blkno) | 1405 | u64 *fe_blkno) |
@@ -1440,10 +1414,10 @@ int ocfs2_claim_new_inode(struct ocfs2_super *osb, | |||
1440 | BUG_ON(ac->ac_bits_given != 0); | 1414 | BUG_ON(ac->ac_bits_given != 0); |
1441 | BUG_ON(ac->ac_bits_wanted != 1); | 1415 | BUG_ON(ac->ac_bits_wanted != 1); |
1442 | BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); | 1416 | BUG_ON(ac->ac_which != OCFS2_AC_USE_INODE); |
1443 | BUG_ON(ac->ac_handle != handle); | ||
1444 | 1417 | ||
1445 | status = ocfs2_claim_suballoc_bits(osb, | 1418 | status = ocfs2_claim_suballoc_bits(osb, |
1446 | ac, | 1419 | ac, |
1420 | handle, | ||
1447 | 1, | 1421 | 1, |
1448 | 1, | 1422 | 1, |
1449 | suballoc_bit, | 1423 | suballoc_bit, |
@@ -1528,7 +1502,7 @@ static inline void ocfs2_block_to_cluster_group(struct inode *inode, | |||
1528 | * of any size. | 1502 | * of any size. |
1529 | */ | 1503 | */ |
1530 | int ocfs2_claim_clusters(struct ocfs2_super *osb, | 1504 | int ocfs2_claim_clusters(struct ocfs2_super *osb, |
1531 | struct ocfs2_journal_handle *handle, | 1505 | handle_t *handle, |
1532 | struct ocfs2_alloc_context *ac, | 1506 | struct ocfs2_alloc_context *ac, |
1533 | u32 min_clusters, | 1507 | u32 min_clusters, |
1534 | u32 *cluster_start, | 1508 | u32 *cluster_start, |
@@ -1546,7 +1520,6 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb, | |||
1546 | 1520 | ||
1547 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL | 1521 | BUG_ON(ac->ac_which != OCFS2_AC_USE_LOCAL |
1548 | && ac->ac_which != OCFS2_AC_USE_MAIN); | 1522 | && ac->ac_which != OCFS2_AC_USE_MAIN); |
1549 | BUG_ON(ac->ac_handle != handle); | ||
1550 | 1523 | ||
1551 | if (ac->ac_which == OCFS2_AC_USE_LOCAL) { | 1524 | if (ac->ac_which == OCFS2_AC_USE_LOCAL) { |
1552 | status = ocfs2_claim_local_alloc_bits(osb, | 1525 | status = ocfs2_claim_local_alloc_bits(osb, |
@@ -1572,6 +1545,7 @@ int ocfs2_claim_clusters(struct ocfs2_super *osb, | |||
1572 | 1545 | ||
1573 | status = ocfs2_claim_suballoc_bits(osb, | 1546 | status = ocfs2_claim_suballoc_bits(osb, |
1574 | ac, | 1547 | ac, |
1548 | handle, | ||
1575 | bits_wanted, | 1549 | bits_wanted, |
1576 | min_clusters, | 1550 | min_clusters, |
1577 | &bg_bit_off, | 1551 | &bg_bit_off, |
@@ -1598,7 +1572,7 @@ bail: | |||
1598 | return status; | 1572 | return status; |
1599 | } | 1573 | } |
1600 | 1574 | ||
1601 | static inline int ocfs2_block_group_clear_bits(struct ocfs2_journal_handle *handle, | 1575 | static inline int ocfs2_block_group_clear_bits(handle_t *handle, |
1602 | struct inode *alloc_inode, | 1576 | struct inode *alloc_inode, |
1603 | struct ocfs2_group_desc *bg, | 1577 | struct ocfs2_group_desc *bg, |
1604 | struct buffer_head *group_bh, | 1578 | struct buffer_head *group_bh, |
@@ -1653,7 +1627,7 @@ bail: | |||
1653 | /* | 1627 | /* |
1654 | * expects the suballoc inode to already be locked. | 1628 | * expects the suballoc inode to already be locked. |
1655 | */ | 1629 | */ |
1656 | static int ocfs2_free_suballoc_bits(struct ocfs2_journal_handle *handle, | 1630 | static int ocfs2_free_suballoc_bits(handle_t *handle, |
1657 | struct inode *alloc_inode, | 1631 | struct inode *alloc_inode, |
1658 | struct buffer_head *alloc_bh, | 1632 | struct buffer_head *alloc_bh, |
1659 | unsigned int start_bit, | 1633 | unsigned int start_bit, |
@@ -1737,7 +1711,7 @@ static inline u64 ocfs2_which_suballoc_group(u64 block, unsigned int bit) | |||
1737 | return group; | 1711 | return group; |
1738 | } | 1712 | } |
1739 | 1713 | ||
1740 | int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, | 1714 | int ocfs2_free_dinode(handle_t *handle, |
1741 | struct inode *inode_alloc_inode, | 1715 | struct inode *inode_alloc_inode, |
1742 | struct buffer_head *inode_alloc_bh, | 1716 | struct buffer_head *inode_alloc_bh, |
1743 | struct ocfs2_dinode *di) | 1717 | struct ocfs2_dinode *di) |
@@ -1750,7 +1724,7 @@ int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, | |||
1750 | inode_alloc_bh, bit, bg_blkno, 1); | 1724 | inode_alloc_bh, bit, bg_blkno, 1); |
1751 | } | 1725 | } |
1752 | 1726 | ||
1753 | int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, | 1727 | int ocfs2_free_extent_block(handle_t *handle, |
1754 | struct inode *eb_alloc_inode, | 1728 | struct inode *eb_alloc_inode, |
1755 | struct buffer_head *eb_alloc_bh, | 1729 | struct buffer_head *eb_alloc_bh, |
1756 | struct ocfs2_extent_block *eb) | 1730 | struct ocfs2_extent_block *eb) |
@@ -1763,7 +1737,7 @@ int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, | |||
1763 | bit, bg_blkno, 1); | 1737 | bit, bg_blkno, 1); |
1764 | } | 1738 | } |
1765 | 1739 | ||
1766 | int ocfs2_free_clusters(struct ocfs2_journal_handle *handle, | 1740 | int ocfs2_free_clusters(handle_t *handle, |
1767 | struct inode *bitmap_inode, | 1741 | struct inode *bitmap_inode, |
1768 | struct buffer_head *bitmap_bh, | 1742 | struct buffer_head *bitmap_bh, |
1769 | u64 start_blk, | 1743 | u64 start_blk, |
diff --git a/fs/ocfs2/suballoc.h b/fs/ocfs2/suballoc.h index c787838d1052..1a3c94cb9250 100644 --- a/fs/ocfs2/suballoc.h +++ b/fs/ocfs2/suballoc.h | |||
@@ -43,7 +43,6 @@ struct ocfs2_alloc_context { | |||
43 | #define OCFS2_AC_USE_INODE 3 | 43 | #define OCFS2_AC_USE_INODE 3 |
44 | #define OCFS2_AC_USE_META 4 | 44 | #define OCFS2_AC_USE_META 4 |
45 | u32 ac_which; | 45 | u32 ac_which; |
46 | struct ocfs2_journal_handle *ac_handle; | ||
47 | 46 | ||
48 | /* these are used by the chain search */ | 47 | /* these are used by the chain search */ |
49 | u16 ac_chain; | 48 | u16 ac_chain; |
@@ -60,45 +59,42 @@ static inline int ocfs2_alloc_context_bits_left(struct ocfs2_alloc_context *ac) | |||
60 | } | 59 | } |
61 | 60 | ||
62 | int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, | 61 | int ocfs2_reserve_new_metadata(struct ocfs2_super *osb, |
63 | struct ocfs2_journal_handle *handle, | ||
64 | struct ocfs2_dinode *fe, | 62 | struct ocfs2_dinode *fe, |
65 | struct ocfs2_alloc_context **ac); | 63 | struct ocfs2_alloc_context **ac); |
66 | int ocfs2_reserve_new_inode(struct ocfs2_super *osb, | 64 | int ocfs2_reserve_new_inode(struct ocfs2_super *osb, |
67 | struct ocfs2_journal_handle *handle, | ||
68 | struct ocfs2_alloc_context **ac); | 65 | struct ocfs2_alloc_context **ac); |
69 | int ocfs2_reserve_clusters(struct ocfs2_super *osb, | 66 | int ocfs2_reserve_clusters(struct ocfs2_super *osb, |
70 | struct ocfs2_journal_handle *handle, | ||
71 | u32 bits_wanted, | 67 | u32 bits_wanted, |
72 | struct ocfs2_alloc_context **ac); | 68 | struct ocfs2_alloc_context **ac); |
73 | 69 | ||
74 | int ocfs2_claim_metadata(struct ocfs2_super *osb, | 70 | int ocfs2_claim_metadata(struct ocfs2_super *osb, |
75 | struct ocfs2_journal_handle *handle, | 71 | handle_t *handle, |
76 | struct ocfs2_alloc_context *ac, | 72 | struct ocfs2_alloc_context *ac, |
77 | u32 bits_wanted, | 73 | u32 bits_wanted, |
78 | u16 *suballoc_bit_start, | 74 | u16 *suballoc_bit_start, |
79 | u32 *num_bits, | 75 | u32 *num_bits, |
80 | u64 *blkno_start); | 76 | u64 *blkno_start); |
81 | int ocfs2_claim_new_inode(struct ocfs2_super *osb, | 77 | int ocfs2_claim_new_inode(struct ocfs2_super *osb, |
82 | struct ocfs2_journal_handle *handle, | 78 | handle_t *handle, |
83 | struct ocfs2_alloc_context *ac, | 79 | struct ocfs2_alloc_context *ac, |
84 | u16 *suballoc_bit, | 80 | u16 *suballoc_bit, |
85 | u64 *fe_blkno); | 81 | u64 *fe_blkno); |
86 | int ocfs2_claim_clusters(struct ocfs2_super *osb, | 82 | int ocfs2_claim_clusters(struct ocfs2_super *osb, |
87 | struct ocfs2_journal_handle *handle, | 83 | handle_t *handle, |
88 | struct ocfs2_alloc_context *ac, | 84 | struct ocfs2_alloc_context *ac, |
89 | u32 min_clusters, | 85 | u32 min_clusters, |
90 | u32 *cluster_start, | 86 | u32 *cluster_start, |
91 | u32 *num_clusters); | 87 | u32 *num_clusters); |
92 | 88 | ||
93 | int ocfs2_free_dinode(struct ocfs2_journal_handle *handle, | 89 | int ocfs2_free_dinode(handle_t *handle, |
94 | struct inode *inode_alloc_inode, | 90 | struct inode *inode_alloc_inode, |
95 | struct buffer_head *inode_alloc_bh, | 91 | struct buffer_head *inode_alloc_bh, |
96 | struct ocfs2_dinode *di); | 92 | struct ocfs2_dinode *di); |
97 | int ocfs2_free_extent_block(struct ocfs2_journal_handle *handle, | 93 | int ocfs2_free_extent_block(handle_t *handle, |
98 | struct inode *eb_alloc_inode, | 94 | struct inode *eb_alloc_inode, |
99 | struct buffer_head *eb_alloc_bh, | 95 | struct buffer_head *eb_alloc_bh, |
100 | struct ocfs2_extent_block *eb); | 96 | struct ocfs2_extent_block *eb); |
101 | int ocfs2_free_clusters(struct ocfs2_journal_handle *handle, | 97 | int ocfs2_free_clusters(handle_t *handle, |
102 | struct inode *bitmap_inode, | 98 | struct inode *bitmap_inode, |
103 | struct buffer_head *bitmap_bh, | 99 | struct buffer_head *bitmap_bh, |
104 | u64 start_blk, | 100 | u64 start_blk, |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 76b46ebbb10c..6e300a88a47e 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -68,9 +68,7 @@ | |||
68 | 68 | ||
69 | #include "buffer_head_io.h" | 69 | #include "buffer_head_io.h" |
70 | 70 | ||
71 | static kmem_cache_t *ocfs2_inode_cachep = NULL; | 71 | static struct kmem_cache *ocfs2_inode_cachep = NULL; |
72 | |||
73 | kmem_cache_t *ocfs2_lock_cache = NULL; | ||
74 | 72 | ||
75 | /* OCFS2 needs to schedule several differnt types of work which | 73 | /* OCFS2 needs to schedule several differnt types of work which |
76 | * require cluster locking, disk I/O, recovery waits, etc. Since these | 74 | * require cluster locking, disk I/O, recovery waits, etc. Since these |
@@ -141,6 +139,7 @@ enum { | |||
141 | Opt_hb_local, | 139 | Opt_hb_local, |
142 | Opt_data_ordered, | 140 | Opt_data_ordered, |
143 | Opt_data_writeback, | 141 | Opt_data_writeback, |
142 | Opt_atime_quantum, | ||
144 | Opt_err, | 143 | Opt_err, |
145 | }; | 144 | }; |
146 | 145 | ||
@@ -154,6 +153,7 @@ static match_table_t tokens = { | |||
154 | {Opt_hb_local, OCFS2_HB_LOCAL}, | 153 | {Opt_hb_local, OCFS2_HB_LOCAL}, |
155 | {Opt_data_ordered, "data=ordered"}, | 154 | {Opt_data_ordered, "data=ordered"}, |
156 | {Opt_data_writeback, "data=writeback"}, | 155 | {Opt_data_writeback, "data=writeback"}, |
156 | {Opt_atime_quantum, "atime_quantum=%u"}, | ||
157 | {Opt_err, NULL} | 157 | {Opt_err, NULL} |
158 | }; | 158 | }; |
159 | 159 | ||
@@ -303,7 +303,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb) | |||
303 | { | 303 | { |
304 | struct ocfs2_inode_info *oi; | 304 | struct ocfs2_inode_info *oi; |
305 | 305 | ||
306 | oi = kmem_cache_alloc(ocfs2_inode_cachep, SLAB_NOFS); | 306 | oi = kmem_cache_alloc(ocfs2_inode_cachep, GFP_NOFS); |
307 | if (!oi) | 307 | if (!oi) |
308 | return NULL; | 308 | return NULL; |
309 | 309 | ||
@@ -508,6 +508,27 @@ bail: | |||
508 | return status; | 508 | return status; |
509 | } | 509 | } |
510 | 510 | ||
511 | static int ocfs2_verify_heartbeat(struct ocfs2_super *osb) | ||
512 | { | ||
513 | if (ocfs2_mount_local(osb)) { | ||
514 | if (osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL) { | ||
515 | mlog(ML_ERROR, "Cannot heartbeat on a locally " | ||
516 | "mounted device.\n"); | ||
517 | return -EINVAL; | ||
518 | } | ||
519 | } | ||
520 | |||
521 | if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { | ||
522 | if (!ocfs2_mount_local(osb) && !ocfs2_is_hard_readonly(osb)) { | ||
523 | mlog(ML_ERROR, "Heartbeat has to be started to mount " | ||
524 | "a read-write clustered device.\n"); | ||
525 | return -EINVAL; | ||
526 | } | ||
527 | } | ||
528 | |||
529 | return 0; | ||
530 | } | ||
531 | |||
511 | static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | 532 | static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) |
512 | { | 533 | { |
513 | struct dentry *root; | 534 | struct dentry *root; |
@@ -516,16 +537,24 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
516 | struct inode *inode = NULL; | 537 | struct inode *inode = NULL; |
517 | struct ocfs2_super *osb = NULL; | 538 | struct ocfs2_super *osb = NULL; |
518 | struct buffer_head *bh = NULL; | 539 | struct buffer_head *bh = NULL; |
540 | char nodestr[8]; | ||
519 | 541 | ||
520 | mlog_entry("%p, %p, %i", sb, data, silent); | 542 | mlog_entry("%p, %p, %i", sb, data, silent); |
521 | 543 | ||
522 | /* for now we only have one cluster/node, make sure we see it | 544 | if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) { |
523 | * in the heartbeat universe */ | ||
524 | if (!o2hb_check_local_node_heartbeating()) { | ||
525 | status = -EINVAL; | 545 | status = -EINVAL; |
526 | goto read_super_error; | 546 | goto read_super_error; |
527 | } | 547 | } |
528 | 548 | ||
549 | /* for now we only have one cluster/node, make sure we see it | ||
550 | * in the heartbeat universe */ | ||
551 | if (parsed_opt & OCFS2_MOUNT_HB_LOCAL) { | ||
552 | if (!o2hb_check_local_node_heartbeating()) { | ||
553 | status = -EINVAL; | ||
554 | goto read_super_error; | ||
555 | } | ||
556 | } | ||
557 | |||
529 | /* probe for superblock */ | 558 | /* probe for superblock */ |
530 | status = ocfs2_sb_probe(sb, &bh, §or_size); | 559 | status = ocfs2_sb_probe(sb, &bh, §or_size); |
531 | if (status < 0) { | 560 | if (status < 0) { |
@@ -541,11 +570,6 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
541 | } | 570 | } |
542 | brelse(bh); | 571 | brelse(bh); |
543 | bh = NULL; | 572 | bh = NULL; |
544 | |||
545 | if (!ocfs2_parse_options(sb, data, &parsed_opt, 0)) { | ||
546 | status = -EINVAL; | ||
547 | goto read_super_error; | ||
548 | } | ||
549 | osb->s_mount_opt = parsed_opt; | 573 | osb->s_mount_opt = parsed_opt; |
550 | 574 | ||
551 | sb->s_magic = OCFS2_SUPER_MAGIC; | 575 | sb->s_magic = OCFS2_SUPER_MAGIC; |
@@ -588,21 +612,16 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
588 | } | 612 | } |
589 | 613 | ||
590 | if (!ocfs2_is_hard_readonly(osb)) { | 614 | if (!ocfs2_is_hard_readonly(osb)) { |
591 | /* If this isn't a hard readonly mount, then we need | ||
592 | * to make sure that heartbeat is in a valid state, | ||
593 | * and that we mark ourselves soft readonly is -oro | ||
594 | * was specified. */ | ||
595 | if (!(osb->s_mount_opt & OCFS2_MOUNT_HB_LOCAL)) { | ||
596 | mlog(ML_ERROR, "No heartbeat for device (%s)\n", | ||
597 | sb->s_id); | ||
598 | status = -EINVAL; | ||
599 | goto read_super_error; | ||
600 | } | ||
601 | |||
602 | if (sb->s_flags & MS_RDONLY) | 615 | if (sb->s_flags & MS_RDONLY) |
603 | ocfs2_set_ro_flag(osb, 0); | 616 | ocfs2_set_ro_flag(osb, 0); |
604 | } | 617 | } |
605 | 618 | ||
619 | status = ocfs2_verify_heartbeat(osb); | ||
620 | if (status < 0) { | ||
621 | mlog_errno(status); | ||
622 | goto read_super_error; | ||
623 | } | ||
624 | |||
606 | osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, | 625 | osb->osb_debug_root = debugfs_create_dir(osb->uuid_str, |
607 | ocfs2_debugfs_root); | 626 | ocfs2_debugfs_root); |
608 | if (!osb->osb_debug_root) { | 627 | if (!osb->osb_debug_root) { |
@@ -635,9 +654,14 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
635 | 654 | ||
636 | ocfs2_complete_mount_recovery(osb); | 655 | ocfs2_complete_mount_recovery(osb); |
637 | 656 | ||
638 | printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %d, slot %d) " | 657 | if (ocfs2_mount_local(osb)) |
658 | snprintf(nodestr, sizeof(nodestr), "local"); | ||
659 | else | ||
660 | snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); | ||
661 | |||
662 | printk(KERN_INFO "ocfs2: Mounting device (%s) on (node %s, slot %d) " | ||
639 | "with %s data mode.\n", | 663 | "with %s data mode.\n", |
640 | osb->dev_str, osb->node_num, osb->slot_num, | 664 | osb->dev_str, nodestr, osb->slot_num, |
641 | osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : | 665 | osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK ? "writeback" : |
642 | "ordered"); | 666 | "ordered"); |
643 | 667 | ||
@@ -707,6 +731,7 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
707 | while ((p = strsep(&options, ",")) != NULL) { | 731 | while ((p = strsep(&options, ",")) != NULL) { |
708 | int token, option; | 732 | int token, option; |
709 | substring_t args[MAX_OPT_ARGS]; | 733 | substring_t args[MAX_OPT_ARGS]; |
734 | struct ocfs2_super * osb = OCFS2_SB(sb); | ||
710 | 735 | ||
711 | if (!*p) | 736 | if (!*p) |
712 | continue; | 737 | continue; |
@@ -747,6 +772,16 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
747 | case Opt_data_writeback: | 772 | case Opt_data_writeback: |
748 | *mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; | 773 | *mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; |
749 | break; | 774 | break; |
775 | case Opt_atime_quantum: | ||
776 | if (match_int(&args[0], &option)) { | ||
777 | status = 0; | ||
778 | goto bail; | ||
779 | } | ||
780 | if (option >= 0) | ||
781 | osb->s_atime_quantum = option; | ||
782 | else | ||
783 | osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | ||
784 | break; | ||
750 | default: | 785 | default: |
751 | mlog(ML_ERROR, | 786 | mlog(ML_ERROR, |
752 | "Unrecognized mount option \"%s\" " | 787 | "Unrecognized mount option \"%s\" " |
@@ -867,7 +902,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
867 | goto bail; | 902 | goto bail; |
868 | } | 903 | } |
869 | 904 | ||
870 | status = ocfs2_meta_lock(inode, NULL, &bh, 0); | 905 | status = ocfs2_meta_lock(inode, &bh, 0); |
871 | if (status < 0) { | 906 | if (status < 0) { |
872 | mlog_errno(status); | 907 | mlog_errno(status); |
873 | goto bail; | 908 | goto bail; |
@@ -903,7 +938,7 @@ bail: | |||
903 | } | 938 | } |
904 | 939 | ||
905 | static void ocfs2_inode_init_once(void *data, | 940 | static void ocfs2_inode_init_once(void *data, |
906 | kmem_cache_t *cachep, | 941 | struct kmem_cache *cachep, |
907 | unsigned long flags) | 942 | unsigned long flags) |
908 | { | 943 | { |
909 | struct ocfs2_inode_info *oi = data; | 944 | struct ocfs2_inode_info *oi = data; |
@@ -914,9 +949,7 @@ static void ocfs2_inode_init_once(void *data, | |||
914 | oi->ip_open_count = 0; | 949 | oi->ip_open_count = 0; |
915 | spin_lock_init(&oi->ip_lock); | 950 | spin_lock_init(&oi->ip_lock); |
916 | ocfs2_extent_map_init(&oi->vfs_inode); | 951 | ocfs2_extent_map_init(&oi->vfs_inode); |
917 | INIT_LIST_HEAD(&oi->ip_handle_list); | ||
918 | INIT_LIST_HEAD(&oi->ip_io_markers); | 952 | INIT_LIST_HEAD(&oi->ip_io_markers); |
919 | oi->ip_handle = NULL; | ||
920 | oi->ip_created_trans = 0; | 953 | oi->ip_created_trans = 0; |
921 | oi->ip_last_trans = 0; | 954 | oi->ip_last_trans = 0; |
922 | oi->ip_dir_start_lookup = 0; | 955 | oi->ip_dir_start_lookup = 0; |
@@ -948,14 +981,6 @@ static int ocfs2_initialize_mem_caches(void) | |||
948 | if (!ocfs2_inode_cachep) | 981 | if (!ocfs2_inode_cachep) |
949 | return -ENOMEM; | 982 | return -ENOMEM; |
950 | 983 | ||
951 | ocfs2_lock_cache = kmem_cache_create("ocfs2_lock", | ||
952 | sizeof(struct ocfs2_journal_lock), | ||
953 | 0, | ||
954 | SLAB_HWCACHE_ALIGN, | ||
955 | NULL, NULL); | ||
956 | if (!ocfs2_lock_cache) | ||
957 | return -ENOMEM; | ||
958 | |||
959 | return 0; | 984 | return 0; |
960 | } | 985 | } |
961 | 986 | ||
@@ -963,11 +988,8 @@ static void ocfs2_free_mem_caches(void) | |||
963 | { | 988 | { |
964 | if (ocfs2_inode_cachep) | 989 | if (ocfs2_inode_cachep) |
965 | kmem_cache_destroy(ocfs2_inode_cachep); | 990 | kmem_cache_destroy(ocfs2_inode_cachep); |
966 | if (ocfs2_lock_cache) | ||
967 | kmem_cache_destroy(ocfs2_lock_cache); | ||
968 | 991 | ||
969 | ocfs2_inode_cachep = NULL; | 992 | ocfs2_inode_cachep = NULL; |
970 | ocfs2_lock_cache = NULL; | ||
971 | } | 993 | } |
972 | 994 | ||
973 | static int ocfs2_get_sector(struct super_block *sb, | 995 | static int ocfs2_get_sector(struct super_block *sb, |
@@ -1001,7 +1023,11 @@ static int ocfs2_fill_local_node_info(struct ocfs2_super *osb) | |||
1001 | 1023 | ||
1002 | /* XXX hold a ref on the node while mounte? easy enough, if | 1024 | /* XXX hold a ref on the node while mounte? easy enough, if |
1003 | * desirable. */ | 1025 | * desirable. */ |
1004 | osb->node_num = o2nm_this_node(); | 1026 | if (ocfs2_mount_local(osb)) |
1027 | osb->node_num = 0; | ||
1028 | else | ||
1029 | osb->node_num = o2nm_this_node(); | ||
1030 | |||
1005 | if (osb->node_num == O2NM_MAX_NODES) { | 1031 | if (osb->node_num == O2NM_MAX_NODES) { |
1006 | mlog(ML_ERROR, "could not find this host's node number\n"); | 1032 | mlog(ML_ERROR, "could not find this host's node number\n"); |
1007 | status = -ENOENT; | 1033 | status = -ENOENT; |
@@ -1086,6 +1112,9 @@ static int ocfs2_mount_volume(struct super_block *sb) | |||
1086 | goto leave; | 1112 | goto leave; |
1087 | } | 1113 | } |
1088 | 1114 | ||
1115 | if (ocfs2_mount_local(osb)) | ||
1116 | goto leave; | ||
1117 | |||
1089 | /* This should be sent *after* we recovered our journal as it | 1118 | /* This should be sent *after* we recovered our journal as it |
1090 | * will cause other nodes to unmark us as needing | 1119 | * will cause other nodes to unmark us as needing |
1091 | * recovery. However, we need to send it *before* dropping the | 1120 | * recovery. However, we need to send it *before* dropping the |
@@ -1116,6 +1145,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) | |||
1116 | { | 1145 | { |
1117 | int tmp; | 1146 | int tmp; |
1118 | struct ocfs2_super *osb = NULL; | 1147 | struct ocfs2_super *osb = NULL; |
1148 | char nodestr[8]; | ||
1119 | 1149 | ||
1120 | mlog_entry("(0x%p)\n", sb); | 1150 | mlog_entry("(0x%p)\n", sb); |
1121 | 1151 | ||
@@ -1179,8 +1209,13 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err) | |||
1179 | 1209 | ||
1180 | atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); | 1210 | atomic_set(&osb->vol_state, VOLUME_DISMOUNTED); |
1181 | 1211 | ||
1182 | printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %d)\n", | 1212 | if (ocfs2_mount_local(osb)) |
1183 | osb->dev_str, osb->node_num); | 1213 | snprintf(nodestr, sizeof(nodestr), "local"); |
1214 | else | ||
1215 | snprintf(nodestr, sizeof(nodestr), "%d", osb->node_num); | ||
1216 | |||
1217 | printk(KERN_INFO "ocfs2: Unmounting device (%s) on (node %s)\n", | ||
1218 | osb->dev_str, nodestr); | ||
1184 | 1219 | ||
1185 | ocfs2_delete_osb(osb); | 1220 | ocfs2_delete_osb(osb); |
1186 | kfree(osb); | 1221 | kfree(osb); |
@@ -1196,7 +1231,7 @@ static int ocfs2_setup_osb_uuid(struct ocfs2_super *osb, const unsigned char *uu | |||
1196 | 1231 | ||
1197 | BUG_ON(uuid_bytes != OCFS2_VOL_UUID_LEN); | 1232 | BUG_ON(uuid_bytes != OCFS2_VOL_UUID_LEN); |
1198 | 1233 | ||
1199 | osb->uuid_str = kcalloc(1, OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL); | 1234 | osb->uuid_str = kzalloc(OCFS2_VOL_UUID_LEN * 2 + 1, GFP_KERNEL); |
1200 | if (osb->uuid_str == NULL) | 1235 | if (osb->uuid_str == NULL) |
1201 | return -ENOMEM; | 1236 | return -ENOMEM; |
1202 | 1237 | ||
@@ -1227,7 +1262,7 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
1227 | 1262 | ||
1228 | mlog_entry_void(); | 1263 | mlog_entry_void(); |
1229 | 1264 | ||
1230 | osb = kcalloc(1, sizeof(struct ocfs2_super), GFP_KERNEL); | 1265 | osb = kzalloc(sizeof(struct ocfs2_super), GFP_KERNEL); |
1231 | if (!osb) { | 1266 | if (!osb) { |
1232 | status = -ENOMEM; | 1267 | status = -ENOMEM; |
1233 | mlog_errno(status); | 1268 | mlog_errno(status); |
@@ -1280,6 +1315,8 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
1280 | init_waitqueue_head(&osb->checkpoint_event); | 1315 | init_waitqueue_head(&osb->checkpoint_event); |
1281 | atomic_set(&osb->needs_checkpoint, 0); | 1316 | atomic_set(&osb->needs_checkpoint, 0); |
1282 | 1317 | ||
1318 | osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | ||
1319 | |||
1283 | osb->node_num = O2NM_INVALID_NODE_NUM; | 1320 | osb->node_num = O2NM_INVALID_NODE_NUM; |
1284 | osb->slot_num = OCFS2_INVALID_SLOT; | 1321 | osb->slot_num = OCFS2_INVALID_SLOT; |
1285 | 1322 | ||
@@ -1350,7 +1387,7 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
1350 | */ | 1387 | */ |
1351 | /* initialize our journal structure */ | 1388 | /* initialize our journal structure */ |
1352 | 1389 | ||
1353 | journal = kcalloc(1, sizeof(struct ocfs2_journal), GFP_KERNEL); | 1390 | journal = kzalloc(sizeof(struct ocfs2_journal), GFP_KERNEL); |
1354 | if (!journal) { | 1391 | if (!journal) { |
1355 | mlog(ML_ERROR, "unable to alloc journal\n"); | 1392 | mlog(ML_ERROR, "unable to alloc journal\n"); |
1356 | status = -ENOMEM; | 1393 | status = -ENOMEM; |
@@ -1365,7 +1402,7 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
1365 | spin_lock_init(&journal->j_lock); | 1402 | spin_lock_init(&journal->j_lock); |
1366 | journal->j_trans_id = (unsigned long) 1; | 1403 | journal->j_trans_id = (unsigned long) 1; |
1367 | INIT_LIST_HEAD(&journal->j_la_cleanups); | 1404 | INIT_LIST_HEAD(&journal->j_la_cleanups); |
1368 | INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery, osb); | 1405 | INIT_WORK(&journal->j_recovery_work, ocfs2_complete_recovery); |
1369 | journal->j_state = OCFS2_JOURNAL_FREE; | 1406 | journal->j_state = OCFS2_JOURNAL_FREE; |
1370 | 1407 | ||
1371 | /* get some pseudo constants for clustersize bits */ | 1408 | /* get some pseudo constants for clustersize bits */ |
@@ -1536,6 +1573,7 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
1536 | { | 1573 | { |
1537 | int status = 0; | 1574 | int status = 0; |
1538 | int dirty; | 1575 | int dirty; |
1576 | int local; | ||
1539 | struct ocfs2_dinode *local_alloc = NULL; /* only used if we | 1577 | struct ocfs2_dinode *local_alloc = NULL; /* only used if we |
1540 | * recover | 1578 | * recover |
1541 | * ourselves. */ | 1579 | * ourselves. */ |
@@ -1563,8 +1601,10 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
1563 | "recovering volume.\n"); | 1601 | "recovering volume.\n"); |
1564 | } | 1602 | } |
1565 | 1603 | ||
1604 | local = ocfs2_mount_local(osb); | ||
1605 | |||
1566 | /* will play back anything left in the journal. */ | 1606 | /* will play back anything left in the journal. */ |
1567 | ocfs2_journal_load(osb->journal); | 1607 | ocfs2_journal_load(osb->journal, local); |
1568 | 1608 | ||
1569 | if (dirty) { | 1609 | if (dirty) { |
1570 | /* recover my local alloc if we didn't unmount cleanly. */ | 1610 | /* recover my local alloc if we didn't unmount cleanly. */ |
@@ -1674,7 +1714,7 @@ void __ocfs2_error(struct super_block *sb, | |||
1674 | va_list args; | 1714 | va_list args; |
1675 | 1715 | ||
1676 | va_start(args, fmt); | 1716 | va_start(args, fmt); |
1677 | vsprintf(error_buf, fmt, args); | 1717 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); |
1678 | va_end(args); | 1718 | va_end(args); |
1679 | 1719 | ||
1680 | /* Not using mlog here because we want to show the actual | 1720 | /* Not using mlog here because we want to show the actual |
@@ -1695,7 +1735,7 @@ void __ocfs2_abort(struct super_block* sb, | |||
1695 | va_list args; | 1735 | va_list args; |
1696 | 1736 | ||
1697 | va_start(args, fmt); | 1737 | va_start(args, fmt); |
1698 | vsprintf(error_buf, fmt, args); | 1738 | vsnprintf(error_buf, sizeof(error_buf), fmt, args); |
1699 | va_end(args); | 1739 | va_end(args); |
1700 | 1740 | ||
1701 | printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n", | 1741 | printk(KERN_CRIT "OCFS2: abort (device %s): %s: %s\n", |
diff --git a/fs/ocfs2/symlink.c b/fs/ocfs2/symlink.c index c0f68aa6c175..957d6878b03e 100644 --- a/fs/ocfs2/symlink.c +++ b/fs/ocfs2/symlink.c | |||
@@ -126,6 +126,10 @@ static int ocfs2_readlink(struct dentry *dentry, | |||
126 | goto out; | 126 | goto out; |
127 | } | 127 | } |
128 | 128 | ||
129 | /* | ||
130 | * Without vfsmount we can't update atime now, | ||
131 | * but we will update atime here ultimately. | ||
132 | */ | ||
129 | ret = vfs_readlink(dentry, buffer, buflen, link); | 133 | ret = vfs_readlink(dentry, buffer, buflen, link); |
130 | 134 | ||
131 | brelse(bh); | 135 | brelse(bh); |
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c index 9707ed7a3206..39814b900fc0 100644 --- a/fs/ocfs2/uptodate.c +++ b/fs/ocfs2/uptodate.c | |||
@@ -69,7 +69,7 @@ struct ocfs2_meta_cache_item { | |||
69 | sector_t c_block; | 69 | sector_t c_block; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static kmem_cache_t *ocfs2_uptodate_cachep = NULL; | 72 | static struct kmem_cache *ocfs2_uptodate_cachep = NULL; |
73 | 73 | ||
74 | void ocfs2_metadata_cache_init(struct inode *inode) | 74 | void ocfs2_metadata_cache_init(struct inode *inode) |
75 | { | 75 | { |
diff --git a/fs/ocfs2/vote.c b/fs/ocfs2/vote.c index 5b4dca79990b..0afd8b9af70f 100644 --- a/fs/ocfs2/vote.c +++ b/fs/ocfs2/vote.c | |||
@@ -479,7 +479,7 @@ static struct ocfs2_net_wait_ctxt *ocfs2_new_net_wait_ctxt(unsigned int response | |||
479 | { | 479 | { |
480 | struct ocfs2_net_wait_ctxt *w; | 480 | struct ocfs2_net_wait_ctxt *w; |
481 | 481 | ||
482 | w = kcalloc(1, sizeof(*w), GFP_NOFS); | 482 | w = kzalloc(sizeof(*w), GFP_NOFS); |
483 | if (!w) { | 483 | if (!w) { |
484 | mlog_errno(-ENOMEM); | 484 | mlog_errno(-ENOMEM); |
485 | goto bail; | 485 | goto bail; |
@@ -642,7 +642,7 @@ static struct ocfs2_vote_msg * ocfs2_new_vote_request(struct ocfs2_super *osb, | |||
642 | 642 | ||
643 | BUG_ON(!ocfs2_is_valid_vote_request(type)); | 643 | BUG_ON(!ocfs2_is_valid_vote_request(type)); |
644 | 644 | ||
645 | request = kcalloc(1, sizeof(*request), GFP_NOFS); | 645 | request = kzalloc(sizeof(*request), GFP_NOFS); |
646 | if (!request) { | 646 | if (!request) { |
647 | mlog_errno(-ENOMEM); | 647 | mlog_errno(-ENOMEM); |
648 | } else { | 648 | } else { |
@@ -1000,6 +1000,9 @@ int ocfs2_register_net_handlers(struct ocfs2_super *osb) | |||
1000 | { | 1000 | { |
1001 | int status = 0; | 1001 | int status = 0; |
1002 | 1002 | ||
1003 | if (ocfs2_mount_local(osb)) | ||
1004 | return 0; | ||
1005 | |||
1003 | status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE, | 1006 | status = o2net_register_handler(OCFS2_MESSAGE_TYPE_RESPONSE, |
1004 | osb->net_key, | 1007 | osb->net_key, |
1005 | sizeof(struct ocfs2_response_msg), | 1008 | sizeof(struct ocfs2_response_msg), |