diff options
| author | Chen, Kenneth W <kenneth.w.chen@intel.com> | 2006-03-22 03:09:02 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-22 10:54:04 -0500 |
| commit | bba1e9b2111b14625f670bd07e57fd7ed57ce804 (patch) | |
| tree | fc46b8702597fafde7d1a550dcbc948f173303ad /fs/hugetlbfs/inode.c | |
| parent | 42b88befd6e0dae1a5fe04c03925037fa890e1f3 (diff) | |
[PATCH] convert hugetlbfs_counter to atomic
Implementation of hugetlbfs_counter() is functionally equivalent to
atomic_inc_return(). Use the simpler atomic form.
Signed-off-by: Ken Chen <kenneth.w.chen@intel.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/hugetlbfs/inode.c')
| -rw-r--r-- | fs/hugetlbfs/inode.c | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 1a1c2fcb7823..25fa8bba8cb5 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c | |||
| @@ -737,21 +737,6 @@ static struct file_system_type hugetlbfs_fs_type = { | |||
| 737 | 737 | ||
| 738 | static struct vfsmount *hugetlbfs_vfsmount; | 738 | static struct vfsmount *hugetlbfs_vfsmount; |
| 739 | 739 | ||
| 740 | /* | ||
| 741 | * Return the next identifier for a shm file | ||
| 742 | */ | ||
| 743 | static unsigned long hugetlbfs_counter(void) | ||
| 744 | { | ||
| 745 | static DEFINE_SPINLOCK(lock); | ||
| 746 | static unsigned long counter; | ||
| 747 | unsigned long ret; | ||
| 748 | |||
| 749 | spin_lock(&lock); | ||
| 750 | ret = ++counter; | ||
| 751 | spin_unlock(&lock); | ||
| 752 | return ret; | ||
| 753 | } | ||
| 754 | |||
| 755 | static int can_do_hugetlb_shm(void) | 740 | static int can_do_hugetlb_shm(void) |
| 756 | { | 741 | { |
| 757 | return likely(capable(CAP_IPC_LOCK) || | 742 | return likely(capable(CAP_IPC_LOCK) || |
| @@ -767,6 +752,7 @@ struct file *hugetlb_zero_setup(size_t size) | |||
| 767 | struct dentry *dentry, *root; | 752 | struct dentry *dentry, *root; |
| 768 | struct qstr quick_string; | 753 | struct qstr quick_string; |
| 769 | char buf[16]; | 754 | char buf[16]; |
| 755 | static atomic_t counter; | ||
| 770 | 756 | ||
| 771 | if (!can_do_hugetlb_shm()) | 757 | if (!can_do_hugetlb_shm()) |
| 772 | return ERR_PTR(-EPERM); | 758 | return ERR_PTR(-EPERM); |
| @@ -775,7 +761,7 @@ struct file *hugetlb_zero_setup(size_t size) | |||
| 775 | return ERR_PTR(-ENOMEM); | 761 | return ERR_PTR(-ENOMEM); |
| 776 | 762 | ||
| 777 | root = hugetlbfs_vfsmount->mnt_root; | 763 | root = hugetlbfs_vfsmount->mnt_root; |
| 778 | snprintf(buf, 16, "%lu", hugetlbfs_counter()); | 764 | snprintf(buf, 16, "%u", atomic_inc_return(&counter)); |
| 779 | quick_string.name = buf; | 765 | quick_string.name = buf; |
| 780 | quick_string.len = strlen(quick_string.name); | 766 | quick_string.len = strlen(quick_string.name); |
| 781 | quick_string.hash = 0; | 767 | quick_string.hash = 0; |
