From patchwork Wed Jul 1 11:21:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 29346 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.samba.org (mail.samba.org [66.70.73.150]) by bilbo.ozlabs.org (Postfix) with ESMTP id B0AEBB70B0 for ; Wed, 1 Jul 2009 21:23:22 +1000 (EST) Received: from dp.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id 2E2F4163CFF for ; Wed, 1 Jul 2009 11:22:45 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on dp.samba.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.8 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.1.7 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from mx2.redhat.com (mx2.redhat.com [66.187.237.31]) by lists.samba.org (Postfix) with ESMTP id 7D473163BF6 for ; Wed, 1 Jul 2009 11:20:33 +0000 (GMT) Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n61BL4YH010671; Wed, 1 Jul 2009 07:21:04 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n61BL3l9017783; Wed, 1 Jul 2009 07:21:03 -0400 Received: from [10.11.12.147] (vpn-12-147.rdu.redhat.com [10.11.12.147]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n61BL2nI004281; Wed, 1 Jul 2009 07:21:02 -0400 Subject: Re: [linux-cifs-client] mkstemp fails on cifs linux-2.6.31-rc1 / samba-3.3.6 From: Jeff Layton To: Shirish Pargaonkar In-Reply-To: <4a4634330907010401x5b3208c2mf3490b577cbd35f9@mail.gmail.com> References: <200906301300.13865.wilhelm.meier@fh-kl.de> <1246366908.13212.10.camel@tupile.poochiereds.net> <4a4634330906300627y271d0f36v1c608789a1235185@mail.gmail.com> <1246369203.13212.18.camel@tupile.poochiereds.net> <4a4634330906301136l426b2ecifdeb10ac731394a4@mail.gmail.com> <4a4634330907010401x5b3208c2mf3490b577cbd35f9@mail.gmail.com> Date: Wed, 01 Jul 2009 07:21:09 -0400 Message-Id: <1246447269.19612.8.camel@tupile.poochiereds.net> Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Cc: wilhelm.meier@fh-kl.de, linux-cifs-client@lists.samba.org X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces+incoming=patchwork.ozlabs.org@lists.samba.org Errors-To: linux-cifs-client-bounces+incoming=patchwork.ozlabs.org@lists.samba.org On Wed, 2009-07-01 at 06:01 -0500, Shirish Pargaonkar wrote: > > I think the problem is, why EEXIST since file does not exist. The > looping is I guess > because mktemp then attempts to create another file and receives EEXIST and it > goes on forever. > So the basic issues is why EEXIST since mktemp is attempting a file > which does not > exist on the server. The problem is that the lookup is returning a positive dentry since it just created the file. This makes the VFS turn around and return -EEXIST (see the second O_EXCL check in do_filp_open). So we do have to skip the create on lookup for O_EXCL or it won't work. I think what's needed is something like this patch. It seems to fix the testcase for me. That said, this is not adequately regression tested and should not be committed until it is. On that note, I'd like to reiterate my earlier sentiment that all of this create-on-lookup code was committed prematurely and should be backed out until it's more fully baked. Just my USD$.02... >From 7edbbd8dfa17b7865a25c97f3b586fefbf2a73b3 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 1 Jul 2009 07:12:03 -0400 Subject: [PATCH] cifs: fix regression with O_EXCL creates and optimize away lookup Signed-off-by: Jeff Layton --- fs/cifs/dir.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-) diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 7dc6b74..0ac4859 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -643,6 +643,15 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, } } + /* + * O_EXCL: optimize away the lookup, but don't hash the dentry. Let + * the VFS handle the create. + */ + if (nd->flags & LOOKUP_EXCL) { + d_instantiate(direntry, NULL); + return 0; + } + /* can not grab the rename sem here since it would deadlock in the cases (beginning of sys_rename itself) in which we already have the sb rename sem */ -- 1.6.0.6