public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: linux-xfs@vger.kernel.org, ross.zwisler@linux.intel.com,
	david@fromorbit.com, darrick.wong@oracle.com,
	sandeen@sandeen.net
Subject: Re: [PATCH] xfs_io: Make HAVE_MAP_SYNC more robust
Date: Wed, 20 Jul 2022 14:32:42 -0700	[thread overview]
Message-ID: <Yth0es3DkTQRAxJl@magnolia> (raw)
In-Reply-To: <20220720205307.2345230-1-f.fainelli@gmail.com>

On Wed, Jul 20, 2022 at 01:53:07PM -0700, Florian Fainelli wrote:
> MIPS platforms building with recent kernel headers and the musl-libc toolchain
> will expose the following build failure:
> 
> mmap.c: In function 'mmap_f':
> mmap.c:196:12: error: 'MAP_SYNC' undeclared (first use in this function); did you mean 'MS_SYNC'?
>   196 |    flags = MAP_SYNC | MAP_SHARED_VALIDATE;
>       |            ^~~~~~~~
>       |            MS_SYNC
> mmap.c:196:12: note: each undeclared identifier is reported only once for each function it appears in
> make[4]: *** [../include/buildrules:81: mmap.o] Error 1

Didn't we already fix this?
https://lore.kernel.org/linux-xfs/20220508193029.1277260-1-fontaine.fabrice@gmail.com/

Didn't we already fix this?
https://lore.kernel.org/linux-xfs/20181116162346.456255382F@mx7.valuehost.ru/

Oh, I guess the maintainer didn't apply either of these patches, so this
has been broken for years.

Well... MAP_SYNC has been with us for a while now, perhaps it makes more
sense to remove all the override cruft and make xfs_io not export -S if
if neither kernel headers nor libc define it?

--D

> 
> The reason for that is that the linux.h header file which intends to provide a fallback definition for MAP_SYNC and MAP_SHARED_VALIDATE is included too early through:
> 
> input.h -> libfrog/projects.h -> xfs.h -> linux.h and this happens
> *before* sys/mman.h is included.
> 
> sys/mman.h -> bits/mman.h which has a:
>   #undef MAP_SYNC
> 
> see: https://git.musl-libc.org/cgit/musl/tree/arch/mips/bits/mman.h#n21
> 
> The end result is that sys/mman.h being included for the first time
> ends-up overriding the HAVE_MAP_SYNC fallbacks.
> 
> To remedy that, make sure that linux.h is updated to include sys/mman.h
> such that its fallbacks are independent of the inclusion order. As a
> consequence this forces us to ensure that we do not re-define
> accidentally MAP_SYNC or MAP_SHARED_VALIDATE so we protect against that.
> 
> Fixes: dad796834cb9 ("xfs_io: add MAP_SYNC support to mmap()")
> Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
>  include/linux.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/include/linux.h b/include/linux.h
> index 3d9f4e3dca80..c3cc8e30c677 100644
> --- a/include/linux.h
> +++ b/include/linux.h
> @@ -252,8 +252,13 @@ struct fsxattr {
>  #endif
>  
>  #ifndef HAVE_MAP_SYNC
> +#include <sys/mman.h>
> +#ifndef MAP_SYNC
>  #define MAP_SYNC 0
> +#endif
> +#ifndef MAP_SHARED_VALIDATE
>  #define MAP_SHARED_VALIDATE 0
> +#endif
>  #else
>  #include <asm-generic/mman.h>
>  #include <asm-generic/mman-common.h>
> -- 
> 2.25.1
> 

  reply	other threads:[~2022-07-20 21:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 20:53 [PATCH] xfs_io: Make HAVE_MAP_SYNC more robust Florian Fainelli
2022-07-20 21:32 ` Darrick J. Wong [this message]
2022-07-20 21:40   ` Florian Fainelli
2022-07-20 22:16     ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yth0es3DkTQRAxJl@magnolia \
    --to=djwong@kernel.org \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=f.fainelli@gmail.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ross.zwisler@linux.intel.com \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox