aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/ocfs2/localalloc.c34
-rw-r--r--fs/ocfs2/ocfs2.h10
-rw-r--r--fs/ocfs2/super.c8
3 files changed, 26 insertions, 26 deletions
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
index 28e492e4ec88..b05ce6642919 100644
--- a/fs/ocfs2/localalloc.c
+++ b/fs/ocfs2/localalloc.c
@@ -47,8 +47,6 @@
47 47
48#define OCFS2_LOCAL_ALLOC(dinode) (&((dinode)->id2.i_lab)) 48#define OCFS2_LOCAL_ALLOC(dinode) (&((dinode)->id2.i_lab))
49 49
50static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb);
51
52static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc); 50static u32 ocfs2_local_alloc_count_bits(struct ocfs2_dinode *alloc);
53 51
54static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, 52static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb,
@@ -75,21 +73,13 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
75static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, 73static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
76 struct inode *local_alloc_inode); 74 struct inode *local_alloc_inode);
77 75
78static inline int ocfs2_local_alloc_window_bits(struct ocfs2_super *osb)
79{
80 BUG_ON(osb->s_clustersize_bits > 20);
81
82 /* Size local alloc windows by the megabyte */
83 return osb->local_alloc_size << (20 - osb->s_clustersize_bits);
84}
85
86/* 76/*
87 * Tell us whether a given allocation should use the local alloc 77 * Tell us whether a given allocation should use the local alloc
88 * file. Otherwise, it has to go to the main bitmap. 78 * file. Otherwise, it has to go to the main bitmap.
89 */ 79 */
90int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits) 80int ocfs2_alloc_should_use_local(struct ocfs2_super *osb, u64 bits)
91{ 81{
92 int la_bits = ocfs2_local_alloc_window_bits(osb); 82 int la_bits = osb->local_alloc_bits;
93 int ret = 0; 83 int ret = 0;
94 84
95 if (osb->local_alloc_state != OCFS2_LA_ENABLED) 85 if (osb->local_alloc_state != OCFS2_LA_ENABLED)
@@ -120,14 +110,16 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb)
120 110
121 mlog_entry_void(); 111 mlog_entry_void();
122 112
123 if (osb->local_alloc_size == 0) 113 if (osb->local_alloc_bits == 0)
124 goto bail; 114 goto bail;
125 115
126 if (ocfs2_local_alloc_window_bits(osb) >= osb->bitmap_cpg) { 116 if (osb->local_alloc_bits >= osb->bitmap_cpg) {
127 mlog(ML_NOTICE, "Requested local alloc window %d is larger " 117 mlog(ML_NOTICE, "Requested local alloc window %d is larger "
128 "than max possible %u. Using defaults.\n", 118 "than max possible %u. Using defaults.\n",
129 ocfs2_local_alloc_window_bits(osb), (osb->bitmap_cpg - 1)); 119 osb->local_alloc_bits, (osb->bitmap_cpg - 1));
130 osb->local_alloc_size = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE; 120 osb->local_alloc_bits =
121 ocfs2_megabytes_to_clusters(osb->sb,
122 OCFS2_DEFAULT_LOCAL_ALLOC_SIZE);
131 } 123 }
132 124
133 /* read the alloc off disk */ 125 /* read the alloc off disk */
@@ -190,8 +182,7 @@ bail:
190 if (inode) 182 if (inode)
191 iput(inode); 183 iput(inode);
192 184
193 mlog(0, "Local alloc window bits = %d\n", 185 mlog(0, "Local alloc window bits = %d\n", osb->local_alloc_bits);
194 ocfs2_local_alloc_window_bits(osb));
195 186
196 mlog_exit(status); 187 mlog_exit(status);
197 return status; 188 return status;
@@ -490,7 +481,7 @@ int ocfs2_reserve_local_alloc_bits(struct ocfs2_super *osb,
490 goto bail; 481 goto bail;
491 } 482 }
492 483
493 if (bits_wanted > ocfs2_local_alloc_window_bits(osb)) { 484 if (bits_wanted > osb->local_alloc_bits) {
494 mlog(0, "Asking for more than my max window size!\n"); 485 mlog(0, "Asking for more than my max window size!\n");
495 status = -ENOSPC; 486 status = -ENOSPC;
496 goto bail; 487 goto bail;
@@ -803,7 +794,7 @@ static int ocfs2_local_alloc_reserve_for_window(struct ocfs2_super *osb,
803 goto bail; 794 goto bail;
804 } 795 }
805 796
806 (*ac)->ac_bits_wanted = ocfs2_local_alloc_window_bits(osb); 797 (*ac)->ac_bits_wanted = osb->local_alloc_bits;
807 798
808 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac); 799 status = ocfs2_reserve_cluster_bitmap_bits(osb, *ac);
809 if (status < 0) { 800 if (status < 0) {
@@ -849,7 +840,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
849 "one\n"); 840 "one\n");
850 841
851 mlog(0, "Allocating %u clusters for a new window.\n", 842 mlog(0, "Allocating %u clusters for a new window.\n",
852 ocfs2_local_alloc_window_bits(osb)); 843 osb->local_alloc_bits);
853 844
854 /* Instruct the allocation code to try the most recently used 845 /* Instruct the allocation code to try the most recently used
855 * cluster group. We'll re-record the group used this pass 846 * cluster group. We'll re-record the group used this pass
@@ -859,8 +850,7 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb,
859 /* we used the generic suballoc reserve function, but we set 850 /* we used the generic suballoc reserve function, but we set
860 * everything up nicely, so there's no reason why we can't use 851 * everything up nicely, so there's no reason why we can't use
861 * the more specific cluster api to claim bits. */ 852 * the more specific cluster api to claim bits. */
862 status = ocfs2_claim_clusters(osb, handle, ac, 853 status = ocfs2_claim_clusters(osb, handle, ac, osb->local_alloc_bits,
863 ocfs2_local_alloc_window_bits(osb),
864 &cluster_off, &cluster_count); 854 &cluster_off, &cluster_count);
865 if (status < 0) { 855 if (status < 0) {
866 if (status != -ENOSPC) 856 if (status != -ENOSPC)
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 7f625f2b1117..43dd42e313a1 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -252,7 +252,7 @@ struct ocfs2_super
252 struct ocfs2_journal *journal; 252 struct ocfs2_journal *journal;
253 unsigned long osb_commit_interval; 253 unsigned long osb_commit_interval;
254 254
255 int local_alloc_size; 255 unsigned int local_alloc_bits;
256 enum ocfs2_local_alloc_state local_alloc_state; 256 enum ocfs2_local_alloc_state local_alloc_state;
257 struct buffer_head *local_alloc_bh; 257 struct buffer_head *local_alloc_bh;
258 u64 la_last_gd; 258 u64 la_last_gd;
@@ -554,6 +554,14 @@ static inline unsigned int ocfs2_pages_per_cluster(struct super_block *sb)
554 return pages_per_cluster; 554 return pages_per_cluster;
555} 555}
556 556
557static inline unsigned int ocfs2_megabytes_to_clusters(struct super_block *sb,
558 unsigned int megs)
559{
560 BUILD_BUG_ON(OCFS2_MAX_CLUSTERSIZE > 1048576);
561
562 return megs << (20 - OCFS2_SB(sb)->s_clustersize_bits);
563}
564
557static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) 565static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb)
558{ 566{
559 spin_lock(&osb->osb_lock); 567 spin_lock(&osb->osb_lock);
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 70334d85aff1..3dee61ebd69a 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -637,7 +637,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
637 osb->s_atime_quantum = parsed_options.atime_quantum; 637 osb->s_atime_quantum = parsed_options.atime_quantum;
638 osb->preferred_slot = parsed_options.slot; 638 osb->preferred_slot = parsed_options.slot;
639 osb->osb_commit_interval = parsed_options.commit_interval; 639 osb->osb_commit_interval = parsed_options.commit_interval;
640 osb->local_alloc_size = parsed_options.localalloc_opt; 640 osb->local_alloc_bits = ocfs2_megabytes_to_clusters(sb, parsed_options.localalloc_opt);
641 641
642 status = ocfs2_verify_userspace_stack(osb, &parsed_options); 642 status = ocfs2_verify_userspace_stack(osb, &parsed_options);
643 if (status) 643 if (status)
@@ -938,6 +938,7 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
938{ 938{
939 struct ocfs2_super *osb = OCFS2_SB(mnt->mnt_sb); 939 struct ocfs2_super *osb = OCFS2_SB(mnt->mnt_sb);
940 unsigned long opts = osb->s_mount_opt; 940 unsigned long opts = osb->s_mount_opt;
941 unsigned int local_alloc_megs;
941 942
942 if (opts & OCFS2_MOUNT_HB_LOCAL) 943 if (opts & OCFS2_MOUNT_HB_LOCAL)
943 seq_printf(s, ",_netdev,heartbeat=local"); 944 seq_printf(s, ",_netdev,heartbeat=local");
@@ -970,8 +971,9 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
970 seq_printf(s, ",commit=%u", 971 seq_printf(s, ",commit=%u",
971 (unsigned) (osb->osb_commit_interval / HZ)); 972 (unsigned) (osb->osb_commit_interval / HZ));
972 973
973 if (osb->local_alloc_size != OCFS2_DEFAULT_LOCAL_ALLOC_SIZE) 974 local_alloc_megs = osb->local_alloc_bits >> (20 - osb->s_clustersize_bits);
974 seq_printf(s, ",localalloc=%d", osb->local_alloc_size); 975 if (local_alloc_megs != OCFS2_DEFAULT_LOCAL_ALLOC_SIZE)
976 seq_printf(s, ",localalloc=%d", local_alloc_megs);
975 977
976 if (opts & OCFS2_MOUNT_LOCALFLOCKS) 978 if (opts & OCFS2_MOUNT_LOCALFLOCKS)
977 seq_printf(s, ",localflocks,"); 979 seq_printf(s, ",localflocks,");