dir.c (8a517c514d5893602cf85c1b4c47afbbc04d2198) dir.c (8cb471e8f82506937fe5e2e9fb0bf90f6b1f1170)
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * dir.c
5 *
6 * Creates, reads, walks and deletes directory-nodes
7 *
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.

--- 550 unchanged lines hidden (view full) ---

559 * what's passed in is assumed to be a valid directory block.
560 */
561static int ocfs2_read_dir_block_direct(struct inode *dir, u64 phys,
562 struct buffer_head **bh)
563{
564 int ret;
565 struct buffer_head *tmp = *bh;
566
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * dir.c
5 *
6 * Creates, reads, walks and deletes directory-nodes
7 *
8 * Copyright (C) 2002, 2004 Oracle. All rights reserved.

--- 550 unchanged lines hidden (view full) ---

559 * what's passed in is assumed to be a valid directory block.
560 */
561static int ocfs2_read_dir_block_direct(struct inode *dir, u64 phys,
562 struct buffer_head **bh)
563{
564 int ret;
565 struct buffer_head *tmp = *bh;
566
567 ret = ocfs2_read_block(dir, phys, &tmp, ocfs2_validate_dir_block);
567 ret = ocfs2_read_block(INODE_CACHE(dir), phys, &tmp,
568 ocfs2_validate_dir_block);
568 if (ret) {
569 mlog_errno(ret);
570 goto out;
571 }
572
573 if (ocfs2_supports_dir_trailer(dir)) {
574 ret = ocfs2_check_dir_trailer(dir, tmp);
575 if (ret) {

--- 41 unchanged lines hidden (view full) ---

617
618static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di,
619 struct buffer_head **dx_root_bh)
620{
621 int ret;
622 u64 blkno = le64_to_cpu(di->i_dx_root);
623 struct buffer_head *tmp = *dx_root_bh;
624
569 if (ret) {
570 mlog_errno(ret);
571 goto out;
572 }
573
574 if (ocfs2_supports_dir_trailer(dir)) {
575 ret = ocfs2_check_dir_trailer(dir, tmp);
576 if (ret) {

--- 41 unchanged lines hidden (view full) ---

618
619static int ocfs2_read_dx_root(struct inode *dir, struct ocfs2_dinode *di,
620 struct buffer_head **dx_root_bh)
621{
622 int ret;
623 u64 blkno = le64_to_cpu(di->i_dx_root);
624 struct buffer_head *tmp = *dx_root_bh;
625
625 ret = ocfs2_read_block(dir, blkno, &tmp, ocfs2_validate_dx_root);
626 ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp,
627 ocfs2_validate_dx_root);
626
627 /* If ocfs2_read_block() got us a new bh, pass it up. */
628 if (!ret && !*dx_root_bh)
629 *dx_root_bh = tmp;
630
631 return ret;
632}
633

--- 23 unchanged lines hidden (view full) ---

657}
658
659static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno,
660 struct buffer_head **dx_leaf_bh)
661{
662 int ret;
663 struct buffer_head *tmp = *dx_leaf_bh;
664
628
629 /* If ocfs2_read_block() got us a new bh, pass it up. */
630 if (!ret && !*dx_root_bh)
631 *dx_root_bh = tmp;
632
633 return ret;
634}
635

--- 23 unchanged lines hidden (view full) ---

659}
660
661static int ocfs2_read_dx_leaf(struct inode *dir, u64 blkno,
662 struct buffer_head **dx_leaf_bh)
663{
664 int ret;
665 struct buffer_head *tmp = *dx_leaf_bh;
666
665 ret = ocfs2_read_block(dir, blkno, &tmp, ocfs2_validate_dx_leaf);
667 ret = ocfs2_read_block(INODE_CACHE(dir), blkno, &tmp,
668 ocfs2_validate_dx_leaf);
666
667 /* If ocfs2_read_block() got us a new bh, pass it up. */
668 if (!ret && !*dx_leaf_bh)
669 *dx_leaf_bh = tmp;
670
671 return ret;
672}
673
674/*
675 * Read a series of dx_leaf blocks. This expects all buffer_head
676 * pointers to be NULL on function entry.
677 */
678static int ocfs2_read_dx_leaves(struct inode *dir, u64 start, int num,
679 struct buffer_head **dx_leaf_bhs)
680{
681 int ret;
682
669
670 /* If ocfs2_read_block() got us a new bh, pass it up. */
671 if (!ret && !*dx_leaf_bh)
672 *dx_leaf_bh = tmp;
673
674 return ret;
675}
676
677/*
678 * Read a series of dx_leaf blocks. This expects all buffer_head
679 * pointers to be NULL on function entry.
680 */
681static int ocfs2_read_dx_leaves(struct inode *dir, u64 start, int num,
682 struct buffer_head **dx_leaf_bhs)
683{
684 int ret;
685
683 ret = ocfs2_read_blocks(dir, start, num, dx_leaf_bhs, 0,
686 ret = ocfs2_read_blocks(INODE_CACHE(dir), start, num, dx_leaf_bhs, 0,
684 ocfs2_validate_dx_leaf);
685 if (ret)
686 mlog_errno(ret);
687
688 return ret;
689}
690
691static struct buffer_head *ocfs2_find_entry_el(const char *name, int namelen,

--- 1635 unchanged lines hidden (view full) ---

2327
2328 status = ocfs2_do_extend_dir(osb->sb, handle, inode, fe_bh,
2329 data_ac, NULL, &new_bh);
2330 if (status < 0) {
2331 mlog_errno(status);
2332 goto bail;
2333 }
2334
687 ocfs2_validate_dx_leaf);
688 if (ret)
689 mlog_errno(ret);
690
691 return ret;
692}
693
694static struct buffer_head *ocfs2_find_entry_el(const char *name, int namelen,

--- 1635 unchanged lines hidden (view full) ---

2330
2331 status = ocfs2_do_extend_dir(osb->sb, handle, inode, fe_bh,
2332 data_ac, NULL, &new_bh);
2333 if (status < 0) {
2334 mlog_errno(status);
2335 goto bail;
2336 }
2337
2335 ocfs2_set_new_buffer_uptodate(inode, new_bh);
2338 ocfs2_set_new_buffer_uptodate(INODE_CACHE(inode), new_bh);
2336
2337 status = ocfs2_journal_access_db(handle, inode, new_bh,
2338 OCFS2_JOURNAL_ACCESS_CREATE);
2339 if (status < 0) {
2340 mlog_errno(status);
2341 goto bail;
2342 }
2343 memset(new_bh->b_data, 0, osb->sb->s_blocksize);

--- 69 unchanged lines hidden (view full) ---

2413 (unsigned long long)OCFS2_I(dir)->ip_blkno,
2414 (unsigned long long)dr_blkno);
2415
2416 dx_root_bh = sb_getblk(osb->sb, dr_blkno);
2417 if (dx_root_bh == NULL) {
2418 ret = -EIO;
2419 goto out;
2420 }
2339
2340 status = ocfs2_journal_access_db(handle, inode, new_bh,
2341 OCFS2_JOURNAL_ACCESS_CREATE);
2342 if (status < 0) {
2343 mlog_errno(status);
2344 goto bail;
2345 }
2346 memset(new_bh->b_data, 0, osb->sb->s_blocksize);

--- 69 unchanged lines hidden (view full) ---

2416 (unsigned long long)OCFS2_I(dir)->ip_blkno,
2417 (unsigned long long)dr_blkno);
2418
2419 dx_root_bh = sb_getblk(osb->sb, dr_blkno);
2420 if (dx_root_bh == NULL) {
2421 ret = -EIO;
2422 goto out;
2423 }
2421 ocfs2_set_new_buffer_uptodate(dir, dx_root_bh);
2424 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dx_root_bh);
2422
2423 ret = ocfs2_journal_access_dr(handle, dir, dx_root_bh,
2424 OCFS2_JOURNAL_ACCESS_CREATE);
2425 if (ret < 0) {
2426 mlog_errno(ret);
2427 goto out;
2428 }
2429

