Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp123048ybv; Wed, 5 Feb 2020 02:30:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxyLehfapa1yjfEU4CX4phH/XvGn5GItuT5x3QTuS0yhZXlcwdhxsVGzDb0bWphMuNm16ym X-Received: by 2002:a9d:5885:: with SMTP id x5mr24945577otg.132.1580898603294; Wed, 05 Feb 2020 02:30:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580898603; cv=none; d=google.com; s=arc-20160816; b=zLSrk773QnLK+o95lKCaLOmktVTBq9a1TuZwFwORMJlkBSvVYS4+EXczrcyOGLCTX1 qtVcV24Z8vbNb504291lai6r4oPKzbpPWN4g7L1+YuFa/gxIUfCIeg4+9eoZDUvWhCeM 2ICEmJjeuFuNoyTxW3BI15GiMOqs54j6IPta0ifywyNCxAGBm/pNOJOFzaLOaks8+0NP 0UrvdITtJLlptvdwxwGEBeCe66I05Syi4ACvN8rl42nBzwTudWo4BCW/1QfzoohD27AJ Co8bxfRChs+8/peLZQBzHpZNlFb1uKJdbstIESNrZdpz8/X04c8WjF1RNjn5DT/dVIDQ oFgA== 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 :message-id:date:subject:cc:to:from; bh=r7Mwbyjx6+a3jOXHjvsrLKOkQ9uirHWAquZA7DnKH80=; b=yAPmD9CIo5jmVhJ573IdGPWKnxud0N/eYaIyrb/PpcQQXuaFX5altTUKI02OgROk// 99ZWmxIjerZk396f8g9cfec/y20a3QR1FX8PnRN82qWvrhJxlvtA+AlUFt9wAagDImoI 6ODReQytofWwqnnP+GfKCUYmtOasiL+6+57cgLlRWeavf/i5IxcrprG88C7F5rqWDWEZ HGG9QfbZD4PDZFeduMuxny2UJfSG7xHcC3HfrCUjX32be0mVfUcyGAJaLwh1AiJeiTTr h48WnZI8k9F6dOrUiIGAUURJnxB2AWXEuBWGvLvL/clXr65OMrQ8FA77FYBCGJuSwSeC LJ/w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1si13848083otp.25.2020.02.05.02.29.49; Wed, 05 Feb 2020 02:30:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728142AbgBEK2t (ORCPT + 99 others); Wed, 5 Feb 2020 05:28:49 -0500 Received: from mx2.suse.de ([195.135.220.15]:37754 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727341AbgBEK2t (ORCPT ); Wed, 5 Feb 2020 05:28:49 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 53CD1B00D; Wed, 5 Feb 2020 10:28:47 +0000 (UTC) From: Luis Henriques To: Jeff Layton , Sage Weil , Ilya Dryomov , "Yan, Zheng" , Gregory Farnum Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Luis Henriques , stable@vger.kernel.org Subject: [PATCH] ceph: fix copy_file_range error path in short copies Date: Wed, 5 Feb 2020 10:28:52 +0000 Message-Id: <20200205102852.12236-1-lhenriques@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: file_update_time(dst_file); inode_inc_iversion_raw(dst_inode);