Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1422826ybv; Thu, 6 Feb 2020 03:53:29 -0800 (PST) X-Google-Smtp-Source: APXvYqykgeyYR7iFwP2vZdK9E5hnuhuUfmbO+dndwhFkeZnj+7apwIz/k/ZVD5S2wnqLXO+YxQlV X-Received: by 2002:aca:ad11:: with SMTP id w17mr6723893oie.85.1580990009260; Thu, 06 Feb 2020 03:53:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580990009; cv=none; d=google.com; s=arc-20160816; b=NvEKK8S86E2xvWtehMCkzExiqBKlvQKhnccV1Yx/1ad8Oo+qabjC/V6lNjZYgIfEaE KD283lkTVH3QP3i5+Ehgx93Og0eVdVz3XD0Vo5Nqj6pEQWy76HKPaldvr0Kthd781hZj zJ9jIYp2KvA4nYbcn2wqoXgwVVXan5sTRuLtYO2+XdnAuYTehs6/tsCbvAxgfIrgFNAx iYa/ZninJAHPt7yQ1BKlGAOTpnSmk8g9ESB1pXNQFlm6jSM7p8njuzA8Jt3EcW4RNl6t akUQMzvRj3VxkgrKCH10TbRLvJxSqzqtEFprOPmWcEy7J8myAje8h6tBcNshewVgnGRo 4a7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=v0WMANlZnSYXf7Rnqi8wuKNyTi+/uQwD1tQR02yFKbI=; b=JxzJ/O+ZlCYWOSr/7JDZas//fWBJgQZegAXXkZ4X9R8O9kCwW4YO95Mj2A0uaaLDFp H0FkuGfdy82xbl1e0fxhli4/VMRKP3HQQ6ry7gw6U1jaU2g/WpC5mnYUQVLaMk1DohF/ Zd49/ee9L2yl3fJ39Pk8RWmHE093TFTsdF7WEerlNhKKROIKUCJPaplbZHhAoapXWjbI JWUtMYN8k/kMc8o/6WweRilWAnn4edgzhf/XHD5Ra/E8TWoPelT2ZNpJnNTe51IHMhiI xuPh4FPWIGlvmL5hMN2//rONorhF+m9reErRn/RxWoy+mEbLo4Qy4+jZMXZeJ1VmXXHD zqSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CUjOOdSi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g2si1812586otn.117.2020.02.06.03.53.17; Thu, 06 Feb 2020 03:53:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CUjOOdSi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727641AbgBFLqa (ORCPT + 99 others); Thu, 6 Feb 2020 06:46:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:36786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726538AbgBFLqa (ORCPT ); Thu, 6 Feb 2020 06:46:30 -0500 Received: from tleilax.poochiereds.net (68-20-15-154.lightspeed.rlghnc.sbcglobal.net [68.20.15.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6A9321741; Thu, 6 Feb 2020 11:46:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580989589; bh=6GUHZBcWcsn4ojh9JNJ8oG/rmTYEQXxR7VWpZUWgw7c=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=CUjOOdSilh7/I/uqGXI/mKxCf9U4WLq1ZWq4tbu5VxIzBDnk+ag6BZ+CEOvQWM5MN GY7HnI0tNAmVFV9BE7KFYu5GgwE/2evTXIgZgnqhbDwW0eTQrI91HnAhdP1+vh5Zcd fah4YX92ml1JOzq05PdtXP9WWEQjgeeR30L+RZQQ= Message-ID: Subject: Re: [PATCH v2] ceph: fix copy_file_range error path in short copies From: Jeff Layton To: Luis Henriques , Sage Weil , Ilya Dryomov , "Yan, Zheng" , Gregory Farnum Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Thu, 06 Feb 2020 06:46:27 -0500 In-Reply-To: <20200206103842.14936-1-lhenriques@suse.com> References: <20200205192414.GA27345@suse.com> <20200206103842.14936-1-lhenriques@suse.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.34.3 (3.34.3-1.fc31) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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