diff options
| -rw-r--r-- | fs/gfs2/dir.h | 1 | ||||
| -rw-r--r-- | fs/gfs2/ops_fstype.c | 67 | ||||
| -rw-r--r-- | fs/gfs2/super.c | 74 | ||||
| -rw-r--r-- | fs/gfs2/super.h | 1 |
4 files changed, 68 insertions, 75 deletions
diff --git a/fs/gfs2/dir.h b/fs/gfs2/dir.h index 8a468cac9328..4f919440c3be 100644 --- a/fs/gfs2/dir.h +++ b/fs/gfs2/dir.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #define __DIR_DOT_H__ | 11 | #define __DIR_DOT_H__ |
| 12 | 12 | ||
| 13 | #include <linux/dcache.h> | 13 | #include <linux/dcache.h> |
| 14 | #include <linux/crc32.h> | ||
| 14 | 15 | ||
| 15 | struct inode; | 16 | struct inode; |
| 16 | struct gfs2_inode; | 17 | struct gfs2_inode; |
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index fc300eafda84..4cae60f4a175 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #include "util.h" | 33 | #include "util.h" |
| 34 | #include "log.h" | 34 | #include "log.h" |
| 35 | #include "quota.h" | 35 | #include "quota.h" |
| 36 | #include "dir.h" | ||
| 36 | 37 | ||
| 37 | #define DO 0 | 38 | #define DO 0 |
| 38 | #define UNDO 1 | 39 | #define UNDO 1 |
| @@ -638,6 +639,72 @@ static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp) | |||
| 638 | sdp->sd_lockstruct.ls_lockspace); | 639 | sdp->sd_lockstruct.ls_lockspace); |
| 639 | } | 640 | } |
| 640 | 641 | ||
| 642 | /** | ||
| 643 | * gfs2_jindex_hold - Grab a lock on the jindex | ||
| 644 | * @sdp: The GFS2 superblock | ||
| 645 | * @ji_gh: the holder for the jindex glock | ||
| 646 | * | ||
| 647 | * Returns: errno | ||
| 648 | */ | ||
| 649 | |||
| 650 | static int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) | ||
| 651 | { | ||
| 652 | struct gfs2_inode *dip = GFS2_I(sdp->sd_jindex); | ||
| 653 | struct qstr name; | ||
| 654 | char buf[20]; | ||
| 655 | struct gfs2_jdesc *jd; | ||
| 656 | int error; | ||
| 657 | |||
| 658 | name.name = buf; | ||
| 659 | |||
| 660 | mutex_lock(&sdp->sd_jindex_mutex); | ||
| 661 | |||
| 662 | for (;;) { | ||
| 663 | error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, ji_gh); | ||
| 664 | if (error) | ||
| 665 | break; | ||
| 666 | |||
| 667 | name.len = sprintf(buf, "journal%u", sdp->sd_journals); | ||
| 668 | name.hash = gfs2_disk_hash(name.name, name.len); | ||
| 669 | |||
| 670 | error = gfs2_dir_check(sdp->sd_jindex, &name, NULL); | ||
| 671 | if (error == -ENOENT) { | ||
| 672 | error = 0; | ||
| 673 | break; | ||
| 674 | } | ||
| 675 | |||
| 676 | gfs2_glock_dq_uninit(ji_gh); | ||
| 677 | |||
| 678 | if (error) | ||
| 679 | break; | ||
| 680 | |||
| 681 | error = -ENOMEM; | ||
| 682 | jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL); | ||
| 683 | if (!jd) | ||
| 684 | break; | ||
| 685 | |||
| 686 | INIT_LIST_HEAD(&jd->extent_list); | ||
| 687 | jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1); | ||
| 688 | if (!jd->jd_inode || IS_ERR(jd->jd_inode)) { | ||
| 689 | if (!jd->jd_inode) | ||
| 690 | error = -ENOENT; | ||
| 691 | else | ||
| 692 | error = PTR_ERR(jd->jd_inode); | ||
| 693 | kfree(jd); | ||
| 694 | break; | ||
| 695 | } | ||
| 696 | |||
| 697 | spin_lock(&sdp->sd_jindex_spin); | ||
| 698 | jd->jd_jid = sdp->sd_journals++; | ||
| 699 | list_add_tail(&jd->jd_list, &sdp->sd_jindex_list); | ||
| 700 | spin_unlock(&sdp->sd_jindex_spin); | ||
| 701 | } | ||
| 702 | |||
| 703 | mutex_unlock(&sdp->sd_jindex_mutex); | ||
| 704 | |||
| 705 | return error; | ||
| 706 | } | ||
| 707 | |||
| 641 | static int init_journal(struct gfs2_sbd *sdp, int undo) | 708 | static int init_journal(struct gfs2_sbd *sdp, int undo) |
| 642 | { | 709 | { |
| 643 | struct inode *master = sdp->sd_master_dir->d_inode; | 710 | struct inode *master = sdp->sd_master_dir->d_inode; |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index b85877062a48..3dd9f5788cb0 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
| @@ -34,76 +34,6 @@ | |||
| 34 | #include "util.h" | 34 | #include "util.h" |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | * gfs2_jindex_hold - Grab a lock on the jindex | ||
| 38 | * @sdp: The GFS2 superblock | ||
| 39 | * @ji_gh: the holder for the jindex glock | ||
| 40 | * | ||
| 41 | * This is very similar to the gfs2_rindex_hold() function, except that | ||
| 42 | * in general we hold the jindex lock for longer periods of time and | ||
| 43 | * we grab it far less frequently (in general) then the rgrp lock. | ||
| 44 | * | ||
| 45 | * Returns: errno | ||
| 46 | */ | ||
| 47 | |||
| 48 | int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) | ||
| 49 | { | ||
| 50 | struct gfs2_inode *dip = GFS2_I(sdp->sd_jindex); | ||
| 51 | struct qstr name; | ||
| 52 | char buf[20]; | ||
| 53 | struct gfs2_jdesc *jd; | ||
| 54 | int error; | ||
| 55 | |||
| 56 | name.name = buf; | ||
| 57 | |||
| 58 | mutex_lock(&sdp->sd_jindex_mutex); | ||
| 59 | |||
| 60 | for (;;) { | ||
| 61 | error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, ji_gh); | ||
| 62 | if (error) | ||
| 63 | break; | ||
| 64 | |||
| 65 | name.len = sprintf(buf, "journal%u", sdp->sd_journals); | ||
| 66 | name.hash = gfs2_disk_hash(name.name, name.len); | ||
| 67 | |||
| 68 | error = gfs2_dir_check(sdp->sd_jindex, &name, NULL); | ||
| 69 | if (error == -ENOENT) { | ||
| 70 | error = 0; | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | |||
| 74 | gfs2_glock_dq_uninit(ji_gh); | ||
| 75 | |||
| 76 | if (error) | ||
| 77 | break; | ||
| 78 | |||
| 79 | error = -ENOMEM; | ||
| 80 | jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL); | ||
| 81 | if (!jd) | ||
| 82 | break; | ||
| 83 | |||
| 84 | INIT_LIST_HEAD(&jd->extent_list); | ||
| 85 | jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1); | ||
| 86 | if (!jd->jd_inode || IS_ERR(jd->jd_inode)) { | ||
| 87 | if (!jd->jd_inode) | ||
| 88 | error = -ENOENT; | ||
| 89 | else | ||
| 90 | error = PTR_ERR(jd->jd_inode); | ||
| 91 | kfree(jd); | ||
| 92 | break; | ||
| 93 | } | ||
| 94 | |||
| 95 | spin_lock(&sdp->sd_jindex_spin); | ||
| 96 | jd->jd_jid = sdp->sd_journals++; | ||
| 97 | list_add_tail(&jd->jd_list, &sdp->sd_jindex_list); | ||
| 98 | spin_unlock(&sdp->sd_jindex_spin); | ||
| 99 | } | ||
| 100 | |||
| 101 | mutex_unlock(&sdp->sd_jindex_mutex); | ||
| 102 | |||
| 103 | return error; | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 107 | * gfs2_jindex_free - Clear all the journal index information | 37 | * gfs2_jindex_free - Clear all the journal index information |
| 108 | * @sdp: The GFS2 superblock | 38 | * @sdp: The GFS2 superblock |
| 109 | * | 39 | * |
| @@ -580,10 +510,6 @@ static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, | |||
| 580 | struct gfs2_log_header_host lh; | 510 | struct gfs2_log_header_host lh; |
| 581 | int error; | 511 | int error; |
| 582 | 512 | ||
| 583 | error = gfs2_jindex_hold(sdp, &ji_gh); | ||
| 584 | if (error) | ||
| 585 | return error; | ||
| 586 | |||
| 587 | list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { | 513 | list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { |
| 588 | lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL); | 514 | lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL); |
| 589 | if (!lfcc) { | 515 | if (!lfcc) { |
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h index 1848dad3ecba..c6254596713a 100644 --- a/fs/gfs2/super.h +++ b/fs/gfs2/super.h | |||
| @@ -25,7 +25,6 @@ static inline unsigned int gfs2_jindex_size(struct gfs2_sbd *sdp) | |||
| 25 | return x; | 25 | return x; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh); | ||
| 29 | void gfs2_jindex_free(struct gfs2_sbd *sdp); | 28 | void gfs2_jindex_free(struct gfs2_sbd *sdp); |
| 30 | 29 | ||
| 31 | struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid); | 30 | struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid); |
