]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/log
thirdparty/xfsprogs-dev.git
4 years agoxfs_admin: support adding features to V5 filesystems
Darrick J. Wong [Wed, 24 Feb 2021 01:20:57 +0000 (20:20 -0500)] 
xfs_admin: support adding features to V5 filesystems

Teach the xfs_admin script how to add features to V5 filesystems.
Technically speaking we could add lazycount to the list, but that option
is only useful for the V4 format which is deprecated.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: allow upgrades on v5 filesystems
Darrick J. Wong [Wed, 24 Feb 2021 01:20:42 +0000 (20:20 -0500)] 
xfs_repair: allow upgrades on v5 filesystems

Add some helper functions so that we can allow users to upgrade V5
filesystems in a sane manner.  This just lands the boilerplate; the
actual feature validation and whatnot will land in the next patches.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
[sandeen: change subject slightly]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoman: mark all deprecated V4 format options
Darrick J. Wong [Wed, 24 Feb 2021 00:35:55 +0000 (19:35 -0500)] 
man: mark all deprecated V4 format options

Update the manual pages for the most popular tools to note which options
are only useful with the V4 XFS format, and that the V4 format is
deprecated and will be removed no later than September 2030.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
[sandeen: tweak wording and formatting a little]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: add post-phase error injection points
Darrick J. Wong [Wed, 24 Feb 2021 00:10:00 +0000 (19:10 -0500)] 
xfs_repair: add post-phase error injection points

Create an error injection point so that we can simulate repair failing
after a certain phase.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: factor phase transitions into a helper
Darrick J. Wong [Wed, 24 Feb 2021 00:10:00 +0000 (19:10 -0500)] 
xfs_repair: factor phase transitions into a helper

Create a helper function to centralize all the stuff we do at the end of
a repair phase (which for now is limited to reporting progress).  The
next patch will add more interesting things to this helper.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: simulate system failure after a certain number of writes
Darrick J. Wong [Wed, 24 Feb 2021 00:10:00 +0000 (19:10 -0500)] 
libxfs: simulate system failure after a certain number of writes

Add an error injection knob so that we can simulate system failure after
a certain number of disk writes.  This knob is being added so that we
can check repair's behavior after an arbitrary number of tests.

Set LIBXFS_DEBUG_WRITE_CRASH={ddev,logdev,rtdev}=nn in the environment
to make libxfs SIGKILL itself after nn writes to the data, log, or rt
devices.  Note that this only applies to xfs_buf writes and zero_range.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: set NEEDSREPAIR the first time we write to a filesystem
Darrick J. Wong [Wed, 24 Feb 2021 00:10:00 +0000 (19:10 -0500)] 
xfs_repair: set NEEDSREPAIR the first time we write to a filesystem

Add a hook to the buffer cache so that xfs_repair can intercept the
first write to a V5 filesystem to set the NEEDSREPAIR flag.  In the
event that xfs_repair dirties the filesystem and goes down, this ensures
that the sysadmin will have to re-start repair before mounting.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: clear the needsrepair flag
Darrick J. Wong [Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)] 
xfs_repair: clear the needsrepair flag

Clear the needsrepair flag, since it's used to prevent mounting of an
inconsistent filesystem.  We only do this if we make it to the end of
repair with a non-zero error code, and all the rebuilt indices and
corrected metadata are persisted correctly.

Note that we cannot combine clearing needsrepair with clearing the quota
checked flags because we need to clear the quota flags even if
reformatting the log fails, whereas we can't clear needsrepair if the
log reformat fails.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: clear quota CHKD flags on the incore superblock too
Darrick J. Wong [Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)] 
xfs_repair: clear quota CHKD flags on the incore superblock too

At the end of a repair run, xfs_repair clears the superblock's quota
checked flags if it found mistakes in the quota accounting to force a
quotacheck at the next mount.  This is currently the last time repair
modifies the primary superblock, so it is sufficient to update the
ondisk buffer and not the incore mount structure.

However, we're about to introduce code to clear the needsrepair feature
at the very end of repair, after all metadata blocks have been written
to disk and all disk caches flush.  Since the convention everywhere else
in xfs is to update the incore superblock, call libxfs_sb_to_disk to
translate that into the ondisk buffer, and then write the buffer to
disk, switch the quota CHKD code to use this mechanism too.

(Get rid of dsb too, since the incore super should be in sync with the
ondisk super.)

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: fix unmount error message to have a newline
Darrick J. Wong [Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)] 
xfs_repair: fix unmount error message to have a newline

Add a newline so that this is consistent with the other error messages.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_db: don't allow label/uuid setting if the needsrepair flag is set
Darrick J. Wong [Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)] 
xfs_db: don't allow label/uuid setting if the needsrepair flag is set

