Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752645AbdI2QHB (ORCPT ); Fri, 29 Sep 2017 12:07:01 -0400 Received: from mail-eopbgr00135.outbound.protection.outlook.com ([40.107.0.135]:50503 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752108AbdI2QG4 (ORCPT ); Fri, 29 Sep 2017 12:06:56 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Subject: [PATCH REBASED 6/6] fs: Use killable down_read() in iterate_dir() From: Kirill Tkhai To: linux-ia64@vger.kernel.org, avagin@virtuozzo.com, peterz@infradead.org, heiko.carstens@de.ibm.com, hpa@zytor.com, gorcunov@virtuozzo.com, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, x86@kernel.org, mingo@redhat.com, mattst88@gmail.com, fenghua.yu@intel.com, arnd@arndb.de, ktkhai@virtuozzo.com, ink@jurassic.park.msu.ru, tglx@linutronix.de, rth@twiddle.net, tony.luck@intel.com, linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org, schwidefsky@de.ibm.com, davem@davemloft.net, rientjes@google.com, viro@zeniv.linux.org.uk Date: Fri, 29 Sep 2017 19:06:48 +0300 Message-ID: <150670120820.23930.5455667921545937220.stgit@localhost.localdomain> In-Reply-To: <150670038738.23930.7190484711222807884.stgit@localhost.localdomain> References: <150670038738.23930.7190484711222807884.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:6:15::31) To AM5PR0801MB1330.eurprd08.prod.outlook.com (2603:10a6:203:1f::8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d1e96ca2-7865-4632-378e-08d507541932 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075);SRVR:AM5PR0801MB1330; X-Microsoft-Exchange-Diagnostics: 1;AM5PR0801MB1330;3:wbNhlasU7PogEMLdDFeNpocmyUxyN/6R95tS2CT4CL4HOxSN5gmnGKHaxRordlp3U3CyseO1Zg20bgM9JpW9wDr4ZOmIyJ2DHUwZq1ZIQQTUjFJP/uCuWwQQROCxHAPpL7haxnF8WmlCxr3LWMQnJcBHa8x+EHNyDbOS+HIuFBoFzYqIWhBJ5gow8sRKz8w3/er9AfeSlK1B+u0avz+6Msa8KfK8SwkI48Q539zlqYAZyqh8PRNg7nABK6nshOUE;25:ejenOCgjuZygZC6nMoOj92ekvZWLN50rRcnJIfwgvfV7wV34+INjnq3UQnKctdM83MhT6EgUj4vVJPbHB+KeThRav5gd7EB8GoWi2fNAjWEbgNcWFSGIJlnQ3JSLVe12yJflqRdDPJttUQoeB9WngFwID5V/kluY8whqD6S5LV4rK4ZpJlVXFB10vpEhPlQfhWrn0xmSeUGiMRI/fMw/B8AGIdfGLVdsb0WDH+V726Lf/sNikeGXg5xBn35j73nMNPJMdpkMz1ACImDpt/mOyrRbj5XTWYC03TAM/mSe3rBDJGi3ny3h+u2QmpuoYMklMlobeAp2q6Jessk5yWqcSw==;31:o7Wm0VR959ncHnRFN5zQlGYRy/q5xTtELASux2mKIIMeUp6d3hUZTKHb1n3ATHerIOC1wgnIuOOWaHzqP5/0byIJ/DsNUt0ntJmZ9Jb9n872fk7EaQfuHoRfgQEudjzcIq9idzZwJVLp3P4WlCkTqb2w0Ou1xvV+ZsagK6Hvqz2lf0FFVFXZ0HYJObfmaLlMqpVLN+cUAaJk744OZHahUj5txVIwENRPS7mxGV+xyEE= X-MS-TrafficTypeDiagnostic: AM5PR0801MB1330: X-Microsoft-Exchange-Diagnostics: 1;AM5PR0801MB1330;20:MSWV0utFOLQ3i+fPTJa9UxnAlnM9J15WS2Hio1SN8SqF/VJrZ9+FBGv+daW/a2wZtxUiU85y58jIcFqg7ZLa/gg35hwqFOguvWn0/zEUWaydSivxC8VKAigUXNIq7DWxdsdNDpxfjzpH3Zs68zGz+xVKf9LC4hLG50IPm2dVcAAcSf71HXOXvjkUw5Lsv/w83EfbDrTQXxKCfJ29U8nI6hRWAs+45iY9BPv1V6OJWtd9musdiBdMBu5zp7kzQOkC2Ke9Cqk3cP763S0C2k2b/UaY+8AXKT9WpLgEpB1dyI+2gax73soMyR7cl+eYB8cwLwYjhaxrSywwCkQgWhv+vC2j6ACUC5NUuDuv8mYXEbOHW0DBHrSRUnJS1C+NsPkxkc0fg86yUcSgD12gqqZIcEEYXT+8EXWr1wbFgzCnGL4=;4:TlVlHMrBfS83Ofqc1gydVGnZeTmYD5Iig1nxocNb8cCrz02BAnANhL6ZKC59KMYd8QQmxvvEpZoFmkw8ADQvqNk/3Hb3K2jF97jaCtBTU2koolWdqmPR/13PKUZOwym+s0GU9eBT2BROHQaaAURBqgNkjqHPoyvLvnujz2y/s9b6+gmEK6qkpY94KSirQXVq5KvPYk1ObiejFyN9iTTb7g8y5ejYBndAGB7P+M/wnhb8DcaoUSpcTQWF4+Es5ewJ X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(3002001)(10201501046)(93006095)(93001095)(6041248)(20161123562025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:AM5PR0801MB1330;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:AM5PR0801MB1330; X-Forefront-PRVS: 0445A82F82 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(6009001)(346002)(39830400002)(376002)(189002)(199003)(68736007)(83506001)(8676002)(101416001)(2906002)(106356001)(105586002)(103116003)(81166006)(478600001)(81156014)(7416002)(9686003)(33646002)(316002)(25786009)(6506006)(230700001)(305945005)(86362001)(47776003)(2950100002)(39060400002)(23676002)(16526017)(76176999)(54356999)(189998001)(50466002)(50986999)(5660300001)(53936002)(3846002)(8936002)(55016002)(66066001)(97736004)(7736002)(6116002)(58126008)(61506002)(921003)(1121003)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:AM5PR0801MB1330;H:localhost.localdomain;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtBTTVQUjA4MDFNQjEzMzA7MjM6bFBzd2pQQTJoTlhNZVNhaE5KWTBIRDUw?= =?utf-8?B?RENreVBvOExQZ3V4OHpZUUpuSGU3TS9TZWI3ZlFMOTNHRml2d2hBVldRNjRx?= =?utf-8?B?U3cvaDQyZURVZVNlTVhFUWlwa05UQXlDL2xBTHNGWWlYN1NHUHpLVDBJVVpT?= =?utf-8?B?ZHR4OVhMMktxTDBidVVLTGhSYUdMVUppZDZUeW1nWjlmdEtmVUF4THJoUU5r?= =?utf-8?B?ZnpnUDlYV0wrYTM3Y2I3QkZ0OUlIWXZVNmhkcVI1a1I3aGduYzVwRWwvbjh0?= =?utf-8?B?TndIWFNpR3E2NnptdnlaWCs2ZWFkL3k1T2FoVDRjMWRpVEZvU2x3Q0doclNv?= =?utf-8?B?YlFzUWNyK250ZHhVTkJmeERWVVBDSVl6MStQdDNBTTdmZnlwS2J2OTJzYzd6?= =?utf-8?B?UThKa3JTRmFQbjh5dXNrbU9VZGRibnNVL3J0UUQ0WSt4K3ZTb3VWS1ZoVjlR?= =?utf-8?B?Wm12c0hDQlhRUUd6QVU5bGdYWGpIRkRVYStYRDZncDB5bmxuRlcwTVFhTVlw?= =?utf-8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5bvpo3GqgQn7mUr3scRqKv5gw6LJZdwoiE4kmSqwicEV5G7M5EIp3GSBT8ik4LpaWs= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;AM5PR0801MB1330;20:5m8f/BQI669w4TY+x9oNEZ4E6sD33lAGVSvnqtGkXKt7TEnZ1+/TQ+nY/JPORAGJ/WTpWLd4G7QMmM3l15kdf4TXu4voyU8L7DORzHNccnlzkAwdgpGqynGaKE+aFSa0dmc94GcLW7+ej1cmID1Qj819/mppDEUkKdiHUhJEuTI= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2017 16:06:50.2129 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1330 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1165 Lines: 40 There was mutex_lock_interruptible() initially, and it was changed to rwsem, but there were not killable rwsem primitives that time. >From commit 9902af79c01a: "The main issue is the lack of down_write_killable(), so the places like readdir.c switched to plain inode_lock(); once killable variants of rwsem primitives appear, that'll be dealt with" Use down_read_killable() same as down_write_killable() in !shared case, as concurrent inode_lock() may take much time, that may be wanted to be interrupted by user. Signed-off-by: Kirill Tkhai --- fs/readdir.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/readdir.c b/fs/readdir.c index 89659549c09d..7c584bbb4ce3 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -36,13 +36,12 @@ int iterate_dir(struct file *file, struct dir_context *ctx) if (res) goto out; - if (shared) { - inode_lock_shared(inode); - } else { + if (shared) + res = down_read_killable(&inode->i_rwsem); + else res = down_write_killable(&inode->i_rwsem); - if (res) - goto out; - } + if (res) + goto out; res = -ENOENT; if (!IS_DEADDIR(inode)) {