From patchwork Fri Dec 19 06:38:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nakajima Akira X-Patchwork-Id: 5517611 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BC2259F443 for ; Fri, 19 Dec 2014 06:50:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D83AF2012D for ; Fri, 19 Dec 2014 06:50:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C278F2012B for ; Fri, 19 Dec 2014 06:50:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751681AbaLSGuD (ORCPT ); Fri, 19 Dec 2014 01:50:03 -0500 Received: from fb.nttcom.co.jp ([132.222.120.60]:36179 "EHLO fb.nttcom.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751230AbaLSGuB (ORCPT ); Fri, 19 Dec 2014 01:50:01 -0500 X-Greylist: delayed 710 seconds by postgrey-1.27 at vger.kernel.org; Fri, 19 Dec 2014 01:50:01 EST Received: from email1.nttcom.co.jp (email1 [132.222.120.23]) by fb.nttcom.co.jp (unknown) with ESMTP id sBJ6cDi1016245 for ; Fri, 19 Dec 2014 15:38:13 +0900 (JST) Received: from atmf.nttcom.co.jp (at-mf1 [10.133.179.37]) by email1.nttcom.co.jp (unknown) with ESMTP id sBJ6cAd4023421 for ; Fri, 19 Dec 2014 15:38:10 +0900 (JST) Received: from 10.133.172.233 (10.133.172.233) by Mail-Filter-Server with ESMTP; Fri, 19 Dec 2014 15:38:05 +0900 Received: from imail1i.nttcom.co.jp (imss02 [10.133.158.42]) by imail1v.nttcom.co.jp (unknown) with ESMTP id sBJ6c1W8024831 for ; Fri, 19 Dec 2014 15:38:01 +0900 (JST) Received: from WMCAS5.soad.nttcom.co.jp ([10.144.1.135]) by imail1i.nttcom.co.jp (unknown) with ESMTP id sBJ6c1Eg024828 for ; Fri, 19 Dec 2014 15:38:01 +0900 (JST) Received: from [10.1.1.239] (10.133.1.147) by WMCAS5.soad.nttcom.co.jp (10.144.1.135) with Microsoft SMTP Server id 14.3.146.0; Fri, 19 Dec 2014 15:38:00 +0900 Message-ID: <5493C7D6.4080708@nttcom.co.jp> Date: Fri, 19 Dec 2014 15:38:14 +0900 From: Nakajima Akira User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Subject: [PATCH] cifs: make new inode cache when file type is different X-Originating-IP: [10.133.1.147] 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 In spite of different file type, if file is same name and same inode number, old inode cache is used. This causes that you can not cd directory, can not cat SymbolicLink. So this patch is that if file type is different, return error. Reproducible sample : 1. create file 'a' at cifs client. 2. repeat rm and mkdir 'a' 4 times at server, then direcotry 'a' having same inode number is created. (Repeat 4 times, then same inode number is recycled.) (When server is under RHEL 6.6, 1 time is O.K. Always same inode number is recycled.) 3. ls -li at client, then you can not cd directory, can not remove directory. SymbolicLink has same problem. Bug link: https://bugzilla.kernel.org/show_bug.cgi?id=90011 Signed-off-by: Nakajima Akira . Acked-by: Jeff Layton --- To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -uprN -X linux-3.18-vanilla/Documentation/dontdiff linux-3.18-vanilla/fs/cifs/readdir.c linux-3.18/fs/cifs/readdir.c --- linux-3.18-vanilla/fs/cifs/readdir.c 2014-12-08 07:21:05.000000000 +0900 +++ linux-3.18/fs/cifs/readdir.c 2014-12-18 14:52:56.268466677 +0900 @@ -69,7 +69,8 @@ static inline void dump_cifs_file_struct * Attempt to preload the dcache with the results from the FIND_FIRST/NEXT * * Find the dentry that matches "name". If there isn't one, create one. If it's - * a negative dentry or the uniqueid changed, then drop it and recreate it. + * a negative dentry or the uniqueid or filetype(mode) changed, + * then drop it and recreate it. */ static void cifs_prime_dcache(struct dentry *parent, struct qstr *name, @@ -97,8 +98,11 @@ cifs_prime_dcache(struct dentry *parent, if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) fattr->cf_uniqueid = CIFS_I(inode)->uniqueid; - /* update inode in place if i_ino didn't change */ - if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { + /* update inode in place + * if both i_ino and i_mode didn't change */ + if (CIFS_I(inode)->uniqueid == fattr->cf_uniqueid && + (inode->i_mode & S_IFMT) == + (fattr->cf_mode & S_IFMT)) { cifs_fattr_to_inode(inode, fattr); goto out; }