From patchwork Thu Jul 11 05:11:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 2825989 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6264EC0AB2 for ; Thu, 11 Jul 2013 05:11:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C85320121 for ; Thu, 11 Jul 2013 05:11:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 575ED2011D for ; Thu, 11 Jul 2013 05:11:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750904Ab3GKFLU (ORCPT ); Thu, 11 Jul 2013 01:11:20 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:38468 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750841Ab3GKFLT (ORCPT ); Thu, 11 Jul 2013 01:11:19 -0400 Received: by mail-pa0-f51.google.com with SMTP id lf11so7473710pab.24 for ; Wed, 10 Jul 2013 22:11:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=Kj97hWu0rvZQ80M+JVqBCUGAlH8Rvf2z4HaoJMJ5NIU=; b=Vx4BoCUvN7m/JlOPFj8LqJ5AGEHd1HqpgCzrtY/DjH/P2R0HLMsE8khOCkc4quhyHv wf9n5ZxCoTzW5a69SyPteB1RKCLDvbk0L8BdSCrC741Pv+04FN5AS4CzG0BnWMukZuyX CrdW2JbKmizPxZOaBtAvb+D0bwXz2gnyQckO9PWzDxhzR6kyIefMB9jZ2/rqkF+Ec1QP J8wm4QcEZiuo4AnUZwUC2llzyfJlUvMzt8E9qf1MC3/8ibQ4MCJmn3t+/pQ5lE3C2V2A QEAGQX1Fa++vFLd1ByYEutUT6StnXTPUNVjV3yA8dk4CSwfi8I2uQiIKBF4js+gZuF2D SLtA== MIME-Version: 1.0 X-Received: by 10.66.163.38 with SMTP id yf6mr34940840pab.34.1373519478769; Wed, 10 Jul 2013 22:11:18 -0700 (PDT) Received: by 10.68.122.228 with HTTP; Wed, 10 Jul 2013 22:11:18 -0700 (PDT) Date: Thu, 11 Jul 2013 00:11:18 -0500 Message-ID: Subject: SMB2/SMB3 symlinks broken From: Steve French To: linux-cifs@vger.kernel.org Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Was trying to decide if enabling mfsymlinks by default for smb2/smb3 made sense (since Windows symlinks are for admin only) and these symlinks are commonly used by Apple (and work on cifs), but aren't implemented yet in cifs.ko for smb2 or later mounts In testing though, noticed that specifying "mfsymlinks" on an smb2/smb3 mount causes cifs.ko to send a cifs open (which the server rejects forcing a reconnect). The obvious fix for this would be to make link.c protocol generic as we did for a few other cifs functions - but I am now leaning against this in favor of adding a new version specific op - basically doing an smb2/smb3 protocol worker which calls the smb2/smb3 specific "open_op_close" (need to add write as a valid op) and then add cleanup if the open succeeds but the write fails. Fixing up link.c by making open version generic (see below) is ok (and there are only three places that call) - but write is hard to fixup correctly in a protocol generic way and it prevents us from doing this as one compounded op (open/write/close) or query (open/query/close) to optimize in the smb2/smb3 case. Looks like repeating this type of change 3 times in fs/cifs/link.c is the wrong approach so I will work on an smb2/smb3 symlink version op tomorrow. nls_codepage = cifs_sb->local_nls; @@ -211,9 +212,16 @@ CIFSCreateMFSymLink(const unsigned int xid, struct cifs_tcon *tcon, if (backup_cred(cifs_sb)) create_options |= CREATE_OPEN_BACKUP_INTENT; - rc = CIFSSMBOpen(xid, tcon, fromName, FILE_CREATE, GENERIC_WRITE, - create_options, &netfid, &oplock, NULL, - nls_codepage, remap); + oparms.tcon = tcon; + oparms.cifs_sb = cifs_sb; + oparms.disposition = FILE_CREATE; + oparms.desired_access = GENERIC_WRITE; + oparms.create_options = create_options; + oparms.path = fromName; + oparms.fid = &cfile->fid; + oparms.reconnect = true; + + rc = server->ops->open(xid, &oparms, &oplock, NULL); if (rc != 0) { kfree(buf); return rc; diff --git a/fs/cifs/link.c b/fs/cifs/link.c index b83c3f5..5c9c7ad 100644 --- a/fs/cifs/link.c +++ b/fs/cifs/link.c @@ -189,10 +189,11 @@ CIFSCreateMFSymLink(const unsigned int xid, struct cifs_tcon *tcon, int oplock = 0; int remap; int create_options = CREATE_NOT_DIR; - __u16 netfid = 0; u8 *buf; unsigned int bytes_written = 0; + struct cifs_fid cfile; struct cifs_io_parms io_parms; + struct cifs_open_parms oparms; struct nls_table *nls_codepage;