From: Jeff Layton <jlayton@kernel.org>
To: Luis Henriques <lhenriques@suse.com>, Sage Weil <sage@redhat.com>,
Ilya Dryomov <idryomov@gmail.com>, "Yan, Zheng" <zyan@redhat.com>,
Gregory Farnum <gfarnum@redhat.com>
Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] ceph: fix copy_file_range error path in short copies
Date: Thu, 06 Feb 2020 06:46:27 -0500 [thread overview]
Message-ID: <fceaee0128a0c81991df6e3531e746e4ebbe5a01.camel@kernel.org> (raw)
In-Reply-To: <20200206103842.14936-1-lhenriques@suse.com>
On Thu, 2020-02-06 at 10:38 +0000, Luis Henriques wrote:
> When there's an error in the copying loop but some bytes have already been
> copied into the destination file, it is necessary to dirty the caps and
> eventually update the MDS with the file metadata (timestamps, size). This
> patch fixes this error path.
>
> Another issue this patch fixes is the destination file size being reported
> to the MDS. If we're on the error path but the amount of bytes written
> has already changed the destination file size, the offset to use is
> dst_off and not endoff.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Luis Henriques <lhenriques@suse.com>
> ---
> fs/ceph/file.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index 11929d2bb594..f7f8cb6c243f 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -2104,9 +2104,16 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off,
> CEPH_OSD_OP_FLAG_FADVISE_DONTNEED, 0);
> if (err) {
> dout("ceph_osdc_copy_from returned %d\n", err);
> - if (!ret)
> + /*
> + * If we haven't done any copy yet, just exit with the
> + * error code; otherwise, return the number of bytes
> + * already copied, update metadata and dirty caps.
> + */
> + if (!ret) {
> ret = err;
> - goto out_caps;
> + goto out_caps;
> + }
> + goto update_dst_inode;
> }
> len -= object_size;
> src_off += object_size;
> @@ -2118,16 +2125,17 @@ static ssize_t __ceph_copy_file_range(struct file *src_file, loff_t src_off,
> /* We still need one final local copy */
> do_final_copy = true;
>
> +update_dst_inode:
> file_update_time(dst_file);
> inode_inc_iversion_raw(dst_inode);
>
> - if (endoff > size) {
> + if (dst_off > size) {
> int caps_flags = 0;
>
> /* Let the MDS know about dst file size change */
> - if (ceph_quota_is_max_bytes_approaching(dst_inode, endoff))
> + if (ceph_quota_is_max_bytes_approaching(dst_inode, dst_off))
> caps_flags |= CHECK_CAPS_NODELAY;
> - if (ceph_inode_set_size(dst_inode, endoff))
> + if (ceph_inode_set_size(dst_inode, dst_off))
> caps_flags |= CHECK_CAPS_AUTHONLY;
> if (caps_flags)
> ceph_check_caps(dst_ci, caps_flags, NULL);
Looks good to me. Merged into ceph-client/testing. We'll see about
getting it in before 5.6 ships.
Thanks,
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2020-02-06 11:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-05 10:28 [PATCH] " Luis Henriques
2020-02-05 11:16 ` Ilya Dryomov
2020-02-05 19:24 ` Luis Henriques
2020-02-06 10:38 ` [PATCH v2] " Luis Henriques
2020-02-06 11:46 ` Jeff Layton [this message]
2020-02-10 18:38 ` Ilya Dryomov
2020-02-11 10:32 ` Luis Henriques
2020-02-11 11:04 ` Ilya Dryomov
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=fceaee0128a0c81991df6e3531e746e4ebbe5a01.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=gfarnum@redhat.com \
--cc=idryomov@gmail.com \
--cc=lhenriques@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sage@redhat.com \
--cc=stable@vger.kernel.org \
--cc=zyan@redhat.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
Powered by JetHome