All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allison Collins <allison.henderson@oracle.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/4] xfs_restore: support fallocate when reserving space for a file
Date: Mon, 6 May 2019 17:11:56 -0700	[thread overview]
Message-ID: <55ae004d-9ba4-0a92-b3e5-b71e8182ed1f@oracle.com> (raw)
In-Reply-To: <155085406431.5141.9035398131483539445.stgit@magnolia>

On 2/22/19 9:47 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Update the file creation helper to try fallocate when restoring a
> filesystem before it tries RESVSP.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>   configure.ac          |    2 ++
>   include/builddefs.in  |    1 +
>   m4/Makefile           |    1 +
>   m4/package_libcdev.m4 |   15 +++++++++++++++
>   restore/Makefile      |    4 ++++
>   restore/dirattr.c     |   11 +++++++++++
>   6 files changed, 34 insertions(+)
>   create mode 100644 m4/package_libcdev.m4
> 
> 
> diff --git a/configure.ac b/configure.ac
> index a77054c..73dedd7 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -84,6 +84,8 @@ AC_PACKAGE_NEED_ATTRIBUTES_H
>   AC_PACKAGE_NEED_ATTRIBUTES_MACROS
>   AC_PACKAGE_NEED_ATTRGET_LIBATTR
>   
> +AC_HAVE_FALLOCATE
> +
>   AC_MANUAL_FORMAT
>   
>   AC_CONFIG_FILES([include/builddefs])
> diff --git a/include/builddefs.in b/include/builddefs.in
> index 269c928..1c7e12f 100644
> --- a/include/builddefs.in
> +++ b/include/builddefs.in
> @@ -69,6 +69,7 @@ ENABLE_SHARED	= @enable_shared@
>   ENABLE_GETTEXT	= @enable_gettext@
>   
>   HAVE_ZIPPED_MANPAGES = @have_zipped_manpages@
> +HAVE_FALLOCATE = @have_fallocate@
>   
>   GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
>   #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
> diff --git a/m4/Makefile b/m4/Makefile
> index 9a35056..ae452f7 100644
> --- a/m4/Makefile
> +++ b/m4/Makefile
> @@ -16,6 +16,7 @@ LSRCFILES = \
>   	manual_format.m4 \
>   	package_attrdev.m4 \
>   	package_globals.m4 \
> +	package_libcdev.m4 \
>   	package_ncurses.m4 \
>   	package_pthread.m4 \
>   	package_utilies.m4 \
> diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
> new file mode 100644
> index 0000000..050f82c
> --- /dev/null
> +++ b/m4/package_libcdev.m4
> @@ -0,0 +1,15 @@
> +#
> +# Check if we have a fallocate libc call (Linux)
> +#
> +AC_DEFUN([AC_HAVE_FALLOCATE],
> +  [ AC_MSG_CHECKING([for fallocate])
> +    AC_TRY_LINK([
> +#include <fcntl.h>
> +#include <linux/falloc.h>
> +    ], [
> +         fallocate(0, 0, 0, 0);
> +    ], have_fallocate=yes
> +       AC_MSG_RESULT(yes),
> +       AC_MSG_RESULT(no))
> +    AC_SUBST(have_fallocate)
> +  ])
> diff --git a/restore/Makefile b/restore/Makefile
> index 20c870a..ac3f8c8 100644
> --- a/restore/Makefile
> +++ b/restore/Makefile
> @@ -102,6 +102,10 @@ LTDEPENDENCIES = $(LIBRMT)
>   
>   LCFLAGS = -DRESTORE
>   
> +ifeq ($(HAVE_FALLOCATE),yes)
> +LCFLAGS += -DHAVE_FALLOCATE
> +endif
> +
>   default: depend $(LTCOMMAND)
>   
>   include $(BUILDRULES)
> diff --git a/restore/dirattr.c b/restore/dirattr.c
> index 3fa8fb6..82eb1de 100644
> --- a/restore/dirattr.c
> +++ b/restore/dirattr.c
> @@ -75,6 +75,17 @@ create_filled_file(
>   	if (fd < 0)
>   		return fd;
>   
> +#ifdef HAVE_FALLOCATE
> +	ret = fallocate(fd, 0, 0, size);
> +	if (ret && (errno != EOPNOTSUPP && errno != ENOTTY))
> +		mlog(MLOG_VERBOSE | MLOG_NOTE,
> +_("attempt to reserve %lld bytes for %s using %s failed: %s (%d)\n"),
> +				size, pathname, "fallocate",
> +				strerror(errno), errno);
> +	if (ret == 0)
> +		goto done;
This is the goto I referenced in patch 1.  Otherwise I think the rest is ok.

Reviewed-by: Allison Collins <allison.henderson@oracle.com>

> +#endif
> +
>   	ret = ioctl(fd, XFS_IOC_RESVSP64, &fl);
>   	if (ret && (errno != EOPNOTSUPP && errno != ENOTTY))
>   		mlog(MLOG_VERBOSE | MLOG_NOTE,
> 

  reply	other threads:[~2019-05-07  0:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 16:47 [PATCH 0/4] xfsdump: update to use fallocate Darrick J. Wong
2019-02-22 16:47 ` [PATCH 1/4] xfs_restore: refactor open-coded file creation code Darrick J. Wong
2019-02-22 19:20   ` Andre Noll
2019-02-22 19:28     ` Darrick J. Wong
2019-02-22 19:55       ` Andre Noll
2019-05-07  0:11   ` Allison Collins
2019-05-20 21:05     ` Darrick J. Wong
2019-02-22 16:47 ` [PATCH 2/4] xfs_restore: check return value Darrick J. Wong
2019-05-07  0:11   ` Allison Collins
2019-02-22 16:47 ` [PATCH 3/4] xfs_restore: fix unsupported ioctl detection Darrick J. Wong
2019-05-07  0:11   ` Allison Collins
2019-02-22 16:47 ` [PATCH 4/4] xfs_restore: support fallocate when reserving space for a file Darrick J. Wong
2019-05-07  0:11   ` Allison Collins [this message]
2019-05-06 18:24 ` [PATCH 0/4] xfsdump: update to use fallocate Darrick J. Wong
2019-08-20 20:21 Darrick J. Wong
2019-08-20 20:21 ` [PATCH 4/4] xfs_restore: support fallocate when reserving space for a file 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=55ae004d-9ba4-0a92-b3e5-b71e8182ed1f@oracle.com \
    --to=allison.henderson@oracle.com \
    --cc=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.