vfs_races-2.6-rhel4.patch

来自「非常经典的一个分布式系统」· PATCH 代码 · 共 64 行

PATCH
64
字号
diff -urp RH_2_6_9_42_0_3.orig/fs/dcache.c RH_2_6_9_42_0_3/fs/dcache.c--- RH_2_6_9_42_0_3.orig/fs/dcache.c+++ RH_2_6_9_42_0_3/fs/dcache.c@@ -229,7 +229,14 @@ int d_invalidate(struct dentry * dentry) 		spin_unlock(&dcache_lock); 		return 0; 	}-	/*++        /* network invalidation by Lustre */+	if (dentry->d_flags & DCACHE_LUSTRE_INVALID) {+		spin_unlock(&dcache_lock);+		return 0;+	}++        /* 	 * Check whether to do a partial shrink_dcache 	 * to get rid of unused child entries. 	 */@@ -1187,19 +1194,28 @@ void d_delete(struct dentry * dentry)  * Adds a dentry to the hash according to its name.  */  -void d_rehash(struct dentry * entry)+void __d_rehash(struct dentry * entry, int lock) { 	struct hlist_head *list = d_hash(entry->d_parent, entry->d_name.hash); -	spin_lock(&dcache_lock);+	if (lock)+		spin_lock(&dcache_lock); 	spin_lock(&entry->d_lock);  	entry->d_flags &= ~DCACHE_UNHASHED; 	spin_unlock(&entry->d_lock); 	entry->d_bucket = list;  	hlist_add_head_rcu(&entry->d_hash, list);-	spin_unlock(&dcache_lock);+	if (lock)+		spin_unlock(&dcache_lock); } +EXPORT_SYMBOL(__d_rehash);++void d_rehash(struct dentry * entry)+{+	__d_rehash(entry, 1);+ }+ #define do_switch(x,y) do { \ 	__typeof__ (x) __tmp = x; \ 	x = y; y = __tmp; } while (0)diff -urp RH_2_6_9_42_0_3.orig/include/linux/dcache.h RH_2_6_9_42_0_3/include/linux/dcache.h--- RH_2_6_9_42_0_3.orig/include/linux/dcache.h+++ RH_2_6_9_42_0_3/include/linux/dcache.h@@ -157,6 +157,8 @@ d_iput:		no		no		no       yes  #define DCACHE_REFERENCED	0x0008  /* Recently used, don't discard. */ #define DCACHE_UNHASHED		0x0010	+#define DCACHE_LUSTRE_INVALID     0x0020  /* Lustre invalidated */+  extern spinlock_t dcache_lock; 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?