linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND][BK-PATCH-1/2] Introduce ilookup() for searching for inodes in icache
@ 2002-10-01  8:32 Anton Altaparmakov
  0 siblings, 0 replies; only message in thread
From: Anton Altaparmakov @ 2002-10-01  8:32 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Alexander Viro, Linux Kernel

Linus, please do a

	bk pull http://linux-ntfs.bkbits.net/linux-2.5-ilookup

This is just a resend, no changes. Patches tested with your current BK
tree (2.5.40) and work fine here...

Since noone complained last time can we assume that the patches are
now ok? If so, please, please apply. Thanks!

Best regards,

	Anton

--- description from previous post ---
This is a reworked version of my previous ilookup() patches. We now use
helper functions taking the calculated hash as parameter to do the actual
icache search so that we can use the same helpers in iget_locked() without
having to calculate the hash twice in the slow path of iget_locked().

This patch introduces ilookup() and the helpers.

The next patch switches iget_locked() to using the helpers.

Since the helpers are static inline, the iget_locked() code paths should
be fully identical to what they were before.
--- end of description from previous post ---

-- 
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         |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/fs.h |    4 +
 2 files changed, 121 insertions(+)

through these ChangeSets:

<aia21@cantab.net> (02/09/18 1.536.35.8)
   Add functions for searching for an inode in icache and getting a reference
   to it if present - fs/inode.c::ilookup() and ilookup5(), mirroring the
   iget_locked() and iget5_locked() function pair. Also add two internal
   helpers ifind_fast() and ifind() respectively which will later be used
   by iget_locked() and iget5_locked() to do the search, too.


diff -Nru a/fs/inode.c b/fs/inode.c
--- a/fs/inode.c	Tue Oct  1 09:22:21 2002
+++ b/fs/inode.c	Tue Oct  1 09:22:21 2002
@@ -695,6 +695,123 @@
 	return inode;
 }
 
+/**
+ * ifind - internal function, you want ilookup5() or iget5().
+ * @sb:		super block of file system to search
+ * @hashval:	hash value (usually inode number) to search for
+ * @test:	callback used for comparisons between inodes
+ * @data:	opaque data pointer to pass to @test
+ *
+ * ifind() searches for the inode specified by @hashval and @data in the inode
+ * cache. This is a generalized version of ifind_fast() for file systems where
+ * the inode number is not sufficient for unique identification of an inode.
+ *
+ * If the inode is in the cache, the inode is returned with an incremented
+ * reference count.
+ *
+ * Otherwise NULL is returned.
+ *
+ * Note, @test is called with the inode_lock held, so can't sleep.
+ */
+static inline struct inode *ifind(struct super_block *sb,
+		struct list_head *head, int (*test)(struct inode *, void *),
+		void *data)
+{
+	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);
+		return inode;
+	}
+	spin_unlock(&inode_lock);
+	return NULL;
+}
+
+/**
+ * ifind_fast - internal function, you want ilookup() or iget().
+ * @sb:		super block of file system to search
+ * @ino:	inode number to search for
+ *
+ * ifind_fast() searches for the inode @ino in the inode cache. This is for
+ * file systems where the inode number is sufficient for unique identification
+ * of an inode.
+ *
+ * If the inode is in the cache, the inode is returned with an incremented
+ * reference count.
+ *
+ * Otherwise NULL is returned.
+ */
+static inline struct inode *ifind_fast(struct super_block *sb,
+		struct list_head *head, unsigned long 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);
+		return inode;
+	}
+	spin_unlock(&inode_lock);
+	return NULL;
+}
+
+/**
+ * ilookup5 - search for an inode in the inode cache
+ * @sb:		super block of file system to search
+ * @hashval:	hash value (usually inode number) to search for
+ * @test:	callback used for comparisons between inodes
+ * @data:	opaque data pointer to pass to @test
+ *
+ * ilookup5() uses ifind() to search for the inode specified by @hashval and
+ * @data in the inode cache. This is a generalized version of ilookup() for
+ * file systems where the inode number is not sufficient for unique
+ * identification of an inode.
+ *
+ * If the inode is in the cache, the inode is returned with an incremented
+ * reference count.
+ *
+ * Otherwise NULL is returned.
+ *
+ * Note, @test is called with the inode_lock held, so can't sleep.
+ */
+struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
+		int (*test)(struct inode *, void *), void *data)
+{
+	struct list_head *head = inode_hashtable + hash(sb, hashval);
+
+	return ifind(sb, head, test, data);
+}
+EXPORT_SYMBOL(ilookup5);
+
+/**
+ * ilookup - search for an inode in the inode cache
+ * @sb:		super block of file system to search
+ * @ino:	inode number to search for
+ *
+ * ilookup() uses ifind_fast() to search for the inode @ino in the inode cache.
+ * This is for file systems where the inode number is sufficient for unique
+ * identification of an inode.
+ *
+ * If the inode is in the cache, the inode is returned with an incremented
+ * reference count.
+ *
+ * Otherwise NULL is returned.
+ */
+struct inode *ilookup(struct super_block *sb, unsigned long ino)
+{
+	struct list_head *head = inode_hashtable + hash(sb, ino);
+
+	return ifind_fast(sb, head, ino);
+}
+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
diff -Nru a/include/linux/fs.h b/include/linux/fs.h
--- a/include/linux/fs.h	Tue Oct  1 09:22:21 2002
+++ b/include/linux/fs.h	Tue Oct  1 09:22:21 2002
@@ -1202,6 +1202,10 @@
 extern int inode_needs_sync(struct inode *inode);
 extern void generic_delete_inode(struct inode *inode);
 
+extern struct inode *ilookup5(struct super_block *sb, unsigned long hashval,
+		int (*test)(struct inode *, void *), void *data);
+extern struct inode *ilookup(struct super_block *sb, unsigned long ino);
+
 extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *);
 extern struct inode * iget_locked(struct super_block *, unsigned long);
 extern void unlock_new_inode(struct inode *);

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

This BitKeeper patch contains the following changesets:
1.536.35.8
## Wrapped with gzip_uu ##


begin 664 bkpatch12212
M'XL(`#U;F3T``^U8:V_;-A3]+/Z*"Q38;->1]?!+#C*D[8JM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UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-01  8:32 [RESEND][BK-PATCH-1/2] Introduce ilookup() for searching for inodes in icache Anton Altaparmakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).