ocfs2: mount option localalloc
Subsystems (2)
The only difference from the last post is the change made to ocfs2.txt documenting the new mount option.
Sunil
PATCH 1/1 ocfs2: Local alloc window size changeable via mount option
Local alloc is a performance optimiztion in ocfs2 in which a node takes a window of bits from the global bitmap and then uses that for all small local allocations. This window size is fixed to 8MB currently. This patch allows users to specify the window size in MB including disabling it by passing in 0. If the number specified is too large, the fs will use the default value of 8MB.
mount -o localalloc=X /dev/sdX /mntpoint
--- Documentation/filesystems/ocfs2.txt | 3 ++ fs/ocfs2/localalloc.c | 41 ++++++++++++++++++++++++---------- fs/ocfs2/ocfs2.h | 1 + fs/ocfs2/ocfs2_fs.h | 8 ++++++ fs/ocfs2/suballoc.c | 5 ++- fs/ocfs2/super.c | 17 ++++++++++++++ 6 files changed, 61 insertions(+), 14 deletions(-)
Documentation/filesystems/ocfs2.txt +3 -0
@@ -62,3 +62,6 @@ data=writeback Data ordering is not preserved, data may be written preferred_slot=0(*) During mount, try to use this filesystem slot first. If it is in use by another node, the first empty one found will be chosen. Invalid values will be ignored. +localalloc=8(*) Allows custom localalloc size in MB. If the value is too + large, the fs will silently revert it to the default. + Localalloc is not enabled for local mounts.
fs/ocfs2/localalloc.c +29 -12
83 lines not on this page · raw message
fs/ocfs2/ocfs2.h +1 -0
@@ -232,6 +232,7 @@ struct ocfs2_superatomic_t needs_checkpoint;struct ocfs2_journal *journal; +int local_alloc_size;enum ocfs2_local_alloc_state local_alloc_state;struct buffer_head *local_alloc_bh;u64 la_last_gd;
fs/ocfs2/ocfs2_fs.h +8 -0
@@ -256,6 +256,14 @@ struct ocfs2_space_resv {/* Journal limits (in bytes) */ #define OCFS2_MIN_JOURNAL_SIZE (4 * 1024 * 1024) +/* +* Default local alloc size (in megabytes) +* +* The value chosen should be such that most allocations, including new +* block groups, use local alloc. +*/ +#define OCFS2_DEFAULT_LOCAL_ALLOC_SIZE 8 +struct ocfs2_system_inode_info {char *si_name;int si_iflags;
fs/ocfs2/suballoc.c +3 -2
@@ -1519,8 +1519,9 @@ int __ocfs2_claim_clusters(struct ocfs2_super *osb,if (min_clusters > (osb->bitmap_cpg -1 )) {/* The only paths asking for contiguousness * should know about this already. */ -mlog (ML_ERROR ,"minimum allocation requested exceeds " -"group bitmap size!" ); +mlog (ML_ERROR ,"minimum allocation requested %u exceeds " +"group bitmap size %u!\n" , min_clusters, + osb->bitmap_cpg); status = -ENOSPC ; goto bail; }
fs/ocfs2/super.c +17 -0
@@ -87,6 +87,7 @@ struct mount_optionsunsigned long mount_opt;unsigned int atime_quantum;signed short slot; +unsigned int localalloc_opt; }; static int ocfs2_parse_options(struct super_block *sb, char *options,
@@ -150,6 +151,7 @@ enum { Opt_data_writeback, Opt_atime_quantum, Opt_slot, + Opt_localalloc, Opt_err, };
@@ -165,6 +167,7 @@ static match_table_t tokens = { {Opt_data_writeback, "data=writeback"}, {Opt_atime_quantum, "atime_quantum=%u"}, {Opt_slot, "preferred_slot=%u"}, + {Opt_localalloc, "localalloc=%d"}, {Opt_err, NULL} };
@@ -597,6 +600,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) osb->s_mount_opt = parsed_options.mount_opt; osb->s_atime_quantum = parsed_options.atime_quantum; osb->preferred_slot = parsed_options.slot; + osb->local_alloc_size = parsed_options.localalloc_opt; sb->s_magic =OCFS2_SUPER_MAGIC ;
@@ -750,6 +754,7 @@ static int ocfs2_parse_options(struct super_block *sb, mopt->mount_opt =0 ; mopt->atime_quantum =OCFS2_DEFAULT_ATIME_QUANTUM ; mopt->slot =OCFS2_INVALID_SLOT ; + mopt->localalloc_opt =OCFS2_DEFAULT_LOCAL_ALLOC_SIZE ;if (!options) { status =1 ;
@@ -816,6 +821,15 @@ static int ocfs2_parse_options(struct super_block *sb,if (option) mopt->slot = (s16 )option;break ; +case Opt_localalloc: + option =0 ; +if (match_int (&args[0 ], &option)) { + status =0 ; + goto bail; + } +if (option >=0 && (option <=ocfs2_local_alloc_size (sb) *8 )) + mopt->localalloc_opt = option; +break ;default :mlog (ML_ERROR , "Unrecognized mount option \"%s\" "
@@ -864,6 +878,9 @@ static int ocfs2_show_options(struct seq_file *s, struct vfsmount *mnt)if (osb->s_atime_quantum !=OCFS2_DEFAULT_ATIME_QUANTUM )seq_printf (s,",atime_quantum=%u" , osb->s_atime_quantum); +if (osb->local_alloc_size !=OCFS2_DEFAULT_LOCAL_ALLOC_SIZE ) +seq_printf (s,",localalloc=%d" , osb->local_alloc_size); +return 0 ; }
Signature · 1 line
1.5.2.5
PATCH 1/1 ocfs2: Local alloc window size changeable via mount option
fs/ocfs2/localalloc.c static int ocfs2_local_alloc_new_window(struct ocfs2_super *osb, · line 83
Quoted 8 lines · Sunil Mushran
static inline int
ocfs2_local_alloc_window_bits(struct ocfs2_super *osb){fs/ocfs2/localalloc.c +2
-2-BUG_ON (osb->s_clustersize_bits <12 ); +BUG_ON (osb->s_clustersize_bits >20 ); -return 2048 >> (osb->s_clustersize_bits -12 ); +return osb->local_alloc_size << (20 - osb->s_clustersize_bits); }
Can we document the magic bit numbers somehow? I don't think we
need super-awesome defines or anything, just "20 is 1MB, we're calculating local_alloc_size in MB" or something like that.
Joel
Signature · 9 lines
"I always thought the hardest questions were those I could not answer. Now I know they are the ones I can never ask." - Charlie Watkins Joel Becker Principal Software Developer Oracle E-mail: [email protected] Phone: (650) 506-8127
PATCH 1/1 ocfs2: Local alloc window size changeable via mount option
In reply to Sunil MushranQuoted 6 lines · Sunil Mushran
Local alloc is a performance optimiztion in ocfs2 in which a node takes a window of bits from the global bitmap and then uses that for all small local allocations. This window size is fixed to 8MB currently. This patch allows users to specify the window size in MB including disabling it by passing in 0. If the number specified is too large, the fs will use the default value of 8MB.
Ok, committed and merged. I also added a comment to ocfs2_local_alloc_window_bits().
--Mark
--
Mark Fasheh
Principal Software Developer, Oracle
[email protected]