]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commit
xfsprogs: remove platform_zero_range wrapper
authorEric Sandeen <sandeen@sandeen.net>
Fri, 7 Jun 2024 15:24:52 +0000 (10:24 -0500)
committerCarlos Maiolino <cem@kernel.org>
Mon, 17 Jun 2024 11:51:49 +0000 (13:51 +0200)
commitb3821ed05c8d1309ffcf6ed018fff5bef917b4b5
tree761b708b41ff2e1678106a5919308618be51a9b3
parent7ea701ffc7cf306a903f2966519b3f5aedfb77ea
xfsprogs: remove platform_zero_range wrapper

Now that the HAVE_FALLOCATE guard around including
<linux/falloc.h> in linux/xfs.h has been removed via
15fb447f ("configure: don't check for fallocate"),
bad things can happen because we reference fallocate in
<xfs/linux.h> without defining _GNU_SOURCE:

$ cat test.c
#include <xfs/linux.h>

int main(void)
{
return 0;
}

$ gcc -o test test.c
In file included from test.c:1:
/usr/include/xfs/linux.h: In function ‘platform_zero_range’:
/usr/include/xfs/linux.h:186:15: error: implicit declaration of function ‘fallocate’ [-Wimplicit-function-declaration]
  186 |         ret = fallocate(fd, FALLOC_FL_ZERO_RANGE, start, len);
      |               ^~~~~~~~~

i.e. xfs/linux.h includes fcntl.h without _GNU_SOURCE, so we
don't get an fallocate prototype.

Rather than playing games with header files, just remove the
platform_zero_range() wrapper - we have only one platform, and
only one caller after all - and simply call fallocate directly
if we have the FALLOC_FL_ZERO_RANGE flag defined.

(LTP also runs into this sort of problem at configure time ...)

Darrick points out that this changes a public header, but
platform_zero_range() has only been exposed by default
(without the oddball / internal xfsprogs guard) for a couple
of xfsprogs releases, so it's quite unlikely that anyone is
using this oddball fallocate wrapper.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
V2: remove error variable, add to commit msg
V3: Drop FALLOC_FL_ZERO_RANGE #ifdef per hch's suggestion and
    add his RVB from V2, with changes.

NOTE: compile tested only
include/linux.h
libxfs/rdwr.c