From patchwork Sat Jun 30 09:39:58 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "jeff.liu" X-Patchwork-Id: 168290 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 23DCE2C01F0 for ; Sat, 30 Jun 2012 19:41:13 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752825Ab2F3Jka (ORCPT ); Sat, 30 Jun 2012 05:40:30 -0400 Received: from rcsinet15.oracle.com ([148.87.113.117]:45053 "EHLO rcsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752649Ab2F3Jk2 (ORCPT ); Sat, 30 Jun 2012 05:40:28 -0400 Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by rcsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q5U9eMqO030993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 30 Jun 2012 09:40:23 GMT Received: from acsmt356.oracle.com (acsmt356.oracle.com [141.146.40.156]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q5U9eMnR012926 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 30 Jun 2012 09:40:22 GMT Received: from abhmt116.oracle.com (abhmt116.oracle.com [141.146.116.68]) by acsmt356.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q5U9eLB4016259; Sat, 30 Jun 2012 04:40:21 -0500 Received: from [192.168.1.103] (/114.248.194.226) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 30 Jun 2012 02:40:21 -0700 Message-ID: <4FEEC96E.9070502@oracle.com> Date: Sat, 30 Jun 2012 17:39:58 +0800 From: Jeff Liu Reply-To: jeff.liu@oracle.com Organization: Oracle User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.28) Gecko/20120313 Thunderbird/3.1.20 MIME-Version: 1.0 To: linux-serial@vger.kernel.org CC: "linux-fsdevel@vger.kernel.org" , "linux-ext4@vger.kernel.org" , gregkh@linuxfoundation.org, Jan Kara , "Ted Ts'o" Subject: [PATCH 1/2] Add a new helper for sleepable BTM acquirements which is used by tty_write_message() X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org This helper only used by tty_write_message(), it will sleep until BTM lock acquired. Signed-off-by: Jie Liu --- drivers/tty/tty_mutex.c | 13 +++++++++++++ include/linux/tty.h | 1 + 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/drivers/tty/tty_mutex.c b/drivers/tty/tty_mutex.c index 9ff986c..e638636 100644 --- a/drivers/tty/tty_mutex.c +++ b/drivers/tty/tty_mutex.c @@ -30,3 +30,16 @@ void __lockfunc tty_unlock(void) mutex_unlock(&big_tty_mutex); } EXPORT_SYMBOL(tty_unlock); + +/* + * Wait until getting the big tty mutex. + * This function only used by tty_write_message(). + */ +void __lockfunc tty_lock_wait(void) +{ + while (!mutex_trylock(&big_tty_mutex)) { + set_current_state(TASK_UNINTERRUPTIBLE); + schedule(); + } +} +EXPORT_SYMBOL(tty_lock_wait); diff --git a/include/linux/tty.h b/include/linux/tty.h index 9f47ab5..5e01e0b 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -607,6 +607,7 @@ extern long vt_compat_ioctl(struct tty_struct *tty, /* functions for preparation of BKL removal */ extern void __lockfunc tty_lock(void) __acquires(tty_lock); extern void __lockfunc tty_unlock(void) __releases(tty_lock); +extern void __lockfunc tty_lock_wait(void) __acquires(tty_lock); /* * this shall be called only from where BTM is held (like close)