aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2018-04-30xfsprogs: Release v4.16.1HEADv4.16.1masterEric Sandeen4-2/+12
Update all the necessary files for a 4.16.1 release. Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-30fsck.xfs: do not use 'function' keywordEric Sandeen1-1/+1
It was pointed out on irc that fsck.xfs uses the 'function' keyword although it invokes /bin/sh - 'function' is a bashism. It's not needed here, so just remove it. Fixes: 04a2d5d ("fsck.xfs: allow forced repairs using xfs_repair") Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-26xfsprogs: Release v4.16.0v4.16.0Eric Sandeen4-2/+11
Update all the necessary files for a 4.16.0 release. Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfsprogs: Release v4.16.0-rc1v4.16.0-rc1Eric Sandeen3-3/+20
Update all the necessary files for a 4.16.0-rc1 release. Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_repair: fix getsubopt name definitions to use enumsDarrick J. Wong1-16/+24
Convert the getsubopt usage in xfs_repair to use enums and explicitly initialized array elements, similar to mkfs. This also fixes the hole in the o_opts table caused by 42fa89bc1b8dc8 ("xfs_repair: remove pre_65_beta option") that causes segfaults in xfs/179 and xfs/202. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Fixes: 42fa89bc1b ("xfs_repair: remove pre_65_beta option") Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub_all: use system encoding for lsblk output decodingDarrick J. Wong1-1/+1
Don't hardcode utf-8 as the decoding scheme for lsblk output, since the system could set it to anything else. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub_all: escape paths being passed to systemd service instancesDarrick J. Wong1-1/+23
systemd doesn't like unit instance names with slashes in them, so it replaces them with dashes when it invokes the service. However, it's not smart enough to convert the dashes to something else, so when it unescapes the instance name to feed to xfs_scrub, it turns all dashes into slashes. "/moo-cow" becomes "-moo-cow" becomes "/moo/cow", which is wrong. systemd actually /can/ escape the dashes correctly if it is told that this is a path (and not a unit name), but it didn't do this prior to January 2017, so fix this for them. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: disable private /tmp for scrub serviceDarrick J. Wong1-1/+2
Don't make /tmp private when invoking xfs_scrub as a service, because /tmp might contain or itself be an xfs filesystem mountpoint. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub_all: report versionDarrick J. Wong3-0/+22
Make xfs_scrub_all -V report its version like the other xfs tools. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: refactor mountpoint finding code to use libfrog path codeDarrick J. Wong6-94/+10
Use the libfrog path finding code to determine if the argument being passed in is a mountpoint, remove all mention of taking a block device (we have never supported that) from the documentation, and fix some potential memory leaks. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: don't warn about confusing names if dir/file only writable by rootDarrick J. Wong1-3/+31
If we are scanning the directory entries or attribute names of a dir/file and the inode can only be written by root, don't warn about Unicode confusable names by default because the system administrator presumably made the system like that. Also don't warn about really short confusable names because of the high chance of collisions. If the caller really wants all the output, they can run in verbose mode. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: use Unicode skeleton function to find confusing namesDarrick J. Wong1-27/+120
Drop the weak normalization-based Unicode name collision detection in favor of the confusable name guidelines provided in Unicode TR36 & TR39. This means that we transform the original name into its Unicode skeleton in order to do hashing-based collision detection. The Unicode skeleton is defined as nfd(translation(nfd(string))), which is to say that it flattens sequences that render ambiguously into a unambiguous format. For example, 'l' and '1' can render identically in some typefaces, so they're both squashed to 'l'. From the skeletons we can figure out if two names will look the same, and thereby complain about them. The unicode spoofing is provided by libicu, hence the switch away from libunistring. Note that potentially confusable names are only worth an informational warning, since it's entirely possible that with the system typefaces in use, two names will render distinctly enough that users can tell the difference. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: check name for suspicious charactersDarrick J. Wong1-0/+110
Look for suspicious characters in each name we process. This includes control characters, text direction overrides, zero-width code points, and names that mix characters from different directionalities. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: transition from libunistring to libicu for Unicode processingDarrick J. Wong9-46/+78
Move off of libunistring and onto libicu for Unicode name scanning. This will make it easy to warn about unicode code points that do not belong in identifiers (directional overrides, zero width elements) and warn about names that could render similarly enough to cause confusion. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: make name_entry a first class structureDarrick J. Wong1-107/+157
Instead of open-coding the construction and hashtable insertion of name entries, make name_entry a first class object. This means that we now have name_entry_ prefix functions that take care of computing Unicode normalized names as part of name_entry construction, and we pass around the name_entries when we're looking for suspicious characters and identically rendering names. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: communicate name problems via flagset instead of booleansDarrick J. Wong1-13/+30
Use an unsigned int to pass around name error flags instead of booleans. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: don't complain about different normalizationDarrick J. Wong1-10/+3
Since there are different ways to normalize utf8 names, don't complain when we find a name that is normalized in a different way than the NFKC that we use to find duplicate names. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: only run ascii name checks if unicode name checkerDarrick J. Wong1-11/+13
Skip the ASCII name checks if the Unicode name checker is going to run, since the latter covers everything that the former does. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-12xfs_scrub: avoid buffer overflow when scanning attributesDarrick J. Wong1-3/+3
Avoid a buffer overflow when we're formatting extended attribute names for name checking. The kernel headers provide us with XATTR_NAME_MAX, so we can rely on that. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03libxfs: warn about deprecation of irix, freebsd, darwinEric Sandeen3-0/+12
It's not clear that anyone is using these platforms or if they even build at this point. Get someone's attention if they are trying to use it. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: test XFS_SB_VERSION_SHAREDBIT only onceEric Sandeen1-10/+0
Remove 2 of the 3 identical tests for XFS_SB_VERSION_SHAREDBIT Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfsprogs: remove unused delete_attr_okEric Sandeen3-11/+4
delete_attr_ok is never set to anything but 1; remove it and all associated code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove pre_65_beta optionEric Sandeen2-12/+0
Irix 6.5 was released 20 years ago. Remove this option from the code. (nb: it's not present in the manpage.) Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove unused fs_shared_allowed variableEric Sandeen2-16/+0
The fs_shared_allowed global was set to 1 and then ignored, and in fact the feature is never actualy allowed. Remove it and the last stragglers of the old features comment. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove unused fs_has_extflgbit_allowedEric Sandeen3-19/+1
fs_has_extflgbit_allowed is never set to anything but 1; remove it and all associated code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove unused fs_sb_feature_bits_allowedEric Sandeen3-22/+2
fs_sb_feature_bits_allowed is never set to anything but 1; remove it and all associated code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove unused fs_aligned_inodes_allowedEric Sandeen3-19/+2
fs_aligned_inodes_allowed is never set to anything but 1; remove it and all associated code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove unused fs_has_extflgbit_allowedEric Sandeen3-30/+8
fs_has_extflgbit_allowed is never set to anything but 1; remove it and all associated code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove unused fs_attributes2_allowedEric Sandeen3-22/+3
fs_attributes2_allowed is never set to anything but 1; remove it and all associated code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-04-03xfs_repair: remove unused fs_attributes_allowedEric Sandeen3-23/+3
fs_attributes_allowed is never set to anything but 1; remove it and all associated code. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-27libfrog: handle NULL dir && blkdev in __fs_table_lookup_mountEric Sandeen1-0/+3
If neither dir nor blkdev is set, dpath never gets set, and then gets used (uninitalized) later on. If we are asked where "nothing" is mounted, just return "nowhere." Fixes-coverity-id: 1433615 Fixes-coverity-id: 1433616 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-27xfs_scrub: initialize movon in xfs_scrub_connectionsEric Sandeen1-1/+1
Given the logic in xfs_scrub_connections, it's possible to fail all 3 tests and wind up checking an uninitialized moveon variable at the end. Start out with "true" to avoid this and move on even if all the conditions in the function are false. Fixes-coverity-id: 1433617 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-27xfs_scrub: synchronize error levels & loggingEric Sandeen1-16/+13
Having only a subset of the five error_levels present in the log_level[] array is asking for trouble when someone tries to __str_log(S_PREEN ...) and overruns the array. Tie it all together in a single structure that's initialized together to make the mapping more obvious and idiot-proof. Fixes-coverity-id: 1433618 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-27xfs_spaceman: remove incorrect linux/fs.h includeDarrick J. Wong1-1/+0
Remove the direct linux/fs.h include from spaceman because all xfs utilities should include xfs.h so that we can wrap missing kernel header declarations properly. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26fsck.xfs: allow forced repairs using xfs_repairJan Tulak2-1/+63
The fsck.xfs script did nothing, because xfs doesn't need a fsck to be run on every unclean shutdown. However, sometimes it may happen that the root filesystem really requires the usage of xfs_repair and then it is a hassle. This patch makes the situation a bit easier by detecting forced checks (/forcefsck or fsck.mode=force) and invoking xfs_repair. Signed-off-by: Jan Tulak <jtulak@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26xfs_repair: add flag -e to modify exit code for corrected errorsJan Tulak2-6/+31
xfs_repair without -n ends with a return code 0 if it finished ok, no matter if there were some errors in the fs, or not. The new flag -e means that we can avoid screenscraping and parsing text output to detect if an error was found (and corrected). If something could not be corrected or in any other case than the "found something but fixed it all," the behaviour with this flag is unchanged. Signed-off-by: Jan Tulak <jtulak@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> [sandeen: make -e and -n exclusivity clear in manpage synopsis] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26metadump/restore: don't use errno after fwrite/fread failuresEric Sandeen2-9/+8
fread/fwrite don't set errno, so printing out strerror(errno) after a failure leads to incorrect and confusing messages: # xfs_mdrestore pre_repair.meta pre_repair.img xfs_mdrestore: error reading from file: Success Don't return unset errno from write_index, either. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26mkfs: enable sparse inodes by defaultDarrick J. Wong1-2/+2
Enable the sparse inode feature by default. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26xfs_fsr: refactor mountpoint finding to use libfrog paths functionsDarrick J. Wong4-79/+47
Refactor the mount-point finding code in fsr to use the libfrog helpers instead of open-coding yet another routine. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26libfrog: fs_table_lookup_mount should realpath the argumentDarrick J. Wong1-1/+4
Call realpath on the dir argument so that we're comparing canonical paths when looking for the mountpoint. This fixes the problem where '/home/' doesn't match '/home' even though they refer to the same thing. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26xfs_repair: use custom ifork verifier in mv_orphanageEric Sandeen1-1/+2
Now that we have a custom verifier which can ignore parent inode numbers, use it in mv_orphanage() as well; orphan inodes may have invalid parents, and we're about to reconnect them anyway, so override that test when we get them off disk. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26xfs_repair: implement custom ifork verifiersDarrick J. Wong2-1/+58
There are a few cases where an early stage of xfs_repair will write an invalid inode fork buffer to signal to a later stage that it needs to correct the value. This happens in phase 4 when we detect an inline format directory with an invalid .. pointer. To avoid triggering the ifork verifiers on this, inject a custom verifier for phase 6 that lets this pass for now. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26xfs_scrub: add missing paths headerBaruch Siach1-0/+1
Fix the following build failure with musl libc: xfs_scrub.c: In function ‘main’: xfs_scrub.c:670:11: error: ‘_PATH_MOUNTED’ undeclared (first use in this function) mtab = _PATH_MOUNTED; ^~~~~~~~~~~~~ Signed-off-by: Baruch Siach <baruch@tkos.co.il> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26workqueue: add missing pthreads headerBaruch Siach1-0/+2
Fix the following build failure with musl libc: In file included from read_verify.c:25:0: ../include/workqueue.h:39:2: error: unknown type name 'pthread_t' pthread_t *threads; ^~~~~~~~~ ../include/workqueue.h:42:2: error: unknown type name 'pthread_mutex_t' pthread_mutex_t lock; ^~~~~~~~~~~~~~~ ../include/workqueue.h:43:2: error: unknown type name 'pthread_cond_t' pthread_cond_t wakeup; ^~~~~~~~~~~~~~ Signed-off-by: Baruch Siach <baruch@tkos.co.il> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-26xfs_io: fix operation time reportingDave Chinner1-8/+8
CUrrently the 100th/sec units always report zero, such as: 32 MiB, 8192 ops; 0:00:21.00 (1.476 MiB/sec and 377.9260 ops/sec) ^^ This is incorrect. Fix the maths that is wrong by removing all the unnecesary floating point maths and just using basic integer division... Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_repair: don't fail directory repairs when grabbing inodesDarrick J. Wong6-20/+41
There are a few places where xfs_repair needs to be able to load a damaged directory inode to perform repairs. Since inline data fork verifiers can now be customized, refactor libxfs_iget to enable repair to get at this so that we don't crash in phase 6. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_db: print transaction reservation type informationDarrick J. Wong5-1/+68
Create a new xfs_db command to print the transaction reservation info for a given filesystem. This will make it easier to compare the calculations made by the kernel and xfsprogs in case there is a discrepancy. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_scrub: don't try to scan xattrs if bstat says there aren't anyDarrick J. Wong1-3/+6
Only try to scan the extended attributes of a file if bstat says that the file actually has any. Surprisingly, this reduces the phase 5 runtime by 40% if most of the files don't have attrs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_scrub: fix #include ordering to avoid build failureDarrick J. Wong21-90/+21
Fix the ordering of the header includes in all the scrub source. We put xfs.h first so that it will pull in include/linux.h which pulls in linux/fs.h + whatever overrides are necessary (currently limited to struct fsxattr) to make things work on this platform, and then we remove the #includes for anything that will get pulled (directly or indirectly) by xfs.h for cleanliness. Without this, a user compiling new xfsprogs on a system with a 4.7 kernel gets this: Building scrub [CC] disk.o In file included from ../include/xfs.h:37:0, from disk.c:40: ../include/xfs/linux.h:185:8: error: redefinition of 'struct fsxattr' struct fsxattr { ^~~~~~~ In file included from disk.c:31:0: /usr/include/linux/fs.h:155:8: note: originally defined here struct fsxattr { ^~~~~~~ gmake[2]: *** [../include/buildrules:60: disk.o] Error 1 gmake[1]: *** [include/buildrules:36: scrub] Error 2 make: *** [Makefile:77: default] Error 2 Reported-by: Mikael Magnusson <mikachu@gmail.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_scrub: don't ask user to run xfs_repair for only warningsDarrick J. Wong3-3/+8
Don't advise the user to run xfs_repair on a filesystem that triggers warnings but no errors; there's no corruption for it to fix. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_scrub: log operational messages when interactiveDarrick J. Wong5-5/+74
Record the summary of an interactive session in the system log so that future support requests can get a better picture of what happened. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_db: don't crash in ablock if there's no inodeDarrick J. Wong1-0/+5
Make sure we actually have an inode selected before trying to unwrap its attribute fork. Found via a crash in xfs/288 with project quotas enabled. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08misc: fix gcc 7.3 warningsDarrick J. Wong3-2/+4
Fix various compiler warnings that pop up in 7.3. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfsprogs: new libxfs-apply option for Signed-off-by: tagEric Sandeen1-1/+16
Technically when a maintainer moves a patch from another project, they should add their Signed-off-by: tag. Get that info automatically from git-config, and add an option to to override it if desired, to make that easy when cross-porting libxfs patches Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfsprogs: call libxfs_destroy from other utilitiesEric Sandeen4-0/+5
Call libxfs_destroy() from xfs_copy, xfs_db, mkfs.xfs, and xfs_repair to allow us to detect leaked items in these utilities as well. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08libxfs: Catch non-empty zones on destroyEric Sandeen3-13/+38
Create and use a kmem_zone_destroy which warns if we are releasing a non-empty zone when the LIBXFS_LEAK_CHECK environment variable is set, wire this into libxfs_destroy(), and call that when various tools exit. The LIBXFS_LEAK_CHECK environment variable also causes the program to exit with failure when a leak is detected, useful for failing automated tests if leaks are encountered. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08libxfs: move xfs_inode_zone to rdwr.cEric Sandeen2-3/+2
The zone itself is created in rdwr.c, so define it there as well, and add it to the list of externs in manage_zones along with all the rest, for consistency. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08libxfs: add function to free all buffers in bcacheEric Sandeen3-1/+23
libxfs_bcache_purge simply moves all "free" buffers onto the xfs_buf_freelist mru list; add a new function to actually free them when we tear everything down, so leak checkers don't go nuts about lots of unfreed xfs_bufs at exit. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08libxfs: Replace XFS_BUF_SET_PTR with xfs_buf_associate_memoryEric Sandeen2-6/+10
We test the return value of the macro, but it returns returns a side-effect which looks like failure. Write a userspace-libxfs-specific version of xfs_buf_associate_memory to make this code a tad more like the kernel, with a proper return value to boot. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_io: add RWF_DSYNC support to pwriteDave Chinner2-4/+14
Enable testing write behaviour with the per-io RWF_DSYNC flag. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_scrub: make interpreter explicit to python3Luis R. Rodriguez1-1/+1
Using #!/usr/bin/env makes some package dependency tools such as rpm complain given that it cannot verify package dependencies. Making it explicit resolves this lint rant. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_repair: Add missing braces to allow zeroing of corrupt logXiao Yang1-1/+2
When xlog_find_tail() fails to find the head or the tail, the missing braces leads that an unparseable log always exits with status 2, even if we've asked for -n or -L which should proceed. We can expose this issue by xfstests case xfs/098. Fixes: commit b04647edea32 ("xfs_repair: exit with status 2 if log dirtiness is unknown") Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_io: support a basic extent swap commandBrian Foster5-2/+116
Extent swap is a low level mechanism exported by XFS to facilitate filesystem defragmentation. It is typically invoked by xfs_fsr under conditions that will atomically adjust inode extent state without loss of file data. While xfs_fsr provides some debug capability to tailor its behavior, it is not flexible enough to facilitate low level tests of the extent swap mechanism. For example, xfs_fsr may skip swaps between inodes that consist solely of preallocated extents because it considers such files already 100% defragmented. Further, xfs_fsr copies data between files where doing so may be unnecessary and thus inefficient for lower level tests. Add a basic swapext command to xfs_io that allows userspace invocation of the command under more controlled conditions. This facilites targeted tests without interference from xfs_fsr policy, such as using files with only preallocated extents, known/expected failure cases, etc. This command makes no effort to retain data across the operation. As such, it is for testing purposes only. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08xfs_io: Add missing perror for write_once (-O)Goldwyn Rodrigues1-1/+3
This got missed in the last set of patches. Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08misc: enable link time optimization, if requestedDarrick J. Wong4-2/+49
Enable link time optimization (LTO) if the builder requests it. The extra link optimization results in smaller binaries. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-03-08misc: enable retpolines across all xfsprogs utilitiesDarrick J. Wong3-0/+30
Detect and enable retpolines for all code, to mitigate Spectre v2 (branch target injection) on x86. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-28xfs: fix u32 type usage in sb validation functionDarrick J. Wong0-0/+0
Source kernel commit: 131fa58d391fc0939f6c66b23776ad5df5db20f9 Don't use u32, use uint32_t, because this won't work in xfsprogs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> [sandeen: no-op commit, fixed previously to keep build working] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: don't screw up direct writes when freesp is fragmentedDarrick J. Wong1-0/+20
Source kernel commit: 6d8a45ce29c7d67cc4fc3016dc2a07660c62482a xfs_bmap_btalloc is given a range of file offset blocks that must be allocated to some data/attr/cow fork. If the fork has an extent size hint associated with it, the request will be enlarged on both ends to try to satisfy the alignment hint. If free space is fragmentated, sometimes we can allocate some blocks but not enough to fulfill any of the requested range. Since bmapi_allocate always trims the new extent mapping to match the originally requested range, this results in bmapi_write returning zero and no mapping. The consequences of this vary -- buffered writes will simply re-call bmapi_write until it can satisfy at least one block from the original request. Direct IO overwrites notice nmaps == 0 and return -ENOSPC through the dio mechanism out to userspace with the weird result that writes fail even when we have enough space because the ENOSPC return overrides any partial write status. For direct CoW writes the situation was disastrous because nobody notices us returning an invalid zero-length wrong-offset mapping to iomap and the write goes off into space. Therefore, if free space is so fragmented that we managed to allocate some space but not enough to map into even a single block of the original allocation request range, we should break the alignment hint in order to guarantee at least some forward progress for the direct write. If we return a short allocation to iomap_apply it'll call back about the remaining blocks. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: treat CoW fork operations as delalloc for quota accountingDarrick J. Wong1-2/+30
Source kernel commit: 4b4c1326fd7c7210d23d9dd3bfc51f2b6477bb9e Since the CoW fork only exists in memory, it is incorrect to update the on-disk quota block counts when we modify the CoW fork. Unlike the data fork, even real extents in the CoW fork are only delalloc-style reservations (on-disk they're owned by the refcountbt) so they must not be tracked in the on disk quota info. Ensure the i_delayed_blks accounting reflects this too. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor accounting updates out of xfs_bmap_btallocDarrick J. Wong1-13/+17
Source kernel commit: 751f3767c245f9adf4f0a4f8f04aae9ae1d675a0 Move all the inode and quota accounting updates out of xfs_bmap_btalloc in preparation for fixing some quota accounting problems with copy on write. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor inode verifier corruption error printingDarrick J. Wong4-11/+34
Source kernel commit: 22431bf3dfbf44d7356933776eb486a6a01dea6f Refactor inode verifier error reporting into a non-libxfs function so that we aren't encoding the message format in libxfs. This also changes the kernel dmesg output to resemble buffer verifier errors more closely. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: bmap code cleanupShan Hai1-24/+8
Source kernel commit: 6ca30729c206d62d88730a904af7d543a56273d8 Remove the extent size hint and realtime inode relevant code from the xfs_bmapi_reserve_delalloc since it is not called on the inode with extent size hint set or on a realtime inode. Signed-off-by: Shan Hai <shan.hai@oracle.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26Split buffer's b_fspriv fieldCarlos Maiolino15-41/+41
Source kernel commit: fb1755a645972ed096047583600838f6cf414e2b By splitting the b_fspriv field into two different fields (b_log_item and b_li_list). It's possible to get rid of an old ABI workaround, by using the new b_log_item field to store xfs_buf_log_item separated from the log items attached to the buffer, which will be linked in the new b_li_list field. This way, there is no more need to reorder the log items list to place the buf_log_item at the beginning of the list, simplifying a bit the logic to handle buffer IO. This also opens the possibility to change buffer's log items list into a proper list_head. b_log_item field is still defined as a void *, because it is still used by the log buffers to store xlog_in_core structures, and there is no need to add an extra field on xfs_buf just for xlog_in_core. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> [darrick: minor style changes] Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> [sandeen: b_li_list unused in userspace] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: convert to new i_version APIJeff Layton2-2/+8
Source kernel commit: f0e28280629e0ec7921f3179409a179b1ea41f24 Signed-off-by: Jeff Layton <jlayton@redhat.com> Acked-by: Darrick J. Wong <darrick.wong@oracle.com> Acked-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: check sb_agblocks and sb_agblklog when validating superblockDarrick J. Wong3-0/+39
Source kernel commit: 4bb73d014785cc55225686f9f46e7192fb59d26b Currently, we don't check sb_agblocks or sb_agblklog when we validate the superblock, which means that we can fuzz garbage values into those values and the mount succeeds. This leads to all sorts of UBSAN warnings in xfs/350 since we can then coerce other parts of xfs into shifting by ridiculously large values. Once we've validated agblocks, make sure the agcount makes sense. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> [sandeen: fix up u32 usage now so we keep building] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: recheck reflink / dirty page status before freeing CoW reservationsDarrick J. Wong1-1/+9
Source kernel commit: be78ff0e72778eb4df4aac66edb9e97462bfe00d Eryu Guan reported seeing occasional hangs when running generic/269 with a new fsstress that supports clonerange/deduperange. The cause of this hang is an infinite loop when we convert the CoW fork extents from unwritten to real just prior to writing the pages out; the infinite loop happens because there's nothing in the CoW fork to convert, and so it spins forever. The fundamental issue here is that when we go to perform these CoW fork conversions, we're supposed to have an extent waiting for us, but the low space CoW reaper has snuck in and blown them away! There are four conditions that can dissuade the reaper from touching our file -- no reflink iflag; dirty page cache; writeback in progress; or directio in progress. We check the four conditions prior to taking the locks, but we neglect to recheck them once we have the locks, which is how we end up whacking the writeback that's in progress. Therefore, refactor the four checks into a helper function and call it once again once we have the locks to make sure we really want to reap the inode. While we're at it, add an ASSERT for this weird condition so that we'll fail noisily if we ever screw this up again. Reported-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Tested-by: Eryu Guan <eguan@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: btree format ifork loader should check for zero numrecsDarrick J. Wong1-0/+1
Source kernel commit: 55e45429ce3e4ac9dd2bf4937b1a499a69ccc4ca A btree format inode fork with zero records makes no sense, so reject it if we see it, or else we can miscalculate memory allocations. Found by zeroes fuzzing {a,u3}.bmbt.numrecs in xfs/{374,378,412} with KASAN. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: attr leaf verifier needs to check for obviously bad countDarrick J. Wong1-5/+21
Source kernel commit: 79a69bf8dc240ebeb105226a8a8540df136bf987 In the attribute leaf verifier, we can check for obviously bad values of firstused and count so that later attempts at lasthash don't run off the end of the memory buffer. Found by ones fuzzing hdr.count in xfs/400 with KASAN. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: directory scrubber must walk through data block to offsetDarrick J. Wong3-22/+27
Source kernel commit: ce92d29ddf9908d397895c46b7c78e9db8df414d In xfs_scrub_dir_rec, we must walk through the directory block entries to arrive at the offset given by the hash structure. If we blindly trust the hash address, we can end up midway into a directory entry and stray outside the block. Found by lastbit fuzzing lents[3].address in xfs/390 with KASAN enabled. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: cross-reference the realtime bitmapDarrick J. Wong1-0/+21
Source kernel commit: 46d9bfb5e706493777b9dfed666cd8967f69e6fd While we're scrubbing various btrees, cross-reference the records with the other metadata. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: add scrub cross-referencing helpers for the refcount btreesDarrick J. Wong2-0/+22
Source kernel commit: 49db55eca5665e32c9d3e67a7d5694bcc6c274de Add a couple of functions to the refcount btrees that will be used to cross-reference metadata against the refcountbt. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: add scrub cross-referencing helpers for the rmap btreesDarrick J. Wong2-0/+72
Source kernel commit: ed7c52d4bf92ac1f05b8c251a44a8bf4688f8786 Add a couple of functions to the rmap btrees that will be used to cross-reference metadata against the rmapbt. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: add scrub cross-referencing helpers for the inode btreesDarrick J. Wong2-0/+105
Source kernel commit: 2e001266b67c865ad904e1889658282d0773b207 Add a couple of functions to the inode btrees that will be used to cross-reference metadata against the inobt. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: add scrub cross-referencing helpers for the free space btreesDarrick J. Wong4-1/+62
Source kernel commit: ce1d802e6a889b8ee53b3444c6d7e8cfecadac50 Add a couple of functions to the free space btrees that will be used to cross-reference metadata against the bnobt/cntbt, and a generic btree function that provides the real implementation. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: cancel tx on xfs_defer_finish() error during xattr set/removeBrian Foster1-4/+0
Source kernel commit: c468562879a766de2c2fbedd41b653a7bf4c157d Chris Dunlop reports a problem where an xattr operation fails, reports the following error to syslog and hangs during unmount: ================================================ [ BUG: lock held when returning to user space! ] ... ------------------------------------------------ <PID> is leaving the kernel with locks still held! 1 lock held by <PID>: #0: (sb_internal){......}, at: [<ffffffffa07692a3>] xfs_trans_alloc+0xe3/0x130 [xfs] The failure/shutdown occurs during deferred ops processing which leads to an error return from xfs_defer_finish() via xfs_attr_leaf_addname(). While the root cause of the failure is unknown corruption, the cause of the subsequent BUG above and unmount hang is failure to cancel the transaction before returning to userspace. The transaction is not cancelled because the out_defer_cancel error handling paths in the xfs_attr_[leaf|node]_[add|remove]name() functions clear args.trans without releasing the transaction. The callers therefore lose the reference to the transaction and fail to cancel it. Since xfs_attr_[set|remove]() always cancel args.trans when != NULL and xfs_defer_finish()->...->xfs_trans_roll() should always return with a valid transaction, update the leaf/node xattr functions to not reset args.trans in the error path responsible for cancelling deferred ops. Reported-by: Chris Dunlop <chris@onthe.net.au> Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: account finobt blocks properly in perag reservationBrian Foster1-4/+25
Source kernel commit: ad90bb585c45917b6c1bb01c812fba337e689362 XFS started using the perag metadata reservation pool for free inode btree blocks in commit 76d771b4cbe33 ("xfs: use per-AG reservations for the finobt"). To handle backwards compatibility, finobt blocks are accounted against the pool so long as the full reservation is available at mount time. Otherwise the ->m_inotbt_nores flag is set and the filesystem falls back to the traditional per-transaction finobt reservation. This commit has two problems: - finobt blocks are always accounted against the metadata reservation on allocation, regardless of ->m_inotbt_nores state - finobt blocks are never returned to the reservation pool on free The first problem affects reflink+finobt filesystems where the full finobt reservation is not available at mount time. finobt blocks are essentially stolen from the reflink reservation, putting refcountbt management at risk of allocation failure. The second problem is an unconditional leak of metadata reservation whenever finobt is enabled. Update the finobt block allocation callouts to consider ->m_inotbt_nores and account blocks appropriately. Blocks should be consistently accounted against the metadata pool when ->m_inotbt_nores is false and otherwise tagged as RESV_NONE. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: fix check on struct_version for versions 4 or greaterColin Ian King1-1/+1
Source kernel commit: a8789a5ae28f69d7f3791a0e74f8c44222f3108b It appears that the check for versions 4 or more is incorrect and is off-by-one. Fix this. Detected by CoverityScan, CID#1463775 ("Logically dead code") Fixes: ac503a4cc9e8 ("xfs: refactor the geometry structure filling function") Signed-off-by: Colin Ian King <colin.king@canonical.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: use %px for data pointers when debuggingDarrick J. Wong2-1/+11
Source kernel commit: c96900435fa9fdfd9702a60cd765bd85e380303e Starting with commit 57e734423ad ("vsprintf: refactor %pK code out of pointer"), the behavior of the raw '%p' printk format specifier was changed to print a 32-bit hash of the pointer value to avoid leaking kernel pointers into dmesg. For most situations that's good. This is /undesirable/ behavior when we're trying to debug XFS, however, so define a PTR_FMT that prints the actual pointer when we're in debug mode. Note that %p for tracepoints still prints the raw pointer, so in the long run we could consider rewriting some of these messages as tracepoints. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: change 0x%p -> %p in print messagesDarrick J. Wong3-3/+3
Source kernel commit: 3d170aa24283568b1ed92a09daa0e05a8788c6a4 Since %p prepends "0x" to the outputted string, we can drop the prefix. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: harden directory integrity checks some moreDarrick J. Wong1-0/+8
Source kernel commit: 46c59736d8090e602f960aeaf1c6b8292151bf38 If a malicious filesystem image contains a block+ format directory wherein the directory inode's core.mode is set such that S_ISDIR(core.mode) == 0, and if there are subdirectories of the corrupted directory, an attempt to traverse up the directory tree will crash the kernel in __xfs_dir3_data_check. Running the online scrub's parent checks will tend to do this. The crash occurs because the directory inode's d_ops get set to xfs_dir[23]_nondir_ops (it's not a directory) but the parent pointer scrubber's indiscriminate call to xfs_readdir proceeds past the ASSERT if we have non fatal asserts configured. Fix the null pointer dereference crash in __xfs_dir3_data_check by looking for S_ISDIR or wrong d_ops; and teach the parent scrubber to bail out if it is fed a non-directory "parent". Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor the geometry structure filling functionDarrick J. Wong4-75/+89
Source kernel commit: ac503a4cc9e8ab574032e3e217ffb555f5bf2341 Refactor the geometry structure filling function to use the superblock to fill the fields. While we're at it, make the function less indenty and use some whitespace to make the function easier to read. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: hoist xfs_fs_geometry to libxfsDarrick J. Wong2-0/+82
Source kernel commit: c368ebcd4cc3bbc08602adce083ad3cc76a15258 Move xfs_fs_geometry to libxfs so that we can clean up the fs geometry reporting in xfsprogs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: trace log reservations at mount timeDarrick J. Wong2-1/+4
Source kernel commit: b872af2c8700e9d64af8e13811b7679ede26ca00 At each mount, emit the transaction reservation type information via tracepoints. This makes it easier to compare the log reservation info calculated by the kernel and xfsprogs so that we can more easily diagnose minimum log size failures on freshly formatted filesystems. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: standardize quota verification function outputsDarrick J. Wong2-94/+54
Source kernel commit: eebf3cab9c5eac7fdb54fb9e9fb38c06f46f17f3 Rename xfs_dqcheck to xfs_dquot_verify and make it return an xfs_failaddr_t like every other structure verifier function. This enables us to check on-disk quotas in the same way that we check everything else. Callers are now responsible for logging errors, as XFS_QMOPT_DOWARN goes away. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: separate dquot repair into a separate functionDarrick J. Wong2-8/+17
Source kernel commit: eeea79802871fef82a8ca6ab1220515855e5cdcc Move the dquot repair code into a separate function and remove XFS_QMOPT_DQREPAIR in favor of calling the helper directly. Remove other dead code because quotacheck is the only caller of DQREPAIR. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: create a new buf_ops pointer to verify structure metadataDarrick J. Wong17-21/+125
Source kernel commit: b55725974c9d3a5afcdf83daff6fba7d3f91ffca Expose all metadata structure buffer verifier functions via buf_ops. These will be used by the online scrub mechanism to look for problems with buffers that are already sitting around in memory. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: fail out of xfs_attr3_leaf_lookup_int if it looks corruptDarrick J. Wong1-3/+6
Source kernel commit: 8ba92d43d499f4920af983a7c16e02304dd36932 If the xattr leaf block looks corrupt, return -EFSCORRUPTED to userspace instead of ASSERTing on debug kernels or running off the end of the buffer on regular kernels. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: provide a centralized method for verifying inline fork dataDarrick J. Wong5-24/+94
Source kernel commit: 9cfb9b47479e237d217dbcfafe034cbf98f45909 Replace the current haphazard dir2 shortform verifier callsites with a centralized verifier function that can be called either with the default verifier functions or with a custom set. This helps us strengthen integrity checking while providing us with flexibility for repair tools. xfs_repair wants this to be able to supply its own verifier functions when trying to fix possibly corrupt metadata. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor short form directory structure verifier functionDarrick J. Wong3-17/+16
Source kernel commit: dc042c2d8ff629dd411e9a60bce9c379e2f8aaf8 Change the short form directory structure verifier function to return the instruction pointer of a failing check or NULL if everything's ok. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: create structure verifier function for short form symlinksDarrick J. Wong2-0/+35
Source kernel commit: 0795e004fd4f2723f3dbf09a195cd7ccf3c74c58 Create a function to check the structure of short form symlink targets. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: create structure verifier function for shortform xattrsDarrick J. Wong4-0/+83
Source kernel commit: 1e1bbd8e7ee0624034e9bf1e91ac11a7aaa2f8a6 Create a function to perform structure verification for short form extended attributes. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: move inode fork verifiers to xfs_dinode_verifyDarrick J. Wong2-89/+69
Source kernel commit: 71493b839e294065ba63bd6f8d07263f3afee8c6 Consolidate the fork size and format verifiers to xfs_dinode_verify so that we can reject bad inodes earlier and in a single place. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: verify dinode header firstDarrick J. Wong1-10/+13
Source kernel commit: 50aa90ef03007beca2c9108993f5b4f2bb4f0a66 Move the v3 inode integrity information (crc, owner, metauuid) before we look at anything else in the inode so that we don't waste time on a torn write or a totally garbled block. This makes xfs_dinode_verify more consistent with the other verifiers. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor verifier callers to print address of failing checkDarrick J. Wong20-100/+205
Source kernel commit: bc1a09b8e334bf5fca1d6727aec538dcff957961 Refactor the callers of verifiers to print the instruction address of a failing check. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: have buffer verifier functions report failing addressDarrick J. Wong20-274/+322
Source kernel commit: a6a781a58befcbd467ce843af4eaca3906aa1f08 Modify each function that checks the contents of a metadata buffer to return the instruction address of the failing test so that we can report more precise failure errors to the log. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor xfs_verifier_error and xfs_buf_ioerrorDarrick J. Wong20-144/+79
Source kernel commit: 31ca03c92c329525ee3a97d99c47f1ebbaed5d63 Since all verification errors also mark the buffer as having an error, we can combine these two calls. Later we'll add a xfs_failaddr_t parameter to promote the idea of reporting corruption errors and the address of the failing check to enable better debugging reports. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: remove XFS_WANT_CORRUPTED_RETURN from dir3 data verifiersDarrick J. Wong3-53/+61
Source kernel commit: 9101d3707b9acae8bbb0d82d47e99cf5c60b3ee5 Since __xfs_dir3_data_check verifies on-disk metadata, we can't have it noisily blowing asserts and hanging the system on corrupt data coming in off the disk. Instead, have it return a boolean like all the other checker functions, and only have it noisily fail if we fail in debug mode. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor short form btree pointer verificationDarrick J. Wong1-6/+6
Source kernel commit: e1e55aaf1cc646b736439cbd5af229759029ae34 Now that we have xfs_verify_agbno, use it to verify short form btree pointers instead of open-coding them. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor long-format btree header verification routinesDarrick J. Wong3-20/+50
Source kernel commit: 8368a6019d5bbb8b56c140029dcf5ea570b638f1 Create two helper functions to verify the headers of a long format btree block. We'll use this later for the realtime rmapbt. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: remove XFS_FSB_SANITY_CHECKDarrick J. Wong4-9/+5
Source kernel commit: 59f6fec3bdb2aafc84d39f34000819d232182d71 We already have a function to verify fsb pointers, so get rid of the last users of the (less robust) macro. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: eliminate duplicate icreate tx reservation functionsBrian Foster1-46/+6
Source kernel commit: c017cb5ddfd6326032570d5eba83308c8a9c13a9 The create transaction reservation calculation has two different branches of code depending on whether the filesystem is a v5 format fs or older. Each branch considers the max reservation between the allocation case (new chunk allocation + record insert) and the modify case (chunk exists, record modification) of inode allocation. The modify case is the same for both superblock versions with the exception of the finobt. The finobt helper checks the feature bit, however, and so the modify case already shares the same code. Now that inode chunk allocation has been refactored into a helper that checks the superblock version to calculate the appropriate reservation for the create transaction, the only remaining difference between the create and icreate branches is the call to the finobt helper. As noted above, the finobt helper is a no-op when the feature is not enabled. Therefore, these branches are effectively duplicate and can be condensed. Remove the xfs_calc_create_*() branch of functions and update the various callers to use the xfs_calc_icreate_*() variant. The latter creates the same reservation size for v4 create transactions as the removed branch. As such, this patch does not result in transaction reservation changes. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: refactor inode chunk alloc/free tx reservationBrian Foster1-15/+49
Source kernel commit: 57af33e451b73f56feb428f5856cdf6e4e0c60cd The reservation for the various forms of inode allocation is scattered across several different functions. This includes two variants of chunk allocation (v5 icreate transactions vs. older create transactions) and the inode free transaction. To clean up some of this code and clarify the purpose of specific allocfree reservations, continue the pattern of defining helper functions for smaller operational units of broader transactions. Refactor the reservation into an inode chunk alloc/free helper that considers the various conditions based on filesystem format. An inode chunk free involves an extent free and buffer invalidations. The latter requires reservation for log headers only. An inode chunk allocation modifies the free space btrees and logs the chunk on v4 supers. v5 supers initialize the inode chunk using ordered buffers and so do not log the chunk. As a side effect of this refactoring, add one more allocfree res to the ifree transaction. Technically this does not serve a specific purpose because inode chunks are freed via deferred operations and thus occur after a transaction roll. tr_ifree has a bit of a history of tx overruns caused by too many agfl fixups during sustained file deletion workloads, so add this extra reservation as a form of padding nonetheless. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: include an allocfree res for inobt modificationsBrian Foster1-41/+43
Source kernel commit: f03c78f39710995d2766236f229295d91b8de9dd Analysis of recent reports of log reservation overruns and code inspection has uncovered that the reservations associated with inode operations may not cover the worst case scenarios. In particular, many cases only include one allocfree res. for a particular operation even though said operations may also entail AGFL fixups and inode btree block allocations in addition to the actual inode chunk allocation. This can easily turn into two or three block allocations (or frees) per operation. In theory, the only way to define the worst case reservation is to include an allocfree res for each individual allocation in a transaction. Since that is impractical (we can perform multiple agfl fixups per tx and not every allocation results in a full tree operation), we need to find a reasonable compromise that addresses the deficiency in practice without blowing out the size of the transactions. Since the inode btrees are not filled by the AGFL, record insertion and removal can directly result in block allocations and frees depending on the shape of the tree. These allocations and frees occur in the same transaction context as the inobt update itself, but are separate from the allocation/free that might be required for an inode chunk. Therefore, it makes sense to assume that an [f]inobt insert/remove can directly result in one or more block allocations on behalf of the tree. Refactor the inode transaction reservations to include one allocfree res. per inode btree modification to cover allocations required by the tree itself. This separates the reservation required to allocate the inode chunk from the reservation required for inobt record insertion/removal. Apply the same logic to the finobt. This results in killing off the finobt modify condition because we no longer assume that the broader transaction reservation will cover finobt block allocations and finobt shape changes can occur in either of the inobt allocation or modify situations. Suggested-by: Dave Chinner <david@fromorbit.com> Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: truncate transaction does not modify the inobtBrian Foster1-8/+1
Source kernel commit: a606ebdb859e78beb757dfefa08001df366e2ef5 The truncate transaction does not ever modify the inode btree, but includes an associated log reservation. Update xfs_calc_itruncate_reservation() to remove the reservation associated with inobt updates. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: fix up agi unlinked list reservationsBrian Foster1-3/+4
Source kernel commit: e8341d9f6348640dff01d8c4a33695dc82bab5a3 The current AGI unlinked list addition and removal reservations do not reflect the worst case log usage. An unlinked list removal can log up to two on-disk inode clusters but only includes reservation for one. An unlinked list addition logs the on-disk cluster but includes reservation for an in-core inode. Update the AGI unlinked list reservation helpers to calculate the correct worst case reservation for the associated operations. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfs: include inobt buffers in ifree tx log reservationBrian Foster1-9/+6
Source kernel commit: a6f485908d5210a5662f7a031bd1deeb3867e466 The tr_ifree transaction handles inode unlinks and inode chunk frees. The current transaction calculation does not accurately reflect worst case changes to the inode btree, however. The inobt portion of the current transaction reservation only covers modification of a single inobt buffer (for the particular inode record). This is a historical artifact from the days before XFS supported full inode chunk removal. When support for inode chunk removal was added in commit 254f6311ed1b ("Implement deletion of inode clusters in XFS."), the additional log reservation required for chunk removal was not added correctly. The new reservation only considered the header overhead of associated buffers rather than the full contents of the btrees and AGF and AGFL buffers affected by the transaction. The reservation for the free space btrees was subsequently fixed up in ITRUNCATE log reservation"), but the res. for full inobt joins has never been added. Further review of the ifree reservation uncovered a couple more problems: - The undocumented +2 blocks are intended for the AGF and AGFL, but are also not sized correctly and should be logged as full sectors (not FSBs). - The additional single block header is undocumented and serves no apparent purpose. Update xfs_calc_ifree_reservation() to include a full inobt join in the reservation calculation. Refactor the undocumented blocks appropriately and fix up the comments to reflect the current calculation. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26xfsprogs: Release v4.15.1v4.15.1Eric Sandeen4-2/+13
Update all the necessary files for a 4.15.1 release. Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26po/pl.po: update Polish translation for 4.15.0Jakub Bogusz1-1482/+2720
Polish translation update for xfsprogs 4.15.0 Signed-off-by: Jakub Bogusz <qboosh@pld-linux.org> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26debian: don't fail postinst when upgrading chrootDarrick J. Wong1-1/+1
If we're upgrading a systemd-enabled chroot we'll fail because systemctl can't connect to a running systemd (nor should it). We don't need to issue daemon-reload inside a chroot that doesn't have a running systemd, so we can ignore the return value. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Nathan Scott <nathans@debian.org> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-26debian: add build-depends on pkg-configDarrick J. Wong1-1/+1
Since the configure scripts now depend on pkg-config to autodetect where systemd service files go, we need to list pkg-config as a build dependency. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-23xfsprogs: Release v4.15.0v4.15.0Eric Sandeen4-3/+11
Update all the necessary files for a 4.15.0 release. Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-23Fix spelling mistake in mkfs lazy superblock diagnosticNathan Scott1-1/+1
Signed-off-by: <nathans@debian.org> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-23Fix grammar and spelling in strings and man pagesNathan Scott5-11/+11
Signed-off-by: Nathan Scott <nathans@debian.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-23Add xfs_scrub_fail systemd service file docs entryNathan Scott1-0/+1
Signed-off-by: Nathan Scott <nathans@debian.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-23Update .gitignore list for generated scrub cron fileNathan Scott1-0/+1
Signed-off-by: Nathan Scott <nathans@debian.org> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-23Several updates to use more modern Debian packagingNathan Scott6-5/+22
Switch to Debian packaging features available in more recent years to resolve some long-standing issues. In particular, using the quilt format gives non-native package builds finally, while keeping the ability for developers to do upstream deb builds. Also split the binary-arch and binary-indep debian/rules targets as is now mandated, and update to latest standard version. Mark a bunch of long-resolved bugs as fixed in the deb changelog so they are automatically closed by the next update. Signed-off-by: Nathan Scott <nathans@debian.org> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-13xfsprogs: Release v4.15.0-rc1v4.15.0-rc1Eric Sandeen3-3/+14
Update all the necessary files for a 4.15.0-rc1 release. Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-13xfs_scrub: refactor outcome display into a separate helperDarrick J. Wong1-18/+28
Move all the printing of the scrub outcome into a separate helper to declutter the main function. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> [sandeen: put "Unmount ..." on its own line] Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-12xfs_scrub: always init phase informationDarrick J. Wong1-5/+5
Make sure we initialize the overall phase state before we start executing any code that can end up in the report-status-and-exit paths. Otherwise if debugging is turned on we get garbage io/cpu stat reports. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-12xfs_scrub: reclassify some of the warning messagesDarrick J. Wong2-5/+5
Some of the warning messages are actually runtime errors in optional components, so turn them into informational messages. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-12xfs_scrub: reclassify runtime errorsDarrick J. Wong10-25/+25
If the program encounters runtime errors, these should be noted as information. Because these errors abort the execution flow (which is counted as a runtime error), we need only call str_info to log the event. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-12xfs_scrub: classify lack of ioctl support as a runtime errorDarrick J. Wong1-2/+2
If the kernel doesn't have the SCRUB_METADATA ioctl that's a runtime error, not a fs error. Account it as such. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-12xfs_scrub: remove preen modeDarrick J. Wong6-82/+32
While it's true that the kernel can tell us whether something needs repairs or it needs optimizing, from the admin's perspective there's no point in having an optimize-only mode -- either fix everything, or don't. This is what xfs_repair does w.r.t. -n, so let's do the same thing too. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-05xfs_mdrestore: Don't rewind source file streamMarco Benatto1-35/+33
Today, xfs_mdrestore from stdin will fail if the -i flag is specified, because it attempts to rewind the stream after the initial read of the metablock. This fails, and results in an abort with "specified file is not a metadata dump." Read the metablock exactly once in main(), validate the magic, print informational flags if requested, and then pass it to perform_restore() which will then continue the restore process. Reported-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Marco A Benatto <marco.antonio.780@gmail.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-05xfs_mdrestore: Add -i option to built-in helpMarco Benatto1-1/+1
Currently we are missing -i option from usage(). This patch adds it to this biult-in help. Signed-off-by: Marco A Benatto <marco.antonio.780@gmail.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-05xfs_io: fix copy_file_range symbol name collisionDarrick J. Wong1-3/+8
glibc 2.27 has a copy_file_range wrapper, so we need to change our internal function out of the way to avoid compiler warnings. Reported-by: fredrik@crux.nu Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-05xfs_scrub: kill dead codeDarrick J. Wong1-1/+0
We can't reach the return mess at the bottom of __xfs_scrub_test so get rid of it. Fixes-coverity-id: 1428798 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-05xfs_scrub: close dir_fd if we don't get a DIR pointerDarrick J. Wong1-0/+2
If we don't get a directory pointer, close dir_fd before jumping out. Fixes-coverity-id: 1428799 Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-05mkfs: don't create realtime filesystems with reflink enabledDarrick J. Wong1-0/+7
We don't support reflink on the realtime device, so don't let people create such things. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: handle scrub-only kernels more helpfullyEric Sandeen1-3/+3
If xfs_scrub is run today against a 4.15 kernel, it fails with EXPERIMENTAL xfs_scrub program in use! Use at your own risk! Error: /home: Kernel metadata optimization facility is required. Info: /home: Scrub aborted after phase 1. /home: 2 errors found. Be a bit kinder to the user and suggest a path forward. By the time we fail for missing preen or repair functionality, we do know that scrub is available, so suggest it. Further, rather than stating what is required, state what was not found ... we're failing, so state what was missing, vs. what is required - seems a bit more definitive. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: wire up repair ioctlDarrick J. Wong9-0/+188
Create the mechanism we need to actually call the kernel's online repair functionality. The interface will consume a repair description; the descriptor management will follow in the next patch. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02debian/control: remove nonexistent libreadline5-dev build dependencyDarrick J. Wong1-1/+1
libreadline5-dev hasn't existed as a package for quite some time now; even Debian "oldoldstable" doesn't know what that is. Drop it in favor of libreadline-gplv2-dev. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: integrate services with systemdDarrick J. Wong15-1/+285
Create a systemd service unit so that we can run the online scrubber under systemd with (somewhat) appropriate containment. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: create a script to scrub all xfs filesystemsDarrick J. Wong4-5/+200
Create an xfs_scrub_all command to find all XFS filesystems and run an online scrub against them all. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: progress indicatorDarrick J. Wong14-8/+460
Implement a progress indicator. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: fstrim the free areas if there are no errors on the filesystemDarrick J. Wong7-2/+131
If the filesystem scan comes out clean or fixes all the problems, call fstrim to clean out the free areas (if it's an ssd/thinp/whatever). Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: check summary countersDarrick J. Wong6-1/+302
Make sure the filesystem summary counters are somewhat close to what we can find by scanning the filesystem. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: optionally use SCSI READ VERIFY commands to scrub data blocks on diskDarrick J. Wong6-1/+188
If we sense that we're talking to a raw SCSI disk, use the SCSI READ VERIFY command to ask the disk to verify a disk internally. This can sharply reduce the runtime of the data block verification phase on devices whose internal bandwidth exceeds their link bandwidth. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: scrub file data blocksDarrick J. Wong9-2/+815
Read all data blocks from the disk, hoping to catch IO errors. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: create infrastructure to read verify data blocksDarrick J. Wong4-0/+323
Manage the scheduling, issuance, and reporting of data block verification reads. This enables us to combine adjacent (or nearly adjacent) read requests, and to take advantage of high-IOPS devices by issuing IO from multiple threads. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: create a bitmap data structureDarrick J. Wong3-0/+450
Create an efficient tree-based bitmap data structure. We will use this during the data block scan to record the LBAs of IO errors so that we can report broken files to userspace. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: warn about normalized Unicode name collisionsDarrick J. Wong10-26/+514
Iterate all directory and xattr names to look for name collisions amongst Unicode normalized names. This is generally a sign of buggy programs or malicious duplicate files. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: warn about suspicious characters in directory/xattr namesDarrick J. Wong10-1/+285
Look for control characters and punctuation that interfere with shell globbing in directory entry names and extended attribute key names. Technically these aren't filesystem corruptions because names are arbitrary sequences of bytes, but they've been known to cause problems in the Unix environment so warn if we see them. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: check directory connectivityDarrick J. Wong4-0/+104
Opening directories by file handle will cause the kernel to perform parent lookups all the way to the root directory. Take advantage of this to ensure that directories actually connect to the root. Some day we'll have parent pointers and can make this more comprehensive. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: scan inodesDarrick J. Wong4-0/+156
Scan all the inodes in the system for problems. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: thread-safe stats counterDarrick J. Wong6-0/+301
Create a threaded stats counter that we'll use to track scan progress. This includes things like how much of the disk blocks we've scanned, or later how much progress we've made in each phase. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: scan filesystem and AG metadataDarrick J. Wong4-0/+136
Scrub the filesystem and per-AG metadata. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: wrap the scrub ioctlDarrick J. Wong6-0/+716
Create some wrappers to call the scrub ioctls. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: filesystem counter collection functionsDarrick J. Wong3-0/+243
Add a couple of helper functions to estimate the inode and block counters on the filesystem. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: add file space map iteration functionsDarrick J. Wong3-0/+198
These helpers enable userspace to iterate all the space map information for a file. The iteration function uses GETBMAPX. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: add space map iteration functionsDarrick J. Wong3-0/+289
These helpers enable userspace to iterate all the space map information in a filesystem. The iteration function uses GETFSMAP. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: add inode iteration functionsDarrick J. Wong3-0/+331
These helpers enable userspace to count or iterate all inodes in a filesystem. The counting function uses INUMBERS, while the inode iterator uses INUMBERS and BULKSTAT to iterate over every inode that should be in the filesystem. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: find XFS filesystem geometryDarrick J. Wong7-1/+376
Discover the geometry of the XFS filesystem that we've been told to scan, and set up some common functions that will be used by the scrub phases. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: create an abstraction for a block deviceDarrick J. Wong3-0/+209
Create an abstraction to handle all of our low level disk operations. We'll eventually use it to bind to a fs mount point and block device. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: figure out how many threads we're going to needDarrick J. Wong3-0/+31
Create the plumbing to figure out how many threads we're going to want to do all of our scrubbing. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: dispatch the various phases of the scrub programDarrick J. Wong7-0/+371
Create the dispatching routines that we'll use to call out to each separate phase of the program. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: set up command line argument parsingDarrick J. Wong3-1/+266
Parse command line options in order to set up the context in which we will scrub the filesystem. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: common error handlingDarrick J. Wong4-0/+133
Standardize how we record and report errors. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_scrub: create online filesystem scrub programDarrick J. Wong9-2/+356
Create the foundations of a filesystem scrubbing tool that asks the kernel to inspect all metadata in the filesystem and (ultimately) to repair anything that's broken. Also create the man page for the utility. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02mkfs: more sunit/swidth sanity checkingEric Sandeen1-3/+3
This fixes 2 issues with stripe geometry validation. # mkfs.xfs -d sunit=64,swidth=0 ... both data sunit and data swidth options must be specified But I did specify it, I specified 0! So use cli_opt_set() to detect that it was specified. But we can't allow the above configuration (in fact it causes a % 0 later in mkfs), so catch it in the "swidth must be a multiple of sunit" test a bit further down. (sunit=0,swidth=0 /is/ valid, it's used to override disk geometry if desired.) Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02mkfs: always explain why numeric inputs are invalidDarrick J. Wong1-6/+8
Always explain why invalid numeric inputs are not valid, and in a complete sentence since that's what illegal_optio() sets us up for. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02mkfs: don't call values 'illegal', they're invalidDarrick J. Wong1-2/+2
Specifying invalid inputs to mkfs does not break any (reasonable) laws, so the error message should complain about invalid inputs. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02mkfs: don't crash on dswidth overflowDarrick J. Wong1-1/+9
I ran mkfs.xfs -d su=1048576,sw=$((18 * 1048576)), forgetting that sw takes a multiple of su (unlike swidth which takes any space unit). I was surprised when we hit a floating point exception, which I traced back to an integer overflow when we calculate swidth from dsw. So, do the 64-bit multiplication so we can detect the overflow and complain about it. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02misc: ubsan fixesDarrick J. Wong2-4/+4
Fix a few things the undefined behavior sanitizer complained about. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-02-02xfs_db: interpret inode timestamps as signed integersDarrick J. Wong1-1/+2
The Linux kernel treats core.*time.sec as a signed integer value, so xfs_db should do likewise, or else files will have inconsistent times if the seconds count is negative. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25xfsprogs: update dead urlsDarrick J. Wong4-6/+6
Since oss.sgi.com is dead and xfs.org is slowly migrating to xfs.wiki.kernel.org, update all the documentation links to point to the current landing pads. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25xfs_copy: accept CRC version of ABTB_MAGIC in ASSERTEric Sandeen1-1/+2
Not sure how this was missed for so long, but to handle CRC filesystems, this ASSERT on block magic must accept CRC magic as well. Reported-by: Radek Burkat <radek@pinkbike.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Bill O'Donnell <billodo@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25xfs_logprint: fix v3 inode formattingEric Sandeen1-1/+1
Line up flags2/cowextsize line with all the others, using tabs. Fixes: 1fe708d60 ("xfs_logprint: support cowextsize reporting in log contents") Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25libxfs: use a memory zone for log itemsEric Sandeen1-9/+10
In addition to more closely matching the kernel, this will help us catch any leaks from these allocations. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25libxfs: use a memory zone for transactionsEric Sandeen2-11/+21
In addition to more closely matching the kernel, this will help us catch any leaks from these allocations. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25libxfs: remove unused buf_fsprivate3Eric Sandeen2-6/+0
The buf_fsprivate3 field has no actual use, other than a pointless "if it's not set, set it" in xfs_buf_item_init; nobody cares after that. Remove it. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25xfs: add a proper transaction pointer to struct xfs_bufChristoph Hellwig2-25/+23
Source kernel commit bf9d9013a2a559858efb590bf922377be9d6d969 Replace the typeless b_fspriv2 and the ugly macros around it with a properly typed transaction pointer. As a fallout the log buffer state debug checks are also removed. We could have kept them using casts, but as they do not have a real purpose we can as well just remove them. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-25xfs: remove wrappers around b_fsprivChristoph Hellwig4-33/+25
Source kernel commit adadbeefb34f755a3477da51035eeeec2c1fde38 Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Alex Elder <aelder@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04find-api-violations: fix a broken grep patternDarrick J. Wong1-1/+1
One of the grep patterns in find-api-violations is mistaken for a (broken) range specifier when LC_ALL=C, so fix it to work properly. This was found by wiring up the script to xfstests. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04xfs_repair: fix libxfs namespace problemsDarrick J. Wong3-3/+3
Call libxfs_ functions, not xfs_ functions. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04xfs_db: fix crash when field list selector string has trailing slashDarrick J. Wong1-0/+1
If I run the following command: xfs_db /dev/sdf -x -c 'agf 0' -c 'addr refcntroot' -c 'addr ptrs[1]\' it errors out with "bad character in field \" and then ftok_free crashes on an invalid free() because picking up the previous token (the closing bracket) xrealloc'd the token array to be 5 elements long but never set the last element's tok pointer. Consequently the ftok_free tries to free whatever garbage pointer is in that last element and kaboom. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@sandeen.net> [sandeen: slightly clarify commit log] Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04xfs_db: check should deal with cow staging extents correctlyDarrick J. Wong1-4/+15
Teach xfs_check to record cow staging extents correctly. This means that we strip off the high bit before using startblock. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04libhandle: zap fdhash in fshandle_destroyDarrick J. Wong1-0/+1
Set fdhash_head to zero once we've destroyed the handle list to avoid dangling pointer problems. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04xfs_io: add a new 'log_writes' commandRoss Zwisler10-2/+157
Add a new 'log_writes' command to xfs_io so that we can add dm-log-writes log marks. It's helpful to allow users of xfs_io to adds these marks from within xfs_io instead of waiting until after xfs_io exits because then they are able to replay the dm-log-writes log up to immediately after another xfs_io operation such as mwrite. This isolates the log replay from other operations that happen as part of xfs_io exiting (file handles being closed, mmaps being torn down, etc.). This also allows users to insert multiple marks between different xfs_io commands. Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> Suggested-by: Dave Chinner <david@fromorbit.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04xfs_io: add MAP_SYNC support to mmap()Ross Zwisler8-6/+60
Add support for a new -S flag to xfs_io's mmap command. This opens the mapping with the (MAP_SYNC | MAP_SHARED_VALIDATE) flags instead of the standard MAP_SHARED flag. Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com> Suggested-by: Dave Chinner <david@fromorbit.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04mkfs: do not allow both "dev" and "name" subopts for log or realtimeEric Sandeen1-2/+6
Todauy this works, with last-parsed-wins semantics: mkfs.xfs -f -l logdev=/dev/sda1,name=/dev/sda2 /dev/sda3 Disallow it to avoid ambiguity. Signed-off-by: Eric Sandeen <sandeen@sandeen.net> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04mkfs: pass switch case value directly into getnum/getstrEric Sandeen1-47/+47
Parsing did this sort of thing: case D_AGCOUNT: cli->agcount = getnum(value, opts, D_AGCOUNT); which was just begging for a cut and paste error between the case value and the enum passed into getnum/getstr. Pass "subopt" instead so that it is always consistent with the case. Signed-off-by: Eric Sandeen <sandeen@sandeen.net> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-04mkfs: un-document removed logarithm based CLI optionsEric Sandeen2-39/+30
Remove logarithm-based options from usage() and manpage. Fixes: 70f72d5 "mkfs: remove logarithm based CLI options" Signed-off-by: Eric Sandeen <sandeen@sandeen.net> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-03mkfs: remove logarithm based CLI optionsDave Chinner1-140/+10
Very few people use the log2 based size options for various mkfs parameters and they just clutter up the code. Get rid of them. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-03mkfs: resolve sector size CLI conflictsDave Chinner1-12/+31
Now we have a two dimensional conflict array, convert the sector size CLI option conflict determination to use it. To get the error specification just right, we also need to tweak how we store and validate the sector size CLI parameter state in the options table. Old: $ mkfs.xfs -N -s size=4k -d sectsize=512 /dev/pmem0 Cannot specify both -d sectsize and -d sectlog ..... New: $ mkfs.xfs -N -s size=4k -d sectsize=512 /dev/pmem0 Cannot specify both -s size and -d sectsize ..... Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eric Sandeen <sandeen@sandeen.net> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-03mkfs: convert subopt name, val pairs to enums and declared arraysDave Chinner1-123/+153
Replace the nasty #define + implicit array index definitions with pre-declared enums and index specific name array declarations. This cleans up the code quite a bit and the pre-declaration of the enums allows tables to use indexes from other tables in things like conflict specifications. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-03mkfs: support arbitrary conflict specificationDave Chinner1-127/+130
Currently the conflict table is a single dimension, allowing conflicts to be specified in the same option table. however, we have conflicts that span option tables (e.g. sector size) and so we need to encode both the table and the option that conflicts. Add support for a two dimensional conflict definition and convert all the code over to use it. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eric Sandeen <sandeen@sandeen.net> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-03mkfs: protofile only needs to be set up onceDave Chinner1-2/+0
Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-03mkfs: simplify minimum log size calculationDave Chinner4-152/+52
mkfs jumps through hoops to call libxfs_log_calc_minimum_size() to set the minimum log size. We already have a xfs_mount at this point, we just need to set the superblock up slightly earlier and then mkfs can call libxfs_log_calc_minimum_size() directly. This means we can remove mkfs/maxtrres.c completely. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
2018-01-03mkfs: use opts parameter during option parsingDave Chinner1-30/+30
Rather than hard coding the global table variable into the parsing functions. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>