public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Jan Tulak <jtulak@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 08/11] xfsprogs: replace obsolete memalign with posix_memalign
Date: Tue, 18 Aug 2015 18:20:46 +1000	[thread overview]
Message-ID: <20150818082046.GK714@dastard> (raw)
In-Reply-To: <CACj3i73JFbDaOtggH2JQX6+5hQU3dJFBMObD3qq_BrfEkYA8mw@mail.gmail.com>

On Tue, Aug 18, 2015 at 09:04:24AM +0200, Jan Tulak wrote:
> On Mon, Aug 17, 2015 at 9:36 PM, Christoph Hellwig <hch@infradead.org>
> wrote:
> 
> > On Mon, Aug 17, 2015 at 06:23:23PM +0200, Jan Tulak wrote:
> > > Memalign from <malloc.h> was marked obsolete in favor of a posix
> > > variant from <stdlib.h>. So replace all calls and remove <malloc.h>
> > > includes. This also enhances support on other posix platforms,
> > > which doesn't have <malloc.h>.
> > >
> > > Because posix_memalign returns any error as a return code, not in
> > > errno, change relevant checks in code (and add a missing one).
> >
> > I have to say I hate the posix_memalign calling convention.  Any chance
> > you could just provide a memalign impementation using posix_memalign for
> > MacOS?
> >
> 
> I thought about it. However, with memalign from malloc marked obsolete
> (and with posix_memalign having guaranteed alignment restrictions [1]), I
> saw it better
> to use the posix variant everywhere.

Putting a sane wrapper around an nasty library function is just
fine. The memalign wrapper makes sense from this perspective - even
gcc can't tell if variables passed to posix_memalign are correctly
initialised or not, whereas no such problems exist for memalign().

> I could make a wrapper simulating the old memalign behaviour, but I don't
> think it would make sense.

I think it makes more sense than using posix_memalign() everywhere
and then ignoring the return variable that tells you it failed...

> I searched for this, but didn't find any reasonable answer:
> How long can be things in standard libraries marked obsolete before
> removing?

With a wrapper, we don't care.

> [1] man memalign:
>        On many systems there are alignment restrictions, for example, on buf-
>        fers  used  for  direct  block  device  I/O.  POSIX specifies the path-
>        conf(path,_PC_REC_XFER_ALIGN) call that tells what alignment is needed.
>        Now one can use posix_memalign() to satisfy this requirement.
>
>        posix_memalign()  verifies  that  alignment  matches  the  requirements
>        detailed above.  memalign() may not check that the  alignment argument
>        is correct.

Yes, you can get it wrong with memalign. But we don't, because we
follow the rules for DIO buffer alignment and set it correctly.
Being able to directly control the alignment of the memory buffer is
a reason for using memalign() over posix_memalign(), not the other
way around.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-08-18  8:21 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-17 16:23 [PATCH 00/11] xfsprogs: Partial OS X support Jan Tulak
2015-08-17 16:23 ` [PATCH 01/11] xfsprogs: undefined variable fix Jan Tulak
2015-08-17 19:22   ` Christoph Hellwig
2015-08-17 16:23 ` [PATCH 02/11] xfsprogs: Add ifdef dirent checks where it was missing Jan Tulak
2015-08-17 19:23   ` Christoph Hellwig
2015-08-18  6:49     ` Jan Tulak
2015-08-17 16:23 ` [PATCH 03/11] xfsprogs: Change OS X-specific CFLAGS/LDFLAGS Jan Tulak
2015-08-17 16:23 ` [PATCH 04/11] xfsprogs: Add includes required for OS X builds Jan Tulak
2015-08-17 19:23   ` Christoph Hellwig
2015-08-17 16:23 ` [PATCH 05/11] xfsprogs: missing and dummy calls for OS X support Jan Tulak
2015-08-17 19:32   ` Christoph Hellwig
2015-08-18  0:17     ` Dave Chinner
2015-08-24 12:53     ` Jan Tulak
2015-08-18 21:45   ` Dave Chinner
2015-08-19  8:09     ` Christoph Hellwig
2015-08-19  9:14       ` Jan Tulak
2015-08-19  9:19         ` Christoph Hellwig
2015-08-19 10:26       ` Dave Chinner
2015-08-20  0:22         ` Dave Chinner
2015-08-20  7:33           ` Jan Tulak
2015-08-21  0:43             ` Dave Chinner
2015-08-17 16:23 ` [PATCH 06/11] xfsprogs: Add mntent.h check into autoconf Jan Tulak
2015-08-17 19:32   ` Christoph Hellwig
2015-08-17 16:23 ` [PATCH 07/11] xfsprogs: Add fls " Jan Tulak
2015-08-17 19:32   ` Christoph Hellwig
2015-08-17 16:23 ` [PATCH 08/11] xfsprogs: replace obsolete memalign with posix_memalign Jan Tulak
2015-08-17 19:36   ` Christoph Hellwig
2015-08-18  7:04     ` Jan Tulak
2015-08-18  8:20       ` Dave Chinner [this message]
2015-08-18  8:33         ` Jan Tulak
2015-08-18 22:01           ` Dave Chinner
2015-08-19  8:06             ` Jan Tulak
2015-08-17 16:23 ` [PATCH 09/11] xfsprogs: prevent LIST_ macros conflicts Jan Tulak
2015-08-17 19:36   ` Christoph Hellwig
2015-08-17 16:23 ` [PATCH 10/11] xfsprogs: Update doc for OS X Jan Tulak
2015-08-17 19:36   ` Christoph Hellwig
2015-08-17 16:23 ` [PATCH 11/11] xfsprogs: Add a way to compile without blkid Jan Tulak
2015-08-17 19:39   ` Christoph Hellwig
2015-08-18  7:59     ` Jan Tulak
2015-08-18 12:02     ` [PATCH v2 " Jan Tulak
2015-08-17 21:55 ` [PATCH 00/11] xfsprogs: Partial OS X support Dave Chinner
2015-08-18  9:14   ` Jan Tulak

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=20150818082046.GK714@dastard \
    --to=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=jtulak@redhat.com \
    --cc=xfs@oss.sgi.com \
    /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