All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ceph: add destination file data sync before doing any remote copy
@ 2018-10-23  8:53 Luis Henriques
  2018-10-23 11:38 ` Yan, Zheng
  0 siblings, 1 reply; 2+ messages in thread
From: Luis Henriques @ 2018-10-23  8:53 UTC (permalink / raw)
  To: Yan, Zheng, Sage Weil, Ilya Dryomov
  Cc: ceph-devel, linux-kernel, Luis Henriques

If we try to copy into a file that was just written, any data that is remote
copied will be overwritten by our buffered writes once they are flushed.  When
this happens, the call to invalidate_inode_pages2_range will also return a
-EBUSY error.

This patch fixes this by also sync'ing the destination file before starting any
copy.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
---
 fs/ceph/file.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index f788496fafcc..b4607baa8969 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -1932,10 +1932,17 @@ static ssize_t ceph_copy_file_range(struct file *src_file, loff_t src_off,
 	if (!prealloc_cf)
 		return -ENOMEM;
 
-	/* Start by sync'ing the source file */
+	/* Start by sync'ing the source and destination files */
 	ret = file_write_and_wait_range(src_file, src_off, (src_off + len));
-	if (ret < 0)
+	if (ret < 0) {
+		dout("failed to write src file (%zd)\n", ret);
+		goto out;
+	}
+	ret = file_write_and_wait_range(dst_file, dst_off, (dst_off + len));
+	if (ret < 0) {
+		dout("failed to write dst file (%zd)\n", ret);
 		goto out;
+	}
 
 	/*
 	 * We need FILE_WR caps for dst_ci and FILE_RD for src_ci as other

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

* Re: [PATCH] ceph: add destination file data sync before doing any remote copy
  2018-10-23  8:53 [PATCH] ceph: add destination file data sync before doing any remote copy Luis Henriques
@ 2018-10-23 11:38 ` Yan, Zheng
  0 siblings, 0 replies; 2+ messages in thread
From: Yan, Zheng @ 2018-10-23 11:38 UTC (permalink / raw)
  To: Luis Henriques
  Cc: Zheng Yan, Sage Weil, Ilya Dryomov, ceph-devel,
	Linux Kernel Mailing List

On Tue, Oct 23, 2018 at 5:08 PM Luis Henriques <lhenriques@suse.com> wrote:
>
> If we try to copy into a file that was just written, any data that is remote
> copied will be overwritten by our buffered writes once they are flushed.  When
> this happens, the call to invalidate_inode_pages2_range will also return a
> -EBUSY error.
>
> This patch fixes this by also sync'ing the destination file before starting any
> copy.
>
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
> ---
>  fs/ceph/file.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index f788496fafcc..b4607baa8969 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -1932,10 +1932,17 @@ static ssize_t ceph_copy_file_range(struct file *src_file, loff_t src_off,
>         if (!prealloc_cf)
>                 return -ENOMEM;
>
> -       /* Start by sync'ing the source file */
> +       /* Start by sync'ing the source and destination files */
>         ret = file_write_and_wait_range(src_file, src_off, (src_off + len));
> -       if (ret < 0)
> +       if (ret < 0) {
> +               dout("failed to write src file (%zd)\n", ret);
> +               goto out;
> +       }
> +       ret = file_write_and_wait_range(dst_file, dst_off, (dst_off + len));
> +       if (ret < 0) {
> +               dout("failed to write dst file (%zd)\n", ret);
>                 goto out;
> +       }
>
>         /*
>          * We need FILE_WR caps for dst_ci and FILE_RD for src_ci as other

Applied, thanks

Yan, Zheng

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

end of thread, other threads:[~2018-10-23 11:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23  8:53 [PATCH] ceph: add destination file data sync before doing any remote copy Luis Henriques
2018-10-23 11:38 ` Yan, Zheng

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.