--- 60 unchanged lines hidden (view full) ---

2490 for (i = 0; i < num_dx_leaves; i++) {
2491 bh = sb_getblk(osb->sb, start_blk + i);
2492 if (bh == NULL) {
2493 ret = -EIO;
2494 goto out;
2495 }
2496 dx_leaves[i] = bh;
2497
2425
2426 ret = ocfs2_journal_access_dr(handle, dir, dx_root_bh,
2427 OCFS2_JOURNAL_ACCESS_CREATE);
2428 if (ret < 0) {
2429 mlog_errno(ret);
2430 goto out;
2431 }
2432

--- 60 unchanged lines hidden (view full) ---

2493 for (i = 0; i < num_dx_leaves; i++) {
2494 bh = sb_getblk(osb->sb, start_blk + i);
2495 if (bh == NULL) {
2496 ret = -EIO;
2497 goto out;
2498 }
2499 dx_leaves[i] = bh;
2500
2498 ocfs2_set_new_buffer_uptodate(dir, bh);
2501 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), bh);
2499
2500 ret = ocfs2_journal_access_dl(handle, dir, bh,
2501 OCFS2_JOURNAL_ACCESS_CREATE);
2502 if (ret < 0) {
2503 mlog_errno(ret);
2504 goto out;
2505 }
2506