The NEEDSREPAIR flag can be set on filesystems where we /know/ that
there's something wrong with the metadata and want to force the sysadmin
to run xfs_repair before the next mount.  The goal here is to prevent
non-repair changes to a filesystem when we are confident of its
instability.  Normally we wouldn't bother with such safety checks for
the debugger, but the label and uuid functions can be called from
xfs_admin, so we should prevent these administrative tasks until the
filesystem can be repaired.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_db: report the needsrepair flag in check and version commands
Darrick J. Wong [Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)] 
xfs_db: report the needsrepair flag in check and version commands

Teach the version and check commands to report the presence of the
NEEDSREPAIR flag.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_admin: support filesystems with realtime devices
Darrick J. Wong [Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)] 
xfs_admin: support filesystems with realtime devices

Add a -r option to xfs_admin so that we can pass the name of the
realtime device to xfs_repair.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_admin: clean up string quoting
Darrick J. Wong [Wed, 24 Feb 2021 00:09:28 +0000 (19:09 -0500)] 
xfs_admin: clean up string quoting

Clean up the string quoting in this script so that we don't trip over
users feeding us arguments like "/dev/sd ha ha ha lol".

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: fix weirdness in directory name check code
Darrick J. Wong [Fri, 12 Feb 2021 22:23:06 +0000 (17:23 -0500)] 
xfs_scrub: fix weirdness in directory name check code

Remove the redundant second check of fd and ISDIR in check_inode_names,
and rework the comment to describe why we can't run phase 5 if we found
other corruptions in the filesystem.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: check dquot id and type
Darrick J. Wong [Fri, 12 Feb 2021 22:23:06 +0000 (17:23 -0500)] 
xfs_repair: check dquot id and type

Make sure that we actually check the type and id of an ondisk dquot.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: handle concurrent directory updates during name scan
Darrick J. Wong [Fri, 12 Feb 2021 22:23:06 +0000 (17:23 -0500)] 
xfs_scrub: handle concurrent directory updates during name scan

The name scanner in xfs_scrub cannot lock a namespace (dirent or xattr)
and the kernel does not provide a stable cursor interface, which means
that we can see the same byte sequence multiple times during a scan.
This isn't a confusing name error since the kernel enforces uniqueness
on the byte sequence, so all we need to do here is update the old entry.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: load and unload libicu properly
Darrick J. Wong [Fri, 12 Feb 2021 22:23:06 +0000 (17:23 -0500)] 
xfs_scrub: load and unload libicu properly

