aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/dir.c
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-10-17 22:25:01 -0400
committerMark Fasheh <mfasheh@suse.com>2009-01-05 11:40:32 -0500
commit13723d00e374c2a6d6ccb5af6de965e89c3e1b01 (patch)
tree70dcd8f3d188bf2f62e4bf4b44a0662d8cd527ca /fs/ocfs2/dir.c
parentffdd7a54631f07918b75e324d86713a08c11ec06 (diff)
ocfs2: Use metadata-specific ocfs2_journal_access_*() functions.
The per-metadata-type ocfs2_journal_access_*() functions hook up jbd2 commit triggers and allow us to compute metadata ecc right before the buffers are written out. This commit provides ecc for inodes, extent blocks, group descriptors, and quota blocks. It is not safe to use extened attributes and metaecc at the same time yet. The ocfs2_extent_tree and ocfs2_path abstractions in alloc.c both hide the type of block at their root. Before, it didn't matter, but now the root block must use the appropriate ocfs2_journal_access_*() function. To keep this abstract, the structures now have a pointer to the matching journal_access function and a wrapper call to call it. A few places use naked ocfs2_write_block() calls instead of adding the blocks to the journal. We make sure to calculate their checksum and ecc before the write. Since we pass around the journal_access functions. Let's typedef them in ocfs2.h. Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/dir.c')
-rw-r--r--fs/ocfs2/dir.c48
1 files changed, 31 insertions, 17 deletions
diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c
index 3708fe482e3e..45e4e03d8f71 100644
--- a/fs/ocfs2/dir.c
+++ b/fs/ocfs2/dir.c
@@ -378,14 +378,18 @@ int ocfs2_update_entry(struct inode *dir, handle_t *handle,
378 struct inode *new_entry_inode) 378 struct inode *new_entry_inode)
379{ 379{
380 int ret; 380 int ret;
381 ocfs2_journal_access_func access = ocfs2_journal_access_db;
381 382
382 /* 383 /*
383 * The same code works fine for both inline-data and extent 384 * The same code works fine for both inline-data and extent
384 * based directories, so no need to split this up. 385 * based directories, so no need to split this up. The only
386 * difference is the journal_access function.
385 */ 387 */
386 388
387 ret = ocfs2_journal_access(handle, dir, de_bh, 389 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
388 OCFS2_JOURNAL_ACCESS_WRITE); 390 access = ocfs2_journal_access_di;
391
392 ret = access(handle, dir, de_bh, OCFS2_JOURNAL_ACCESS_WRITE);
389 if (ret) { 393 if (ret) {
390 mlog_errno(ret); 394 mlog_errno(ret);
391 goto out; 395 goto out;
@@ -407,9 +411,13 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
407{ 411{
408 struct ocfs2_dir_entry *de, *pde; 412 struct ocfs2_dir_entry *de, *pde;
409 int i, status = -ENOENT; 413 int i, status = -ENOENT;
414 ocfs2_journal_access_func access = ocfs2_journal_access_db;
410 415
411 mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p)\n", handle, dir, de_del, bh); 416 mlog_entry("(0x%p, 0x%p, 0x%p, 0x%p)\n", handle, dir, de_del, bh);
412 417
418 if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
419 access = ocfs2_journal_access_di;
420
413 i = 0; 421 i = 0;
414 pde = NULL; 422 pde = NULL;
415 de = (struct ocfs2_dir_entry *) first_de; 423 de = (struct ocfs2_dir_entry *) first_de;
@@ -420,8 +428,8 @@ static int __ocfs2_delete_entry(handle_t *handle, struct inode *dir,
420 goto bail; 428 goto bail;
421 } 429 }
422 if (de == de_del) { 430 if (de == de_del) {
423 status = ocfs2_journal_access(handle, dir, bh, 431 status = access(handle, dir, bh,
424 OCFS2_JOURNAL_ACCESS_WRITE); 432 OCFS2_JOURNAL_ACCESS_WRITE);
425 if (status < 0) { 433 if (status < 0) {
426 status = -EIO; 434 status = -EIO;
427 mlog_errno(status); 435 mlog_errno(status);
@@ -581,8 +589,14 @@ int __ocfs2_add_entry(handle_t *handle,
581 goto bail; 589 goto bail;
582 } 590 }
583 591
584 status = ocfs2_journal_access(handle, dir, insert_bh, 592 if (insert_bh == parent_fe_bh)
585 OCFS2_JOURNAL_ACCESS_WRITE); 593 status = ocfs2_journal_access_di(handle, dir,
594 insert_bh,
595 OCFS2_JOURNAL_ACCESS_WRITE);
596 else
597 status = ocfs2_journal_access_db(handle, dir,
598 insert_bh,
599 OCFS2_JOURNAL_ACCESS_WRITE);
586 /* By now the buffer is marked for journaling */ 600 /* By now the buffer is marked for journaling */
587 offset += le16_to_cpu(de->rec_len); 601 offset += le16_to_cpu(de->rec_len);
588 if (le64_to_cpu(de->inode)) { 602 if (le64_to_cpu(de->inode)) {
@@ -1081,8 +1095,8 @@ static int ocfs2_fill_new_dir_id(struct ocfs2_super *osb,
1081 struct ocfs2_inline_data *data = &di->id2.i_data; 1095 struct ocfs2_inline_data *data = &di->id2.i_data;
1082 unsigned int size = le16_to_cpu(data->id_count); 1096 unsigned int size = le16_to_cpu(data->id_count);
1083 1097
1084 ret = ocfs2_journal_access(handle, inode, di_bh, 1098 ret = ocfs2_journal_access_di(handle, inode, di_bh,
1085 OCFS2_JOURNAL_ACCESS_WRITE); 1099 OCFS2_JOURNAL_ACCESS_WRITE);
1086 if (ret) { 1100 if (ret) {
1087 mlog_errno(ret); 1101 mlog_errno(ret);
1088 goto out; 1102 goto out;
@@ -1129,8 +1143,8 @@ static int ocfs2_fill_new_dir_el(struct ocfs2_super *osb,
1129 1143
1130 ocfs2_set_new_buffer_uptodate(inode, new_bh); 1144 ocfs2_set_new_buffer_uptodate(inode, new_bh);
1131 1145
1132 status = ocfs2_journal_access(handle, inode, new_bh, 1146 status = ocfs2_journal_access_db(handle, inode, new_bh,
1133 OCFS2_JOURNAL_ACCESS_CREATE); 1147 OCFS2_JOURNAL_ACCESS_CREATE);
1134 if (status < 0) { 1148 if (status < 0) {
1135 mlog_errno(status); 1149 mlog_errno(status);
1136 goto bail; 1150 goto bail;
@@ -1292,8 +1306,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1292 1306
1293 ocfs2_set_new_buffer_uptodate(dir, dirdata_bh); 1307 ocfs2_set_new_buffer_uptodate(dir, dirdata_bh);
1294 1308
1295 ret = ocfs2_journal_access(handle, dir, dirdata_bh, 1309 ret = ocfs2_journal_access_db(handle, dir, dirdata_bh,
1296 OCFS2_JOURNAL_ACCESS_CREATE); 1310 OCFS2_JOURNAL_ACCESS_CREATE);
1297 if (ret) { 1311 if (ret) {
1298 mlog_errno(ret); 1312 mlog_errno(ret);
1299 goto out_commit; 1313 goto out_commit;
@@ -1319,8 +1333,8 @@ static int ocfs2_expand_inline_dir(struct inode *dir, struct buffer_head *di_bh,
1319 * We let the later dirent insert modify c/mtime - to the user 1333 * We let the later dirent insert modify c/mtime - to the user
1320 * the data hasn't changed. 1334 * the data hasn't changed.
1321 */ 1335 */
1322 ret = ocfs2_journal_access(handle, dir, di_bh, 1336 ret = ocfs2_journal_access_di(handle, dir, di_bh,
1323 OCFS2_JOURNAL_ACCESS_CREATE); 1337 OCFS2_JOURNAL_ACCESS_CREATE);
1324 if (ret) { 1338 if (ret) {
1325 mlog_errno(ret); 1339 mlog_errno(ret);
1326 goto out_commit; 1340 goto out_commit;
@@ -1583,8 +1597,8 @@ do_extend:
1583 1597
1584 ocfs2_set_new_buffer_uptodate(dir, new_bh); 1598 ocfs2_set_new_buffer_uptodate(dir, new_bh);
1585 1599
1586 status = ocfs2_journal_access(handle, dir, new_bh, 1600 status = ocfs2_journal_access_db(handle, dir, new_bh,
1587 OCFS2_JOURNAL_ACCESS_CREATE); 1601 OCFS2_JOURNAL_ACCESS_CREATE);
1588 if (status < 0) { 1602 if (status < 0) {
1589 mlog_errno(status); 1603 mlog_errno(status);
1590 goto bail; 1604 goto bail;