--- 493 unchanged lines hidden (view full) ---

3000 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
3001 dirdata_bh = sb_getblk(sb, blkno);
3002 if (!dirdata_bh) {
3003 ret = -EIO;
3004 mlog_errno(ret);
3005 goto out_commit;
3006 }
3007
2502
2503 ret = ocfs2_journal_access_dl(handle, dir, bh,
2504 OCFS2_JOURNAL_ACCESS_CREATE);
2505 if (ret < 0) {
2506 mlog_errno(ret);
2507 goto out;
2508 }
2509

--- 493 unchanged lines hidden (view full) ---

3003 blkno = ocfs2_clusters_to_blocks(dir->i_sb, bit_off);
3004 dirdata_bh = sb_getblk(sb, blkno);
3005 if (!dirdata_bh) {
3006 ret = -EIO;
3007 mlog_errno(ret);
3008 goto out_commit;
3009 }
3010
3008 ocfs2_set_new_buffer_uptodate(dir, dirdata_bh);
3011 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), dirdata_bh);
3009
3010 ret = ocfs2_journal_access_db(handle, dir, dirdata_bh,
3011 OCFS2_JOURNAL_ACCESS_CREATE);
3012 if (ret) {
3013 mlog_errno(ret);
3014 goto out_commit;
3015 }
3016

--- 365 unchanged lines hidden (view full) ---

3382
3383 status = ocfs2_do_extend_dir(osb->sb, handle, dir, parent_fe_bh,
3384 data_ac, meta_ac, &new_bh);
3385 if (status < 0) {
3386 mlog_errno(status);
3387 goto bail;
3388 }
3389
3012
3013 ret = ocfs2_journal_access_db(handle, dir, dirdata_bh,
3014 OCFS2_JOURNAL_ACCESS_CREATE);
3015 if (ret) {
3016 mlog_errno(ret);
3017 goto out_commit;
3018 }
3019

--- 365 unchanged lines hidden (view full) ---

3385
3386 status = ocfs2_do_extend_dir(osb->sb, handle, dir, parent_fe_bh,
3387 data_ac, meta_ac, &new_bh);
3388 if (status < 0) {
3389 mlog_errno(status);
3390 goto bail;
3391 }
3392
3390 ocfs2_set_new_buffer_uptodate(dir, new_bh);
3393 ocfs2_set_new_buffer_uptodate(INODE_CACHE(dir), new_bh);
3391
3392 status = ocfs2_journal_access_db(handle, dir, new_bh,
3393 OCFS2_JOURNAL_ACCESS_CREATE);
3394 if (status < 0) {
3395 mlog_errno(status);
3396 goto bail;
3397 }
3398 memset(new_bh->b_data, 0, sb->s_blocksize);

--- 1161 unchanged lines hidden (view full) ---

4560
4561remove_index:
4562 ret = ocfs2_dx_dir_remove_index(dir, di_bh, dx_root_bh);
4563 if (ret) {
4564 mlog_errno(ret);
4565 goto out;
4566 }
4567
3394
3395 status = ocfs2_journal_access_db(handle, dir, new_bh,
3396 OCFS2_JOURNAL_ACCESS_CREATE);
3397 if (status < 0) {
3398 mlog_errno(status);
3399 goto bail;
3400 }
3401 memset(new_bh->b_data, 0, sb->s_blocksize);

--- 1161 unchanged lines hidden (view full) ---

4563
4564remove_index:
4565 ret = ocfs2_dx_dir_remove_index(dir, di_bh, dx_root_bh);
4566 if (ret) {
4567 mlog_errno(ret);
4568 goto out;
4569 }
4570
4568 ocfs2_remove_from_cache(dir, dx_root_bh);
4571 ocfs2_remove_from_cache(INODE_CACHE(dir), dx_root_bh);
4569out:
4570 ocfs2_schedule_truncate_log_flush(osb, 1);
4571 ocfs2_run_deallocs(osb, &dealloc);
4572
4573 brelse(dx_root_bh);
4574 return ret;
4575}
4572out:
4573 ocfs2_schedule_truncate_log_flush(osb, 1);
4574 ocfs2_run_deallocs(osb, &dealloc);
4575
4576 brelse(dx_root_bh);
4577 return ret;
4578}