/etc/mkfs.ocfs2.conf support
Changes to support mkfs.ocfs2.conf
Mostly picked from e2fsprogs
---
mkfs.ocfs2/Makefile +9 -1
@@ -28,7 +28,7 @@ LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a INCLUDES = -I$(TOPDIR)/include -I. DEFINES = -DVERSION=\"$(VERSION)\" -CFILES = mkfs.c check.c +CFILES = prof_err.c profile.c mkfs.c check.c HFILES = mkfs.h OBJS = $(subst .c,.o,$(CFILES))
@@ -40,4 +40,12 @@ DIST_FILES = $(CFILES) $(HFILES) mkfs.ocfs2.8.in mkfs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS) $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) $(UUID_LIBS) +prof_err.c prof_err.h: prof_err.et + compile_et prof_err.et + +CLEAN_RULES = clean-err + +clean-err: + rm -f prof_err.c prof_err.h + include $(TOPDIR)/Postamble.make
mkfs.ocfs2/mkfs.c +120 -6
189 lines not on this page · raw message
mkfs.ocfs2/prof_err.et new file +47 -0
47 lines not on this page · raw message
mkfs.ocfs2/profile.c new file +1387 -0
1,387 lines not on this page · raw message
mkfs.ocfs2/profile.h new file +70 -0
70 lines not on this page · raw message
Quoted 58 lines · Goldwyn Rodrigues
Changes to support mkfs.ocfs2.conf
Mostly picked from e2fsprogs---
mkfs.ocfs2/Makefile +9
-1@@ -28,7 +28,7 @@ LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a INCLUDES = -I$(TOPDIR)/include -I. DEFINES = -DVERSION=\"$(VERSION)\" -CFILES = mkfs.c check.c +CFILES = prof_err.c profile.c mkfs.c check.c HFILES = mkfs.h OBJS = $(subst .c,.o,$(CFILES))@@ -40,4 +40,12 @@ DIST_FILES = $(CFILES) $(HFILES) mkfs.ocfs2.8.in mkfs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS) $(LIBO2DLM_DEPS) $(LIBO2CB_DEPS) $(LINK) $(LIBOCFS2_LIBS) $(LIBO2DLM_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) $(UUID_LIBS) +prof_err.c prof_err.h: prof_err.et + compile_et prof_err.et + +CLEAN_RULES = clean-err + +clean-err: + rm -f prof_err.c prof_err.h + include $(TOPDIR)/Postamble.makemkfs.ocfs2/mkfs.c +12
-0@@ -24,6 +24,9 @@*/ #include "mkfs.h" +#include "profile.h" + +profile_t profile;static State *get_state (int argc,char **argv);static int get_number (char *arg,uint64_t *res);@@ -507,11 +510,104 @@ parse_fs_type_opts(char *progname, const char *typestr, } } +static void syntax_err_report (const char *filename,long err,int line_num) +{ +fprintf (stderr,"Syntax error in mke2fs config file (%s, line #%d)\n\t%s\n" , filename, line_num,error_message (err)); +exit (1 ); +} + + +static const char *config_fn[] = {"/etc/mkfs.ocfs2.conf" ,0 }; +static const char *default_files[] = {"<default>" ,0 };
mkfs.ocfs2/mkfs.c parse_fs_type_opts(char *progname, const char *typestr, · line 531
Quoted 10 lines
mkfs.ocfs2/mkfs.c +10
-0+const char *mkfs_default_profile = +"[defaults]\n" +" block-size = 4096\n" +"\n" +"[fs_types]\n" +" datafiles = {\n" +" journal = {\n" +" size = 8192\n" +" }\n" +" }\n"
Is this making '-T datafiles' the default? It should not be...
--Mark
--
Mark Fasheh
Principal Software Developer, Oracle
[email protected]
Quoted 17 lines · Mark Fasheh
Quoted 4 lines · Goldwyn Rodrigues
mkfs.ocfs2/mkfs.c +3
-0+ +static const char *config_fn[] = {"/etc/mkfs.ocfs2.conf" ,0 }; +static const char *default_files[] = {"<default>" ,0 };mkfs.ocfs2/mkfs.c parse_fs_type_opts(char *progname, const char *typestr, · line 531
Quoted 10 lines
mkfs.ocfs2/mkfs.c +10
-0+const char *mkfs_default_profile = +"[defaults]\n" +" block-size = 4096\n" +"\n" +"[fs_types]\n" +" datafiles = {\n" +" journal = {\n" +" size = 8192\n" +" }\n" +" }\n" Is this making '-T datafiles' the default? It should not be...
Quoted 2 lines
--Mark
No, it does not. It means that whenever the user supplies '-T datafiles' in the command line, the journal size would be set to 8192 by default. This was the only default value I could interpret from the current code.
However, it does assume the default block size is 4K. I will remove that.
Signature · 1 line
Goldwyn
Quoted 2 lines · Goldwyn Rodrigues
Changes to support mkfs.ocfs2.conf
Mostly picked from e2fsprogs
Interesting. I didn't even know this existed :-) First thought
- what version of e2fsprogs is this from? I grabbed 1.40.4, the latest on my Debian installation, and its profile.c is very different.
mkfs.ocfs2/Makefile LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a · line 34
Quoted 13 lines
mkfs.ocfs2/Makefile +1
-1@@ -28,7 +28,7 @@ LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a INCLUDES = -I$(TOPDIR)/include -I. DEFINES = -DVERSION=\"$(VERSION)\" -CFILES = mkfs.c check.c +CFILES = prof_err.c profile.c mkfs.c check.c HFILES = mkfs.h OBJS = $(subst .c,.o,$(CFILES))
You can't put prof_err.c in CFILES - that will include it inDIST_FILES, which we don't want. Conversely, you need to add prof_err.et to DIST_FILES. I suggest
- Add prof_err.et to DIST_FILES
- Add prof_err.o to OBJS
This will force prof_err.o to be included in the mkfs.ocfs2 dependencies. .c.o rules will cause prof_err.c to be required, and this will trigger the compile_et of prof_err.et. Meanwhile, having prof_err.et in DIST_FILES makes sure it's part of the tarball.
See libocfs2/Makefile for how we do this. You might also want
to add HEADERS_GEN like you see in there so that you can declare:
HFILES = mkfs.hHFILES_GEN = prof_err.h
$(OBJS): $(HFILES) $(HFILES_GEN)
This triggers a build dependency on prof_err.h for all objects.
mkfs.ocfs2/Makefile
Quoted 6 lines
mkfs.ocfs2/Makefile +6
-0+ /* Read from the configuration file and set the values */ + blocksize = get_bytesize_from_profile(ft_str,"block-size" , blocksize); + cluster_size = get_bytesize_from_profile(ft_str, "cluster-size", cluster_size); + journal_size_in_bytes = get_journalsize_from_profile(ft_str, journal_size_in_bytes); + blockscount = get_bytesize_from_profile(ft_str, "blocks-count", blockscount); + initial_slots = get_uint_from_profile(ft_str, "number-of-nodes", initial_slots);
Here, you are relying on multiple things:
1) If the value is nonzero, nothing will happen. Why hide this above in get_*_from_profile()? Why not say
if (!blocksize) blocksize = get_bytesize_from_profile(ft_str, "block-size");
2) if ft_str is NULL, only the [defaults] section is honored. This is not obvious without reading profile.c, so one could think that it might select the first fs_type in the [fs_type] section. Put a comment in the get_*_from_profile() functions, right before you set names[1] = category, stating that NULL means ignored.
3) Setting these here will cause fill_defaults() to skip them. If get_*_from_profile() returns 0 (unset), fill_defaults() will fill them. This is the correct behavior, but it strikes me as non-obvious and could use a comment somewhere.
Joel
Signature · 9 lines
Life's Little Instruction Book #347 "Never waste the oppourtunity to tell someone you love them." Joel Becker Principal Software Developer Oracle E-mail: [email protected] Phone: (650) 506-8127
Quoted 7 lines · Joel Becker
Quoted 2 lines · Goldwyn Rodrigues
Changes to support mkfs.ocfs2.conf
Mostly picked from e2fsprogsInteresting. I didn't even know this existed :-) First thought
- what version of e2fsprogs is this from? I grabbed 1.40.4, the latest on my Debian installation, and itsprofile.cis very different.
I used 1.40.2, but I don't think the profile.c would be any different in the two versions.
What I changed from orignal e2fsprogs:
- changed the function prototype to take char *[], instead of separate name, subname and subsubname, in order to include a further level of attribute handling for journal
- removed the string and boolean parsing functions. These are not required now, but might be required in the future.
- removed the debug set, perhaps it could be included as a part of testing.
- the original profile in e2fsprogs has been picked from kerberos, and was split in multiple files. The old comments are still present. I removed them.
Quoted 29 lines
Quoted 6 lines
mkfs.ocfs2/Makefile +0
-0mkfs.ocfs2/Makefile LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a · line 34
Quoted 8 lines
mkfs.ocfs2/Makefile +1
-1@@ -28,7 +28,7 @@ LIBO2DLM_DEPS = $(TOPDIR)/libo2dlm/libo2dlm.a INCLUDES = -I$(TOPDIR)/include -I. DEFINES = -DVERSION=\"$(VERSION)\" -CFILES = mkfs.c check.c +CFILES = prof_err.c profile.c mkfs.c check.c HFILES = mkfs.h OBJS = $(subst .c,.o,$(CFILES))You can't put
prof_err.cin CFILES - that will include it inDIST_FILES, which we don't want. Conversely, you need to add prof_err.et toDIST_FILES. I suggest- Add prof_err.et to
DIST_FILES
- Add prof_err.o to OBJSThis will force prof_err.o to be included in the mkfs.ocfs2 dependencies. .c.o rules will cause
prof_err.cto be required, and this will trigger thecompile_etof prof_err.et. Meanwhile, having prof_err.et inDIST_FILESmakes sure it's part of the tarball.
See libocfs2/Makefile for how we do this. You might also want
to addHEADERS_GENlike you see in there so that you can declare:
Quoted 6 lines
HFILES =
mkfs.hHFILES_GEN=prof_err.h$(OBJS): $(HFILES) $(HFILES_GEN)
This triggers a build dependency on
prof_err.hfor all objects.
Ok, I understood this.
Quoted 10 lines
mkfs.ocfs2/Makefile
Quoted 7 lines
mkfs.ocfs2/Makefile +6
-0+ /* Read from the configuration file and set the values */ + blocksize = get_bytesize_from_profile(ft_str,"block-size" , blocksize); + cluster_size = get_bytesize_from_profile(ft_str, "cluster-size", cluster_size); + journal_size_in_bytes = get_journalsize_from_profile(ft_str, journal_size_in_bytes); + blockscount = get_bytesize_from_profile(ft_str, "blocks-count", blockscount); + initial_slots = get_uint_from_profile(ft_str, "number-of-nodes", initial_slots);Here, you are relying on multiple things:
Quoted 5 lines
1) If the value is nonzero, nothing will happen. Why hide this above in get_*_from_profile()? Why not say
if (!blocksize) blocksize = get_bytesize_from_profile(ft_str, "block-size");
Yes. This is the way it is done in e2fsprogs as well, but I thought of folding even the condition inside the function. I'll do it the way you suggested to avoid an additional function call.
Quoted 10 lines
2) if
ft_stris NULL, only the [defaults] section is honored. This is not obvious without readingprofile.c, so one could think that it might select the firstfs_typein the [fs_type] section. Put a comment in the get_*_from_profile() functions, right before you set names[1] = category, stating that NULL means ignored.
3) Setting these here will causefill_defaults()to skip them. If get_*_from_profile() returns 0 (unset),fill_defaults()will fill them. This is the correct behavior, but it strikes me as non-obvious and could use a comment somewhere.
I missed on the comments. will do it.
Thanks for the review, I shall re-post the patches soon.
Signature · 1 line
Goldwyn