From: Jonathan Corbet <corbet@lwn.net>
To: linux-kernel@vger.kernel.org
Cc: Casey Schaufler <casey@schaufler-ca.com>
Subject: [PATCH] de-semaphorize smackfs
Date: Mon, 17 Mar 2008 17:14:40 -0600 [thread overview]
Message-ID: <30338.1205795680@vena.lwn.net> (raw)
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);
next reply other threads:[~2008-03-17 23:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-17 23:14 Jonathan Corbet [this message]
2008-03-18 7:35 ` Christoph Hellwig
2008-03-18 12:01 ` Ahmed S. Darwish
2008-03-18 15:41 ` Daniel Walker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30338.1205795680@vena.lwn.net \
--to=corbet@lwn.net \
--cc=casey@schaufler-ca.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®