linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] e4defrag: fix build when posix_fadvise is missing
@ 2014-01-01 10:28 Baruch Siach
  2014-01-01 17:22 ` Theodore Ts'o
  0 siblings, 1 reply; 7+ messages in thread
From: Baruch Siach @ 2014-01-01 10:28 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4, Baruch Siach

uClibc declares posix_fadvise() even when the architecture does not provide
one. The static posix_fadvise() signature is not compatible with POSIX. Rename
the internal implementation to fix this. Fixes the following build failure
when building against uClibc:

e4defrag.c:189:2: warning: #warning Using locally defined posix_fadvise interface. [-Wcpp]
e4defrag.c:203:12: error: conflicting types for ‘posix_fadvise’

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 misc/e4defrag.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index c6a5f0d..4e84a74 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -200,7 +200,8 @@ static struct frag_statistic_ino	frag_rank[SHOW_FRAG_FILES];
  * @len:		area length.
  * @advise:		process flag.
  */
-static int posix_fadvise(int fd, loff_t offset, size_t len, int advise)
+#define posix_fadvise	__posix_fadvise
+static int __posix_fadvise(int fd, loff_t offset, size_t len, int advise)
 {
 	return syscall(__NR_fadvise64_64, fd, offset, len, advise);
 }
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] e4defrag: fix build when posix_fadvise is missing
  2014-01-01 10:28 [PATCH] e4defrag: fix build when posix_fadvise is missing Baruch Siach
@ 2014-01-01 17:22 ` Theodore Ts'o
  2014-01-01 17:31   ` Baruch Siach
  0 siblings, 1 reply; 7+ messages in thread
From: Theodore Ts'o @ 2014-01-01 17:22 UTC (permalink / raw)
  To: Baruch Siach; +Cc: linux-ext4

On Wed, Jan 01, 2014 at 12:28:23PM +0200, Baruch Siach wrote:
> uClibc declares posix_fadvise() even when the architecture does not provide
> one. The static posix_fadvise() signature is not compatible with POSIX. Rename
> the internal implementation to fix this.

If the architecture doesn't provide posix_fadvise(), does that imply
that __NR_fadvise64_64 also doesn't exist?

Or do you mean that for some reason, uClibc is not providing
posix_fadvise on all architectures, even though the kernel supports it?

That seems wierd.

	      	     		    	 	- Ted

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] e4defrag: fix build when posix_fadvise is missing
  2014-01-01 17:22 ` Theodore Ts'o
@ 2014-01-01 17:31   ` Baruch Siach
  2014-01-01 17:37     ` Theodore Ts'o
  0 siblings, 1 reply; 7+ messages in thread
From: Baruch Siach @ 2014-01-01 17:31 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

Hi Ted,

On Wed, Jan 01, 2014 at 12:22:05PM -0500, Theodore Ts'o wrote:
> On Wed, Jan 01, 2014 at 12:28:23PM +0200, Baruch Siach wrote:
> > uClibc declares posix_fadvise() even when the architecture does not provide
> > one. The static posix_fadvise() signature is not compatible with POSIX. Rename
> > the internal implementation to fix this.
> 
> If the architecture doesn't provide posix_fadvise(), does that imply
> that __NR_fadvise64_64 also doesn't exist?
> 
> Or do you mean that for some reason, uClibc is not providing
> posix_fadvise on all architectures, even though the kernel supports it?
> 
> That seems wierd.

The xtensa architecture has __NR_fadvise64_64 but not __NR_fadvise64. Should I 
clarify this in the commit log?

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] e4defrag: fix build when posix_fadvise is missing
  2014-01-01 17:31   ` Baruch Siach
@ 2014-01-01 17:37     ` Theodore Ts'o
  2014-01-01 19:08       ` Baruch Siach
  0 siblings, 1 reply; 7+ messages in thread
From: Theodore Ts'o @ 2014-01-01 17:37 UTC (permalink / raw)
  To: Baruch Siach; +Cc: linux-ext4

On Wed, Jan 01, 2014 at 07:31:46PM +0200, Baruch Siach wrote:
> > Or do you mean that for some reason, uClibc is not providing
> > posix_fadvise on all architectures, even though the kernel supports it?
> > 
> > That seems wierd.
> 
> The xtensa architecture has __NR_fadvise64_64 but not __NR_fadvise64. Should I 
> clarify this in the commit log?

Is uClibc providing a posix_fadvise64()?  Maybe the better fix would be
to try to use posix_fadvise64 if it is exists, with posix_fadvise()
and the locally defined posix_fadvise() as fallbacks.

If not, why is uClibc not providing any userspace access to
posix_fadvise, if the kernel suppots it, and it's insisting on
providing a function delcaration for it?

						- Ted

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] e4defrag: fix build when posix_fadvise is missing
  2014-01-01 17:37     ` Theodore Ts'o
