Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sat, 7 Sep 2002 10:24:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sat, 7 Sep 2002 10:24:51 -0400 Received: from plum.csi.cam.ac.uk ([131.111.8.3]:63148 "EHLO plum.csi.cam.ac.uk") by vger.kernel.org with ESMTP id ; Sat, 7 Sep 2002 10:24:47 -0400 Subject: [BK-PATCH 2/3] Introduce fs/inode.c::ilookup(). To: torvalds@transmeta.com (Linus Torvalds) Date: Sat, 7 Sep 2002 15:29:27 +0100 (BST) Cc: linux-kernel@vger.kernel.org (Linux Kernel), viro@math.psu.edu (Alexander Viro) X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-Id: From: Anton Altaparmakov Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7104 Lines: 192 Linus, Here is the second patch changing iget{,5}_locked() to use ilookup{,5}(). Best regards, Anton -- Anton Altaparmakov (replace at with @) Linux NTFS maintainer / IRC: #ntfs on irc.openprojects.net WWW: http://linux-ntfs.sf.net/, http://www-stu.christs.cam.ac.uk/~aia21/ =================================================================== This will update the following files: fs/inode.c | 82 +++++++++++++++++++++++++++++++++---------------------------- 1 files changed, 45 insertions(+), 37 deletions(-) through these ChangeSets: (02/09/07 1.623) Cleanup: Convert fs/inode.c::iget_locked() and iget5_locked() to use ilookup() and ilookup5() respectively. diff -Nru a/fs/inode.c b/fs/inode.c --- a/fs/inode.c Sat Sep 7 14:52:36 2002 +++ b/fs/inode.c Sat Sep 7 14:52:36 2002 @@ -536,7 +536,7 @@ inode->i_state &= ~(I_LOCK|I_NEW); wake_up_inode(inode); } - +EXPORT_SYMBOL(unlock_new_inode); /* * This is called without the inode lock held.. Be careful. @@ -764,65 +764,73 @@ } EXPORT_SYMBOL(ilookup); -/* - * This is iget without the read_inode portion of get_new_inode - * the filesystem gets back a new locked and hashed inode and gets - * to fill it in before unlocking it via unlock_new_inode(). +/** + * iget5_locked - obtain an inode from a mounted file system + * @sb: super block of file system + * @hashval: hash value (usually inode number) + * @test: callback used for comparisons between inodes + * @set: callback used to initialize a new struct inode + * @data: opaque data pointer to pass to @test and @set + * + * This is iget() without the read_inode() portion of get_new_inode(). + * + * The inode specified by @hasval and @data is looked up in the inode cache + * and if present it is returned with an increased reference count. + * + * If it is not present, get_new_inode() is used to allocate a new inode and + * this is returned locked, hashed, and with the I_NEW flag set. The file + * system gets to fill it in before unlocking it via unlock_new_inode(). + * + * Note both @test and @set are called with the inode_lock held, so can't sleep. */ -struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *data) +struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, + int (*test)(struct inode *, void *), + int (*set)(struct inode *, void *), void *data) { - struct list_head * head = inode_hashtable + hash(sb, hashval); - struct inode * inode; + struct list_head *head = inode_hashtable + hash(sb, hashval); + struct inode *inode; - spin_lock(&inode_lock); - inode = find_inode(sb, head, test, data); - if (inode) { - __iget(inode); - spin_unlock(&inode_lock); - wait_on_inode(inode); + inode = ilookup5(sb, hashval, test, data); + if (inode) return inode; - } - spin_unlock(&inode_lock); - /* * get_new_inode() will do the right thing, re-trying the search * in case it had to block at any point. */ return get_new_inode(sb, head, test, set, data); } +EXPORT_SYMBOL(iget5_locked); -/* - * Because most filesystems are based on 32-bit unique inode numbers some - * functions are duplicated to keep iget_locked as a fast path. We can avoid - * unnecessary pointer dereferences and function calls for this specific - * case. The duplicated functions (find_inode_fast and get_new_inode_fast) - * have the same pre- and post-conditions as their original counterparts. +/** + * iget_locked - obtain an inode from a mounted file system + * @sb: super block of file system + * @ino: inode number to search for + * + * This is a fast version of iget5_locked() for file systems where the inode + * number is sufficient for unique identification of an inode. + * + * The inode specified by @ino is looked up in the inode cache and if present + * it is returned with an increased reference count. + * + * If it is not present, get_new_inode_fast() is used to allocate a new inode + * and this is returned locked, hashed, and with the I_NEW flag set. The file + * system gets to fill it in before unlocking it via unlock_new_inode(). */ struct inode *iget_locked(struct super_block *sb, unsigned long ino) { - struct list_head * head = inode_hashtable + hash(sb, ino); - struct inode * inode; + struct list_head *head = inode_hashtable + hash(sb, ino); + struct inode *inode; - spin_lock(&inode_lock); - inode = find_inode_fast(sb, head, ino); - if (inode) { - __iget(inode); - spin_unlock(&inode_lock); - wait_on_inode(inode); + inode = ilookup(sb, ino); + if (inode) return inode; - } - spin_unlock(&inode_lock); - /* * get_new_inode_fast() will do the right thing, re-trying the search * in case it had to block at any point. */ return get_new_inode_fast(sb, head, ino); } - -EXPORT_SYMBOL(iget5_locked); EXPORT_SYMBOL(iget_locked); -EXPORT_SYMBOL(unlock_new_inode); /** * __insert_inode_hash - hash an inode =================================================================== This BitKeeper patch contains the following changesets: 1.623 ## Wrapped with gzip_uu ## begin 664 bkpatch2633 M'XL(`*0$>CT``]U7;6_;-A#^;/V*`_IAMNL74I*ME\%#UZ38@G5MD+;8]LF@ M92HF*HN:2"7+X!^_.TJ.':=%T&(%AB6&*9.\N^>>>^[B/(,/1M9I3RCA<^\9 M_*R-37N9**U834II<>M*:]R:-J:>FCJ;%JIL_AK[D]E8%5I_;"H/[UP*FVW@ M1M8F[?%)<+]C[RJ9]JY>_?3A]8]7GK=8P-E&E-?RG;2P6'A6US>B6)L7PFX* M74YL+4JSE59,,KW=W5_=^8SY^#OC4AYW)X M<^?`)W,_`.9/63)E$?`@]>BTG69JJ:VF7A^`M_/(\)YOWP M!!6'+(ZY2`*L@!_R9+=B/`YBF2=LO5[-`_Z(\D<>7`W].4MVW$_"R$GJ<.=I M37TIHL>B^B0B%K/9S@^PH*VJDE-1L>2SH@IG,`ZB_X6LVIJ\A7%]ZUZHD\NC MF%^ALO-9D`#W+MKEU>^7;Z_>+]_]\>O+MZ_[34E0EZ6\7;H`@^^]\V@>0>A= M1!$#'GO3X="#X8.\8`QZ984J,1=P9I#7>@L"MKH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