From: Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
To: sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Cc: containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org,
ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH]: Factor out PTY index allocation
Date: Thu, 17 Apr 2008 14:17:25 -0700 [thread overview]
Message-ID: <20080417141725.7cd8e50e.akpm@linux-foundation.org> (raw)
In-Reply-To: <20080416221723.GB7112-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
On Wed, 16 Apr 2008 15:17:23 -0700
sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org wrote:
> Factor out the code used to allocate/free a pts index into new interfaces,
> devpts_new_index() and devpts_kill_index(). This localizes the external
> data structures used in managing the pts indices.
err...
> - mutex_lock(&allocated_ptys_lock);
> + down(&allocated_ptys_lock);
Why the mutex-to-semaphore conversion?
--- a/fs/devpts/inode.c~devpts-factor-out-pty-index-allocation-fix
+++ a/fs/devpts/inode.c
@@ -17,6 +17,7 @@
#include <linux/namei.h>
#include <linux/mount.h>
#include <linux/tty.h>
+#include <linux/mutex.h>
#include <linux/idr.h>
#include <linux/devpts_fs.h>
#include <linux/parser.h>
@@ -29,7 +30,7 @@
extern int pty_limit; /* Config limit on Unix98 ptys */
static DEFINE_IDR(allocated_ptys);
-static DECLARE_MUTEX(allocated_ptys_lock);
+static DEFINE_MUTEX(allocated_ptys_lock);
static struct vfsmount *devpts_mnt;
static struct dentry *devpts_root;
@@ -186,10 +187,10 @@ retry:
return -ENOMEM;
}
- down(&allocated_ptys_lock);
+ mutex_lock(&allocated_ptys_lock);
idr_ret = idr_get_new(&allocated_ptys, NULL, &index);
if (idr_ret < 0) {
- up(&allocated_ptys_lock);
+ mutex_unlock(&allocated_ptys_lock);
if (idr_ret == -EAGAIN)
goto retry;
return -EIO;
@@ -197,18 +198,18 @@ retry:
if (index >= pty_limit) {
idr_remove(&allocated_ptys, index);
- up(&allocated_ptys_lock);
+ mutex_unlock(&allocated_ptys_lock);
return -EIO;
}
- up(&allocated_ptys_lock);
+ mutex_unlock(&allocated_ptys_lock);
return index;
}
void devpts_kill_index(int idx)
{
- down(&allocated_ptys_lock);
+ mutex_lock(&allocated_ptys_lock);
idr_remove(&allocated_ptys, idx);
- up(&allocated_ptys_lock);
+ mutex_unlock(&allocated_ptys_lock);
}
int devpts_pty_new(struct tty_struct *tty)
_
next prev parent reply other threads:[~2008-04-17 21:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-16 22:17 [PATCH]: Factor out PTY index allocation sukadev
[not found] ` <20080416221723.GB7112-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2008-04-17 15:42 ` Serge E. Hallyn
2008-04-17 16:05 ` H. Peter Anvin
2008-04-17 21:17 ` Andrew Morton [this message]
2008-04-17 23:53 ` Matthew Helsley
2008-04-17 21:08 ` Jiri Slaby
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=20080417141725.7cd8e50e.akpm@linux-foundation.org \
--to=akpm-de/tnxtf+jlsfhdxvbkv3wd2fqjk+8+b@public.gmane.org \
--cc=containers-qjLDD68F18O7TbgM5vRIOg@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sukadev-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.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