@ 2014-01-01 19:08       ` Baruch Siach
  2014-01-01 20:46         ` Theodore Ts'o
  0 siblings, 1 reply; 7+ messages in thread
From: Baruch Siach @ 2014-01-01 19:08 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

Hi Ted,

On Wed, Jan 01, 2014 at 12:37:44PM -0500, Theodore Ts'o wrote:
> On Wed, Jan 01, 2014 at 07:31:46PM +0200, Baruch Siach wrote:
> > > Or do you mean that for some reason, uClibc is not providing
> > > posix_fadvise on all architectures, even though the kernel supports it?
> > > 
> > > That seems wierd.
> > 
> > The xtensa architecture has __NR_fadvise64_64 but not __NR_fadvise64. Should I 
> > clarify this in the commit log?
> 
> Is uClibc providing a posix_fadvise64()?

Yes. uClibc does provide posix_fadvise64() when __NR_fadvise64_64 is 
available.

> Maybe the better fix would be to try to use posix_fadvise64 if it is exists, 
> with posix_fadvise() and the locally defined posix_fadvise() as fallbacks.

OK. So you suggest to add another autoconf test for posix_fadvise64 and use 
that as a fall back before trying direct syscall()?

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] e4defrag: fix build when posix_fadvise is missing
  2014-01-01 19:08       ` Baruch Siach
@ 2014-01-01 20:46         ` Theodore Ts'o
  2014-01-02  6:49           ` Baruch Siach
  0 siblings, 1 reply; 7+ messages in thread
From: Theodore Ts'o @ 2014-01-01 20:46 UTC (permalink / raw)
  To: Baruch Siach; +Cc: linux-ext4

On Wed, Jan 01, 2014 at 09:08:00PM +0200, Baruch Siach wrote:
> 
> Yes. uClibc does provide posix_fadvise64() when __NR_fadvise64_64 is 
> available.
> 
> > Maybe the better fix would be to try to use posix_fadvise64 if it is exists, 
> > with posix_fadvise() and the locally defined posix_fadvise() as fallbacks.
> 
> OK. So you suggest to add another autoconf test for posix_fadvise64 and use 
> that as a fall back before trying direct syscall()?

Yes, I think that's the more general and hence the more correct
answer.  In fact what we have right now is arguably wrong, since on a
32-bit platform where off_t is 32-bits, and which defines
posix_fadvise, we wouldn't correctly handle files that are larger than
2GB.  So if posix_fadvise64 exists, we should be using in preference
to posix_fadvise(), even if both are provided by the C library.

Would you mind sending such a revised patch?

Many thanks!!

						- Ted

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] e4defrag: fix build when posix_fadvise is missing
  2014-01-01 20:46         ` Theodore Ts'o
@ 2014-01-02  6:49           ` Baruch Siach
  0 siblings, 0 replies; 7+ messages in thread
From: Baruch Siach @ 2014-01-02  6:49 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-ext4

Hi Ted,

On Wed, Jan 01, 2014 at 03:46:50PM -0500, Theodore Ts'o wrote:
> On Wed, Jan 01, 2014 at 09:08:00PM +0200, Baruch Siach wrote:
> > Yes. uClibc does provide posix_fadvise64() when __NR_fadvise64_64 is 
> > available.
> > 
> > > Maybe the better fix would be to try to use posix_fadvise64 if it is exists, 
> > > with posix_fadvise() and the locally defined posix_fadvise() as fallbacks.
> > 
> > OK. So you suggest to add another autoconf test for posix_fadvise64 and use 
> > that as a fall back before trying direct syscall()?
> 
> Yes, I think that's the more general and hence the more correct
> answer.  In fact what we have right now is arguably wrong, since on a
> 32-bit platform where off_t is 32-bits, and which defines
> posix_fadvise, we wouldn't correctly handle files that are larger than
> 2GB.  So if posix_fadvise64 exists, we should be using in preference
> to posix_fadvise(), even if both are provided by the C library.
> 
> Would you mind sending such a revised patch?

Just sent. Thanks for reviewing.

Turns out that this is actually an uClibc bug. There used to be a 
posix_fadvise definition for xtensa as a wrapper around the __NR_fadvise64_64 
system call. This broke with uClibc commit ee84b8b400 (linux: posix_fadvise: 
use new SYSCALL_ALIGN_64BIT). The patch I have sent can be used as a 
workaround for now. I'll send a separate patch for uClibc later.

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-01-02  6:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-01 10:28 [PATCH] e4defrag: fix build when posix_fadvise is missing Baruch Siach
2014-01-01 17:22 ` Theodore Ts'o
2014-01-01 17:31   ` Baruch Siach
2014-01-01 17:37     ` Theodore Ts'o
2014-01-01 19:08       ` Baruch Siach
2014-01-01 20:46         ` Theodore Ts'o
2014-01-02  6:49           ` Baruch Siach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).