Fix use of fallocate on systems that do not export FALLOC_FL_KEEP_SIZE and FALLOC_FL_PUNCH_HOLE in fcntl.h

Submitted by Pawel Stradomski on July 24, 2018, 11:10 a.m.

Details

Message ID 0000000000004c6e440571bcd979@google.com
State Rejected
Series "Fix use of fallocate on systems that do not export FALLOC_FL_KEEP_SIZE and FALLOC_FL_PUNCH_HOLE in fcntl.h"
Headers show

Commit Message

Pawel Stradomski July 24, 2018, 11:10 a.m.
Signed-off-by: Pawel Stradomski <pstradomski@google.com>
---
 criu/pie/restorer.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
index 3f1a8a6b..c5aee895 100644
--- a/criu/pie/restorer.c
+++ b/criu/pie/restorer.c
@@ -50,6 +50,15 @@ 
 #define PR_SET_PDEATHSIG 1
 #endif
 
+#ifndef FALLOC_FL_KEEP_SIZE
+#define FALLOC_FL_KEEP_SIZE     0x01
+#endif
+
+#ifndef FALLOC_FL_PUNCH_HOLE
+#define FALLOC_FL_PUNCH_HOLE    0x02
+#endif
+
+
 #define sys_prctl_safe(opcode, val1, val2, val3)			\
 	({								\
 		long __ret = sys_prctl(opcode, val1, val2, val3, 0);	\
@@ -1379,7 +1388,6 @@  long __export_restore_task(struct task_restore_args *args)
 			/* TODO: Check if auto-dedup is enabled instead of trusting fallocate to fail
 			 * if the file is not opened for writing. */
 			if (r > 0) {
-				pr_debug("   `fallocate %d %ld %ld\n", args->vma_ios_fd,  rio->off, r);
 				sys_fallocate(args->vma_ios_fd, FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE,
 					rio->off, r);
 			}

Comments

Pawel Stradomski July 24, 2018, 11:25 a.m.
I'm not sure how to tell patchwork this should be applied on top of
the previous change. Any hints?
wt., 24 lip 2018 o 13:13 Pawel Stradomski <pstradomski@google.com> napisał(a):
>
> Signed-off-by: Pawel Stradomski <pstradomski@google.com>
> ---
>  criu/pie/restorer.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
> index 3f1a8a6b..c5aee895 100644
> --- a/criu/pie/restorer.c
> +++ b/criu/pie/restorer.c
> @@ -50,6 +50,15 @@
>  #define PR_SET_PDEATHSIG 1
>  #endif
>
> +#ifndef FALLOC_FL_KEEP_SIZE
> +#define FALLOC_FL_KEEP_SIZE     0x01
> +#endif
> +
> +#ifndef FALLOC_FL_PUNCH_HOLE
> +#define FALLOC_FL_PUNCH_HOLE    0x02
> +#endif
> +
> +
>  #define sys_prctl_safe(opcode, val1, val2, val3)                       \
>         ({                                                              \
>                 long __ret = sys_prctl(opcode, val1, val2, val3, 0);    \
> @@ -1379,7 +1388,6 @@ long __export_restore_task(struct task_restore_args *args)
>                         /* TODO: Check if auto-dedup is enabled instead of trusting fallocate to fail
>                          * if the file is not opened for writing. */
>                         if (r > 0) {
> -                               pr_debug("   `fallocate %d %ld %ld\n", args->vma_ios_fd,  rio->off, r);
>                                 sys_fallocate(args->vma_ios_fd, FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE,
>                                         rio->off, r);
>                         }
> --
> 2.18.0.233.g985f88cf7e-goog
>
Andrey Vagin July 24, 2018, 10:23 p.m.
On Tue, Jul 24, 2018 at 01:25:34PM +0200, Paweł Stradomski wrote:
> I'm not sure how to tell patchwork this should be applied on top of
> the previous change. Any hints?

If a previous patch isn't merged, you need to resent it with a fix.

> wt., 24 lip 2018 o 13:13 Pawel Stradomski <pstradomski@google.com> napisał(a):
> >
> > Signed-off-by: Pawel Stradomski <pstradomski@google.com>
> > ---
> >  criu/pie/restorer.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/criu/pie/restorer.c b/criu/pie/restorer.c
> > index 3f1a8a6b..c5aee895 100644
> > --- a/criu/pie/restorer.c
> > +++ b/criu/pie/restorer.c
> > @@ -50,6 +50,15 @@
> >  #define PR_SET_PDEATHSIG 1
> >  #endif
> >
> > +#ifndef FALLOC_FL_KEEP_SIZE
> > +#define FALLOC_FL_KEEP_SIZE     0x01
> > +#endif
> > +
> > +#ifndef FALLOC_FL_PUNCH_HOLE
> > +#define FALLOC_FL_PUNCH_HOLE    0x02
> > +#endif
> > +
> > +
> >  #define sys_prctl_safe(opcode, val1, val2, val3)                       \
> >         ({                                                              \
> >                 long __ret = sys_prctl(opcode, val1, val2, val3, 0);    \
> > @@ -1379,7 +1388,6 @@ long __export_restore_task(struct task_restore_args *args)
> >                         /* TODO: Check if auto-dedup is enabled instead of trusting fallocate to fail
> >                          * if the file is not opened for writing. */
> >                         if (r > 0) {
> > -                               pr_debug("   `fallocate %d %ld %ld\n", args->vma_ios_fd,  rio->off, r);
> >                                 sys_fallocate(args->vma_ios_fd, FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE,
> >                                         rio->off, r);
> >                         }
> > --
> > 2.18.0.233.g985f88cf7e-goog
> >
> 
> 
> -- 
> Paweł Stradomski
> 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu