From patchwork Mon Dec 3 11:44:37 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1832641 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 3C8B13FC5A for ; Mon, 3 Dec 2012 11:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752813Ab2LCLoq (ORCPT ); Mon, 3 Dec 2012 06:44:46 -0500 Received: from mail-ye0-f174.google.com ([209.85.213.174]:59351 "EHLO mail-ye0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751235Ab2LCLoq (ORCPT ); Mon, 3 Dec 2012 06:44:46 -0500 Received: by mail-ye0-f174.google.com with SMTP id m6so364871yen.19 for ; Mon, 03 Dec 2012 03:44:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=+PBZL4ozgVVZcMdfMaj4w7qgZf/m5+0OM3/pjuMx2MU=; b=E1D4x2JJjRNXvbU30cTzOJMIvHnrGIcY25pWqsU88UFjDqT9qqPNBkCNRKceEBOwuE Q/2CZSLC3KKhtrDWxP82j3z9s1O2trNSBTznvC3jUlIBVhG1fxXPZWA702+fKaAj5vId jeTyJuc72/C7lg15OHYbP6ApuD/i0Rrt4NSXyKni/NOOd6USzDgri+wTmSBJUyGfHmb/ qgDulaZ+BorJNwlHmG/ufod7CVLjdybDbiZTvWOhpsc83Jj5evjMrh9PiQegNssW6XHH gsT8nej6FKjUcjmRz00Op6gPTHOZDp9qowBrqWMovUlFMwuzlIymdcJ2qXqUakKgkenU AhPw== Received: by 10.100.238.20 with SMTP id l20mr2820550anh.79.1354535085734; Mon, 03 Dec 2012 03:44:45 -0800 (PST) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id l35sm12765125yhi.12.2012.12.03.03.44.43 (version=SSLv3 cipher=OTHER); Mon, 03 Dec 2012 03:44:44 -0800 (PST) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org Subject: [PATCH] cifs: rename cifs_readdir_lookup to cifs_prime_dcache and make it void return Date: Mon, 3 Dec 2012 06:44:37 -0500 Message-Id: <1354535077-21548-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 X-Gm-Message-State: ALoCoQlRAr6/yMCqRLCcpQ+AT4ubJ0wmYZafySQkUIqeXajGxVsSe7mJbUwkOZ8ZDXLym+CYEPae Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org The caller doesn't do anything with the dentry, so there's no point in holding a reference to it on return. Also cifs_prime_dcache better describes the actual purpose of the function. Signed-off-by: Jeff Layton --- fs/cifs/readdir.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/fs/cifs/readdir.c b/fs/cifs/readdir.c index 6492092..6002fdc 100644 --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -66,18 +66,20 @@ static inline void dump_cifs_file_struct(struct file *file, char *label) #endif /* DEBUG2 */ /* + * 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. */ -static struct dentry * -cifs_readdir_lookup(struct dentry *parent, struct qstr *name, +static void +cifs_prime_dcache(struct dentry *parent, struct qstr *name, struct cifs_fattr *fattr) { struct dentry *dentry, *alias; struct inode *inode; struct super_block *sb = parent->d_inode->i_sb; - cFYI(1, "For %s", name->name); + cFYI(1, "%s: for %s", __func__, name->name); if (parent->d_op && parent->d_op->d_hash) parent->d_op->d_hash(parent, parent->d_inode, name); @@ -87,37 +89,32 @@ cifs_readdir_lookup(struct dentry *parent, struct qstr *name, dentry = d_lookup(parent, name); if (dentry) { int err; + inode = dentry->d_inode; /* update inode in place if i_ino didn't change */ if (inode && CIFS_I(inode)->uniqueid == fattr->cf_uniqueid) { cifs_fattr_to_inode(inode, fattr); - return dentry; + goto out; } err = d_invalidate(dentry); dput(dentry); if (err) - return NULL; + return; } dentry = d_alloc(parent, name); - if (dentry == NULL) - return NULL; + if (!dentry) + return; inode = cifs_iget(sb, fattr); - if (!inode) { - dput(dentry); - return NULL; - } + if (!inode) + goto out; alias = d_materialise_unique(dentry, inode); - if (alias != NULL) { - dput(dentry); - if (IS_ERR(alias)) - return NULL; - dentry = alias; - } - - return dentry; + if (alias && !IS_ERR(alias)) + dput(alias); +out: + dput(dentry); } static void @@ -662,7 +659,6 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, struct cifs_sb_info *cifs_sb = CIFS_SB(sb); struct cifs_dirent de = { NULL, }; struct cifs_fattr fattr; - struct dentry *dentry; struct qstr name; int rc = 0; ino_t ino; @@ -733,13 +729,11 @@ static int cifs_filldir(char *find_entry, struct file *file, filldir_t filldir, */ fattr.cf_flags |= CIFS_FATTR_NEED_REVAL; - ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); - dentry = cifs_readdir_lookup(file->f_dentry, &name, &fattr); + cifs_prime_dcache(file->f_dentry, &name, &fattr); + ino = cifs_uniqueid_to_ino_t(fattr.cf_uniqueid); rc = filldir(dirent, name.name, name.len, file->f_pos, ino, fattr.cf_dtype); - - dput(dentry); return rc; }