[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-fsdevel
Subject:    [BK-PATCH-2.5-2/2] Introduce ilookup() for searching for inodes in icache
From:       Anton Altaparmakov <aia21 () cantab ! net>
Date:       2002-09-19 9:51:03
[Download RAW message or body]

And here is the second patch which switches iget_locked() to use the new
helpers and it adds some documentation.

No functionality changed at all.

Best regards,

	Anton
-- 
Anton Altaparmakov <aia21 at cantab.net> (replace at with @)
Linux NTFS maintainer / IRC: #ntfs on irc.freenode.net
WWW: http://linux-ntfs.sf.net/, http://www-stu.christs.cam.ac.uk/~aia21/

===================================================================

This will update the following files:

 fs/inode.c |   87 +++++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 50 insertions(+), 37 deletions(-)

through these ChangeSets:

<aia21@cantab.net> (02/09/18 1.536.1.38)
   Cleanup: Convert fs/inode.c::iget_locked() and iget5_locked() to use
   the new ifind_fast() and ifind() helpers, respectively.


diff -Nru a/fs/inode.c b/fs/inode.c
--- a/fs/inode.c	Thu Sep 19 10:39:43 2002
+++ b/fs/inode.c	Thu Sep 19 10:39:43 2002
@@ -535,7 +535,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.
@@ -812,65 +812,78 @@
 }
 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) to get
+ * @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().
+ *
+ * iget5_locked() uses ifind() to search for the inode specified by @hashval
+ * and @data in the inode cache and if present it is returned with an increased
+ * reference count. This is a generalized version of iget_locked() for file
+ * systems where the inode number is not sufficient for unique identification
+ * of an inode.
+ *
+ * If the inode is not in cache, get_new_inode() is called 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 = ifind(sb, head, 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 get
+ *
+ * This is iget() without the read_inode() portion of get_new_inode_fast().
+ *
+ * iget_locked() uses ifind_fast() to search for the inode specified by @ino in
+ * the inode cache and if present it is returned with an increased reference
+ * count. This is for file systems where the inode number is sufficient for
+ * unique identification of an inode.
+ *
+ * If the inode is not in cache, get_new_inode_fast() is called 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 = ifind_fast(sb, head, 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.536.1.38
## Wrapped with gzip_uu ##


begin 664 bkpatch16654
M'XL(`%^;B3T``[U7VW+;-A!]%K]B9_)06=&%X$6BV%$GC9UI/4T3CY-,VR<-
M1$(6)A2@$*!==_3QW06IN]U<&]MCTB#VX.S9LTOY";PSHDQ;7/*`>4_@5VUL
MVLJXLGS65\+BTK76N#2H3#DP938HI*K^[@7]N"<+K=]7*P_W7'&;+>!6E"9M
ML7ZX7;'W*Y&VKE_\\N[ES]>>-YG`^8*K&_%&6)A,/*O+6U[DYAFWBT*KOBVY
M,DMA>3_3R_5VZSKP_0"_8S8*_7BX9D,_&JTSEC/&(R9R/XB28>2Y')[MN!\#
MC%G"AF$0!>L@"?S0NP#6C\-A'PDGX`<#?SQ@";`D#5@:CY[Z+/5].`:%IPQZ
MOO<<OBWW<R^#\T)P5:U2.-<*I;0P-P.I="[Z69K*&V&GA<[>B[Q]!ESE0"OQ
M;LEJJ(Q`&+L0H,0=R+E4^73.C=T$T`+>+T2QPDIUH11F)3(K;T5QW_=^`Y2%
M,>]J5R.O]Y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QH<!
MBGF91/[)H-[7U`WI*'!'12-@P_TA_;_.:`1*6P=-N!W%WV+&-2_*_4'WT)S;
MO$\_;=CA&JX3WE>.M]UL(["C\;:96Y\PM`X'%F$].+.^<F!M1'ID:A&:^X#R
M;:9677WQA5.KUN!T<%TD,7,]&P=?VK/XZ#_Z-8Y<$\7CDWZMY=LU;8-ST*U#
FAMUZD8RHV_$28M-N_Z/#@F3O3;6<L!E^RL1/R-Z_^.]Z8D,.````
`
end
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic