Skip to content

mkfs: factor the crap out of the code

Dave Chinner linux-xfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest42 patches 21 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/42mkfs: can't specify sector size of internal logmkfs/xfs_mkfs.c+4 -00 replies
2/42mkfs: make subopt table constmkfs/xfs_mkfs.c+15 -150 replies
3/42mkfs: introduce a structure to hold CLI optionsinclude/libxfs.h mkfs/xfs_mkfs.c+91 -180 replies
4/42mkfs: add generic subopt parsing tablemkfs/xfs_mkfs.c+130 -00 replies
5/42mkfs: factor block subopts parsermkfs/xfs_mkfs.c+22 -210 replies
6/42mkfs: factor data subopts parsermkfs/xfs_mkfs.c+91 -800 replies
7/42mkfs: factor inode subopts parsermkfs/xfs_mkfs.c+48 -460 replies
8/42mkfs: factor log subopts parsermkfs/xfs_mkfs.c+65 -620 replies
9/42mkfs: factor meta subopts parsermkfs/xfs_mkfs.c+28 -330 replies
10/42mkfs: factor naming subopts parsermkfs/xfs_mkfs.c+30 -380 replies
11/42mkfs: factor rt subopts parsermkfs/xfs_mkfs.c+26 -290 replies
12/42mkfs: factor sector subopts parsermkfs/xfs_mkfs.c+33 -360 replies
13/42mkfs: Introduce mkfs configuration structuremkfs/xfs_mkfs.c+87 -00 replies
14/42mkfs: factor printing of mkfs configmkfs/xfs_mkfs.c+35 -250 replies
15/42mkfs: factor in memory superblock setupmkfs/xfs_mkfs.c+82 -590 replies
16/42mkfs: factor out device preparationmkfs/xfs_mkfs.c+96 -710 replies
17/42mkfs: factor writing AG headersmkfs/xfs_mkfs.c+390 -3600 replies
18/42mkfs: factor secondary superblock updatesmkfs/xfs_mkfs.c+36 -270 replies
19/42mkfs: introduce default configuration structuremkfs/xfs_mkfs.c+61 -160 replies
20/42mkfs: rename top level CLI parametersmkfs/xfs_mkfs.c+12 -120 replies
21/42mkfs: factor sectorsize validationmkfs/xfs_mkfs.c+114 -930 replies
22/42mkfs: factor blocksize validationmkfs/xfs_mkfs.c+38 -300 replies
23/42mkfs: factor log sector size validationmkfs/xfs_mkfs.c+65 -360 replies
24/42mkfs: factor superblock feature validationmkfs/xfs_mkfs.c+127 -1010 replies
25/42mkfs: factor directory blocksize validationmkfs/xfs_mkfs.c+42 -360 replies
26/42mkfs: factor inode size validationmkfs/xfs_mkfs.c+53 -480 replies
27/42mkfs: factor out device size calculationsmkfs/xfs_mkfs.c+43 -510 replies
28/42mkfs: fix hidden parameter in DTOBT()mkfs/xfs_mkfs.c+14 -140 replies
29/42mkfs: factor rtdev extent size validationmkfs/xfs_mkfs.c+59 -490 replies
30/42mkfs: rework stripe calculationsmkfs/xfs_mkfs.c+180 -1500 replies
31/42mkfs: factor device openingmkfs/xfs_mkfs.c+51 -410 replies
32/42mkfs: factor data device validationmkfs/xfs_mkfs.c+49 -260 replies
33/42mkfs: factor log device validationmkfs/xfs_mkfs.c+89 -580 replies
34/42mkfs: factor rt device validationmkfs/xfs_mkfs.c+63 -460 replies
35/42mkfs: factor AG geometry calculationsmkfs/xfs_mkfs.c+42 -190 replies
36/42mkfs: factor AG alignmentmkfs/xfs_mkfs.c+117 -1291 reply
37/42mkfs: rework imaxpct calculationmkfs/xfs_mkfs.c+29 -360 replies
38/42mkfs: factor initial mount setupmkfs/xfs_mkfs.c+141 -1240 replies
39/42mkfs: factor log size calculationsmkfs/xfs_mkfs.c+217 -2031 reply
40/42mkfs: cleanup redundant temporary codemkfs/xfs_mkfs.c+34 -1510 replies
41/42mkfs: move error functionsmkfs/xfs_mkfs.c+157 -1670 replies
42/42mkfs: tidy up definitionsmkfs/xfs_mkfs.c+17 -240 replies

Reviews trailers per patch

None of the 42 patches has a Reviewed-by or Acked-by.

PatchChandan Rajendra
SeriesT-b
1/42
2/42
3/42
4/42
5/42
6/42
7/42
8/42
9/42
10/42
11/42
12/42
13/42
14/42
15/42
16/42
17/42
18/42
19/42
20/42
21/42
22/42
23/42
24/42
25/42
26/42
27/42
28/42
29/42
30/42
31/42
32/42
33/42
34/42
35/42
36/42
37/42
38/42
39/42
40/42
41/42
42/42

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/42] mkfs: factor the crap out of the code

Everyone who tries to modify mkfs quickly learns that it is a pile of spaghetti, the only difference in opinion is whether it is a steaming, cold or rotten pile. This patchset attempts to untangle the ball of pasta and turn it into a set of clear, obvious operations that lead to a filesystem being formatted correctly.

The patch series is really in three parts, splitting the code up into roughly three modules. The first part introduces a mkfs parameters structure and factors the on-disk formatting code to use only information in that structure. The second part introduces a command line input structure and factors the input parsing to use it. This requires a bunch of temporary code to keep the rest of the code working. The third part is factoring the input validation and geometry calculation code to use the input structure and put the output into the mkfs parameter structure and to remove all the temporary support code.

The result is three modules - input parsing, validation+calculations and formatting - with well defined data flow between them. This also paves the way to supporting config files to set defaults via a separate (new) module. The overall data flow now looks like this:

Build defaults --\
                  ---> mkfs_default_params -> CLI -> mkfs_params

config file -----/

It is not worth spending a lot of time reviewing the temporary code that is added - it gets removed before the end of the series. No attempt has been made to ensure that mkfs works 100% correctly after each patch is applied - the only guarantee is that it will build cleanly. It /should/ work if a bisect lands in the middle of the series, but trying to exhaustively test each patch is OK would take more effort than it is worth. As such, testing has only been performed on the whole series.

The new output from mkfs to indicate where it has sourced the defaults from causes xfstests to have conniptions. This requires some updates to the mkfs output filters that are already in place but it is a fairly trivial update. Test xfs/191 has a couple of new failures, but that is because the new code now correctly parses things like agsize so that block and sector size based specifications work with default mkfs values. This will require test updates.

Future work will be to split the xfs_mkfs.c file into a file per module (i.e. seperate files for CLI parsing, mkfs formating, validation+calculation and, finally, one for config file support), but otherwise the majority of the factoring work is now complete.

Comments, flames, etc all welcome.

-Dave.

Overall Diffstat:

 include/libxfs.h |    2 
 mkfs/xfs_mkfs.c  | 4615 ++++++++++++++++++++++++++++++-------------------------
 2 files changed, 2578 insertions(+), 2039 deletions(-)