[PATCH 00/19] mkfs cleaning

jtulak
2016-03-24T11:15:43Z

From: Jan Tulak <jtulak@redhat.com>

Hi guys,
a new iteration of this patchset after a long time.

(Jump down to the quote of the original post from Dave who started this set.)

I tried to solve all the issues you mentioned the last time (thanks for them!)
and I went also through more intense testing. As far as I'm aware, the only
few occassions where xfstests currently fails with this patchset is because
I fixed some wrong/not ideal behaviour in the original code. It should be
clean also from Coverity's point of view.

Some tests which now fails and will need a change are xfs/078, 206, 216
and 217. See "[PATCH 15/19] mkfs: don't treat files as though they are block
devices" for more details

Each specific patch has a changelog of the things chaged in it since the last
version.

I hope that this patchset is getting into a reasonable form. While it doesn't
clean everything, it greately cleans some parts of mkfs and fixes some issues.

And to remind what this patchset is about, here is the original Dave's email.

> Hi folks,
>␣
> This is still a work in progress, but is compelte enough to get
> feedback on the general structure. The problem being solved here is
> that mkfs does a terrible job of input validation from the command
> line, has huge amounts of repeated code in the sub options
> processing loops and has many, many unnecessary variable for
> tracking simply things like whether a parameter was specified.
>␣
> This patchset introduces a parameter table structure that is used to
> define the parameters and their constraints. Things like minimum and
> maximum valid values, default values, conflicting options, etc are
> all contained within the table, so all the "policy" is found in a
> single place.
>␣
> This greatly reduces the complexity of the option parsing loop. It
> doesn't remove all the complexity (yet) because many of the options
> have special cases or more complex conflicts than I've yet added
> support for. The idea is, however, that all of the sub-option
> parameter setup will eventually end up being implemented as a
> generic loop as the parameter structure will hold all the
> information about in the input parameters.
>␣
> To get there, the parameter table still needs more work - it needs
> to hold the value/string for the parameter, and we need to reference
> those in the code.
>␣
> The flow on effect of this is that we can remove the many, many
> individual variables and start passing the option structures to
> functions rather than avoiding using functions because passing so
> many variables is messy and nasty. IOWs, it lays the groundwork for
> factoring xfs_mkfs.c into something more than a bunch of spagetti...
>␣
> Anyway, have a look and see what you think about progress so far.
>␣
> FWIW, the first patch is following up on the multi-disk discussion
> Christoph and I had, and the last patch in the series covers all the
> issues that arose with "-d file" and treating files like block
> devices....
>␣
> Cheers,
>␣
> Dave.

Dave Chinner (15):
xfsprogs: use common code for multi-disk detection
mkfs: sanitise ftype parameter values.
mkfs: Sanitise the superblock feature macros
mkfs: validate all input values
mkfs: factor boolean option parsing
mkfs: validate logarithmic parameters sanely
mkfs: structify input parameter passing
mkfs: getbool is redundant
mkfs: use getnum_checked for all ranged parameters
mkfs: add respecification detection to generic parsing
mkfs: table based parsing for converted parameters
mkfs: merge getnum
mkfs: encode conflicts into parsing table
mkfs: add string options to generic parsing
mkfs: don't treat files as though they are block devices

Jan Tulak (4):
mkfs: move spinodes crc check
xfsprogs: disable truncating of files
mkfs: unit conversions are case insensitive
mkfs: add optional 'reason' for illegal_option

include/Makefile | 5 +-
include/xfs_multidisk.h | 73 ++
libxfs/init.c | 14 +-
libxfs/linux.c | 12 +-
man/man8/mkfs.xfs.8 | 37 +-
mkfs/Makefile | 2 +-
mkfs/maxtrres.c | 2 +-
mkfs/proto.c | 58 +-
mkfs/xfs_mkfs.c | 2003 +++++++++++++++++++++++++++++------------------
mkfs/xfs_mkfs.h | 89 ---
repair/xfs_repair.c | 44 +-
11 files changed, 1437 insertions(+), 902 deletions(-)
create mode 100644 include/xfs_multidisk.h
delete mode 100644 mkfs/xfs_mkfs.h

--
2.6.0