[SSI] openssi/kernel/include/cluster/ssi/util unum.h,1.4,1.5
Roger Tsang <[email protected]> Sun, 08 Aug 2010 02:18:29 +0000
| Newsgroups | gmane.linux.cluster.ssic.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ssic-linux/openssi/kernel/include/cluster/ssi/util
In directory sfp-cvsdas-3.v30.ch3.sourceforge.com:/tmp/cvs-serv2698/include/cluster/ssi/util
Modified Files:
Tag: OPENSSI-FC
unum.h
Log Message:
- Fix unum_getnum() possible inode number overflow beyond 24-bit. Bits 25 to 31 are reserved for SSI node number.
Index: unum.h
===================================================================
RCS file: /cvsroot/ssic-linux/openssi/kernel/include/cluster/ssi/util/unum.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- unum.h 20 Oct 2004 03:23:36 -0000 1.4
+++ unum.h 8 Aug 2010 02:18:27 -0000 1.5
@@ -25,6 +25,7 @@
#include <linux/spinlock.h>
#include <cluster/nsc.h>
+#include <cluster/config.h>
enum unum_domain {
unum_pipeino,
@@ -35,23 +36,28 @@
unum_domain_len
};
-static spinlock_t unum_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(unum_lock);
/* SSI_XXX: Eventually replace with real number block server */
/*
* SSI_XXX: The numbers we hand out would not be immediately
* available to a unumsvr rebuild
*/
-static inline unsigned long
+static unsigned long
unum_getnum(enum unum_domain domain)
{
#ifdef __arch_um__
extern clusternode_t this_node;
#endif
- static unsigned long ctr = 255;
+ static unsigned long ctr;
unsigned long ret;
+
+ BUG_ON(NSC_MAX_NODE_VALUE > 0xff);
+
spin_lock(&unum_lock);
- ret = this_node<<24 | ++ctr;
+ if (++ctr & (ULONG_MAX<<24))
+ ctr = 0;
+ ret = this_node<<24 | ctr;
spin_unlock(&unum_lock);
return ret;
}
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev