While looking at the generic semaphore patch, I came to wonder what the remaining semaphore users in the kernel were actually doing. After a quick grep for down_interruptible(), smackfs remained at the bottom of my screen. It seems like a straightforward mutex case - low-hanging fruit. So here's a conversion patch; compile-tested only, but what could go wrong? jon Convert smackfs from a semaphore to a mutex Signed-off-by: Jonathan Corbet <corbet@lwn.net> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c index afe7c9b..6e09cec 100644 --- a/security/smack/smackfs.c +++ b/security/smack/smackfs.c @@ -76,7 +76,7 @@ struct smk_list_entry *smack_list; /* * Disable concurrent writing open() operations */ -static struct semaphore smack_write_sem; +static DEFINE_MUTEX(smack_write_mutex); /* * Values for parsing cipso rules @@ -171,7 +171,7 @@ static int smk_open_load(struct inode *inode, struct file *file) if ((file->f_flags & O_ACCMODE) == O_RDONLY) return seq_open(file, &load_seq_ops); - if (down_interruptible(&smack_write_sem)) + if (mutex_lock_interruptible(&smack_write_mutex)) return -ERESTARTSYS; return 0; @@ -192,7 +192,7 @@ static int smk_release_load(struct inode *inode, struct file *file) if ((file->f_flags & O_ACCMODE) == O_RDONLY) return seq_release(inode, file); - up(&smack_write_sem); + mutex_unlock(&smack_write_mutex); return 0; } @@ -1011,7 +1011,7 @@ static int __init init_smk_fs(void) } } - sema_init(&smack_write_sem, 1); + mutex_init(&smack_write_mutex); smk_cipso_doi(); smk_unlbl_ambient(NULL); --
| Linus Torvalds | Linux 2.6.27-rc5 |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Eric Paris | [RFC 0/5] [TALPA] Intro to a linux interface for on access scanning |
git: | |
| Johannes Sixt | [PATCH 02/40] Compile some programs only conditionally. |
| Linus Torvalds | [PATCH 0/6] Initial subproject support (RFC?) |
| Jon Smirl | Figured out how to get Mozilla into git |
| Linus Torvalds | irc usage.. |
| GVG GVG | ssh_exchange_identification: Connection closed by remote host |
| Richard Stallman | Real men don't attack straw men |
| Marcos Laufer | dmesg IBM x3650 OpenBSD 4.3 |
| Tony Bruguier | [newbie] ssh and sftp timing out |
| Jim Winstead Jr. | Re: Root Disk/Book Disk Compatibility |
| Doug Evans | Re: Stabilizing Linux |
| Joseph R. Pannon | Re: Ctrl-Alt-Del |
| Pat Rankin | Re: Nethack + Linux, Please Help! |
| usb mic not detected | 21 minutes ago | Applications and Utilities |
| Treason Uncloaked | 5 hours ago | Linux kernel |
| Shared swap partition | 16 hours ago | Linux general |
| high memory | 2 days ago | Linux kernel |
| semaphore access speed | 2 days ago | Applications and Utilities |
| the kernel how to power off the machine | 2 days ago | Linux kernel |
| Easter Eggs in windows XP | 2 days ago | Windows |
| Root password | 2 days ago | Linux general |
| Where/when DNOTIFY is used? | 2 days ago | Linux kernel |
| How to convert Linux Kernel built-in module into a loadable module | 3 days ago | Linux kernel |
