Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp160086ybv; Wed, 5 Feb 2020 03:17:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzOeZuC4ilNEl184VdQDrXPFClcinwH/Rgh3QqTXizedx5exWvKMu/L/xbg10J2on7WuEhd X-Received: by 2002:a54:4086:: with SMTP id i6mr2514747oii.65.1580901432017; Wed, 05 Feb 2020 03:17:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580901432; cv=none; d=google.com; s=arc-20160816; b=yXWcLKmf/VFerciTGLKoaOjJ7jdAiRe4nphkczQ15yURUNapkaQ4aXkVxIR6Kn45V+ qJGh6V4yB4YObZ+ksEb5GH7kd3mIes8/FpKiUAI1KXMqO3JAxW/pXB4FtFzu47AY4ctQ 4X3lacVfaUDVtbNGGbfrEF7iO6iwDI6X/q0ynm/e8/h796M0as6kEuNsSzcShFtp0gvP cTha7TJWBnKPpfYx/tXymUkpIYhb1rO9LqCkPFzWKs/WiEEAyW+aq5As/NegxVHukK/E nnC4hrARMXccA+LY8VP55TSObKPPoVMMOohaZ99GHdMBL4Jkgev8GuQNpaW7blWOTugM 8FwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=x8ckLRvDL8dg/iPhi1vO5fg6t5hQSAQsmjIQBiNcoB4=; b=BVHFsS898RmqPD6tXfhb/GMSPrlSQ31CObvmzI3csw8UwfpVA++RMhZe3a9ogT0QHj 3X1rTDDBj3FPGqozEucbB9p7kruZQszWBRSdpG7oUL3F7yHSa8NROMWuSfPtIl7q864Y h9RxSZTXdlJ4XjBGats1XKeERs27F0t50tcbj6fKTflmg75RgWfIoOKocDB694Q7s6/2 ZGP07AGk0BjsF2QbzdBVPDSyd1QA9/5n1WWpuSl9yuD+6MYRbmis7mgLnAMItsex/0dt phQE4OjnWRiL6hayR4Gk9LQ4tdJfB3CD8xmr7Zn8H7ztNy+OFCu1dnKUD+dSWB4zT979 j8Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EMit4qaH; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si12783464ote.72.2020.02.05.03.16.54; Wed, 05 Feb 2020 03:17:12 -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=@gmail.com header.s=20161025 header.b=EMit4qaH; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728282AbgBELPu (ORCPT + 99 others); Wed, 5 Feb 2020 06:15:50 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:42852 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727170AbgBELPu (ORCPT ); Wed, 5 Feb 2020 06:15:50 -0500 Received: by mail-lf1-f65.google.com with SMTP id y19so1187119lfl.9; Wed, 05 Feb 2020 03:15:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=x8ckLRvDL8dg/iPhi1vO5fg6t5hQSAQsmjIQBiNcoB4=; b=EMit4qaHp+ClCDjyyJMWphi8crzhLGi3Smu8kLgmk5GeEWZLArq8dWq6YdlNJzI2Gk tzdNIgVZZ8PnQSPgFY+dN9u8RZk5JhdzutPScZWOr6S7IKi466ZmSnxnjRIskLubxiYv 0EazMj9lgI8fWAOpzK/fZslU6nRAOw4Gwz0BezfxkS2HQWJjEEKiUxmqFLvsldQ6Mg5T svzwQH3256oa3SVEHucPnZoIK7k0Alpj8B0lQQ6GEw//CfL0MPfGIec72ClV1tjCrGS1 OgYH7ZgBKyxrdHmHUoZeLo1dswYbKQr/NRyhxocM3avK7u+zYoRrc/xMI4/un4qwBD7+ SaZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=x8ckLRvDL8dg/iPhi1vO5fg6t5hQSAQsmjIQBiNcoB4=; b=r02dXWSVGXd5s9bbPBs8z1Eihk5b4YrgxN8zcaAkQtqqgyLHcotH9hllJVMc0h3jA6 FC41Pu/LCSKYf1M6mrJNVgGG37EiRUwouQiyhRPUzTYavaczf3Sc0wtf994m1YNCP/I6 xASDX5zouV4h0YNTr9y+HYGgatqV9VySpGPcMf4xcyWvD5B4Q1AbKuMtGfHX0W1JSq9i IJaSrXVHfV1uS7sXoLAo4AsO0Qtbugva9aDhx7JqwALysnlgvoMrhOJpIrqc83IM+On+ aUueIYAE6UQOsowEazh1w8kQlXGFvW5f/EdIAJoLo4xgT3r6z+Q+LqTbby5Vj+ciBhpV BHEQ== X-Gm-Message-State: APjAAAWMqvdUfzXswEiFM+xuJWSak+hgVI6Ae8amLdVizyioW1x7siZt vrs/buHe7frouih9jjAUTdqwXIY9VFxL2oCkdx8= X-Received: by 2002:a05:6512:64:: with SMTP id i4mr17458571lfo.55.1580901348247; Wed, 05 Feb 2020 03:15:48 -0800 (PST) MIME-Version: 1.0 References: <20200205102852.12236-1-lhenriques@suse.com> In-Reply-To: <20200205102852.12236-1-lhenriques@suse.com> From: Ilya Dryomov Date: Wed, 5 Feb 2020 12:16:02 +0100 Message-ID: Subject: Re: [PATCH] ceph: fix copy_file_range error path in short copies To: Luis Henriques Cc: Jeff Layton , Sage Weil , "Yan, Zheng" , Gregory Farnum , Ceph Development , LKML , stable@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 5, 2020 at 11:28 AM 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. > > Cc: stable@vger.kernel.org > Signed-off-by: Luis Henriques > --- > fs/ceph/file.c | 12 ++++++++++-- > 1 file changed, 10 insertions(+), 2 deletions(-) > > diff --git a/fs/ceph/file.c b/fs/ceph/file.c > index 11929d2bb594..7be47d24edb1 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 out_early; > } > len -= object_size; > src_off += object_size; > @@ -2118,6 +2125,7 @@ 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; > > +out_early: out_early is misleading, especially given that there already is out_caps, which just puts caps. I suggest something like update_dst_inode. > file_update_time(dst_file); > inode_inc_iversion_raw(dst_inode); > I think this is still buggy. What follows is this: if (endoff > size) { int caps_flags = 0; /* Let the MDS know about dst file size change */ if (ceph_quota_is_max_bytes_approaching(dst_inode, endoff)) caps_flags |= CHECK_CAPS_NODELAY; if (ceph_inode_set_size(dst_inode, endoff)) caps_flags |= CHECK_CAPS_AUTHONLY; if (caps_flags) ceph_check_caps(dst_ci, caps_flags, NULL); } with endoff being: size = i_size_read(dst_inode); endoff = dst_off + len; So a short copy effectively zero-fills the destination file... Thanks, Ilya