From patchwork Mon Nov 9 03:04:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 7580331 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2E94DC05C6 for ; Mon, 9 Nov 2015 03:04:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4729820639 for ; Mon, 9 Nov 2015 03:04:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6630920636 for ; Mon, 9 Nov 2015 03:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbbKIDEy (ORCPT ); Sun, 8 Nov 2015 22:04:54 -0500 Received: from mail-io0-f170.google.com ([209.85.223.170]:35390 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752108AbbKIDEy (ORCPT ); Sun, 8 Nov 2015 22:04:54 -0500 Received: by ioc74 with SMTP id 74so107627291ioc.2; Sun, 08 Nov 2015 19:04:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=L2cBI0+cssabEuifHslHHS0sVOUkgm9/7f3tV10AIPk=; b=xs0MlUK4iPfCqlGtKTlBhggMftfRndw0n2k9lYdw7yDQPggih4WTPvX6MFClY2BlM6 bqReXrnzSUrpZyidqlNDyVr1RvVomqi31VV26wYt8hxye/hx3jDULc9A8Y+MWUrM+cMF inA+J3RmWZrJBTfI6HQdKf3HzfFwIUjYr144/hP/QiqGhbH0X1FLJjBrgnGEeKl2Hq/q xv/LuPBSlRVb3I0MZ9drOJsA/CEsDd41Zu3CXFq36rBlC5UJ0TYjN4mMrDclW7BONc9H MQyzrwexIWb08i8mxtdrTOF2MhJz0BBizVzG1xZVe63a0OAupl6l8jdivBWnO7m/uHYU 2itA== X-Received: by 10.107.7.24 with SMTP id 24mr21672521ioh.48.1447038293585; Sun, 08 Nov 2015 19:04:53 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.116.213 with HTTP; Sun, 8 Nov 2015 19:04:34 -0800 (PST) From: Steve French Date: Sun, 8 Nov 2015 21:04:34 -0600 Message-ID: Subject: Samba server bug: CopyChunk from one share to a different share on same server To: "linux-cifs@vger.kernel.org" , samba-technical , linux-fsdevel Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Tried a quick experiment using cloner (David's tool in xfstests/src/cloner.c) to copy a file from share1 to share2 on the same target server (using CopyChunk and SMB3). Works fine for Windows (tried Windows 8.1 as server) but failed for Samba 4.2. This is one of the more important cases to support (copying a file from one share to another). Samba returned STATUS_OBJECT_NAME_NOT_FOUND on FSCTL_SRV_COPYCHUNK_WRITE unless source and target are on the same share. I didn't try it with vfs_btrfs (the test system was running ext4, and both exports are on the same volume on the server). Was testing the change below where I relax the copy offload check in cifs.ko as follows (to allow cross share copy chunk as Windows often does) diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c index 28a77bf..35cf990 100644 --- a/fs/cifs/ioctl.c +++ b/fs/cifs/ioctl.c @@ -85,9 +85,14 @@ static long cifs_ioctl_clone(unsigned int xid, struct file *dst_file, src_tcon = tlink_tcon(smb_file_src->tlink); target_tcon = tlink_tcon(smb_file_target->tlink); - /* check if source and target are on same tree connection */ - if (src_tcon != target_tcon) { - cifs_dbg(VFS, "file copy src and target on different volume\n"); + /* check source and target on same server (or volume if dup_extents) */ + if (dup_extents && (src_tcon != target_tcon)) { + cifs_dbg(VFS, "source and target of copy not on same share\n"); + goto out_fput; + } + + if (!dup_extents && (src_tcon->ses != target_tcon->ses)) { + cifs_dbg(VFS, "source and target of copy not on same server\n"); goto out_fput; }