diff options
-rw-r--r-- | fs/ocfs2/localalloc.c | 28 | ||||
-rw-r--r-- | fs/ocfs2/localalloc.h | 2 | ||||
-rw-r--r-- | fs/ocfs2/ocfs2.h | 6 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 10 |
4 files changed, 41 insertions, 5 deletions
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 880e4bc827be..e39a3e7146c9 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -75,6 +75,34 @@ static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, | |||
75 | static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, | 75 | static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, |
76 | struct inode *local_alloc_inode); | 76 | struct inode *local_alloc_inode); |
77 | 77 | ||
78 | void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb) | ||
79 | { | ||
80 | struct super_block *sb = osb->sb; | ||
81 | unsigned int la_default_mb = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE; | ||
82 | unsigned int la_max_mb; | ||
83 | |||
84 | la_max_mb = ocfs2_clusters_to_megabytes(sb, | ||
85 | ocfs2_local_alloc_size(sb) * 8); | ||
86 | |||
87 | mlog(0, "requested: %dM, max: %uM, default: %uM\n", | ||
88 | requested_mb, la_max_mb, la_default_mb); | ||
89 | |||
90 | if (requested_mb == -1) { | ||
91 | /* No user request - use defaults */ | ||
92 | osb->local_alloc_default_bits = | ||
93 | ocfs2_megabytes_to_clusters(sb, la_default_mb); | ||
94 | } else if (requested_mb > la_max_mb) { | ||
95 | /* Request is too big, we give the maximum available */ | ||
96 | osb->local_alloc_default_bits = | ||
97 | ocfs2_megabytes_to_clusters(sb, la_max_mb); | ||
98 | } else { | ||
99 | osb->local_alloc_default_bits = | ||
100 | ocfs2_megabytes_to_clusters(sb, requested_mb); | ||
101 | } | ||
102 | |||
103 | osb->local_alloc_bits = osb->local_alloc_default_bits; | ||
104 | } | ||
105 | |||
78 | static inline int ocfs2_la_state_enabled(struct ocfs2_super *osb) | 106 | static inline int ocfs2_la_state_enabled(struct ocfs2_super *osb) |
79 | { | 107 | { |
80 | return (osb->local_alloc_state == OCFS2_LA_THROTTLED || | 108 | return (osb->local_alloc_state == OCFS2_LA_THROTTLED || |
diff --git a/fs/ocfs2/localalloc.h b/fs/ocfs2/localalloc.h index ac5ea9f86653..04195c67f7c1 100644 --- a/fs/ocfs2/localalloc.h +++ b/fs/ocfs2/localalloc.h | |||
@@ -30,6 +30,8 @@ int ocfs2_load_local_alloc(struct ocfs2_super *osb); | |||
30 | 30 | ||
31 | void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb); | 31 | void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb); |
32 | 32 | ||
33 | void ocfs2_la_set_sizes(struct ocfs2_super *osb, int requested_mb); | ||
34 | |||
33 | int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, | 35 | int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, |
34 | int node_num, | 36 | int node_num, |
35 | struct ocfs2_dinode **alloc_copy); | 37 | struct ocfs2_dinode **alloc_copy); |
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h index 9552560df6cd..e98c954cf961 100644 --- a/fs/ocfs2/ocfs2.h +++ b/fs/ocfs2/ocfs2.h | |||
@@ -768,6 +768,12 @@ static inline unsigned int ocfs2_megabytes_to_clusters(struct super_block *sb, | |||
768 | return megs << (20 - OCFS2_SB(sb)->s_clustersize_bits); | 768 | return megs << (20 - OCFS2_SB(sb)->s_clustersize_bits); |
769 | } | 769 | } |
770 | 770 | ||
771 | static inline unsigned int ocfs2_clusters_to_megabytes(struct super_block *sb, | ||
772 | unsigned int clusters) | ||
773 | { | ||
774 | return clusters >> (20 - OCFS2_SB(sb)->s_clustersize_bits); | ||
775 | } | ||
776 | |||
771 | static inline void _ocfs2_set_bit(unsigned int bit, unsigned long *bitmap) | 777 | static inline void _ocfs2_set_bit(unsigned int bit, unsigned long *bitmap) |
772 | { | 778 | { |
773 | ext2_set_bit(bit, bitmap); | 779 | ext2_set_bit(bit, bitmap); |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 2a9f4c455f28..fc839996d052 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -94,7 +94,7 @@ struct mount_options | |||
94 | unsigned long mount_opt; | 94 | unsigned long mount_opt; |
95 | unsigned int atime_quantum; | 95 | unsigned int atime_quantum; |
96 | signed short slot; | 96 | signed short slot; |
97 | unsigned int localalloc_opt; | 97 | int localalloc_opt; |
98 | unsigned int resv_level; | 98 | unsigned int resv_level; |
99 | char cluster_stack[OCFS2_STACK_LABEL_LEN + 1]; | 99 | char cluster_stack[OCFS2_STACK_LABEL_LEN + 1]; |
100 | }; | 100 | }; |
@@ -1031,8 +1031,8 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) | |||
1031 | osb->s_atime_quantum = parsed_options.atime_quantum; | 1031 | osb->s_atime_quantum = parsed_options.atime_quantum; |
1032 | osb->preferred_slot = parsed_options.slot; | 1032 | osb->preferred_slot = parsed_options.slot; |
1033 | osb->osb_commit_interval = parsed_options.commit_interval; | 1033 | osb->osb_commit_interval = parsed_options.commit_interval; |
1034 | osb->local_alloc_default_bits = ocfs2_megabytes_to_clusters(sb, parsed_options.localalloc_opt); | 1034 | |
1035 | osb->local_alloc_bits = osb->local_alloc_default_bits; | 1035 | ocfs2_la_set_sizes(osb, parsed_options.localalloc_opt); |
1036 | osb->osb_resv_level = parsed_options.resv_level; | 1036 | osb->osb_resv_level = parsed_options.resv_level; |
1037 | 1037 | ||
1038 | status = ocfs2_verify_userspace_stack(osb, &parsed_options); | 1038 | status = ocfs2_verify_userspace_stack(osb, &parsed_options); |
@@ -1292,7 +1292,7 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
1292 | mopt->mount_opt = 0; | 1292 | mopt->mount_opt = 0; |
1293 | mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; | 1293 | mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; |
1294 | mopt->slot = OCFS2_INVALID_SLOT; | 1294 | mopt->slot = OCFS2_INVALID_SLOT; |
1295 | mopt->localalloc_opt = OCFS2_DEFAULT_LOCAL_ALLOC_SIZE; | 1295 | mopt->localalloc_opt = -1; |
1296 | mopt->cluster_stack[0] = '\0'; | 1296 | mopt->cluster_stack[0] = '\0'; |
1297 | mopt->resv_level = OCFS2_DEFAULT_RESV_LEVEL; | 1297 | mopt->resv_level = OCFS2_DEFAULT_RESV_LEVEL; |
1298 | 1298 | ||
@@ -1385,7 +1385,7 @@ static int ocfs2_parse_options(struct super_block *sb, | |||
1385 | status = 0; | 1385 | status = 0; |
1386 | goto bail; | 1386 | goto bail; |
1387 | } | 1387 | } |
1388 | if (option >= 0 && (option <= ocfs2_local_alloc_size(sb) * 8)) | 1388 | if (option >= 0) |
1389 | mopt->localalloc_opt = option; | 1389 | mopt->localalloc_opt = option; |
1390 | break; | 1390 | break; |
1391 | case Opt_localflocks: | 1391 | case Opt_localflocks: |