diff options
Diffstat (limited to 'fs/ocfs2')
-rw-r--r-- | fs/ocfs2/alloc.c | 90 | ||||
-rw-r--r-- | fs/ocfs2/alloc.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/aops.c | 22 | ||||
-rw-r--r-- | fs/ocfs2/aops.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/dir.c | 33 | ||||
-rw-r--r-- | fs/ocfs2/dir.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmdomain.c | 3 | ||||
-rw-r--r-- | fs/ocfs2/dlmglue.c | 60 | ||||
-rw-r--r-- | fs/ocfs2/dlmglue.h | 9 | ||||
-rw-r--r-- | fs/ocfs2/export.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 343 | ||||
-rw-r--r-- | fs/ocfs2/file.h | 11 | ||||
-rw-r--r-- | fs/ocfs2/inode.c | 33 | ||||
-rw-r--r-- | fs/ocfs2/inode.h | 9 | ||||
-rw-r--r-- | fs/ocfs2/ioctl.c | 10 | ||||
-rw-r--r-- | fs/ocfs2/journal.c | 271 | ||||
-rw-r--r-- | fs/ocfs2/journal.h | 78 | ||||
-rw-r--r-- | fs/ocfs2/localalloc.c | 126 | ||||
-rw-r--r-- | fs/ocfs2/localalloc.h | 3 | ||||
-rw-r--r-- | fs/ocfs2/mmap.c | 11 | ||||
-rw-r--r-- | fs/ocfs2/namei.c | 296 | ||||
-rw-r--r-- | fs/ocfs2/namei.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2.h | 4 | ||||
-rw-r--r-- | fs/ocfs2/suballoc.c | 174 | ||||
-rw-r--r-- | fs/ocfs2/suballoc.h | 16 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 32 | ||||
-rw-r--r-- | fs/ocfs2/symlink.c | 4 |
27 files changed, 754 insertions, 894 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 0b2ad163005e..edc91ca3792a 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 | } |
@@ -1349,7 +1341,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
1349 | int i; | 1341 | int i; |
1350 | unsigned int clusters, num_recs, start_cluster; | 1342 | unsigned int clusters, num_recs, start_cluster; |
1351 | u64 start_blk; | 1343 | u64 start_blk; |
1352 | struct ocfs2_journal_handle *handle; | 1344 | handle_t *handle; |
1353 | struct inode *tl_inode = osb->osb_tl_inode; | 1345 | struct inode *tl_inode = osb->osb_tl_inode; |
1354 | struct ocfs2_truncate_log *tl; | 1346 | struct ocfs2_truncate_log *tl; |
1355 | 1347 | ||
@@ -1375,8 +1367,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
1375 | } | 1367 | } |
1376 | } | 1368 | } |
1377 | 1369 | ||
1378 | handle = ocfs2_start_trans(osb, NULL, | 1370 | handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_UPDATE); |
1379 | OCFS2_TRUNCATE_LOG_UPDATE); | ||
1380 | if (IS_ERR(handle)) { | 1371 | if (IS_ERR(handle)) { |
1381 | status = PTR_ERR(handle); | 1372 | status = PTR_ERR(handle); |
1382 | mlog_errno(status); | 1373 | mlog_errno(status); |
@@ -1389,7 +1380,7 @@ int ocfs2_complete_truncate_log_recovery(struct ocfs2_super *osb, | |||
1389 | 1380 | ||
1390 | status = ocfs2_truncate_log_append(osb, handle, | 1381 | status = ocfs2_truncate_log_append(osb, handle, |
1391 | start_blk, clusters); | 1382 | start_blk, clusters); |
1392 | ocfs2_commit_trans(handle); | 1383 | ocfs2_commit_trans(osb, handle); |
1393 | if (status < 0) { | 1384 | if (status < 0) { |
1394 | mlog_errno(status); | 1385 | mlog_errno(status); |
1395 | goto bail_up; | 1386 | goto bail_up; |
@@ -1546,7 +1537,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb, | |||
1546 | struct inode *inode, | 1537 | struct inode *inode, |
1547 | struct buffer_head *fe_bh, | 1538 | struct buffer_head *fe_bh, |
1548 | struct buffer_head *old_last_eb_bh, | 1539 | struct buffer_head *old_last_eb_bh, |
1549 | struct ocfs2_journal_handle *handle, | 1540 | handle_t *handle, |
1550 | struct ocfs2_truncate_context *tc) | 1541 | struct ocfs2_truncate_context *tc) |
1551 | { | 1542 | { |
1552 | int status, i, depth; | 1543 | int status, i, depth; |
@@ -1785,7 +1776,7 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb, | |||
1785 | struct ocfs2_extent_block *eb; | 1776 | struct ocfs2_extent_block *eb; |
1786 | struct ocfs2_extent_list *el; | 1777 | struct ocfs2_extent_list *el; |
1787 | struct buffer_head *last_eb_bh; | 1778 | struct buffer_head *last_eb_bh; |
1788 | struct ocfs2_journal_handle *handle = NULL; | 1779 | handle_t *handle = NULL; |
1789 | struct inode *tl_inode = osb->osb_tl_inode; | 1780 | struct inode *tl_inode = osb->osb_tl_inode; |
1790 | 1781 | ||
1791 | mlog_entry_void(); | 1782 | mlog_entry_void(); |
@@ -1871,7 +1862,7 @@ start: | |||
1871 | 1862 | ||
1872 | credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, | 1863 | credits = ocfs2_calc_tree_trunc_credits(osb->sb, clusters_to_del, |
1873 | fe, el); | 1864 | fe, el); |
1874 | handle = ocfs2_start_trans(osb, NULL, credits); | 1865 | handle = ocfs2_start_trans(osb, credits); |
1875 | if (IS_ERR(handle)) { | 1866 | if (IS_ERR(handle)) { |
1876 | status = PTR_ERR(handle); | 1867 | status = PTR_ERR(handle); |
1877 | handle = NULL; | 1868 | handle = NULL; |
@@ -1894,7 +1885,7 @@ start: | |||
1894 | mutex_unlock(&tl_inode->i_mutex); | 1885 | mutex_unlock(&tl_inode->i_mutex); |
1895 | tl_sem = 0; | 1886 | tl_sem = 0; |
1896 | 1887 | ||
1897 | ocfs2_commit_trans(handle); | 1888 | ocfs2_commit_trans(osb, handle); |
1898 | handle = NULL; | 1889 | handle = NULL; |
1899 | 1890 | ||
1900 | BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters); | 1891 | BUG_ON(le32_to_cpu(fe->i_clusters) < target_i_clusters); |
@@ -1909,7 +1900,7 @@ bail: | |||
1909 | mutex_unlock(&tl_inode->i_mutex); | 1900 | mutex_unlock(&tl_inode->i_mutex); |
1910 | 1901 | ||
1911 | if (handle) | 1902 | if (handle) |
1912 | ocfs2_commit_trans(handle); | 1903 | ocfs2_commit_trans(osb, handle); |
1913 | 1904 | ||
1914 | if (last_eb_bh) | 1905 | if (last_eb_bh) |
1915 | brelse(last_eb_bh); | 1906 | brelse(last_eb_bh); |
@@ -2014,10 +2005,7 @@ int ocfs2_prepare_truncate(struct ocfs2_super *osb, | |||
2014 | mutex_lock(&ext_alloc_inode->i_mutex); | 2005 | mutex_lock(&ext_alloc_inode->i_mutex); |
2015 | (*tc)->tc_ext_alloc_inode = ext_alloc_inode; | 2006 | (*tc)->tc_ext_alloc_inode = ext_alloc_inode; |
2016 | 2007 | ||
2017 | status = ocfs2_meta_lock(ext_alloc_inode, | 2008 | status = ocfs2_meta_lock(ext_alloc_inode, &ext_alloc_bh, 1); |
2018 | NULL, | ||
2019 | &ext_alloc_bh, | ||
2020 | 1); | ||
2021 | if (status < 0) { | 2009 | if (status < 0) { |
2022 | mlog_errno(status); | 2010 | mlog_errno(status); |
2023 | 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..2f7268e81520 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); |
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/dir.c b/fs/ocfs2/dir.c index 04e01915b86e..baad2aa27c14 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c | |||
@@ -82,6 +82,7 @@ int ocfs2_readdir(struct file * filp, void * dirent, filldir_t filldir) | |||
82 | struct inode *inode = filp->f_dentry->d_inode; | 82 | struct inode *inode = filp->f_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/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 637646e6922e..420a375a3949 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); |
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c index 8801e41afe80..69fba16efbd1 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" |
@@ -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; |
@@ -1579,7 +1580,6 @@ static int ocfs2_assign_bh(struct inode *inode, | |||
1579 | * the result of the lock will be communicated via the callback. | 1580 | * the result of the lock will be communicated via the callback. |
1580 | */ | 1581 | */ |
1581 | int ocfs2_meta_lock_full(struct inode *inode, | 1582 | int ocfs2_meta_lock_full(struct inode *inode, |
1582 | struct ocfs2_journal_handle *handle, | ||
1583 | struct buffer_head **ret_bh, | 1583 | struct buffer_head **ret_bh, |
1584 | int ex, | 1584 | int ex, |
1585 | int arg_flags) | 1585 | int arg_flags) |
@@ -1668,12 +1668,6 @@ int ocfs2_meta_lock_full(struct inode *inode, | |||
1668 | } | 1668 | } |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | if (handle) { | ||
1672 | status = ocfs2_handle_add_lock(handle, inode); | ||
1673 | if (status < 0) | ||
1674 | mlog_errno(status); | ||
1675 | } | ||
1676 | |||
1677 | bail: | 1671 | bail: |
1678 | if (status < 0) { | 1672 | if (status < 0) { |
1679 | if (ret_bh && (*ret_bh)) { | 1673 | if (ret_bh && (*ret_bh)) { |
@@ -1713,18 +1707,16 @@ bail: | |||
1713 | * the lock inversion simply. | 1707 | * the lock inversion simply. |
1714 | */ | 1708 | */ |
1715 | int ocfs2_meta_lock_with_page(struct inode *inode, | 1709 | int ocfs2_meta_lock_with_page(struct inode *inode, |
1716 | struct ocfs2_journal_handle *handle, | ||
1717 | struct buffer_head **ret_bh, | 1710 | struct buffer_head **ret_bh, |
1718 | int ex, | 1711 | int ex, |
1719 | struct page *page) | 1712 | struct page *page) |
1720 | { | 1713 | { |
1721 | int ret; | 1714 | int ret; |
1722 | 1715 | ||
1723 | ret = ocfs2_meta_lock_full(inode, handle, ret_bh, ex, | 1716 | ret = ocfs2_meta_lock_full(inode, ret_bh, ex, OCFS2_LOCK_NONBLOCK); |
1724 | OCFS2_LOCK_NONBLOCK); | ||
1725 | if (ret == -EAGAIN) { | 1717 | if (ret == -EAGAIN) { |
1726 | unlock_page(page); | 1718 | unlock_page(page); |
1727 | if (ocfs2_meta_lock(inode, handle, ret_bh, ex) == 0) | 1719 | if (ocfs2_meta_lock(inode, ret_bh, ex) == 0) |
1728 | ocfs2_meta_unlock(inode, ex); | 1720 | ocfs2_meta_unlock(inode, ex); |
1729 | ret = AOP_TRUNCATED_PAGE; | 1721 | ret = AOP_TRUNCATED_PAGE; |
1730 | } | 1722 | } |
@@ -1732,6 +1724,44 @@ int ocfs2_meta_lock_with_page(struct inode *inode, | |||
1732 | return ret; | 1724 | return ret; |
1733 | } | 1725 | } |
1734 | 1726 | ||
1727 | int ocfs2_meta_lock_atime(struct inode *inode, | ||
1728 | struct vfsmount *vfsmnt, | ||
1729 | int *level) | ||
1730 | { | ||
1731 | int ret; | ||
1732 | |||
1733 | mlog_entry_void(); | ||
1734 | ret = ocfs2_meta_lock(inode, NULL, 0); | ||
1735 | if (ret < 0) { | ||
1736 | mlog_errno(ret); | ||
1737 | return ret; | ||
1738 | } | ||
1739 | |||
1740 | /* | ||
1741 | * If we should update atime, we will get EX lock, | ||
1742 | * otherwise we just get PR lock. | ||
1743 | */ | ||
1744 | if (ocfs2_should_update_atime(inode, vfsmnt)) { | ||
1745 | struct buffer_head *bh = NULL; | ||
1746 | |||
1747 | ocfs2_meta_unlock(inode, 0); | ||
1748 | ret = ocfs2_meta_lock(inode, &bh, 1); | ||
1749 | if (ret < 0) { | ||
1750 | mlog_errno(ret); | ||
1751 | return ret; | ||
1752 | } | ||
1753 | *level = 1; | ||
1754 | if (ocfs2_should_update_atime(inode, vfsmnt)) | ||
1755 | ocfs2_update_inode_atime(inode, bh); | ||
1756 | if (bh) | ||
1757 | brelse(bh); | ||
1758 | } else | ||
1759 | *level = 0; | ||
1760 | |||
1761 | mlog_exit(ret); | ||
1762 | return ret; | ||
1763 | } | ||
1764 | |||
1735 | void ocfs2_meta_unlock(struct inode *inode, | 1765 | void ocfs2_meta_unlock(struct inode *inode, |
1736 | int ex) | 1766 | int ex) |
1737 | { | 1767 | { |
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/file.c b/fs/ocfs2/file.c index 1be74c4e7814..8786b3c490aa 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> |
@@ -134,7 +136,58 @@ 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 | if ((vfsmnt->mnt_flags & MNT_NOATIME) || | ||
153 | ((vfsmnt->mnt_flags & MNT_NODIRATIME) && S_ISDIR(inode->i_mode))) | ||
154 | return 0; | ||
155 | |||
156 | now = CURRENT_TIME; | ||
157 | if ((now.tv_sec - inode->i_atime.tv_sec <= osb->s_atime_quantum)) | ||
158 | return 0; | ||
159 | else | ||
160 | return 1; | ||
161 | } | ||
162 | |||
163 | int ocfs2_update_inode_atime(struct inode *inode, | ||
164 | struct buffer_head *bh) | ||
165 | { | ||
166 | int ret; | ||
167 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
168 | handle_t *handle; | ||
169 | |||
170 | mlog_entry_void(); | ||
171 | |||
172 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); | ||
173 | if (handle == NULL) { | ||
174 | ret = -ENOMEM; | ||
175 | mlog_errno(ret); | ||
176 | goto out; | ||
177 | } | ||
178 | |||
179 | inode->i_atime = CURRENT_TIME; | ||
180 | ret = ocfs2_mark_inode_dirty(handle, inode, bh); | ||
181 | if (ret < 0) | ||
182 | mlog_errno(ret); | ||
183 | |||
184 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); | ||
185 | out: | ||
186 | mlog_exit(ret); | ||
187 | return ret; | ||
188 | } | ||
189 | |||
190 | int ocfs2_set_inode_size(handle_t *handle, | ||
138 | struct inode *inode, | 191 | struct inode *inode, |
139 | struct buffer_head *fe_bh, | 192 | struct buffer_head *fe_bh, |
140 | u64 new_i_size) | 193 | u64 new_i_size) |
@@ -163,10 +216,9 @@ static int ocfs2_simple_size_update(struct inode *inode, | |||
163 | { | 216 | { |
164 | int ret; | 217 | int ret; |
165 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 218 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
166 | struct ocfs2_journal_handle *handle = NULL; | 219 | handle_t *handle = NULL; |
167 | 220 | ||
168 | handle = ocfs2_start_trans(osb, NULL, | 221 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
169 | OCFS2_INODE_UPDATE_CREDITS); | ||
170 | if (handle == NULL) { | 222 | if (handle == NULL) { |
171 | ret = -ENOMEM; | 223 | ret = -ENOMEM; |
172 | mlog_errno(ret); | 224 | mlog_errno(ret); |
@@ -178,7 +230,7 @@ static int ocfs2_simple_size_update(struct inode *inode, | |||
178 | if (ret < 0) | 230 | if (ret < 0) |
179 | mlog_errno(ret); | 231 | mlog_errno(ret); |
180 | 232 | ||
181 | ocfs2_commit_trans(handle); | 233 | ocfs2_commit_trans(osb, handle); |
182 | out: | 234 | out: |
183 | return ret; | 235 | return ret; |
184 | } | 236 | } |
@@ -189,14 +241,14 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb, | |||
189 | u64 new_i_size) | 241 | u64 new_i_size) |
190 | { | 242 | { |
191 | int status; | 243 | int status; |
192 | struct ocfs2_journal_handle *handle; | 244 | handle_t *handle; |
193 | 245 | ||
194 | mlog_entry_void(); | 246 | mlog_entry_void(); |
195 | 247 | ||
196 | /* TODO: This needs to actually orphan the inode in this | 248 | /* TODO: This needs to actually orphan the inode in this |
197 | * transaction. */ | 249 | * transaction. */ |
198 | 250 | ||
199 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 251 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
200 | if (IS_ERR(handle)) { | 252 | if (IS_ERR(handle)) { |
201 | status = PTR_ERR(handle); | 253 | status = PTR_ERR(handle); |
202 | mlog_errno(status); | 254 | mlog_errno(status); |
@@ -207,7 +259,7 @@ static int ocfs2_orphan_for_truncate(struct ocfs2_super *osb, | |||
207 | if (status < 0) | 259 | if (status < 0) |
208 | mlog_errno(status); | 260 | mlog_errno(status); |
209 | 261 | ||
210 | ocfs2_commit_trans(handle); | 262 | ocfs2_commit_trans(osb, handle); |
211 | out: | 263 | out: |
212 | mlog_exit(status); | 264 | mlog_exit(status); |
213 | return status; | 265 | return status; |
@@ -328,7 +380,7 @@ int ocfs2_do_extend_allocation(struct ocfs2_super *osb, | |||
328 | struct inode *inode, | 380 | struct inode *inode, |
329 | u32 clusters_to_add, | 381 | u32 clusters_to_add, |
330 | struct buffer_head *fe_bh, | 382 | struct buffer_head *fe_bh, |
331 | struct ocfs2_journal_handle *handle, | 383 | handle_t *handle, |
332 | struct ocfs2_alloc_context *data_ac, | 384 | struct ocfs2_alloc_context *data_ac, |
333 | struct ocfs2_alloc_context *meta_ac, | 385 | struct ocfs2_alloc_context *meta_ac, |
334 | enum ocfs2_alloc_restarted *reason_ret) | 386 | enum ocfs2_alloc_restarted *reason_ret) |
@@ -433,7 +485,7 @@ static int ocfs2_extend_allocation(struct inode *inode, | |||
433 | u32 prev_clusters; | 485 | u32 prev_clusters; |
434 | struct buffer_head *bh = NULL; | 486 | struct buffer_head *bh = NULL; |
435 | struct ocfs2_dinode *fe = NULL; | 487 | struct ocfs2_dinode *fe = NULL; |
436 | struct ocfs2_journal_handle *handle = NULL; | 488 | handle_t *handle = NULL; |
437 | struct ocfs2_alloc_context *data_ac = NULL; | 489 | struct ocfs2_alloc_context *data_ac = NULL; |
438 | struct ocfs2_alloc_context *meta_ac = NULL; | 490 | struct ocfs2_alloc_context *meta_ac = NULL; |
439 | enum ocfs2_alloc_restarted why; | 491 | enum ocfs2_alloc_restarted why; |
@@ -463,13 +515,6 @@ restart_all: | |||
463 | (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode), | 515 | (unsigned long long)OCFS2_I(inode)->ip_blkno, i_size_read(inode), |
464 | fe->i_clusters, clusters_to_add); | 516 | fe->i_clusters, clusters_to_add); |
465 | 517 | ||
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, | 518 | num_free_extents = ocfs2_num_free_extents(osb, |
474 | inode, | 519 | inode, |
475 | fe); | 520 | fe); |
@@ -480,10 +525,7 @@ restart_all: | |||
480 | } | 525 | } |
481 | 526 | ||
482 | if (!num_free_extents) { | 527 | if (!num_free_extents) { |
483 | status = ocfs2_reserve_new_metadata(osb, | 528 | status = ocfs2_reserve_new_metadata(osb, fe, &meta_ac); |
484 | handle, | ||
485 | fe, | ||
486 | &meta_ac); | ||
487 | if (status < 0) { | 529 | if (status < 0) { |
488 | if (status != -ENOSPC) | 530 | if (status != -ENOSPC) |
489 | mlog_errno(status); | 531 | mlog_errno(status); |
@@ -491,10 +533,7 @@ restart_all: | |||
491 | } | 533 | } |
492 | } | 534 | } |
493 | 535 | ||
494 | status = ocfs2_reserve_clusters(osb, | 536 | status = ocfs2_reserve_clusters(osb, clusters_to_add, &data_ac); |
495 | handle, | ||
496 | clusters_to_add, | ||
497 | &data_ac); | ||
498 | if (status < 0) { | 537 | if (status < 0) { |
499 | if (status != -ENOSPC) | 538 | if (status != -ENOSPC) |
500 | mlog_errno(status); | 539 | mlog_errno(status); |
@@ -509,7 +548,7 @@ restart_all: | |||
509 | drop_alloc_sem = 1; | 548 | drop_alloc_sem = 1; |
510 | 549 | ||
511 | credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add); | 550 | credits = ocfs2_calc_extend_credits(osb->sb, fe, clusters_to_add); |
512 | handle = ocfs2_start_trans(osb, handle, credits); | 551 | handle = ocfs2_start_trans(osb, credits); |
513 | if (IS_ERR(handle)) { | 552 | if (IS_ERR(handle)) { |
514 | status = PTR_ERR(handle); | 553 | status = PTR_ERR(handle); |
515 | handle = NULL; | 554 | handle = NULL; |
@@ -589,7 +628,7 @@ leave: | |||
589 | drop_alloc_sem = 0; | 628 | drop_alloc_sem = 0; |
590 | } | 629 | } |
591 | if (handle) { | 630 | if (handle) { |
592 | ocfs2_commit_trans(handle); | 631 | ocfs2_commit_trans(osb, handle); |
593 | handle = NULL; | 632 | handle = NULL; |
594 | } | 633 | } |
595 | if (data_ac) { | 634 | if (data_ac) { |
@@ -624,7 +663,7 @@ static int ocfs2_write_zero_page(struct inode *inode, | |||
624 | struct page *page; | 663 | struct page *page; |
625 | unsigned long index; | 664 | unsigned long index; |
626 | unsigned int offset; | 665 | unsigned int offset; |
627 | struct ocfs2_journal_handle *handle = NULL; | 666 | handle_t *handle = NULL; |
628 | int ret; | 667 | int ret; |
629 | 668 | ||
630 | offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */ | 669 | offset = (size & (PAGE_CACHE_SIZE-1)); /* Within page */ |
@@ -668,7 +707,7 @@ static int ocfs2_write_zero_page(struct inode *inode, | |||
668 | ret = 0; | 707 | ret = 0; |
669 | 708 | ||
670 | if (handle) | 709 | if (handle) |
671 | ocfs2_commit_trans(handle); | 710 | ocfs2_commit_trans(OCFS2_SB(inode->i_sb), handle); |
672 | out_unlock: | 711 | out_unlock: |
673 | unlock_page(page); | 712 | unlock_page(page); |
674 | page_cache_release(page); | 713 | page_cache_release(page); |
@@ -789,7 +828,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
789 | struct super_block *sb = inode->i_sb; | 828 | struct super_block *sb = inode->i_sb; |
790 | struct ocfs2_super *osb = OCFS2_SB(sb); | 829 | struct ocfs2_super *osb = OCFS2_SB(sb); |
791 | struct buffer_head *bh = NULL; | 830 | struct buffer_head *bh = NULL; |
792 | struct ocfs2_journal_handle *handle = NULL; | 831 | handle_t *handle = NULL; |
793 | 832 | ||
794 | mlog_entry("(0x%p, '%.*s')\n", dentry, | 833 | mlog_entry("(0x%p, '%.*s')\n", dentry, |
795 | dentry->d_name.len, dentry->d_name.name); | 834 | dentry->d_name.len, dentry->d_name.name); |
@@ -825,7 +864,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
825 | } | 864 | } |
826 | } | 865 | } |
827 | 866 | ||
828 | status = ocfs2_meta_lock(inode, NULL, &bh, 1); | 867 | status = ocfs2_meta_lock(inode, &bh, 1); |
829 | if (status < 0) { | 868 | if (status < 0) { |
830 | if (status != -ENOENT) | 869 | if (status != -ENOENT) |
831 | mlog_errno(status); | 870 | mlog_errno(status); |
@@ -845,7 +884,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
845 | } | 884 | } |
846 | } | 885 | } |
847 | 886 | ||
848 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 887 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
849 | if (IS_ERR(handle)) { | 888 | if (IS_ERR(handle)) { |
850 | status = PTR_ERR(handle); | 889 | status = PTR_ERR(handle); |
851 | mlog_errno(status); | 890 | mlog_errno(status); |
@@ -863,7 +902,7 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr) | |||
863 | mlog_errno(status); | 902 | mlog_errno(status); |
864 | 903 | ||
865 | bail_commit: | 904 | bail_commit: |
866 | ocfs2_commit_trans(handle); | 905 | ocfs2_commit_trans(osb, handle); |
867 | bail_unlock: | 906 | bail_unlock: |
868 | ocfs2_meta_unlock(inode, 1); | 907 | ocfs2_meta_unlock(inode, 1); |
869 | bail_unlock_rw: | 908 | bail_unlock_rw: |
@@ -906,19 +945,41 @@ bail: | |||
906 | return err; | 945 | return err; |
907 | } | 946 | } |
908 | 947 | ||
948 | int ocfs2_permission(struct inode *inode, int mask, struct nameidata *nd) | ||
949 | { | ||
950 | int ret; | ||
951 | |||
952 | mlog_entry_void(); | ||
953 | |||
954 | ret = ocfs2_meta_lock(inode, NULL, 0); | ||
955 | if (ret) { | ||
956 | mlog_errno(ret); | ||
957 | goto out; | ||
958 | } | ||
959 | |||
960 | ret = generic_permission(inode, mask, NULL); | ||
961 | if (ret) | ||
962 | mlog_errno(ret); | ||
963 | |||
964 | ocfs2_meta_unlock(inode, 0); | ||
965 | out: | ||
966 | mlog_exit(ret); | ||
967 | return ret; | ||
968 | } | ||
969 | |||
909 | static int ocfs2_write_remove_suid(struct inode *inode) | 970 | static int ocfs2_write_remove_suid(struct inode *inode) |
910 | { | 971 | { |
911 | int ret; | 972 | int ret; |
912 | struct buffer_head *bh = NULL; | 973 | struct buffer_head *bh = NULL; |
913 | struct ocfs2_inode_info *oi = OCFS2_I(inode); | 974 | struct ocfs2_inode_info *oi = OCFS2_I(inode); |
914 | struct ocfs2_journal_handle *handle; | 975 | handle_t *handle; |
915 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 976 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
916 | struct ocfs2_dinode *di; | 977 | struct ocfs2_dinode *di; |
917 | 978 | ||
918 | mlog_entry("(Inode %llu, mode 0%o)\n", | 979 | mlog_entry("(Inode %llu, mode 0%o)\n", |
919 | (unsigned long long)oi->ip_blkno, inode->i_mode); | 980 | (unsigned long long)oi->ip_blkno, inode->i_mode); |
920 | 981 | ||
921 | handle = ocfs2_start_trans(osb, NULL, OCFS2_INODE_UPDATE_CREDITS); | 982 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
922 | if (handle == NULL) { | 983 | if (handle == NULL) { |
923 | ret = -ENOMEM; | 984 | ret = -ENOMEM; |
924 | mlog_errno(ret); | 985 | mlog_errno(ret); |
@@ -951,75 +1012,29 @@ static int ocfs2_write_remove_suid(struct inode *inode) | |||
951 | out_bh: | 1012 | out_bh: |
952 | brelse(bh); | 1013 | brelse(bh); |
953 | out_trans: | 1014 | out_trans: |
954 | ocfs2_commit_trans(handle); | 1015 | ocfs2_commit_trans(osb, handle); |
955 | out: | 1016 | out: |
956 | mlog_exit(ret); | 1017 | mlog_exit(ret); |
957 | return ret; | 1018 | return ret; |
958 | } | 1019 | } |
959 | 1020 | ||
960 | static inline int ocfs2_write_should_remove_suid(struct inode *inode) | 1021 | static int ocfs2_prepare_inode_for_write(struct dentry *dentry, |
961 | { | 1022 | loff_t *ppos, |
962 | mode_t mode = inode->i_mode; | 1023 | size_t count, |
963 | 1024 | 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 | { | 1025 | { |
979 | int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; | 1026 | int ret = 0, meta_level = appending; |
1027 | struct inode *inode = dentry->d_inode; | ||
980 | u32 clusters; | 1028 | u32 clusters; |
981 | struct file *filp = iocb->ki_filp; | ||
982 | struct inode *inode = filp->f_dentry->d_inode; | ||
983 | loff_t newsize, saved_pos; | 1029 | loff_t newsize, saved_pos; |
984 | 1030 | ||
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 | /* | 1031 | /* |
1016 | * We sample i_size under a read level meta lock to see if our write | 1032 | * 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 | 1033 | * is extending the file, if it is we back off and get a write level |
1018 | * meta lock. | 1034 | * meta lock. |
1019 | */ | 1035 | */ |
1020 | meta_level = (filp->f_flags & O_APPEND) ? 1 : 0; | ||
1021 | for(;;) { | 1036 | for(;;) { |
1022 | ret = ocfs2_meta_lock(inode, NULL, NULL, meta_level); | 1037 | ret = ocfs2_meta_lock(inode, NULL, meta_level); |
1023 | if (ret < 0) { | 1038 | if (ret < 0) { |
1024 | meta_level = -1; | 1039 | meta_level = -1; |
1025 | mlog_errno(ret); | 1040 | mlog_errno(ret); |
@@ -1035,7 +1050,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1035 | * inode. There's also the dinode i_size state which | 1050 | * inode. There's also the dinode i_size state which |
1036 | * can be lost via setattr during extending writes (we | 1051 | * can be lost via setattr during extending writes (we |
1037 | * set inode->i_size at the end of a write. */ | 1052 | * set inode->i_size at the end of a write. */ |
1038 | if (ocfs2_write_should_remove_suid(inode)) { | 1053 | if (should_remove_suid(dentry)) { |
1039 | if (meta_level == 0) { | 1054 | if (meta_level == 0) { |
1040 | ocfs2_meta_unlock(inode, meta_level); | 1055 | ocfs2_meta_unlock(inode, meta_level); |
1041 | meta_level = 1; | 1056 | meta_level = 1; |
@@ -1045,19 +1060,19 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1045 | ret = ocfs2_write_remove_suid(inode); | 1060 | ret = ocfs2_write_remove_suid(inode); |
1046 | if (ret < 0) { | 1061 | if (ret < 0) { |
1047 | mlog_errno(ret); | 1062 | mlog_errno(ret); |
1048 | goto out; | 1063 | goto out_unlock; |
1049 | } | 1064 | } |
1050 | } | 1065 | } |
1051 | 1066 | ||
1052 | /* work on a copy of ppos until we're sure that we won't have | 1067 | /* work on a copy of ppos until we're sure that we won't have |
1053 | * to recalculate it due to relocking. */ | 1068 | * to recalculate it due to relocking. */ |
1054 | if (filp->f_flags & O_APPEND) { | 1069 | if (appending) { |
1055 | saved_pos = i_size_read(inode); | 1070 | saved_pos = i_size_read(inode); |
1056 | mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); | 1071 | mlog(0, "O_APPEND: inode->i_size=%llu\n", saved_pos); |
1057 | } else { | 1072 | } else { |
1058 | saved_pos = iocb->ki_pos; | 1073 | saved_pos = *ppos; |
1059 | } | 1074 | } |
1060 | newsize = iocb->ki_left + saved_pos; | 1075 | newsize = count + saved_pos; |
1061 | 1076 | ||
1062 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", | 1077 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", |
1063 | (long long) saved_pos, (long long) newsize, | 1078 | (long long) saved_pos, (long long) newsize, |
@@ -1090,19 +1105,66 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1090 | if (!clusters) | 1105 | if (!clusters) |
1091 | break; | 1106 | break; |
1092 | 1107 | ||
1093 | ret = ocfs2_extend_file(inode, NULL, newsize, iocb->ki_left); | 1108 | ret = ocfs2_extend_file(inode, NULL, newsize, count); |
1094 | if (ret < 0) { | 1109 | if (ret < 0) { |
1095 | if (ret != -ENOSPC) | 1110 | if (ret != -ENOSPC) |
1096 | mlog_errno(ret); | 1111 | mlog_errno(ret); |
1097 | goto out; | 1112 | goto out_unlock; |
1098 | } | 1113 | } |
1099 | break; | 1114 | break; |
1100 | } | 1115 | } |
1101 | 1116 | ||
1102 | /* ok, we're done with i_size and alloc work */ | 1117 | if (appending) |
1103 | iocb->ki_pos = saved_pos; | 1118 | *ppos = saved_pos; |
1119 | |||
1120 | out_unlock: | ||
1104 | ocfs2_meta_unlock(inode, meta_level); | 1121 | ocfs2_meta_unlock(inode, meta_level); |
1105 | meta_level = -1; | 1122 | |
1123 | out: | ||
1124 | return ret; | ||
1125 | } | ||
1126 | |||
1127 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | ||
1128 | const struct iovec *iov, | ||
1129 | unsigned long nr_segs, | ||
1130 | loff_t pos) | ||
1131 | { | ||
1132 | int ret, rw_level, have_alloc_sem = 0; | ||
1133 | struct file *filp = iocb->ki_filp; | ||
1134 | struct inode *inode = filp->f_dentry->d_inode; | ||
1135 | int appending = filp->f_flags & O_APPEND ? 1 : 0; | ||
1136 | |||
1137 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, | ||
1138 | (unsigned int)nr_segs, | ||
1139 | filp->f_dentry->d_name.len, | ||
1140 | filp->f_dentry->d_name.name); | ||
1141 | |||
1142 | /* happy write of zero bytes */ | ||
1143 | if (iocb->ki_left == 0) | ||
1144 | return 0; | ||
1145 | |||
1146 | mutex_lock(&inode->i_mutex); | ||
1147 | /* to match setattr's i_mutex -> i_alloc_sem -> rw_lock ordering */ | ||
1148 | if (filp->f_flags & O_DIRECT) { | ||
1149 | have_alloc_sem = 1; | ||
1150 | down_read(&inode->i_alloc_sem); | ||
1151 | } | ||
1152 | |||
1153 | /* concurrent O_DIRECT writes are allowed */ | ||
1154 | rw_level = (filp->f_flags & O_DIRECT) ? 0 : 1; | ||
1155 | ret = ocfs2_rw_lock(inode, rw_level); | ||
1156 | if (ret < 0) { | ||
1157 | rw_level = -1; | ||
1158 | mlog_errno(ret); | ||
1159 | goto out; | ||
1160 | } | ||
1161 | |||
1162 | ret = ocfs2_prepare_inode_for_write(filp->f_dentry, &iocb->ki_pos, | ||
1163 | iocb->ki_left, appending); | ||
1164 | if (ret < 0) { | ||
1165 | mlog_errno(ret); | ||
1166 | goto out; | ||
1167 | } | ||
1106 | 1168 | ||
1107 | /* communicate with ocfs2_dio_end_io */ | 1169 | /* communicate with ocfs2_dio_end_io */ |
1108 | ocfs2_iocb_set_rw_locked(iocb); | 1170 | ocfs2_iocb_set_rw_locked(iocb); |
@@ -1128,8 +1190,6 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1128 | } | 1190 | } |
1129 | 1191 | ||
1130 | out: | 1192 | out: |
1131 | if (meta_level != -1) | ||
1132 | ocfs2_meta_unlock(inode, meta_level); | ||
1133 | if (have_alloc_sem) | 1193 | if (have_alloc_sem) |
1134 | up_read(&inode->i_alloc_sem); | 1194 | up_read(&inode->i_alloc_sem); |
1135 | if (rw_level != -1) | 1195 | if (rw_level != -1) |
@@ -1140,12 +1200,83 @@ out: | |||
1140 | return ret; | 1200 | return ret; |
1141 | } | 1201 | } |
1142 | 1202 | ||
1203 | static ssize_t ocfs2_file_splice_write(struct pipe_inode_info *pipe, | ||
1204 | struct file *out, | ||
1205 | loff_t *ppos, | ||
1206 | size_t len, | ||
1207 | unsigned int flags) | ||
1208 | { | ||
1209 | int ret; | ||
1210 | struct inode *inode = out->f_dentry->d_inode; | ||
1211 | |||
1212 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", out, pipe, | ||
1213 | (unsigned int)len, | ||
1214 | out->f_dentry->d_name.len, | ||
1215 | out->f_dentry->d_name.name); | ||
1216 | |||
1217 | inode_double_lock(inode, pipe->inode); | ||
1218 | |||
1219 | ret = ocfs2_rw_lock(inode, 1); | ||
1220 | if (ret < 0) { | ||
1221 | mlog_errno(ret); | ||
1222 | goto out; | ||
1223 | } | ||
1224 | |||
1225 | ret = ocfs2_prepare_inode_for_write(out->f_dentry, ppos, len, 0); | ||
1226 | if (ret < 0) { | ||
1227 | mlog_errno(ret); | ||
1228 | goto out_unlock; | ||
1229 | } | ||
1230 | |||
1231 | /* ok, we're done with i_size and alloc work */ | ||
1232 | ret = generic_file_splice_write_nolock(pipe, out, ppos, len, flags); | ||
1233 | |||
1234 | out_unlock: | ||
1235 | ocfs2_rw_unlock(inode, 1); | ||
1236 | out: | ||
1237 | inode_double_unlock(inode, pipe->inode); | ||
1238 | |||
1239 | mlog_exit(ret); | ||
1240 | return ret; | ||
1241 | } | ||
1242 | |||
1243 | static ssize_t ocfs2_file_splice_read(struct file *in, | ||
1244 | loff_t *ppos, | ||
1245 | struct pipe_inode_info *pipe, | ||
1246 | size_t len, | ||
1247 | unsigned int flags) | ||
1248 | { | ||
1249 | int ret = 0; | ||
1250 | struct inode *inode = in->f_dentry->d_inode; | ||
1251 | |||
1252 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", in, pipe, | ||
1253 | (unsigned int)len, | ||
1254 | in->f_dentry->d_name.len, | ||
1255 | in->f_dentry->d_name.name); | ||
1256 | |||
1257 | /* | ||
1258 | * See the comment in ocfs2_file_aio_read() | ||
1259 | */ | ||
1260 | ret = ocfs2_meta_lock(inode, NULL, 0); | ||
1261 | if (ret < 0) { | ||
1262 | mlog_errno(ret); | ||
1263 | goto bail; | ||
1264 | } | ||
1265 | ocfs2_meta_unlock(inode, 0); | ||
1266 | |||
1267 | ret = generic_file_splice_read(in, ppos, pipe, len, flags); | ||
1268 | |||
1269 | bail: | ||
1270 | mlog_exit(ret); | ||
1271 | return ret; | ||
1272 | } | ||
1273 | |||
1143 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | 1274 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, |
1144 | const struct iovec *iov, | 1275 | const struct iovec *iov, |
1145 | unsigned long nr_segs, | 1276 | unsigned long nr_segs, |
1146 | loff_t pos) | 1277 | loff_t pos) |
1147 | { | 1278 | { |
1148 | int ret = 0, rw_level = -1, have_alloc_sem = 0; | 1279 | int ret = 0, rw_level = -1, have_alloc_sem = 0, lock_level = 0; |
1149 | struct file *filp = iocb->ki_filp; | 1280 | struct file *filp = iocb->ki_filp; |
1150 | struct inode *inode = filp->f_dentry->d_inode; | 1281 | struct inode *inode = filp->f_dentry->d_inode; |
1151 | 1282 | ||
@@ -1187,12 +1318,12 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
1187 | * like i_size. This allows the checks down below | 1318 | * like i_size. This allows the checks down below |
1188 | * generic_file_aio_read() a chance of actually working. | 1319 | * generic_file_aio_read() a chance of actually working. |
1189 | */ | 1320 | */ |
1190 | ret = ocfs2_meta_lock(inode, NULL, NULL, 0); | 1321 | ret = ocfs2_meta_lock_atime(inode, filp->f_vfsmnt, &lock_level); |
1191 | if (ret < 0) { | 1322 | if (ret < 0) { |
1192 | mlog_errno(ret); | 1323 | mlog_errno(ret); |
1193 | goto bail; | 1324 | goto bail; |
1194 | } | 1325 | } |
1195 | ocfs2_meta_unlock(inode, 0); | 1326 | ocfs2_meta_unlock(inode, lock_level); |
1196 | 1327 | ||
1197 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); | 1328 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); |
1198 | if (ret == -EINVAL) | 1329 | if (ret == -EINVAL) |
@@ -1220,11 +1351,13 @@ bail: | |||
1220 | struct inode_operations ocfs2_file_iops = { | 1351 | struct inode_operations ocfs2_file_iops = { |
1221 | .setattr = ocfs2_setattr, | 1352 | .setattr = ocfs2_setattr, |
1222 | .getattr = ocfs2_getattr, | 1353 | .getattr = ocfs2_getattr, |
1354 | .permission = ocfs2_permission, | ||
1223 | }; | 1355 | }; |
1224 | 1356 | ||
1225 | struct inode_operations ocfs2_special_file_iops = { | 1357 | struct inode_operations ocfs2_special_file_iops = { |
1226 | .setattr = ocfs2_setattr, | 1358 | .setattr = ocfs2_setattr, |
1227 | .getattr = ocfs2_getattr, | 1359 | .getattr = ocfs2_getattr, |
1360 | .permission = ocfs2_permission, | ||
1228 | }; | 1361 | }; |
1229 | 1362 | ||
1230 | const struct file_operations ocfs2_fops = { | 1363 | const struct file_operations ocfs2_fops = { |
@@ -1238,6 +1371,8 @@ const struct file_operations ocfs2_fops = { | |||
1238 | .aio_read = ocfs2_file_aio_read, | 1371 | .aio_read = ocfs2_file_aio_read, |
1239 | .aio_write = ocfs2_file_aio_write, | 1372 | .aio_write = ocfs2_file_aio_write, |
1240 | .ioctl = ocfs2_ioctl, | 1373 | .ioctl = ocfs2_ioctl, |
1374 | .splice_read = ocfs2_file_splice_read, | ||
1375 | .splice_write = ocfs2_file_splice_write, | ||
1241 | }; | 1376 | }; |
1242 | 1377 | ||
1243 | const struct file_operations ocfs2_dops = { | 1378 | 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/inode.c b/fs/ocfs2/inode.c index 16e8e74dc966..42e361f3054f 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: |
@@ -441,7 +440,7 @@ static int ocfs2_read_locked_inode(struct inode *inode, | |||
441 | generation, inode); | 440 | generation, inode); |
442 | 441 | ||
443 | if (can_lock) { | 442 | if (can_lock) { |
444 | status = ocfs2_meta_lock(inode, NULL, NULL, 0); | 443 | status = ocfs2_meta_lock(inode, NULL, 0); |
445 | if (status) { | 444 | if (status) { |
446 | make_bad_inode(inode); | 445 | make_bad_inode(inode); |
447 | mlog_errno(status); | 446 | mlog_errno(status); |
@@ -512,7 +511,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
512 | struct buffer_head *fe_bh) | 511 | struct buffer_head *fe_bh) |
513 | { | 512 | { |
514 | int status = 0; | 513 | int status = 0; |
515 | struct ocfs2_journal_handle *handle = NULL; | 514 | handle_t *handle = NULL; |
516 | struct ocfs2_truncate_context *tc = NULL; | 515 | struct ocfs2_truncate_context *tc = NULL; |
517 | struct ocfs2_dinode *fe; | 516 | struct ocfs2_dinode *fe; |
518 | 517 | ||
@@ -524,7 +523,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
524 | if (!fe->i_clusters) | 523 | if (!fe->i_clusters) |
525 | goto bail; | 524 | goto bail; |
526 | 525 | ||
527 | handle = ocfs2_start_trans(osb, handle, OCFS2_INODE_UPDATE_CREDITS); | 526 | handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); |
528 | if (IS_ERR(handle)) { | 527 | if (IS_ERR(handle)) { |
529 | status = PTR_ERR(handle); | 528 | status = PTR_ERR(handle); |
530 | handle = NULL; | 529 | handle = NULL; |
@@ -538,7 +537,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
538 | goto bail; | 537 | goto bail; |
539 | } | 538 | } |
540 | 539 | ||
541 | ocfs2_commit_trans(handle); | 540 | ocfs2_commit_trans(osb, handle); |
542 | handle = NULL; | 541 | handle = NULL; |
543 | 542 | ||
544 | status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc); | 543 | status = ocfs2_prepare_truncate(osb, inode, fe_bh, &tc); |
@@ -554,7 +553,7 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb, | |||
554 | } | 553 | } |
555 | bail: | 554 | bail: |
556 | if (handle) | 555 | if (handle) |
557 | ocfs2_commit_trans(handle); | 556 | ocfs2_commit_trans(osb, handle); |
558 | 557 | ||
559 | mlog_exit(status); | 558 | mlog_exit(status); |
560 | return status; | 559 | return status; |
@@ -568,7 +567,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
568 | int status; | 567 | int status; |
569 | struct inode *inode_alloc_inode = NULL; | 568 | struct inode *inode_alloc_inode = NULL; |
570 | struct buffer_head *inode_alloc_bh = NULL; | 569 | struct buffer_head *inode_alloc_bh = NULL; |
571 | struct ocfs2_journal_handle *handle; | 570 | handle_t *handle; |
572 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 571 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
573 | struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; | 572 | struct ocfs2_dinode *di = (struct ocfs2_dinode *) di_bh->b_data; |
574 | 573 | ||
@@ -582,7 +581,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
582 | } | 581 | } |
583 | 582 | ||
584 | mutex_lock(&inode_alloc_inode->i_mutex); | 583 | mutex_lock(&inode_alloc_inode->i_mutex); |
585 | status = ocfs2_meta_lock(inode_alloc_inode, NULL, &inode_alloc_bh, 1); | 584 | status = ocfs2_meta_lock(inode_alloc_inode, &inode_alloc_bh, 1); |
586 | if (status < 0) { | 585 | if (status < 0) { |
587 | mutex_unlock(&inode_alloc_inode->i_mutex); | 586 | mutex_unlock(&inode_alloc_inode->i_mutex); |
588 | 587 | ||
@@ -590,7 +589,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
590 | goto bail; | 589 | goto bail; |
591 | } | 590 | } |
592 | 591 | ||
593 | handle = ocfs2_start_trans(osb, NULL, OCFS2_DELETE_INODE_CREDITS); | 592 | handle = ocfs2_start_trans(osb, OCFS2_DELETE_INODE_CREDITS); |
594 | if (IS_ERR(handle)) { | 593 | if (IS_ERR(handle)) { |
595 | status = PTR_ERR(handle); | 594 | status = PTR_ERR(handle); |
596 | mlog_errno(status); | 595 | mlog_errno(status); |
@@ -629,7 +628,7 @@ static int ocfs2_remove_inode(struct inode *inode, | |||
629 | mlog_errno(status); | 628 | mlog_errno(status); |
630 | 629 | ||
631 | bail_commit: | 630 | bail_commit: |
632 | ocfs2_commit_trans(handle); | 631 | ocfs2_commit_trans(osb, handle); |
633 | bail_unlock: | 632 | bail_unlock: |
634 | ocfs2_meta_unlock(inode_alloc_inode, 1); | 633 | ocfs2_meta_unlock(inode_alloc_inode, 1); |
635 | mutex_unlock(&inode_alloc_inode->i_mutex); | 634 | mutex_unlock(&inode_alloc_inode->i_mutex); |
@@ -705,7 +704,7 @@ static int ocfs2_wipe_inode(struct inode *inode, | |||
705 | * delete_inode operation. We do this now to avoid races with | 704 | * delete_inode operation. We do this now to avoid races with |
706 | * recovery completion on other nodes. */ | 705 | * recovery completion on other nodes. */ |
707 | mutex_lock(&orphan_dir_inode->i_mutex); | 706 | mutex_lock(&orphan_dir_inode->i_mutex); |
708 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, &orphan_dir_bh, 1); | 707 | status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1); |
709 | if (status < 0) { | 708 | if (status < 0) { |
710 | mutex_unlock(&orphan_dir_inode->i_mutex); | 709 | mutex_unlock(&orphan_dir_inode->i_mutex); |
711 | 710 | ||
@@ -933,7 +932,7 @@ void ocfs2_delete_inode(struct inode *inode) | |||
933 | * allocation lock here as it won't be needed - nobody will | 932 | * allocation lock here as it won't be needed - nobody will |
934 | * have the file open. | 933 | * have the file open. |
935 | */ | 934 | */ |
936 | status = ocfs2_meta_lock(inode, NULL, &di_bh, 1); | 935 | status = ocfs2_meta_lock(inode, &di_bh, 1); |
937 | if (status < 0) { | 936 | if (status < 0) { |
938 | if (status != -ENOENT) | 937 | if (status != -ENOENT) |
939 | mlog_errno(status); | 938 | mlog_errno(status); |
@@ -1067,12 +1066,6 @@ void ocfs2_clear_inode(struct inode *inode) | |||
1067 | mlog_bug_on_msg(oi->ip_open_count, | 1066 | mlog_bug_on_msg(oi->ip_open_count, |
1068 | "Clear inode of %llu has open count %d\n", | 1067 | "Clear inode of %llu has open count %d\n", |
1069 | (unsigned long long)oi->ip_blkno, oi->ip_open_count); | 1068 | (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 | 1069 | ||
1077 | /* Clear all other flags. */ | 1070 | /* Clear all other flags. */ |
1078 | oi->ip_flags = OCFS2_INODE_CACHE_INLINE; | 1071 | oi->ip_flags = OCFS2_INODE_CACHE_INLINE; |
@@ -1186,7 +1179,7 @@ int ocfs2_inode_revalidate(struct dentry *dentry) | |||
1186 | 1179 | ||
1187 | /* Let ocfs2_meta_lock do the work of updating our struct | 1180 | /* Let ocfs2_meta_lock do the work of updating our struct |
1188 | * inode for us. */ | 1181 | * inode for us. */ |
1189 | status = ocfs2_meta_lock(inode, NULL, NULL, 0); | 1182 | status = ocfs2_meta_lock(inode, NULL, 0); |
1190 | if (status < 0) { | 1183 | if (status < 0) { |
1191 | if (status != -ENOENT) | 1184 | if (status != -ENOENT) |
1192 | mlog_errno(status); | 1185 | mlog_errno(status); |
@@ -1204,7 +1197,7 @@ bail: | |||
1204 | * struct inode. | 1197 | * struct inode. |
1205 | * Only takes ip_lock. | 1198 | * Only takes ip_lock. |
1206 | */ | 1199 | */ |
1207 | int ocfs2_mark_inode_dirty(struct ocfs2_journal_handle *handle, | 1200 | int ocfs2_mark_inode_dirty(handle_t *handle, |
1208 | struct inode *inode, | 1201 | struct inode *inode, |
1209 | struct buffer_head *bh) | 1202 | struct buffer_head *bh) |
1210 | { | 1203 | { |
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h index 9957810fdf85..46a378fbc40b 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 | ||
@@ -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 d95ee2720e6e..1d7f4ab1e5ed 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,39 @@ 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 |
193 | } | 148 | atomic_inc(&(osb->journal->j_num_trans)); |
194 | |||
195 | atomic_inc(&(osb->journal->j_num_trans)); | ||
196 | handle->flags |= OCFS2_HANDLE_STARTED; | ||
197 | 149 | ||
198 | mlog_exit_ptr(handle); | ||
199 | return handle; | 150 | 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 | } | ||
246 | |||
247 | /* This is trivial so we do it out of the main commit | ||
248 | * paths. Beware, it can be called from start_trans too! */ | ||
249 | static void ocfs2_commit_unstarted_handle(struct ocfs2_journal_handle *handle) | ||
250 | { | ||
251 | mlog_entry_void(); | ||
252 | |||
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 | } | 151 | } |
264 | 152 | ||
265 | void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) | 153 | int ocfs2_commit_trans(struct ocfs2_super *osb, |
154 | handle_t *handle) | ||
266 | { | 155 | { |
267 | handle_t *jbd_handle; | 156 | int ret; |
268 | int retval; | 157 | struct ocfs2_journal *journal = osb->journal; |
269 | struct ocfs2_journal *journal = handle->journal; | ||
270 | |||
271 | mlog_entry_void(); | ||
272 | 158 | ||
273 | BUG_ON(!handle); | 159 | BUG_ON(!handle); |
274 | 160 | ||
275 | if (!(handle->flags & OCFS2_HANDLE_STARTED)) { | 161 | ret = journal_stop(handle); |
276 | ocfs2_commit_unstarted_handle(handle); | 162 | if (ret < 0) |
277 | mlog_exit_void(); | 163 | 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 | 164 | ||
310 | up_read(&journal->j_trans_barrier); | 165 | up_read(&journal->j_trans_barrier); |
311 | 166 | ||
312 | kfree(handle); | 167 | return ret; |
313 | mlog_exit_void(); | ||
314 | } | 168 | } |
315 | 169 | ||
316 | /* | 170 | /* |
@@ -326,20 +180,18 @@ void ocfs2_commit_trans(struct ocfs2_journal_handle *handle) | |||
326 | * good because transaction ids haven't yet been recorded on the | 180 | * good because transaction ids haven't yet been recorded on the |
327 | * cluster locks associated with this handle. | 181 | * cluster locks associated with this handle. |
328 | */ | 182 | */ |
329 | int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | 183 | int ocfs2_extend_trans(handle_t *handle, int nblocks) |
330 | int nblocks) | ||
331 | { | 184 | { |
332 | int status; | 185 | int status; |
333 | 186 | ||
334 | BUG_ON(!handle); | 187 | BUG_ON(!handle); |
335 | BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); | ||
336 | BUG_ON(!nblocks); | 188 | BUG_ON(!nblocks); |
337 | 189 | ||
338 | mlog_entry_void(); | 190 | mlog_entry_void(); |
339 | 191 | ||
340 | mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); | 192 | mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); |
341 | 193 | ||
342 | status = journal_extend(handle->k_handle, nblocks); | 194 | status = journal_extend(handle, nblocks); |
343 | if (status < 0) { | 195 | if (status < 0) { |
344 | mlog_errno(status); | 196 | mlog_errno(status); |
345 | goto bail; | 197 | goto bail; |
@@ -347,15 +199,12 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | |||
347 | 199 | ||
348 | if (status > 0) { | 200 | if (status > 0) { |
349 | mlog(0, "journal_extend failed, trying journal_restart\n"); | 201 | mlog(0, "journal_extend failed, trying journal_restart\n"); |
350 | status = journal_restart(handle->k_handle, nblocks); | 202 | status = journal_restart(handle, nblocks); |
351 | if (status < 0) { | 203 | if (status < 0) { |
352 | handle->k_handle = NULL; | ||
353 | mlog_errno(status); | 204 | mlog_errno(status); |
354 | goto bail; | 205 | goto bail; |
355 | } | 206 | } |
356 | handle->max_buffs = nblocks; | 207 | } |
357 | } else | ||
358 | handle->max_buffs += nblocks; | ||
359 | 208 | ||
360 | status = 0; | 209 | status = 0; |
361 | bail: | 210 | bail: |
@@ -364,7 +213,7 @@ bail: | |||
364 | return status; | 213 | return status; |
365 | } | 214 | } |
366 | 215 | ||
367 | int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | 216 | int ocfs2_journal_access(handle_t *handle, |
368 | struct inode *inode, | 217 | struct inode *inode, |
369 | struct buffer_head *bh, | 218 | struct buffer_head *bh, |
370 | int type) | 219 | int type) |
@@ -374,7 +223,6 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
374 | BUG_ON(!inode); | 223 | BUG_ON(!inode); |
375 | BUG_ON(!handle); | 224 | BUG_ON(!handle); |
376 | BUG_ON(!bh); | 225 | BUG_ON(!bh); |
377 | BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); | ||
378 | 226 | ||
379 | mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n", | 227 | mlog_entry("bh->b_blocknr=%llu, type=%d (\"%s\"), bh->b_size = %zu\n", |
380 | (unsigned long long)bh->b_blocknr, type, | 228 | (unsigned long long)bh->b_blocknr, type, |
@@ -403,11 +251,11 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
403 | switch (type) { | 251 | switch (type) { |
404 | case OCFS2_JOURNAL_ACCESS_CREATE: | 252 | case OCFS2_JOURNAL_ACCESS_CREATE: |
405 | case OCFS2_JOURNAL_ACCESS_WRITE: | 253 | case OCFS2_JOURNAL_ACCESS_WRITE: |
406 | status = journal_get_write_access(handle->k_handle, bh); | 254 | status = journal_get_write_access(handle, bh); |
407 | break; | 255 | break; |
408 | 256 | ||
409 | case OCFS2_JOURNAL_ACCESS_UNDO: | 257 | case OCFS2_JOURNAL_ACCESS_UNDO: |
410 | status = journal_get_undo_access(handle->k_handle, bh); | 258 | status = journal_get_undo_access(handle, bh); |
411 | break; | 259 | break; |
412 | 260 | ||
413 | default: | 261 | default: |
@@ -424,17 +272,15 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
424 | return status; | 272 | return status; |
425 | } | 273 | } |
426 | 274 | ||
427 | int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, | 275 | int ocfs2_journal_dirty(handle_t *handle, |
428 | struct buffer_head *bh) | 276 | struct buffer_head *bh) |
429 | { | 277 | { |
430 | int status; | 278 | int status; |
431 | 279 | ||
432 | BUG_ON(!(handle->flags & OCFS2_HANDLE_STARTED)); | ||
433 | |||
434 | mlog_entry("(bh->b_blocknr=%llu)\n", | 280 | mlog_entry("(bh->b_blocknr=%llu)\n", |
435 | (unsigned long long)bh->b_blocknr); | 281 | (unsigned long long)bh->b_blocknr); |
436 | 282 | ||
437 | status = journal_dirty_metadata(handle->k_handle, bh); | 283 | status = journal_dirty_metadata(handle, bh); |
438 | if (status < 0) | 284 | if (status < 0) |
439 | mlog(ML_ERROR, "Could not dirty metadata buffer. " | 285 | mlog(ML_ERROR, "Could not dirty metadata buffer. " |
440 | "(bh->b_blocknr=%llu)\n", | 286 | "(bh->b_blocknr=%llu)\n", |
@@ -456,59 +302,6 @@ int ocfs2_journal_dirty_data(handle_t *handle, | |||
456 | return err; | 302 | return err; |
457 | } | 303 | } |
458 | 304 | ||
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) | 305 | #define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * 5) |
513 | 306 | ||
514 | void ocfs2_set_journal_params(struct ocfs2_super *osb) | 307 | void ocfs2_set_journal_params(struct ocfs2_super *osb) |
@@ -562,8 +355,7 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty) | |||
562 | /* Skip recovery waits here - journal inode metadata never | 355 | /* Skip recovery waits here - journal inode metadata never |
563 | * changes in a live cluster so it can be considered an | 356 | * changes in a live cluster so it can be considered an |
564 | * exception to the rule. */ | 357 | * exception to the rule. */ |
565 | status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, | 358 | status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); |
566 | OCFS2_META_LOCK_RECOVERY); | ||
567 | if (status < 0) { | 359 | if (status < 0) { |
568 | if (status != -ERESTARTSYS) | 360 | if (status != -ERESTARTSYS) |
569 | mlog(ML_ERROR, "Could not get lock on journal!\n"); | 361 | mlog(ML_ERROR, "Could not get lock on journal!\n"); |
@@ -1161,8 +953,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb, | |||
1161 | } | 953 | } |
1162 | SET_INODE_JOURNAL(inode); | 954 | SET_INODE_JOURNAL(inode); |
1163 | 955 | ||
1164 | status = ocfs2_meta_lock_full(inode, NULL, &bh, 1, | 956 | status = ocfs2_meta_lock_full(inode, &bh, 1, OCFS2_META_LOCK_RECOVERY); |
1165 | OCFS2_META_LOCK_RECOVERY); | ||
1166 | if (status < 0) { | 957 | if (status < 0) { |
1167 | mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); | 958 | mlog(0, "status returned from ocfs2_meta_lock=%d\n", status); |
1168 | if (status != -ERESTARTSYS) | 959 | if (status != -ERESTARTSYS) |
@@ -1351,7 +1142,7 @@ static int ocfs2_trylock_journal(struct ocfs2_super *osb, | |||
1351 | SET_INODE_JOURNAL(inode); | 1142 | SET_INODE_JOURNAL(inode); |
1352 | 1143 | ||
1353 | flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; | 1144 | flags = OCFS2_META_LOCK_RECOVERY | OCFS2_META_LOCK_NOQUEUE; |
1354 | status = ocfs2_meta_lock_full(inode, NULL, NULL, 1, flags); | 1145 | status = ocfs2_meta_lock_full(inode, NULL, 1, flags); |
1355 | if (status < 0) { | 1146 | if (status < 0) { |
1356 | if (status != -EAGAIN) | 1147 | if (status != -EAGAIN) |
1357 | mlog_errno(status); | 1148 | mlog_errno(status); |
@@ -1434,7 +1225,7 @@ static int ocfs2_queue_orphans(struct ocfs2_super *osb, | |||
1434 | } | 1225 | } |
1435 | 1226 | ||
1436 | mutex_lock(&orphan_dir_inode->i_mutex); | 1227 | mutex_lock(&orphan_dir_inode->i_mutex); |
1437 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, NULL, 0); | 1228 | status = ocfs2_meta_lock(orphan_dir_inode, NULL, 0); |
1438 | if (status < 0) { | 1229 | if (status < 0) { |
1439 | mlog_errno(status); | 1230 | mlog_errno(status); |
1440 | goto out; | 1231 | goto out; |
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h index 5be161a4ad9f..899112ad8136 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,44 +132,6 @@ 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(struct work_struct *work); | 136 | void ocfs2_complete_recovery(struct work_struct *work); |
176 | 137 | ||
@@ -231,15 +192,14 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode) | |||
231 | * Transaction Handling: | 192 | * Transaction Handling: |
232 | * Manage the lifetime of a transaction handle. | 193 | * Manage the lifetime of a transaction handle. |
233 | * | 194 | * |
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 | 195 | * ocfs2_start_trans - Begin a transaction. Give it an upper estimate of |
240 | * the number of blocks that will be changed during | 196 | * the number of blocks that will be changed during |
241 | * this handle. | 197 | * this handle. |
242 | * ocfs2_commit_trans - Complete a handle. | 198 | * ocfs2_commit_trans - Complete a handle. It might return -EIO if |
199 | * the journal was aborted. The majority of paths don't | ||
200 | * check the return value as an error there comes too | ||
201 | * late to do anything (and will be picked up in a | ||
202 | * later transaction). | ||
243 | * ocfs2_extend_trans - Extend a handle by nblocks credits. This may | 203 | * ocfs2_extend_trans - Extend a handle by nblocks credits. This may |
244 | * commit the handle to disk in the process, but will | 204 | * commit the handle to disk in the process, but will |
245 | * not release any locks taken during the transaction. | 205 | * not release any locks taken during the transaction. |
@@ -249,24 +209,16 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode) | |||
249 | * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. | 209 | * 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 | 210 | * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before |
251 | * the current handle commits. | 211 | * 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 | */ | 212 | */ |
259 | 213 | ||
260 | /* You must always start_trans with a number of buffs > 0, but it's | 214 | /* 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 | 215 | * perfectly legal to go through an entire transaction without having |
262 | * dirtied any buffers. */ | 216 | * dirtied any buffers. */ |
263 | struct ocfs2_journal_handle *ocfs2_alloc_handle(struct ocfs2_super *osb); | 217 | 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); | 218 | int max_buffs); |
267 | void ocfs2_commit_trans(struct ocfs2_journal_handle *handle); | 219 | int ocfs2_commit_trans(struct ocfs2_super *osb, |
268 | int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | 220 | handle_t *handle); |
269 | int nblocks); | 221 | int ocfs2_extend_trans(handle_t *handle, int nblocks); |
270 | 222 | ||
271 | /* | 223 | /* |
272 | * Create access is for when we get a newly created buffer and we're | 224 | * Create access is for when we get a newly created buffer and we're |
@@ -283,7 +235,7 @@ int ocfs2_extend_trans(struct ocfs2_journal_handle *handle, | |||
283 | #define OCFS2_JOURNAL_ACCESS_WRITE 1 | 235 | #define OCFS2_JOURNAL_ACCESS_WRITE 1 |
284 | #define OCFS2_JOURNAL_ACCESS_UNDO 2 | 236 | #define OCFS2_JOURNAL_ACCESS_UNDO 2 |
285 | 237 | ||
286 | int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | 238 | int ocfs2_journal_access(handle_t *handle, |
287 | struct inode *inode, | 239 | struct inode *inode, |
288 | struct buffer_head *bh, | 240 | struct buffer_head *bh, |
289 | int type); | 241 | int type); |
@@ -306,18 +258,10 @@ int ocfs2_journal_access(struct ocfs2_journal_handle *handle, | |||
306 | * <modify the bh> | 258 | * <modify the bh> |
307 | * ocfs2_journal_dirty(handle, bh); | 259 | * ocfs2_journal_dirty(handle, bh); |
308 | */ | 260 | */ |
309 | int ocfs2_journal_dirty(struct ocfs2_journal_handle *handle, | 261 | int ocfs2_journal_dirty(handle_t *handle, |
310 | struct buffer_head *bh); | 262 | struct buffer_head *bh); |
311 | int ocfs2_journal_dirty_data(handle_t *handle, | 263 | int ocfs2_journal_dirty_data(handle_t *handle, |
312 | struct buffer_head *bh); | 264 | 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 | 265 | ||
322 | /* | 266 | /* |
323 | * Credit Macros: | 267 | * Credit Macros: |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 1f17a4d08287..698d79a74ef8 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,7 +770,6 @@ 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) |
@@ -792,7 +783,6 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb, | |||
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..69f85ae392dc 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c | |||
@@ -82,6 +82,8 @@ 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 | |||
85 | /* We don't want to support shared writable mappings yet. */ | 87 | /* We don't want to support shared writable mappings yet. */ |
86 | if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) | 88 | if (((vma->vm_flags & VM_SHARED) || (vma->vm_flags & VM_MAYSHARE)) |
87 | && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { | 89 | && ((vma->vm_flags & VM_WRITE) || (vma->vm_flags & VM_MAYWRITE))) { |
@@ -91,7 +93,14 @@ int ocfs2_mmap(struct file *file, struct vm_area_struct *vma) | |||
91 | return -EINVAL; | 93 | return -EINVAL; |
92 | } | 94 | } |
93 | 95 | ||
94 | file_accessed(file); | 96 | ret = ocfs2_meta_lock_atime(file->f_dentry->d_inode, |
97 | file->f_vfsmnt, &lock_level); | ||
98 | if (ret < 0) { | ||
99 | mlog_errno(ret); | ||
100 | goto out; | ||
101 | } | ||
102 | ocfs2_meta_unlock(file->f_dentry->d_inode, lock_level); | ||
103 | out: | ||
95 | vma->vm_ops = &ocfs2_file_vm_ops; | 104 | vma->vm_ops = &ocfs2_file_vm_ops; |
96 | return 0; | 105 | return 0; |
97 | } | 106 | } |
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index a57b751d4f40..21db45ddf144 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 | { |
@@ -653,7 +642,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
653 | struct inode *dir, | 642 | struct inode *dir, |
654 | struct dentry *dentry) | 643 | struct dentry *dentry) |
655 | { | 644 | { |
656 | struct ocfs2_journal_handle *handle = NULL; | 645 | handle_t *handle; |
657 | struct inode *inode = old_dentry->d_inode; | 646 | struct inode *inode = old_dentry->d_inode; |
658 | int err; | 647 | int err; |
659 | struct buffer_head *fe_bh = NULL; | 648 | struct buffer_head *fe_bh = NULL; |
@@ -666,68 +655,60 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
666 | old_dentry->d_name.len, old_dentry->d_name.name, | 655 | old_dentry->d_name.len, old_dentry->d_name.name, |
667 | dentry->d_name.len, dentry->d_name.name); | 656 | dentry->d_name.len, dentry->d_name.name); |
668 | 657 | ||
669 | if (S_ISDIR(inode->i_mode)) { | 658 | if (S_ISDIR(inode->i_mode)) |
670 | err = -EPERM; | 659 | 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 | 660 | ||
680 | err = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); | 661 | err = ocfs2_meta_lock(dir, &parent_fe_bh, 1); |
681 | if (err < 0) { | 662 | if (err < 0) { |
682 | if (err != -ENOENT) | 663 | if (err != -ENOENT) |
683 | mlog_errno(err); | 664 | mlog_errno(err); |
684 | goto bail; | 665 | return err; |
685 | } | 666 | } |
686 | 667 | ||
687 | if (!dir->i_nlink) { | 668 | if (!dir->i_nlink) { |
688 | err = -ENOENT; | 669 | err = -ENOENT; |
689 | goto bail; | 670 | goto out; |
690 | } | 671 | } |
691 | 672 | ||
692 | err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, | 673 | err = ocfs2_check_dir_for_entry(dir, dentry->d_name.name, |
693 | dentry->d_name.len); | 674 | dentry->d_name.len); |
694 | if (err) | 675 | if (err) |
695 | goto bail; | 676 | goto out; |
696 | 677 | ||
697 | err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, | 678 | err = ocfs2_prepare_dir_for_insert(osb, dir, parent_fe_bh, |
698 | dentry->d_name.name, | 679 | dentry->d_name.name, |
699 | dentry->d_name.len, &de_bh); | 680 | dentry->d_name.len, &de_bh); |
700 | if (err < 0) { | 681 | if (err < 0) { |
701 | mlog_errno(err); | 682 | mlog_errno(err); |
702 | goto bail; | 683 | goto out; |
703 | } | 684 | } |
704 | 685 | ||
705 | err = ocfs2_meta_lock(inode, handle, &fe_bh, 1); | 686 | err = ocfs2_meta_lock(inode, &fe_bh, 1); |
706 | if (err < 0) { | 687 | if (err < 0) { |
707 | if (err != -ENOENT) | 688 | if (err != -ENOENT) |
708 | mlog_errno(err); | 689 | mlog_errno(err); |
709 | goto bail; | 690 | goto out; |
710 | } | 691 | } |
711 | 692 | ||
712 | fe = (struct ocfs2_dinode *) fe_bh->b_data; | 693 | fe = (struct ocfs2_dinode *) fe_bh->b_data; |
713 | if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) { | 694 | if (le16_to_cpu(fe->i_links_count) >= OCFS2_LINK_MAX) { |
714 | err = -EMLINK; | 695 | err = -EMLINK; |
715 | goto bail; | 696 | goto out_unlock_inode; |
716 | } | 697 | } |
717 | 698 | ||
718 | handle = ocfs2_start_trans(osb, handle, OCFS2_LINK_CREDITS); | 699 | handle = ocfs2_start_trans(osb, OCFS2_LINK_CREDITS); |
719 | if (IS_ERR(handle)) { | 700 | if (IS_ERR(handle)) { |
720 | err = PTR_ERR(handle); | 701 | err = PTR_ERR(handle); |
721 | handle = NULL; | 702 | handle = NULL; |
722 | mlog_errno(err); | 703 | mlog_errno(err); |
723 | goto bail; | 704 | goto out_unlock_inode; |
724 | } | 705 | } |
725 | 706 | ||
726 | err = ocfs2_journal_access(handle, inode, fe_bh, | 707 | err = ocfs2_journal_access(handle, inode, fe_bh, |
727 | OCFS2_JOURNAL_ACCESS_WRITE); | 708 | OCFS2_JOURNAL_ACCESS_WRITE); |
728 | if (err < 0) { | 709 | if (err < 0) { |
729 | mlog_errno(err); | 710 | mlog_errno(err); |
730 | goto bail; | 711 | goto out_commit; |
731 | } | 712 | } |
732 | 713 | ||
733 | inc_nlink(inode); | 714 | inc_nlink(inode); |
@@ -741,7 +722,7 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
741 | le16_add_cpu(&fe->i_links_count, -1); | 722 | le16_add_cpu(&fe->i_links_count, -1); |
742 | drop_nlink(inode); | 723 | drop_nlink(inode); |
743 | mlog_errno(err); | 724 | mlog_errno(err); |
744 | goto bail; | 725 | goto out_commit; |
745 | } | 726 | } |
746 | 727 | ||
747 | err = ocfs2_add_entry(handle, dentry, inode, | 728 | err = ocfs2_add_entry(handle, dentry, inode, |
@@ -751,21 +732,27 @@ static int ocfs2_link(struct dentry *old_dentry, | |||
751 | le16_add_cpu(&fe->i_links_count, -1); | 732 | le16_add_cpu(&fe->i_links_count, -1); |
752 | drop_nlink(inode); | 733 | drop_nlink(inode); |
753 | mlog_errno(err); | 734 | mlog_errno(err); |
754 | goto bail; | 735 | goto out_commit; |
755 | } | 736 | } |
756 | 737 | ||
757 | err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); | 738 | err = ocfs2_dentry_attach_lock(dentry, inode, OCFS2_I(dir)->ip_blkno); |
758 | if (err) { | 739 | if (err) { |
759 | mlog_errno(err); | 740 | mlog_errno(err); |
760 | goto bail; | 741 | goto out_commit; |
761 | } | 742 | } |
762 | 743 | ||
763 | atomic_inc(&inode->i_count); | 744 | atomic_inc(&inode->i_count); |
764 | dentry->d_op = &ocfs2_dentry_ops; | 745 | dentry->d_op = &ocfs2_dentry_ops; |
765 | d_instantiate(dentry, inode); | 746 | d_instantiate(dentry, inode); |
766 | bail: | 747 | |
767 | if (handle) | 748 | out_commit: |
768 | ocfs2_commit_trans(handle); | 749 | ocfs2_commit_trans(osb, handle); |
750 | out_unlock_inode: | ||
751 | ocfs2_meta_unlock(inode, 1); | ||
752 | |||
753 | out: | ||
754 | ocfs2_meta_unlock(dir, 1); | ||
755 | |||
769 | if (de_bh) | 756 | if (de_bh) |
770 | brelse(de_bh); | 757 | brelse(de_bh); |
771 | if (fe_bh) | 758 | if (fe_bh) |
@@ -812,13 +799,15 @@ static int ocfs2_unlink(struct inode *dir, | |||
812 | struct dentry *dentry) | 799 | struct dentry *dentry) |
813 | { | 800 | { |
814 | int status; | 801 | int status; |
802 | int child_locked = 0; | ||
815 | struct inode *inode = dentry->d_inode; | 803 | struct inode *inode = dentry->d_inode; |
804 | struct inode *orphan_dir = NULL; | ||
816 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); | 805 | struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); |
817 | u64 blkno; | 806 | u64 blkno; |
818 | struct ocfs2_dinode *fe = NULL; | 807 | struct ocfs2_dinode *fe = NULL; |
819 | struct buffer_head *fe_bh = NULL; | 808 | struct buffer_head *fe_bh = NULL; |
820 | struct buffer_head *parent_node_bh = NULL; | 809 | struct buffer_head *parent_node_bh = NULL; |
821 | struct ocfs2_journal_handle *handle = NULL; | 810 | handle_t *handle = NULL; |
822 | struct ocfs2_dir_entry *dirent = NULL; | 811 | struct ocfs2_dir_entry *dirent = NULL; |
823 | struct buffer_head *dirent_bh = NULL; | 812 | struct buffer_head *dirent_bh = NULL; |
824 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; | 813 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; |
@@ -833,22 +822,14 @@ static int ocfs2_unlink(struct inode *dir, | |||
833 | 822 | ||
834 | if (inode == osb->root_inode) { | 823 | if (inode == osb->root_inode) { |
835 | mlog(0, "Cannot delete the root directory\n"); | 824 | mlog(0, "Cannot delete the root directory\n"); |
836 | status = -EPERM; | 825 | return -EPERM; |
837 | goto leave; | ||
838 | } | 826 | } |
839 | 827 | ||
840 | handle = ocfs2_alloc_handle(osb); | 828 | status = ocfs2_meta_lock(dir, &parent_node_bh, 1); |
841 | if (handle == NULL) { | ||
842 | status = -ENOMEM; | ||
843 | mlog_errno(status); | ||
844 | goto leave; | ||
845 | } | ||
846 | |||
847 | status = ocfs2_meta_lock(dir, handle, &parent_node_bh, 1); | ||
848 | if (status < 0) { | 829 | if (status < 0) { |
849 | if (status != -ENOENT) | 830 | if (status != -ENOENT) |
850 | mlog_errno(status); | 831 | mlog_errno(status); |
851 | goto leave; | 832 | return status; |
852 | } | 833 | } |
853 | 834 | ||
854 | status = ocfs2_find_files_on_disk(dentry->d_name.name, | 835 | status = ocfs2_find_files_on_disk(dentry->d_name.name, |
@@ -869,12 +850,13 @@ static int ocfs2_unlink(struct inode *dir, | |||
869 | goto leave; | 850 | goto leave; |
870 | } | 851 | } |
871 | 852 | ||
872 | status = ocfs2_meta_lock(inode, handle, &fe_bh, 1); | 853 | status = ocfs2_meta_lock(inode, &fe_bh, 1); |
873 | if (status < 0) { | 854 | if (status < 0) { |
874 | if (status != -ENOENT) | 855 | if (status != -ENOENT) |
875 | mlog_errno(status); | 856 | mlog_errno(status); |
876 | goto leave; | 857 | goto leave; |
877 | } | 858 | } |
859 | child_locked = 1; | ||
878 | 860 | ||
879 | if (S_ISDIR(inode->i_mode)) { | 861 | if (S_ISDIR(inode->i_mode)) { |
880 | if (!ocfs2_empty_dir(inode)) { | 862 | if (!ocfs2_empty_dir(inode)) { |
@@ -895,7 +877,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
895 | } | 877 | } |
896 | 878 | ||
897 | if (inode_is_unlinkable(inode)) { | 879 | if (inode_is_unlinkable(inode)) { |
898 | status = ocfs2_prepare_orphan_dir(osb, handle, inode, | 880 | status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, inode, |
899 | orphan_name, | 881 | orphan_name, |
900 | &orphan_entry_bh); | 882 | &orphan_entry_bh); |
901 | if (status < 0) { | 883 | if (status < 0) { |
@@ -904,7 +886,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
904 | } | 886 | } |
905 | } | 887 | } |
906 | 888 | ||
907 | handle = ocfs2_start_trans(osb, handle, OCFS2_UNLINK_CREDITS); | 889 | handle = ocfs2_start_trans(osb, OCFS2_UNLINK_CREDITS); |
908 | if (IS_ERR(handle)) { | 890 | if (IS_ERR(handle)) { |
909 | status = PTR_ERR(handle); | 891 | status = PTR_ERR(handle); |
910 | handle = NULL; | 892 | handle = NULL; |
@@ -923,7 +905,7 @@ static int ocfs2_unlink(struct inode *dir, | |||
923 | 905 | ||
924 | if (inode_is_unlinkable(inode)) { | 906 | if (inode_is_unlinkable(inode)) { |
925 | status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, | 907 | status = ocfs2_orphan_add(osb, handle, inode, fe, orphan_name, |
926 | orphan_entry_bh); | 908 | orphan_entry_bh, orphan_dir); |
927 | if (status < 0) { | 909 | if (status < 0) { |
928 | mlog_errno(status); | 910 | mlog_errno(status); |
929 | goto leave; | 911 | goto leave; |
@@ -960,7 +942,19 @@ static int ocfs2_unlink(struct inode *dir, | |||
960 | 942 | ||
961 | leave: | 943 | leave: |
962 | if (handle) | 944 | if (handle) |
963 | ocfs2_commit_trans(handle); | 945 | ocfs2_commit_trans(osb, handle); |
946 | |||
947 | if (child_locked) | ||
948 | ocfs2_meta_unlock(inode, 1); | ||
949 | |||
950 | ocfs2_meta_unlock(dir, 1); | ||
951 | |||
952 | if (orphan_dir) { | ||
953 | /* This was locked for us in ocfs2_prepare_orphan_dir() */ | ||
954 | ocfs2_meta_unlock(orphan_dir, 1); | ||
955 | mutex_unlock(&orphan_dir->i_mutex); | ||
956 | iput(orphan_dir); | ||
957 | } | ||
964 | 958 | ||
965 | if (fe_bh) | 959 | if (fe_bh) |
966 | brelse(fe_bh); | 960 | brelse(fe_bh); |
@@ -984,7 +978,6 @@ leave: | |||
984 | * if they have the same id, then the 1st one is the only one locked. | 978 | * if they have the same id, then the 1st one is the only one locked. |
985 | */ | 979 | */ |
986 | static int ocfs2_double_lock(struct ocfs2_super *osb, | 980 | static int ocfs2_double_lock(struct ocfs2_super *osb, |
987 | struct ocfs2_journal_handle *handle, | ||
988 | struct buffer_head **bh1, | 981 | struct buffer_head **bh1, |
989 | struct inode *inode1, | 982 | struct inode *inode1, |
990 | struct buffer_head **bh2, | 983 | struct buffer_head **bh2, |
@@ -1000,8 +993,6 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
1000 | (unsigned long long)oi1->ip_blkno, | 993 | (unsigned long long)oi1->ip_blkno, |
1001 | (unsigned long long)oi2->ip_blkno); | 994 | (unsigned long long)oi2->ip_blkno); |
1002 | 995 | ||
1003 | BUG_ON(!handle); | ||
1004 | |||
1005 | if (*bh1) | 996 | if (*bh1) |
1006 | *bh1 = NULL; | 997 | *bh1 = NULL; |
1007 | if (*bh2) | 998 | if (*bh2) |
@@ -1021,25 +1012,41 @@ static int ocfs2_double_lock(struct ocfs2_super *osb, | |||
1021 | inode1 = tmpinode; | 1012 | inode1 = tmpinode; |
1022 | } | 1013 | } |
1023 | /* lock id2 */ | 1014 | /* lock id2 */ |
1024 | status = ocfs2_meta_lock(inode2, handle, bh2, 1); | 1015 | status = ocfs2_meta_lock(inode2, bh2, 1); |
1025 | if (status < 0) { | 1016 | if (status < 0) { |
1026 | if (status != -ENOENT) | 1017 | if (status != -ENOENT) |
1027 | mlog_errno(status); | 1018 | mlog_errno(status); |
1028 | goto bail; | 1019 | goto bail; |
1029 | } | 1020 | } |
1030 | } | 1021 | } |
1022 | |||
1031 | /* lock id1 */ | 1023 | /* lock id1 */ |
1032 | status = ocfs2_meta_lock(inode1, handle, bh1, 1); | 1024 | status = ocfs2_meta_lock(inode1, bh1, 1); |
1033 | if (status < 0) { | 1025 | if (status < 0) { |
1026 | /* | ||
1027 | * An error return must mean that no cluster locks | ||
1028 | * were held on function exit. | ||
1029 | */ | ||
1030 | if (oi1->ip_blkno != oi2->ip_blkno) | ||
1031 | ocfs2_meta_unlock(inode2, 1); | ||
1032 | |||
1034 | if (status != -ENOENT) | 1033 | if (status != -ENOENT) |
1035 | mlog_errno(status); | 1034 | mlog_errno(status); |
1036 | goto bail; | ||
1037 | } | 1035 | } |
1036 | |||
1038 | bail: | 1037 | bail: |
1039 | mlog_exit(status); | 1038 | mlog_exit(status); |
1040 | return status; | 1039 | return status; |
1041 | } | 1040 | } |
1042 | 1041 | ||
1042 | static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2) | ||
1043 | { | ||
1044 | ocfs2_meta_unlock(inode1, 1); | ||
1045 | |||
1046 | if (inode1 != inode2) | ||
1047 | ocfs2_meta_unlock(inode2, 1); | ||
1048 | } | ||
1049 | |||
1043 | #define PARENT_INO(buffer) \ | 1050 | #define PARENT_INO(buffer) \ |
1044 | ((struct ocfs2_dir_entry *) \ | 1051 | ((struct ocfs2_dir_entry *) \ |
1045 | ((char *)buffer + \ | 1052 | ((char *)buffer + \ |
@@ -1050,9 +1057,11 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1050 | struct inode *new_dir, | 1057 | struct inode *new_dir, |
1051 | struct dentry *new_dentry) | 1058 | struct dentry *new_dentry) |
1052 | { | 1059 | { |
1053 | int status = 0, rename_lock = 0; | 1060 | int status = 0, rename_lock = 0, parents_locked = 0; |
1061 | int old_child_locked = 0, new_child_locked = 0; | ||
1054 | struct inode *old_inode = old_dentry->d_inode; | 1062 | struct inode *old_inode = old_dentry->d_inode; |
1055 | struct inode *new_inode = new_dentry->d_inode; | 1063 | struct inode *new_inode = new_dentry->d_inode; |
1064 | struct inode *orphan_dir = NULL; | ||
1056 | struct ocfs2_dinode *newfe = NULL; | 1065 | struct ocfs2_dinode *newfe = NULL; |
1057 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; | 1066 | char orphan_name[OCFS2_ORPHAN_NAMELEN + 1]; |
1058 | struct buffer_head *orphan_entry_bh = NULL; | 1067 | struct buffer_head *orphan_entry_bh = NULL; |
@@ -1060,7 +1069,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1060 | struct buffer_head *insert_entry_bh = NULL; | 1069 | struct buffer_head *insert_entry_bh = NULL; |
1061 | struct ocfs2_super *osb = NULL; | 1070 | struct ocfs2_super *osb = NULL; |
1062 | u64 newfe_blkno; | 1071 | u64 newfe_blkno; |
1063 | struct ocfs2_journal_handle *handle = NULL; | 1072 | handle_t *handle = NULL; |
1064 | struct buffer_head *old_dir_bh = NULL; | 1073 | struct buffer_head *old_dir_bh = NULL; |
1065 | struct buffer_head *new_dir_bh = NULL; | 1074 | struct buffer_head *new_dir_bh = NULL; |
1066 | struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry | 1075 | struct ocfs2_dir_entry *old_de = NULL, *new_de = NULL; // dirent for old_dentry |
@@ -1105,21 +1114,14 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1105 | rename_lock = 1; | 1114 | rename_lock = 1; |
1106 | } | 1115 | } |
1107 | 1116 | ||
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. */ | 1117 | /* if old and new are the same, this'll just do one lock. */ |
1116 | status = ocfs2_double_lock(osb, handle, | 1118 | status = ocfs2_double_lock(osb, &old_dir_bh, old_dir, |
1117 | &old_dir_bh, old_dir, | 1119 | &new_dir_bh, new_dir); |
1118 | &new_dir_bh, new_dir); | ||
1119 | if (status < 0) { | 1120 | if (status < 0) { |
1120 | mlog_errno(status); | 1121 | mlog_errno(status); |
1121 | goto bail; | 1122 | goto bail; |
1122 | } | 1123 | } |
1124 | parents_locked = 1; | ||
1123 | 1125 | ||
1124 | /* make sure both dirs have bhs | 1126 | /* make sure both dirs have bhs |
1125 | * get an extra ref on old_dir_bh if old==new */ | 1127 | * get an extra ref on old_dir_bh if old==new */ |
@@ -1140,12 +1142,13 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1140 | * the vote thread on other nodes won't have to concurrently | 1142 | * the vote thread on other nodes won't have to concurrently |
1141 | * downconvert the inode and the dentry locks. | 1143 | * downconvert the inode and the dentry locks. |
1142 | */ | 1144 | */ |
1143 | status = ocfs2_meta_lock(old_inode, handle, NULL, 1); | 1145 | status = ocfs2_meta_lock(old_inode, NULL, 1); |
1144 | if (status < 0) { | 1146 | if (status < 0) { |
1145 | if (status != -ENOENT) | 1147 | if (status != -ENOENT) |
1146 | mlog_errno(status); | 1148 | mlog_errno(status); |
1147 | goto bail; | 1149 | goto bail; |
1148 | } | 1150 | } |
1151 | old_child_locked = 1; | ||
1149 | 1152 | ||
1150 | status = ocfs2_remote_dentry_delete(old_dentry); | 1153 | status = ocfs2_remote_dentry_delete(old_dentry); |
1151 | if (status < 0) { | 1154 | if (status < 0) { |
@@ -1231,12 +1234,13 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1231 | goto bail; | 1234 | goto bail; |
1232 | } | 1235 | } |
1233 | 1236 | ||
1234 | status = ocfs2_meta_lock(new_inode, handle, &newfe_bh, 1); | 1237 | status = ocfs2_meta_lock(new_inode, &newfe_bh, 1); |
1235 | if (status < 0) { | 1238 | if (status < 0) { |
1236 | if (status != -ENOENT) | 1239 | if (status != -ENOENT) |
1237 | mlog_errno(status); | 1240 | mlog_errno(status); |
1238 | goto bail; | 1241 | goto bail; |
1239 | } | 1242 | } |
1243 | new_child_locked = 1; | ||
1240 | 1244 | ||
1241 | status = ocfs2_remote_dentry_delete(new_dentry); | 1245 | status = ocfs2_remote_dentry_delete(new_dentry); |
1242 | if (status < 0) { | 1246 | if (status < 0) { |
@@ -1252,7 +1256,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1252 | (unsigned long long)newfe_bh->b_blocknr : 0ULL); | 1256 | (unsigned long long)newfe_bh->b_blocknr : 0ULL); |
1253 | 1257 | ||
1254 | if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) { | 1258 | if (S_ISDIR(new_inode->i_mode) || (new_inode->i_nlink == 1)) { |
1255 | status = ocfs2_prepare_orphan_dir(osb, handle, | 1259 | status = ocfs2_prepare_orphan_dir(osb, &orphan_dir, |
1256 | new_inode, | 1260 | new_inode, |
1257 | orphan_name, | 1261 | orphan_name, |
1258 | &orphan_entry_bh); | 1262 | &orphan_entry_bh); |
@@ -1280,7 +1284,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1280 | } | 1284 | } |
1281 | } | 1285 | } |
1282 | 1286 | ||
1283 | handle = ocfs2_start_trans(osb, handle, OCFS2_RENAME_CREDITS); | 1287 | handle = ocfs2_start_trans(osb, OCFS2_RENAME_CREDITS); |
1284 | if (IS_ERR(handle)) { | 1288 | if (IS_ERR(handle)) { |
1285 | status = PTR_ERR(handle); | 1289 | status = PTR_ERR(handle); |
1286 | handle = NULL; | 1290 | handle = NULL; |
@@ -1307,7 +1311,7 @@ static int ocfs2_rename(struct inode *old_dir, | |||
1307 | (newfe->i_links_count == cpu_to_le16(1))){ | 1311 | (newfe->i_links_count == cpu_to_le16(1))){ |
1308 | status = ocfs2_orphan_add(osb, handle, new_inode, | 1312 | status = ocfs2_orphan_add(osb, handle, new_inode, |
1309 | newfe, orphan_name, | 1313 | newfe, orphan_name, |
1310 | orphan_entry_bh); | 1314 | orphan_entry_bh, orphan_dir); |
1311 | if (status < 0) { | 1315 | if (status < 0) { |
1312 | mlog_errno(status); | 1316 | mlog_errno(status); |
1313 | goto bail; | 1317 | goto bail; |
@@ -1424,7 +1428,23 @@ bail: | |||
1424 | ocfs2_rename_unlock(osb); | 1428 | ocfs2_rename_unlock(osb); |
1425 | 1429 | ||
1426 | if (handle) | 1430 | if (handle) |
1427 | ocfs2_commit_trans(handle); | 1431 | ocfs2_commit_trans(osb, handle); |
1432 | |||
1433 | if (parents_locked) | ||
1434 | ocfs2_double_unlock(old_dir, new_dir); | ||
1435 | |||
1436 | if (old_child_locked) | ||
1437 | ocfs2_meta_unlock(old_inode, 1); | ||
1438 | |||
1439 | if (new_child_locked) | ||
1440 | ocfs2_meta_unlock(new_inode, 1); | ||
1441 | |||
1442 | if (orphan_dir) { | ||
1443 | /* This was locked for us in ocfs2_prepare_orphan_dir() */ | ||
1444 | ocfs2_meta_unlock(orphan_dir, 1); | ||
1445 | mutex_unlock(&orphan_dir->i_mutex); | ||
1446 | iput(orphan_dir); | ||
1447 | } | ||
1428 | 1448 | ||
1429 | if (new_inode) | 1449 | if (new_inode) |
1430 | sync_mapping_buffers(old_inode->i_mapping); | 1450 | sync_mapping_buffers(old_inode->i_mapping); |
@@ -1458,7 +1478,7 @@ bail: | |||
1458 | * data, including the null terminator. | 1478 | * data, including the null terminator. |
1459 | */ | 1479 | */ |
1460 | static int ocfs2_create_symlink_data(struct ocfs2_super *osb, | 1480 | static int ocfs2_create_symlink_data(struct ocfs2_super *osb, |
1461 | struct ocfs2_journal_handle *handle, | 1481 | handle_t *handle, |
1462 | struct inode *inode, | 1482 | struct inode *inode, |
1463 | const char *symname) | 1483 | const char *symname) |
1464 | { | 1484 | { |
@@ -1573,7 +1593,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1573 | struct buffer_head *parent_fe_bh = NULL; | 1593 | struct buffer_head *parent_fe_bh = NULL; |
1574 | struct ocfs2_dinode *fe = NULL; | 1594 | struct ocfs2_dinode *fe = NULL; |
1575 | struct ocfs2_dinode *dirfe; | 1595 | struct ocfs2_dinode *dirfe; |
1576 | struct ocfs2_journal_handle *handle = NULL; | 1596 | handle_t *handle = NULL; |
1577 | struct ocfs2_alloc_context *inode_ac = NULL; | 1597 | struct ocfs2_alloc_context *inode_ac = NULL; |
1578 | struct ocfs2_alloc_context *data_ac = NULL; | 1598 | struct ocfs2_alloc_context *data_ac = NULL; |
1579 | 1599 | ||
@@ -1587,19 +1607,12 @@ static int ocfs2_symlink(struct inode *dir, | |||
1587 | 1607 | ||
1588 | credits = ocfs2_calc_symlink_credits(sb); | 1608 | credits = ocfs2_calc_symlink_credits(sb); |
1589 | 1609 | ||
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 */ | 1610 | /* lock the parent directory */ |
1598 | status = ocfs2_meta_lock(dir, handle, &parent_fe_bh, 1); | 1611 | status = ocfs2_meta_lock(dir, &parent_fe_bh, 1); |
1599 | if (status < 0) { | 1612 | if (status < 0) { |
1600 | if (status != -ENOENT) | 1613 | if (status != -ENOENT) |
1601 | mlog_errno(status); | 1614 | mlog_errno(status); |
1602 | goto bail; | 1615 | return status; |
1603 | } | 1616 | } |
1604 | 1617 | ||
1605 | dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data; | 1618 | dirfe = (struct ocfs2_dinode *) parent_fe_bh->b_data; |
@@ -1622,7 +1635,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1622 | goto bail; | 1635 | goto bail; |
1623 | } | 1636 | } |
1624 | 1637 | ||
1625 | status = ocfs2_reserve_new_inode(osb, handle, &inode_ac); | 1638 | status = ocfs2_reserve_new_inode(osb, &inode_ac); |
1626 | if (status < 0) { | 1639 | if (status < 0) { |
1627 | if (status != -ENOSPC) | 1640 | if (status != -ENOSPC) |
1628 | mlog_errno(status); | 1641 | mlog_errno(status); |
@@ -1631,7 +1644,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1631 | 1644 | ||
1632 | /* don't reserve bitmap space for fast symlinks. */ | 1645 | /* don't reserve bitmap space for fast symlinks. */ |
1633 | if (l > ocfs2_fast_symlink_chars(sb)) { | 1646 | if (l > ocfs2_fast_symlink_chars(sb)) { |
1634 | status = ocfs2_reserve_clusters(osb, handle, 1, &data_ac); | 1647 | status = ocfs2_reserve_clusters(osb, 1, &data_ac); |
1635 | if (status < 0) { | 1648 | if (status < 0) { |
1636 | if (status != -ENOSPC) | 1649 | if (status != -ENOSPC) |
1637 | mlog_errno(status); | 1650 | mlog_errno(status); |
@@ -1639,7 +1652,7 @@ static int ocfs2_symlink(struct inode *dir, | |||
1639 | } | 1652 | } |
1640 | } | 1653 | } |
1641 | 1654 | ||
1642 | handle = ocfs2_start_trans(osb, handle, credits); | 1655 | handle = ocfs2_start_trans(osb, credits); |
1643 | if (IS_ERR(handle)) { | 1656 | if (IS_ERR(handle)) { |
1644 | status = PTR_ERR(handle); | 1657 | status = PTR_ERR(handle); |
1645 | handle = NULL; | 1658 | handle = NULL; |
@@ -1717,7 +1730,10 @@ static int ocfs2_symlink(struct inode *dir, | |||
1717 | d_instantiate(dentry, inode); | 1730 | d_instantiate(dentry, inode); |
1718 | bail: | 1731 | bail: |
1719 | if (handle) | 1732 | if (handle) |
1720 | ocfs2_commit_trans(handle); | 1733 | ocfs2_commit_trans(osb, handle); |
1734 | |||
1735 | ocfs2_meta_unlock(dir, 1); | ||
1736 | |||
1721 | if (new_fe_bh) | 1737 | if (new_fe_bh) |
1722 | brelse(new_fe_bh); | 1738 | brelse(new_fe_bh); |
1723 | if (parent_fe_bh) | 1739 | if (parent_fe_bh) |
@@ -1768,7 +1784,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 | 1784 | * If you pass me insert_bh, I'll skip the search of the other dir |
1769 | * blocks and put the record in there. | 1785 | * blocks and put the record in there. |
1770 | */ | 1786 | */ |
1771 | static int __ocfs2_add_entry(struct ocfs2_journal_handle *handle, | 1787 | static int __ocfs2_add_entry(handle_t *handle, |
1772 | struct inode *dir, | 1788 | struct inode *dir, |
1773 | const char *name, int namelen, | 1789 | const char *name, int namelen, |
1774 | struct inode *inode, u64 blkno, | 1790 | struct inode *inode, u64 blkno, |
@@ -1854,7 +1870,7 @@ bail: | |||
1854 | * ocfs2_delete_entry deletes a directory entry by merging it with the | 1870 | * ocfs2_delete_entry deletes a directory entry by merging it with the |
1855 | * previous entry | 1871 | * previous entry |
1856 | */ | 1872 | */ |
1857 | static int ocfs2_delete_entry(struct ocfs2_journal_handle *handle, | 1873 | static int ocfs2_delete_entry(handle_t *handle, |
1858 | struct inode *dir, | 1874 | struct inode *dir, |
1859 | struct ocfs2_dir_entry *de_del, | 1875 | struct ocfs2_dir_entry *de_del, |
1860 | struct buffer_head *bh) | 1876 | struct buffer_head *bh) |
@@ -2085,19 +2101,19 @@ bail: | |||
2085 | } | 2101 | } |
2086 | 2102 | ||
2087 | static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, | 2103 | static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, |
2088 | struct ocfs2_journal_handle *handle, | 2104 | struct inode **ret_orphan_dir, |
2089 | struct inode *inode, | 2105 | struct inode *inode, |
2090 | char *name, | 2106 | char *name, |
2091 | struct buffer_head **de_bh) | 2107 | struct buffer_head **de_bh) |
2092 | { | 2108 | { |
2093 | struct inode *orphan_dir_inode = NULL; | 2109 | struct inode *orphan_dir_inode; |
2094 | struct buffer_head *orphan_dir_bh = NULL; | 2110 | struct buffer_head *orphan_dir_bh = NULL; |
2095 | int status = 0; | 2111 | int status = 0; |
2096 | 2112 | ||
2097 | status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); | 2113 | status = ocfs2_blkno_stringify(OCFS2_I(inode)->ip_blkno, name); |
2098 | if (status < 0) { | 2114 | if (status < 0) { |
2099 | mlog_errno(status); | 2115 | mlog_errno(status); |
2100 | goto leave; | 2116 | return status; |
2101 | } | 2117 | } |
2102 | 2118 | ||
2103 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, | 2119 | orphan_dir_inode = ocfs2_get_system_file_inode(osb, |
@@ -2106,11 +2122,12 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, | |||
2106 | if (!orphan_dir_inode) { | 2122 | if (!orphan_dir_inode) { |
2107 | status = -ENOENT; | 2123 | status = -ENOENT; |
2108 | mlog_errno(status); | 2124 | mlog_errno(status); |
2109 | goto leave; | 2125 | return status; |
2110 | } | 2126 | } |
2111 | 2127 | ||
2112 | ocfs2_handle_add_inode(handle, orphan_dir_inode); | 2128 | mutex_lock(&orphan_dir_inode->i_mutex); |
2113 | status = ocfs2_meta_lock(orphan_dir_inode, handle, &orphan_dir_bh, 1); | 2129 | |
2130 | status = ocfs2_meta_lock(orphan_dir_inode, &orphan_dir_bh, 1); | ||
2114 | if (status < 0) { | 2131 | if (status < 0) { |
2115 | mlog_errno(status); | 2132 | mlog_errno(status); |
2116 | goto leave; | 2133 | goto leave; |
@@ -2120,13 +2137,19 @@ static int ocfs2_prepare_orphan_dir(struct ocfs2_super *osb, | |||
2120 | orphan_dir_bh, name, | 2137 | orphan_dir_bh, name, |
2121 | OCFS2_ORPHAN_NAMELEN, de_bh); | 2138 | OCFS2_ORPHAN_NAMELEN, de_bh); |
2122 | if (status < 0) { | 2139 | if (status < 0) { |
2140 | ocfs2_meta_unlock(orphan_dir_inode, 1); | ||
2141 | |||
2123 | mlog_errno(status); | 2142 | mlog_errno(status); |
2124 | goto leave; | 2143 | goto leave; |
2125 | } | 2144 | } |
2126 | 2145 | ||
2146 | *ret_orphan_dir = orphan_dir_inode; | ||
2147 | |||
2127 | leave: | 2148 | leave: |
2128 | if (orphan_dir_inode) | 2149 | if (status) { |
2150 | mutex_unlock(&orphan_dir_inode->i_mutex); | ||
2129 | iput(orphan_dir_inode); | 2151 | iput(orphan_dir_inode); |
2152 | } | ||
2130 | 2153 | ||
2131 | if (orphan_dir_bh) | 2154 | if (orphan_dir_bh) |
2132 | brelse(orphan_dir_bh); | 2155 | brelse(orphan_dir_bh); |
@@ -2136,28 +2159,19 @@ leave: | |||
2136 | } | 2159 | } |
2137 | 2160 | ||
2138 | static int ocfs2_orphan_add(struct ocfs2_super *osb, | 2161 | static int ocfs2_orphan_add(struct ocfs2_super *osb, |
2139 | struct ocfs2_journal_handle *handle, | 2162 | handle_t *handle, |
2140 | struct inode *inode, | 2163 | struct inode *inode, |
2141 | struct ocfs2_dinode *fe, | 2164 | struct ocfs2_dinode *fe, |
2142 | char *name, | 2165 | char *name, |
2143 | struct buffer_head *de_bh) | 2166 | struct buffer_head *de_bh, |
2167 | struct inode *orphan_dir_inode) | ||
2144 | { | 2168 | { |
2145 | struct inode *orphan_dir_inode = NULL; | ||
2146 | struct buffer_head *orphan_dir_bh = NULL; | 2169 | struct buffer_head *orphan_dir_bh = NULL; |
2147 | int status = 0; | 2170 | int status = 0; |
2148 | struct ocfs2_dinode *orphan_fe; | 2171 | struct ocfs2_dinode *orphan_fe; |
2149 | 2172 | ||
2150 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); | 2173 | mlog_entry("(inode->i_ino = %lu)\n", inode->i_ino); |
2151 | 2174 | ||
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, | 2175 | status = ocfs2_read_block(osb, |
2162 | OCFS2_I(orphan_dir_inode)->ip_blkno, | 2176 | OCFS2_I(orphan_dir_inode)->ip_blkno, |
2163 | &orphan_dir_bh, OCFS2_BH_CACHED, | 2177 | &orphan_dir_bh, OCFS2_BH_CACHED, |
@@ -2209,9 +2223,6 @@ static int ocfs2_orphan_add(struct ocfs2_super *osb, | |||
2209 | (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); | 2223 | (unsigned long long)OCFS2_I(inode)->ip_blkno, osb->slot_num); |
2210 | 2224 | ||
2211 | leave: | 2225 | leave: |
2212 | if (orphan_dir_inode) | ||
2213 | iput(orphan_dir_inode); | ||
2214 | |||
2215 | if (orphan_dir_bh) | 2226 | if (orphan_dir_bh) |
2216 | brelse(orphan_dir_bh); | 2227 | brelse(orphan_dir_bh); |
2217 | 2228 | ||
@@ -2221,7 +2232,7 @@ leave: | |||
2221 | 2232 | ||
2222 | /* unlike orphan_add, we expect the orphan dir to already be locked here. */ | 2233 | /* unlike orphan_add, we expect the orphan dir to already be locked here. */ |
2223 | int ocfs2_orphan_del(struct ocfs2_super *osb, | 2234 | int ocfs2_orphan_del(struct ocfs2_super *osb, |
2224 | struct ocfs2_journal_handle *handle, | 2235 | handle_t *handle, |
2225 | struct inode *orphan_dir_inode, | 2236 | struct inode *orphan_dir_inode, |
2226 | struct inode *inode, | 2237 | struct inode *inode, |
2227 | struct buffer_head *orphan_dir_bh) | 2238 | struct buffer_head *orphan_dir_bh) |
@@ -2300,4 +2311,5 @@ struct inode_operations ocfs2_dir_iops = { | |||
2300 | .rename = ocfs2_rename, | 2311 | .rename = ocfs2_rename, |
2301 | .setattr = ocfs2_setattr, | 2312 | .setattr = ocfs2_setattr, |
2302 | .getattr = ocfs2_getattr, | 2313 | .getattr = ocfs2_getattr, |
2314 | .permission = ocfs2_permission, | ||
2303 | }; | 2315 | }; |
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 9b1bad1d48ec..b767fd7da6eb 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; |
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c index 9d91e66f51a9..000d71cca6c5 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,12 +482,11 @@ 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 = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
484 | if (!(*ac)) { | 492 | if (!(*ac)) { |
@@ -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,19 +521,14 @@ 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 = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
541 | if (!(*ac)) { | 534 | if (!(*ac)) { |
@@ -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,8 +595,6 @@ int ocfs2_reserve_clusters(struct ocfs2_super *osb, | |||
618 | 595 | ||
619 | mlog_entry_void(); | 596 | mlog_entry_void(); |
620 | 597 | ||
621 | BUG_ON(!handle); | ||
622 | |||
623 | *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); | 598 | *ac = kcalloc(1, sizeof(struct ocfs2_alloc_context), GFP_KERNEL); |
624 | if (!(*ac)) { | 599 | if (!(*ac)) { |
625 | status = -ENOMEM; | 600 | status = -ENOMEM; |
@@ -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 9a8089030f55..d9b4214a12da 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -70,8 +70,6 @@ | |||
70 | 70 | ||
71 | static kmem_cache_t *ocfs2_inode_cachep = NULL; | 71 | static kmem_cache_t *ocfs2_inode_cachep = NULL; |
72 | 72 | ||
73 | kmem_cache_t *ocfs2_lock_cache = NULL; | ||
74 | |||
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 |
77 | * types of work tend to be heavy we avoid using the kernel events | 75 | * types of work tend to be heavy we avoid using the kernel events |
@@ -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 | ||
@@ -707,6 +707,7 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
707 | while ((p = strsep(&options, ",")) != NULL) { | 707 | while ((p = strsep(&options, ",")) != NULL) { |
708 | int token, option; | 708 | int token, option; |
709 | substring_t args[MAX_OPT_ARGS]; | 709 | substring_t args[MAX_OPT_ARGS]; |
710 | struct ocfs2_super * osb = OCFS2_SB(sb); | ||
710 | 711 | ||
711 | if (!*p) | 712 | if (!*p) |
712 | continue; | 713 | continue; |
@@ -747,6 +748,16 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
747 | case Opt_data_writeback: | 748 | case Opt_data_writeback: |
748 | *mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; | 749 | *mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; |
749 | break; | 750 | break; |
751 | case Opt_atime_quantum: | ||
752 | if (match_int(&args[0], &option)) { | ||
753 | status = 0; | ||
754 | goto bail; | ||
755 | } | ||
756 | if (option >= 0) | ||
757 | osb->s_atime_quantum = option; | ||
758 | else | ||
759 | osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | ||
760 | break; | ||
750 | default: | 761 | default: |
751 | mlog(ML_ERROR, | 762 | mlog(ML_ERROR, |
752 | "Unrecognized mount option \"%s\" " | 763 | "Unrecognized mount option \"%s\" " |
@@ -867,7 +878,7 @@ static int ocfs2_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
867 | goto bail; | 878 | goto bail; |
868 | } | 879 | } |
869 | 880 | ||
870 | status = ocfs2_meta_lock(inode, NULL, &bh, 0); | 881 | status = ocfs2_meta_lock(inode, &bh, 0); |
871 | if (status < 0) { | 882 | if (status < 0) { |
872 | mlog_errno(status); | 883 | mlog_errno(status); |
873 | goto bail; | 884 | goto bail; |
@@ -914,9 +925,7 @@ static void ocfs2_inode_init_once(void *data, | |||
914 | oi->ip_open_count = 0; | 925 | oi->ip_open_count = 0; |
915 | spin_lock_init(&oi->ip_lock); | 926 | spin_lock_init(&oi->ip_lock); |
916 | ocfs2_extent_map_init(&oi->vfs_inode); | 927 | ocfs2_extent_map_init(&oi->vfs_inode); |
917 | INIT_LIST_HEAD(&oi->ip_handle_list); | ||
918 | INIT_LIST_HEAD(&oi->ip_io_markers); | 928 | INIT_LIST_HEAD(&oi->ip_io_markers); |
919 | oi->ip_handle = NULL; | ||
920 | oi->ip_created_trans = 0; | 929 | oi->ip_created_trans = 0; |
921 | oi->ip_last_trans = 0; | 930 | oi->ip_last_trans = 0; |
922 | oi->ip_dir_start_lookup = 0; | 931 | oi->ip_dir_start_lookup = 0; |
@@ -948,14 +957,6 @@ static int ocfs2_initialize_mem_caches(void) | |||
948 | if (!ocfs2_inode_cachep) | 957 | if (!ocfs2_inode_cachep) |
949 | return -ENOMEM; | 958 | return -ENOMEM; |
950 | 959 | ||
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; | 960 | return 0; |
960 | } | 961 | } |
961 | 962 | ||
@@ -963,11 +964,8 @@ static void ocfs2_free_mem_caches(void) | |||
963 | { | 964 | { |
964 | if (ocfs2_inode_cachep) | 965 | if (ocfs2_inode_cachep) |
965 | kmem_cache_destroy(ocfs2_inode_cachep); | 966 | kmem_cache_destroy(ocfs2_inode_cachep); |
966 | if (ocfs2_lock_cache) | ||
967 | kmem_cache_destroy(ocfs2_lock_cache); | ||
968 | 967 | ||
969 | ocfs2_inode_cachep = NULL; | 968 | ocfs2_inode_cachep = NULL; |
970 | ocfs2_lock_cache = NULL; | ||
971 | } | 969 | } |
972 | 970 | ||
973 | static int ocfs2_get_sector(struct super_block *sb, | 971 | static int ocfs2_get_sector(struct super_block *sb, |
@@ -1280,6 +1278,8 @@ static int ocfs2_initialize_super(struct super_block *sb, | |||
1280 | init_waitqueue_head(&osb->checkpoint_event); | 1278 | init_waitqueue_head(&osb->checkpoint_event); |
1281 | atomic_set(&osb->needs_checkpoint, 0); | 1279 | atomic_set(&osb->needs_checkpoint, 0); |
1282 | 1280 | ||
1281 | osb->s_atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | ||
1282 | |||
1283 | osb->node_num = O2NM_INVALID_NODE_NUM; | 1283 | osb->node_num = O2NM_INVALID_NODE_NUM; |
1284 | osb->slot_num = OCFS2_INVALID_SLOT; | 1284 | osb->slot_num = OCFS2_INVALID_SLOT; |
1285 | 1285 | ||
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); |