Make sure we actually load and unload libicu properly.  This isn't
strictly required since the library can bootstrap itself, but unloading
means fewer things for valgrind to complain about.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_scrub: detect infinite loops when scanning inodes
Darrick J. Wong [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
xfs_scrub: detect infinite loops when scanning inodes

During an inode scan (aka phase 3) when we're scanning the inode btree
to find files to check, make sure that each invocation of inumbers
actually gives us an inobt record with a startino that's at least as
large as what we asked for so that we always make forward progress.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomisc: fix valgrind complaints
Darrick J. Wong [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
misc: fix valgrind complaints

Zero the memory that we pass to the kernel via ioctls so that we never
pass userspace heap/stack garbage around.  This silences valgrind
complaints about uninitialized padding areas.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_db: add an ls command
Darrick J. Wong [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
xfs_db: add an ls command

Add to xfs_db the ability to list a directory.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_db: add a directory path lookup command
Darrick J. Wong [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
xfs_db: add a directory path lookup command

Add a command to xfs_db so that we can navigate to inodes by path.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_quota: drop pointless qsort cmp casting
Eric Sandeen [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
xfs_quota: drop pointless qsort cmp casting

The function cast in this call to qsort is odd - we don't do it
anywhere else, and it doesn't gain us anything or help in any
way.

So remove it; since we are now passing void *p pointers in, locally
use du_t *d pointers to refer to the du_t's in the compare function.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp()
Chandan Babu R [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp()

This commit introduces a check to verify that correct bulkstat structures are
being processed by qsort's cmp() function.

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: xfs_fsr: Limit the scope of cmp()
Chandan Babu R [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
xfsprogs: xfs_fsr: Limit the scope of cmp()

cmp() function is being referred to from within fsr/xfs_fsr.c. Hence
this commit limits its scope to the current file.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: xfs_fsr: Interpret arguments of qsort's compare function correctly
Chandan Babu R [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
xfsprogs: xfs_fsr: Interpret arguments of qsort's compare function correctly

The first argument passed to qsort() in fsrfs() is an array of "struct
xfs_bulkstat". Hence the two arguments to the cmp() function must be
interpreted as being of type "struct xfs_bulkstat *" as against "struct
xfs_bstat *" that is being used to currently typecast them.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomkfs: fix wrong inobtcount usage error output
Zorro Lang [Fri, 12 Feb 2021 22:23:05 +0000 (17:23 -0500)] 
mkfs: fix wrong inobtcount usage error output

When mkfs fails, it shows:
  ...
  /* metadata */         [-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\
                           inobtcnt=0|1,bigtime=0|1]\n\
  ...

The "inobtcnt=0|1" is wrong usage, it must be inobtcount, there's not
an alias. To avoid misadvice, fix it.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: Release v5.11.0-rc0 v5.11.0-rc0
Eric Sandeen [Fri, 12 Feb 2021 22:22:31 +0000 (17:22 -0500)] 
xfsprogs: Release v5.11.0-rc0

Update all the necessary files for a 5.11.0-rc0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: Prevent installing duplicate changelog
Bastian Germann [Fri, 12 Feb 2021 21:35:22 +0000 (16:35 -0500)] 
debian: Prevent installing duplicate changelog

The doc/CHANGES file is both processed by dh_installdocs and
dh_installchangelogs. So it ends up as changelog.gz and CHANGES.gz.
Prevent that by excluding it from dh_installdocs.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: Only build for Linux
Bastian Germann [Fri, 12 Feb 2021 21:35:22 +0000 (16:35 -0500)] 
debian: Only build for Linux

Use architecture linux-any to exclude kfreebsd and hurd from building
the package. Those will always fail.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: Drop unused dh-python from Build-Depends
Bastian Germann [Fri, 12 Feb 2021 21:35:22 +0000 (16:35 -0500)] 
debian: Drop unused dh-python from Build-Depends

xfsprogs participates in dependency loops relevant to architecture
bootstrap. Identifying easily droppable dependencies, it was found
that xfsprogs does not use dh-python in any way.

Reported-by: Helmut Grohne <helmut@subdivi.de>
Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: Update Uploaders list
Nathan Scott [Mon, 18 Jan 2021 21:08:35 +0000 (16:08 -0500)] 
debian: Update Uploaders list

Add Bastian Germann to the uploaders: list

Signed-off-by: Nathan Scott <nathans@debian.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: new changelog entry
Bastian Germann [Mon, 18 Jan 2021 21:07:35 +0000 (16:07 -0500)] 
debian: new changelog entry

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nathan Scott <nathans@debian.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: add missing copyright info
Bastian Germann [Mon, 18 Jan 2021 21:07:35 +0000 (16:07 -0500)] 
debian: add missing copyright info

For binary distribution, the copyright info in (L)GPL licensed, compiled
files needs to be retained in the copyright file.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nathan Scott <nathans@debian.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: use Package-Type over its predecessor
Bastian Germann [Mon, 18 Jan 2021 21:07:35 +0000 (16:07 -0500)] 
debian: use Package-Type over its predecessor

The debian/control file contains an XC-Package-Type field.
As of dpkg-dev 1.15.7, the dpkg development utilities recognize
Package-Type as an official field name.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nathan Scott <nathans@debian.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: remove "Priority: extra"
Bastian Germann [Mon, 18 Jan 2021 21:07:35 +0000 (16:07 -0500)] 
debian: remove "Priority: extra"

Priority "extra" was replaced by "optional" which is already used by the
package in general. There is one Priority extra left, so remove it.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nathan Scott <nathans@debian.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: remove dependency on essential util-linux
Bastian Germann [Mon, 18 Jan 2021 21:07:35 +0000 (16:07 -0500)] 
debian: remove dependency on essential util-linux

Essential packages must not be part of Depends.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Nathan Scott <nathans@debian.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: cryptographically verify upstream tarball
Bastian Germann [Mon, 18 Jan 2021 21:07:35 +0000 (16:07 -0500)] 
debian: cryptographically verify upstream tarball

Debian's uscan utility can verify a downloaded tarball. As the
uncompressed tarball is signed, the decompress rule has to be applied.

Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Reviewed-by: Nathan Scott <nathans@debian.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: remove xfs_buf_t typedef libxfs-5.11-sync
Dave Chinner [Thu, 7 Jan 2021 20:59:18 +0000 (15:59 -0500)] 
xfs: remove xfs_buf_t typedef

Source kernel commit: e82226138b20d4f638426413e83c6b5db532c6a2

Prepare for kernel xfs_buf  alignment by getting rid of the
xfs_buf_t typedef from userspace.

[darrick: This patch is a port of a userspace patch removing the
xfs_buf_t typedef in preparation to make the userspace xfs_buf code
behave more like its kernel counterpart.]

Signed-off-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>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agofs/xfs: convert comma to semicolon
Zheng Yongjun [Thu, 7 Jan 2021 20:59:18 +0000 (15:59 -0500)] 
fs/xfs: convert comma to semicolon

Source kernel commit: 1189686e5440041057f8cc21a7c1d13bb6642cb9

Replace a comma between expression statements by a semicolon.

Signed-off-by: Zheng Yongjun <zhengyongjun3@huawei.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@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>
4 years agoxfs: kill ialloced in xfs_dialloc()
Gao Xiang [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: kill ialloced in xfs_dialloc()

Source kernel commit: 3937493c502566d90a74c3439ebdb663d9380cc3

It's enough to just use return code, and get rid of an argument.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: spilt xfs_dialloc() into 2 functions
Dave Chinner [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: spilt xfs_dialloc() into 2 functions

Source kernel commit: 8d822dc38ad781b1bfa5c03227da80dbd87e9959

This patch explicitly separates free inode chunk allocation and
inode allocation into two individual high level operations.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: move xfs_dialloc_roll() into xfs_dialloc()
Dave Chinner [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: move xfs_dialloc_roll() into xfs_dialloc()

Source kernel commit: f3bf6e0f1196c69a7b0412521596cd1cc7622a82

Get rid of the confusing ialloc_context and failure handling around
xfs_dialloc() by moving xfs_dialloc_roll() into xfs_dialloc().

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: move on-disk inode allocation out of xfs_ialloc()
Dave Chinner [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: move on-disk inode allocation out of xfs_ialloc()

Source kernel commit: 1abcf261016e12246e1f0d2dada9c5c851a9ceb7

So xfs_ialloc() will only address in-core inode allocation then,
Also, rename xfs_ialloc() to xfs_dir_ialloc_init() in order to
keep everything in xfs_inode.c under the same namespace.

[sandeen: make equivalent change in xfsprogs]

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: introduce xfs_dialloc_roll()
Dave Chinner [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: introduce xfs_dialloc_roll()

Source kernel commit: aececc9f8dec92a25c84a3378021636ce58d72dc

Introduce a helper to make the on-disk inode allocation rolling
logic clearer in preparation of the following cleanup.

[sandeen: update xfsprogs struct xfs_trans to match]

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: convert noroom, okalloc in xfs_dialloc() to bool
Gao Xiang [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: convert noroom, okalloc in xfs_dialloc() to bool

Source kernel commit: 15574ebbff260a70d344cfb924a8daf3c47dc303

Boolean is preferred for such use.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: don't catch dax+reflink inodes as corruption in verifier
Eric Sandeen [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: don't catch dax+reflink inodes as corruption in verifier

Source kernel commit: 207ddc0ef4f413ab1f4e0c1fcab2226425dec293

We don't yet support dax on reflinked files, but that is in the works.

Further, having the flag set does not automatically mean that the inode
is actually "in the CPU direct access state," which depends on several
other conditions in addition to the flag being set.

As such, we should not catch this as corruption in the verifier - simply
not actually enabling S_DAX on reflinked files is enough for now.

Fixes: 4f435ebe7d04 ("xfs: don't mix reflink and DAX mode for now")
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
[darrick: fix the scrubber too]
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>
4 years agoxfs: remove unneeded return value check for *init_cursor()
Joseph Qi [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: remove unneeded return value check for *init_cursor()

Source kernel commit: 2e984badbcc0f1cf284441c566ca4309fe59ac05

Since *init_cursor() can always return a valid cursor, the NULL check
in caller is unneeded. So clean them up.
This also keeps the behavior consistent with other callers.

Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
4 years agoxfs: introduce xfs_validate_stripe_geometry()
Gao Xiang [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: introduce xfs_validate_stripe_geometry()

Source kernel commit: 7bc1fea9d36c78e783ce7d4ad28ad129ebcce435

Introduce a common helper to consolidate stripe validation process.
Also make kernel code xfs_validate_sb_common() use it first.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-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>
4 years agoxfs: remove the unused XFS_B_FSB_OFFSET macro
Kaixu Xia [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: remove the unused XFS_B_FSB_OFFSET macro

Source kernel commit: afbd914776db9c035dbe2afa6badb9955ae52492

There are no callers of the XFS_B_FSB_OFFSET macro, so remove it.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
4 years agoxfs: check tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag
Kaixu Xia [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: check tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag

Source kernel commit: 04a58620a17cb14fa20c6e536e03eb27f9af6bc9

Nowadays the only things that the XFS_TRANS_DQ_DIRTY flag seems to do
are indicates the tp->t_dqinfo->dqs[XFS_QM_TRANS_{USR,GRP,PRJ}] values
changed and check in xfs_trans_apply_dquot_deltas() and the unreserve
variant xfs_trans_unreserve_and_mod_dquots(). Actually, we also can
use the tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag, that
is to say, we allocate the new tp->t_dqinfo only when the qtrx values
changed, so the tp->t_dqinfo value isn't NULL equals the XFS_TRANS_DQ_DIRTY
flag is set, we only need to check if tp->t_dqinfo == NULL in
xfs_trans_apply_dquot_deltas() and its unreserve variant to determine
whether lock all of the dquots and join them to the transaction.

Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
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>
4 years agoxfs: refactor file range validation
Darrick J. Wong [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: refactor file range validation

Source kernel commit: 33005fd0a537501111fc97ec330b721388c6b451

Refactor all the open-coded validation of file block ranges into a
single helper, and teach the bmap scrubber to check the ranges.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: refactor realtime volume extent validation
Darrick J. Wong [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: refactor realtime volume extent validation

Source kernel commit: 18695ad4251462b33787b7e375dbda57c1969c8f

Refactor all the open-coded validation of realtime device extents into a
single helper.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: refactor data device extent validation
Darrick J. Wong [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: refactor data device extent validation

Source kernel commit: 67457eb0d225521a0e81327aef808cd0f9075880

Refactor all the open-coded validation of non-static data device extents
into a single helper.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: detect overflows in bmbt records
Darrick J. Wong [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: detect overflows in bmbt records

Source kernel commit: acf104c2331c1ba2a667e65dd36139d1555b1432

Detect file block mappings with a blockcount that's either so large that
integer overflows occur or are zero, because neither are valid in the
filesystem.  Worse yet, attempting directory modifications causes the
iext code to trip over the bmbt key handling and takes the filesystem
down.  We can fix most of this by preventing the bad metadata from
entering the incore structures in the first place.

Found by setting blockcount=0 in a directory data fork mapping and
watching the fireworks.

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>
4 years agoxfs: enable the needsrepair feature
Darrick J. Wong [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: enable the needsrepair feature

Source kernel commit: 96f65bad7c31557c28468ba8c1896c7dd7a6bbfa

Make it so that libxfs recognizes the needsrepair feature.  Note that
the kernel will still refuse to mount these.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: define a new "needrepair" feature
Darrick J. Wong [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: define a new "needrepair" feature

Source kernel commit: 80c720b8eb1c7800133c5ae1686353d33564b773

Define an incompat feature flag to indicate that the filesystem needs to
be repaired.  While libxfs will recognize this feature, the kernel will
refuse to mount if the feature flag is set, and only xfs_repair will be
able to clear the flag.  The goal here is to force the admin to run
xfs_repair to completion after upgrading the filesystem, or if we
otherwise detect anomalies.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: move kernel-specific superblock validation out of libxfs
Darrick J. Wong [Thu, 7 Jan 2021 20:59:17 +0000 (15:59 -0500)] 
xfs: move kernel-specific superblock validation out of libxfs

Source kernel commit: 3945ae03d822aa47584dd502ac024ae1e1eb9e2d

A couple of the superblock validation checks apply only to the kernel,
so move them to xfs_fc_fill_super before we add the needsrepair "feature",
which will prevent the kernel (but not xfsprogs) from mounting the
filesystem.  This also reduces the diff between kernel and userspace
libxfs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: cosmetic changes to libxfs_inode_alloc
Eric Sandeen [Thu, 7 Jan 2021 20:59:03 +0000 (15:59 -0500)] 
libxfs: cosmetic changes to libxfs_inode_alloc

This pre-patch helps make the next libxfs-sync for 5.11 a bit
more clear.

In reality, the libxfs_inode_alloc function matches the kernel's
xfs_dir_ialloc so rename it for clarity before the rest of the
sync, and change several variable names for the same reason.

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>
4 years agoxfsprogs: Release v5.10.0 v5.10.0
Eric Sandeen [Fri, 11 Dec 2020 22:19:43 +0000 (17:19 -0500)] 
xfsprogs: Release v5.10.0

Update all the necessary files for a 5.10.0 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: remove obsolete code for handling mountpoint inodes
Anthony Iliopoulos [Wed, 9 Dec 2020 17:20:40 +0000 (12:20 -0500)] 
xfs_repair: remove obsolete code for handling mountpoint inodes

The S_IFMNT file type was never supported in Linux, remove the related
code that was supposed to deal with it, along with the translation file
entries.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: Release v5.10.0-rc1 v5.10.0-rc1
Eric Sandeen [Fri, 4 Dec 2020 19:46:15 +0000 (14:46 -0500)] 
xfsprogs: Release v5.10.0-rc1

Update all the necessary files for a 5.10.0-rc1 release.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: make things non-gender-specific
Eric Sandeen [Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)] 
xfsprogs: make things non-gender-specific

Users are not exclusively male, so fix that implication
in the xfs_quota manpage and the configure.ac comments.

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>
4 years agoxfs_quota: Remove delalloc caveat from man page
Eric Sandeen [Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)] 
xfs_quota: Remove delalloc caveat from man page

Ever since
89605011915a ("xfs: include reservations in quota reporting")
xfs quota has been in sync with delayed allocations, so this caveat
is no longer relevant or correct; 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>
4 years agoxfs_quota: document how the default quota is stored
Eric Sandeen [Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)] 
xfs_quota: document how the default quota is stored

Nowhere in the man page is the default quota described; what it
does or where it is stored.  Add some brief information about this.

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>
4 years agodebian: add build dependency on libinih-dev
Darrick J. Wong [Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)] 
debian: add build dependency on libinih-dev

mkfs now supports configuration files, which are parsed using libinih.
Add this dependency to the debian build.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agodebian: fix version in changelog
Darrick J. Wong [Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)] 
debian: fix version in changelog

We're still at 5.10-rc0, at least according to the tags.

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>
4 years agolibxfs: add realtime extent reservation and usage tracking to transactions
Darrick J. Wong [Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)] 
libxfs: add realtime extent reservation and usage tracking to transactions

The libxfs resync added to the deferred ops code the ability to capture
the unfinished deferred ops and transaction reservation for later replay
during log recovery.  This nominally requires transactions to have the
ability to track rt extent reservations and usage, so port that missing
piece from the kernel now to avoid leaving logic bombs in case anyone
ever /does/ start messing with realtime.

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>
4 years agolibxfs: fix weird comment
Darrick J. Wong [Fri, 4 Dec 2020 17:17:12 +0000 (12:17 -0500)] 
libxfs: fix weird comment

Not sure what happened with this multiline comment, but clean up all the
stars.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs-apply: don't add duplicate headers
Darrick J. Wong [Fri, 4 Dec 2020 17:16:59 +0000 (12:16 -0500)] 
libxfs-apply: don't add duplicate headers

When we're backporting patches from libxfs, don't add a S-o-b header if
there's already one at the end of the headers of the patch being ported.

That way, we avoid things like:
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.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>
4 years agolibxfs: get rid of b_bcount from xfs_buf
Dave Chinner [Tue, 24 Nov 2020 16:58:25 +0000 (11:58 -0500)] 
libxfs: get rid of b_bcount from xfs_buf

We no longer use it in the kernel - it has been replaced by b_length
and it only exists in userspace because we haven't converted it
over. Do that now before we introduce a heap of code that doesn't
ever set it and so breaks all the progs code.

WHile we are doing this, kill the XFS_BUF_SIZE macro that has also
been removed from the kernel, too.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agorepair: simplify bmap_next_offset
Christoph Hellwig [Mon, 23 Nov 2020 19:49:35 +0000 (14:49 -0500)] 
repair: simplify bmap_next_offset

The tp argument is always NULL, and the whichfork argument is always
XFS_DATA_FORK, so simplify and cleanup the function based on those
assumptions.

[sandeen: rebase for current git tree]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: fix forkoff miscalculation related to XFS_LITINO(mp)
Gao Xiang [Mon, 23 Nov 2020 19:25:15 +0000 (14:25 -0500)] 
xfs: fix forkoff miscalculation related to XFS_LITINO(mp)

Source kernel commit: ada49d64fb3538144192181db05de17e2ffc3551

Currently, commit e9e2eae89ddb dropped a (int) decoration from
XFS_LITINO(mp), and since sizeof() expression is also involved,
the result of XFS_LITINO(mp) is simply as the size_t type
(commonly unsigned long).

Considering the expression in xfs_attr_shortform_bytesfit():
offset = (XFS_LITINO(mp) - bytes) >> 3;
let "bytes" be (int)340, and
"XFS_LITINO(mp)" be (unsigned long)336.

on 64-bit platform, the expression is
offset = ((unsigned long)336 - (int)340) >> 3 =
(int)(0xfffffffffffffffcUL >> 3) = -1

but on 32-bit platform, the expression is
offset = ((unsigned long)336 - (int)340) >> 3 =
(int)(0xfffffffcUL >> 3) = 0x1fffffff
instead.

so offset becomes a large positive number on 32-bit platform, and
cause xfs_attr_shortform_bytesfit() returns maxforkoff rather than 0.

Therefore, one result is
"ASSERT(new_size <= XFS_IFORK_SIZE(ip, whichfork));"

assertion failure in xfs_idata_realloc(), which was also the root
cause of the original bugreport from Dennis, see:
https://bugzilla.redhat.com/show_bug.cgi?id=1894177

And it can also be manually triggered with the following commands:
$ touch a;
$ setfattr -n user.0 -v "`seq 0 80`" a;
$ setfattr -n user.1 -v "`seq 0 80`" a

on 32-bit platform.

Fix the case in xfs_attr_shortform_bytesfit() by bailing out
"XFS_LITINO(mp) < bytes" in advance suggested by Eric and a misleading
comment together with this bugfix suggested by Darrick. It seems the
other users of XFS_LITINO(mp) are not impacted.

Fixes: e9e2eae89ddb ("xfs: only check the superblock version for dinode size calculation")
Cc: <stable@vger.kernel.org> # 5.7+
Reported-and-tested-by: Dennis Gilmore <dgilmore@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Gao Xiang <hsiangkao@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>
4 years agoxfsprogs: get rid of ancient btree tracing fragments
Dave Chinner [Fri, 20 Nov 2020 22:03:30 +0000 (17:03 -0500)] 
xfsprogs: get rid of ancient btree tracing fragments

If we are going to do any userspace tracing, it will be via the
existing libxfs tracepoint hooks, not the ancient Irix tracing
macros.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agolibxfs: rename buftarg->dev to btdev
Dave Chinner [Fri, 20 Nov 2020 22:03:30 +0000 (17:03 -0500)] 
libxfs: rename buftarg->dev to btdev

To prepare for alignment with kernel buftarg code.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: remove unused IO_DEBUG functionality
Dave Chinner [Fri, 20 Nov 2020 22:03:30 +0000 (17:03 -0500)] 
xfsprogs: remove unused IO_DEBUG functionality

Similar to the XFS_BUF_TRACING code, this is largely unused and not
hugely helpfule for tracing buffer IO. Remove it to simplify the
conversion process to the kernel buffer cache.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfsprogs: remove unused buffer tracing code
Dave Chinner [Fri, 20 Nov 2020 22:03:30 +0000 (17:03 -0500)] 
xfsprogs: remove unused buffer tracing code

This isn't particularly useful for finding issues, it's rarely used
and complicates the conversion to the kernel buffer cache code. THe
kernel code also carries it's own trace hooks that could be
implemented if tracing is needed, so remove this code to make the
conversion simpler.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_io: fix up typos in manpage
Eric Sandeen [Fri, 20 Nov 2020 22:03:30 +0000 (17:03 -0500)] 
xfs_io: fix up typos in manpage

We go in reverse direction, not reserve direction.
We go in forward direction, not forwards direction.

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>
4 years agomkfs: document config files in mkfs.xfs(8)
Dave Chinner [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
mkfs: document config files in mkfs.xfs(8)

So people know it exists.

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>
4 years agomkfs: hook up suboption parsing to ini files
Dave Chinner [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
mkfs: hook up suboption parsing to ini files

Now we have the config file parsing hooked up and feeding in
parameters to mkfs, wire the parameters up to the existing CLI
option parsing functions. THis gives the config file exactly the
same capabilities and constraints as the command line option
specification.

[sandeen: fix whitespace, drop "opt" check in parse_subopts()]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomkfs: constify various strings
Dave Chinner [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
mkfs: constify various strings

Because the ini parser uses const strings and so the opt parsing
needs to be told about it to avoid compiler warnings.

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>
4 years agomkfs: add initial ini format config file parsing support
Dave Chinner [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
mkfs: add initial ini format config file parsing support

Add the framework that will allow the config file to be supplied on
the CLI and passed to the library that will parse it. This does not
yet do any option parsing from the config file.

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>
4 years agobuild: add support for libinih for mkfs
Dave Chinner [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
build: add support for libinih for mkfs

Need to make sure the library is present so we can build mkfs with
config file support.

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>
4 years agoPolish translation update for xfsprogs 5.8.0.
Jakub Bogusz [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
Polish translation update for xfsprogs 5.8.0.

[sandeen: reviewed insofar as it only changes .po file]

Signed-off-by: Jakub Bogusz <qboosh@pld-linux.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: directly compare refcount records
Darrick J. Wong [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
xfs_repair: directly compare refcount records

Check that our observed refcount records have exact matches for what's
in the ondisk refcount btree, since they're supposed to match exactly.

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>
4 years agoxfs_repair: correctly detect partially written extents
Darrick J. Wong [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
xfs_repair: correctly detect partially written extents

Recently, I was able to create a realtime file with a 16b extent size
and the following data fork mapping:

data offset 0 startblock 144 (0/144) count 3 flag 0
data offset 3 startblock 147 (0/147) count 3 flag 1
data offset 6 startblock 150 (0/150) count 10 flag 0

Notice how we have a written extent, then an unwritten extent, and then
another written extent.  The current code in process_rt_rec trips over
that third extent, because repair only knows not to complain about inuse
extents if the mapping was unwritten.

This loop logic is confusing, because it tries to do too many things.
Move the phase3 and phase4 code to separate helper functions, then
isolate the code that handles a mapping that starts in the middle of an
rt extent so that it's clearer what's going on.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: skip the rmap and refcount btree checks when the levels are garbage
Darrick J. Wong [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
xfs_repair: skip the rmap and refcount btree checks when the levels are garbage

In validate_ag[fi], we should check that the levels of the rmap and
refcount btrees are valid.  If they aren't, we need to tell phase4 to
skip the comparison between the existing and incore rmap and refcount
data.  The comparison routines use libxfs btree cursors, which assume
that the caller validated bc_nlevels and will corrupt memory if we load
a btree cursor with a garbage level count.

This was found by examing a core dump from a failed xfs/086 invocation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_db: report ranges of invalid rt blocks
Darrick J. Wong [Fri, 20 Nov 2020 22:03:29 +0000 (17:03 -0500)] 
xfs_db: report ranges of invalid rt blocks

Copy-pasta the block range reporting code from check_range into
check_rrange so that we don't flood stdout with a ton of low value
messages when a bit flips somewhere in rt metadata.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs: remove unnecessary parameter from scrub_scan_estimate_blocks
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
xfs: remove unnecessary parameter from scrub_scan_estimate_blocks

The only caller that cares about the file counts uses it to compute the
number of files used, so return that and save a parameter.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomkfs: don't pass on extent size inherit flags when extent size is zero
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
mkfs: don't pass on extent size inherit flags when extent size is zero

If the caller passes in an extent size hint of zero, clear the inherit
flags because a hint value of zero is treated as not a hint.

Otherwise, you get stupid stuff like:
$ mkfs.xfs -d cowextsize=0 /tmp/a.img -f
illegal CoW extent size hint 0, must be less than 9600.

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>
4 years agomkfs: clarify valid "inherit" option values
Eric Sandeen [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
mkfs: clarify valid "inherit" option values

Clarify which values are valid for the various *inherit= mkfs
options.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
[darrick: fix a few nits]
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>
4 years agomkfs: allow users to specify rtinherit=0
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
mkfs: allow users to specify rtinherit=0

mkfs has quite a few boolean options that can be specified in several
ways: "option=1" (turn it on), "option" (turn it on), or "option=0"
(turn it off).  For whatever reason, rtinherit sticks out as the only
mkfs parameter that doesn't behave that way.  Let's make it behave the
same as all the other boolean variables.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agomkfs: format bigtime filesystems
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
mkfs: format bigtime filesystems

Allow formatting with large timestamps.

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>
4 years agoxfs: enable big timestamps
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
xfs: enable big timestamps

Source kernel commit: 29887a22713192509cfc6068ea3b200cdb8856da

Enable the big timestamp feature.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
4 years agoxfs_repair: support bigtime timestamp checking
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
xfs_repair: support bigtime timestamp checking

Make sure that inodes don't have the bigtime flag set when the feature
is disabled, and don't check for overflows in the nanoseconds when
bigtime is enabled because that is no longer possible.  Also make sure
that quotas don't have bigtime set erroneously.

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>
4 years agoxfs_quota: support editing and reporting quotas with bigtime
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
xfs_quota: support editing and reporting quotas with bigtime

Enhance xfs_quota to detect and report grace period expirations past
2038.

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>
4 years agoxfs_db: support printing time limits
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
xfs_db: support printing time limits

Support printing the minimum and maxium timestamp limits on this
filesystem.

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>
4 years agoxfs_db: report bigtime format timestamps
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
xfs_db: report bigtime format timestamps

Report the large format timestamps in a human-readable manner if it is
possible to do so without loss of information.

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>
4 years agolibfrog: list the bigtime feature when reporting geometry
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
libfrog: list the bigtime feature when reporting geometry

When we're reporting on a filesystem's geometry, report if the bigtime
feature is enabled on this filesystem.

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>
4 years agoxfs_db: refactor quota timer printing
Darrick J. Wong [Fri, 20 Nov 2020 22:03:28 +0000 (17:03 -0500)] 
xfs_db: refactor quota timer printing

Introduce type-specific printing functions to xfs_db to print a quota
timer instead of printing a raw int32 value.  This is needed to stay
ahead of changes that we're going to make to the quota timer format in
the following patches.

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>