From: Matthew Helsley <matthltc@us.ibm.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: sukadev@us.ibm.com, serue@us.ibm.com, ebiederm@xmission.com,
hpa@zytor.com, containers@lists.osdl.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH]: Factor out PTY index allocation
Date: Thu, 17 Apr 2008 16:53:49 -0700 [thread overview]
Message-ID: <1208476430.5134.9.camel@localhost.localdomain> (raw)
In-Reply-To: <20080417141725.7cd8e50e.akpm@linux-foundation.org>
On Thu, 2008-04-17 at 14:17 -0700, Andrew Morton wrote:
> On Wed, 16 Apr 2008 15:17:23 -0700
> sukadev@us.ibm.com 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?
The patch series was originally developed for 2.6.22 -- prior to the
semaphore -> mutex migration. This appears to be a mistake in
forward-porting the series.
Acked-by: Matt Helsley <matthltc@us.ibm.com>
>
> --- 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)
> _
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
prev parent reply other threads:[~2008-04-17 23:54 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
2008-04-17 15:42 ` Serge E. Hallyn
2008-04-17 16:05 ` H. Peter Anvin
2008-04-17 21:08 ` Jiri Slaby
2008-04-17 21:17 ` Andrew Morton
2008-04-17 23:53 ` Matthew Helsley [this message]
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=1208476430.5134.9.camel@localhost.localdomain \
--to=matthltc@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=containers@lists.osdl.org \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=serue@us.ibm.com \
--cc=sukadev@us.ibm.com \
/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