From patchwork Wed Dec 29 08:24:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12700791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDB0AC433EF for ; Wed, 29 Dec 2021 08:24:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239269AbhL2IYm (ORCPT ); Wed, 29 Dec 2021 03:24:42 -0500 Received: from mail-eopbgr50130.outbound.protection.outlook.com ([40.107.5.130]:45952 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231653AbhL2IYl (ORCPT ); Wed, 29 Dec 2021 03:24:41 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVAnlxaUZNXRGr3QJiV637DliS7wZRjz4BR0cbAhyRnrnC5B4TUbahCVINqFzIgduM+LtVYU3zzh73mlQGkJiJmgAKOWojAz0/JBcLPCcqw38d1WKtcP3j5ii/b4xsl5XCwOEQBvBPsB9YtgYOlImKsXvUjTZ/LSltyk+ic2AenmBw8Bm+xf9hNBBJHfluuyKY8t5pRUefTwPkkcvQNoU6NphzAS62A/M/aUoaEm/ro4XqZblBcvXKJrWpuMYGu1tisOmuL5PNBpQZMjvOdsq7j4ORpoFa/7OwAsQgC2YnChVfFou3jfk89TXx0Fp/d0aS2mTqPIh11MnCL+gs5j3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OzMWvOPyUAHy4GiWCDlNHmEhx62/dykQ+DN1qasB4W4=; b=lo0dw/okhLfTAAy+iSZSYguL5GdaHbUswVJL/bHkePPOZe6j0QiJz+EJjLIpyfwBo4hr7WaTCo2wMv8eo8HoOCSjvkYWfL4/1y+rn2EpNk04yaXLW42i+zUvHtyXe67kyp9JCffsr7LLWKqNssNjHMXKqS4oRmT81wtpMYC/cj28DU4fLLdWZo2VmNooFwvQnVF7kLmwvCB1inmlUOS7yll4a+gjvSUmXzz/QZiWnc7TdX1V9/C53kC0sHsnsPq/CioETGw9eTON4+WzvG+/OlQg601R42SM+oqV4LvGkb2LjFZalqHDlFKUCedzLP5doGUN9wxhY++18d0JHknhEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OzMWvOPyUAHy4GiWCDlNHmEhx62/dykQ+DN1qasB4W4=; b=Ceqsqy4IBHJXZegtqUOWswIDwjZgDvFKKmap+Suyua/+ULn3CS+rbxz/NGi0iyRlN5gZ6ZnY72JmnOS3EqV3S3VaVOcn6ZjBV2obfcuZR1m1mAupsKqc2tAbQ13l3P1YjylivcRjInK8XM5FKy8TbP40AZCZZPtlrit0I11Y3k0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6241.eurprd08.prod.outlook.com (2603:10a6:20b:281::21) by AM0PR08MB2964.eurprd08.prod.outlook.com (2603:10a6:208:5d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13; Wed, 29 Dec 2021 08:24:36 +0000 Received: from AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f]) by AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f%4]) with mapi id 15.20.4844.014; Wed, 29 Dec 2021 08:24:36 +0000 From: Vasily Averin Subject: [PATCH v3 1/3] nfs: local_lock: handle async processing of F_SETLK with FL_SLEEP To: Trond Myklebust , Anna Schumaker , "J. Bruce Fields" Cc: kernel@openvz.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chuck Lever References: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com> Message-ID: <84ddf570-a315-566e-3386-df14da52f9ff@virtuozzo.com> Date: Wed, 29 Dec 2021 11:24:34 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com> Content-Language: en-US X-ClientProxiedBy: AS9PR06CA0075.eurprd06.prod.outlook.com (2603:10a6:20b:464::23) To AM9PR08MB6241.eurprd08.prod.outlook.com (2603:10a6:20b:281::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eff8a001-5d7d-4ae8-6560-08d9caa4a5e9 X-MS-TrafficTypeDiagnostic: AM0PR08MB2964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LthyPwaGYQQobdZemwWwgVNyP+7miy7gX/JKHvlmxuS1pgZtgt+F3kO/pnWh0Ddgirp7IZ2C01hYgrgGWVyoScfhiPiTd5KG/vuVB464mwZxY/oNDWuMxS49YDhXQpD+h3leaIJsL9QVvIiW5g7XcFtdTvpTM4+fcPLjQQDAPy4LsTtr0nwGOrVcuEO6t9jg5OKKwcicS9A8WkFdT4p74ZMPliLnVaRMdlt6AdJb0kacOEGWECaWnXV3mOS3RuxtK+4RRMeOZl43YyiekaqTkQbSVvsziDnbZPypJUkKVCRoawEWa8l27EOxEhEN21Au0znxn8m4T3qlBHIJzX+Mzfw5Po+3XZ8ipg4olgHYhsFFaHoNGv91NYrFo4XLSLEyniE4c2H9An6AXhhDO+8ewsCdlKQNh03QJEmaqUUXXybs4d9mVlttBU4i2cZdVDxHf0H7645Y6qvFp/QcASy6PVN11S9TzEFxCrFrEqDYG6/zh1gLj24G2pO8GvLhmJyOlOPyev6YL2LOdO9Gyj5DKiyY8zyYkSJTqqa7NN/N4rV0ogGpx04p3LBSlXWgKuPaxMqd1uV/Oz4Nim4Iw++iHMsoHTVKCWzSC8dsAFhhgO3kDjaME5c82guarTSYktol0Ki8ZquW4m5C86lJrMuaDjCGNRAJLm1ZyJIjSPQuNrROnDCVjqrcTUlG0N7lPkVvcFD5xU9uFiUUlWsOrhwzA02GQ6O8zBtoEY6yViFut+m9+SPBnBt0XrwXEZa1cwgHQlhmU5LvmtPWATLHmMw+Xb0qQt4DFDNtgDG+Jjum7q9ahWekdLrvIKZi5pvRn04UXcj1eXTcGscE5M129OnRe22P75HN/F/CNW5pwM/hgJE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR08MB6241.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(38350700002)(38100700002)(2616005)(8936002)(6486002)(31696002)(2906002)(8676002)(6506007)(5660300002)(4326008)(86362001)(110136005)(83380400001)(66476007)(52116002)(66946007)(26005)(508600001)(966005)(66556008)(31686004)(36756003)(316002)(186003)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?UGiploC7RlyXiwH9QhBbrAcXrfbs?= =?utf-8?q?wB+aXcUCmapB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B4TECQtuOs670D3OikJQUm694dEf1FEXJlyR7uoHWtLWfR6?= =?utf-8?q?JUZ3awiCIgIIOr0Y3a5LzdAKVRBsetjKmk8VGfOFYBPrghuv6WcQHfGC88tPb/Gx2?= =?utf-8?q?d09CfFHIgLtQ1zTdr/Iatp8gf+KxzqkR2tAO5RRCbkp2cP4JyInUfiA5kHFCGXzqe?= =?utf-8?q?y0SRGdVCISMTFfhyzMWTGDOe6U+X5+fGvFhR+dLHJ2eDrsVdBPb3AI76b8HvCnrTS?= =?utf-8?q?7br6lXiTyfXePA1p4FfO4dLtKc11S0gGlRcFq218NjlJY/ePZAP/aetZ0zaGBhPFJ?= =?utf-8?q?RmmPM2phZFK2M5ekFAgMvDWYlHe+ZhjorjHGzfZwnDZSidcno8eu5VCWg7XITEU2o?= =?utf-8?q?KI16MbDy17Fk3hhSYqZWTG4R/TTk0+ZQBSj09POfb/faq90d074KP06MTowOupYBv?= =?utf-8?q?ZuSdUbdSTx7IfyQtAbEMemLFYGLXBGGedCktNHGtFJzsMe41q5LEWd+3bJMRtuzIP?= =?utf-8?q?1UwdZNN8RHQRSMGTGnoYqUMqwFqNXbNrXEi1L8vZmoJaQC0adhIL67CYmcbem2C4k?= =?utf-8?q?Mk5jEPwWseraDjdl5IMOC+ndFl4DAPauf6Xh9KEubGYN7iotYQBRndlH9Jgbc5r/U?= =?utf-8?q?hKE4mj/m5MlGQXGfoBPWTWFC2WLq+CqUL/+GCavTPZxjpbfPebiuXyQ=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: eff8a001-5d7d-4ae8-6560-08d9caa4a5e9 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6241.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Dec 2021 08:24:36.5380 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fN4kOsVqxr7waqcqvW9Zk51O6AT9r5YIk+JGp/V1rUgYKK2/f1EVR280kNS0QJQWJmBz9bQnqzIBQ+LIaNNKQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2964 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org nfsd and lockd use F_SETLK cmd with FL_SLEEP and FL_POSIX flags set to request asynchronous processing of blocking locks. Currently nfs mounted with 'local_lock' option use locks_lock_file_wait() function which is blocked for such requests. To handle them correctly non-blocking posix_file_lock() function should be used instead. https://bugzilla.kernel.org/show_bug.cgi?id=215383 Signed-off-by: Vasily Averin --- fs/nfs/file.c | 5 ++++- include/linux/fs.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 24e7dccce355..83cf42cabe41 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -753,6 +753,7 @@ static int do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) { struct inode *inode = filp->f_mapping->host; + unsigned int flags = fl->fl_flags; int status; /* @@ -769,9 +770,11 @@ do_setlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) */ if (!is_local) status = NFS_PROTO(inode)->lock(filp, cmd, fl); + else if (((flags & FL_SLEEP_POSIX) == FL_SLEEP_POSIX) && IS_SETLK(cmd)) + status = posix_lock_file(filp, fl, NULL); else status = locks_lock_file_wait(filp, fl); - if (status < 0) + if (status) goto out; /* diff --git a/include/linux/fs.h b/include/linux/fs.h index bbf812ce89a8..8b6e9332b39f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1042,6 +1042,7 @@ static inline struct file *get_file(struct file *f) #define FL_RECLAIM 4096 /* reclaiming from a reboot server */ #define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE) +#define FL_SLEEP_POSIX (FL_POSIX | FL_SLEEP) /* * Special return value from posix_lock_file() and vfs_lock_file() for From patchwork Wed Dec 29 08:24:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12700792 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 075CBC433F5 for ; Wed, 29 Dec 2021 08:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239277AbhL2IYs (ORCPT ); Wed, 29 Dec 2021 03:24:48 -0500 Received: from mail-eopbgr50094.outbound.protection.outlook.com ([40.107.5.94]:28135 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231653AbhL2IYq (ORCPT ); Wed, 29 Dec 2021 03:24:46 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fxjyDccW6K6Vs8Dbs9n7HOILfThlcgFbUKruZmE6hsCboO4QyNeX7eZsVu5Qt53wt7JPOQv5dEPsynCWjji+ru8sec8EC7Na3C3YeEoczgkZEBisOYQfgweNI/ggIj7+bqRaISMhzMJvDNXiS8QzGDMoa4aoEasrEH/bQinn7xbh+Hal/1REiVgJ+27bNJCwJl9U+M1/GYaT4dg06ouh4Zs+iTs9Fb4XVI5++k2sBRjFh9Yp5n8tRFZA+gK1CEhQ1dh4mnNN71FvABaxW800uA5/06lBLfkLNYTsEMsoTTQze5I1Hd2LA3FTc9mb1MoTQjDcsbfcyOI/szvSJ5IyWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aI9A9SXUZjM2CR3SuatyKczrZlbAmBOJRVxTv4oVq8U=; b=SSNQNK1LBBIGubFiASnrm/29M1zNcwIXCiWeJp0GrutWhPjS7r3rcQWem2oJtUamb/fpAdnoZMwxVw2QCCIEtokIq3K3JDoK005qwohzG6SDPKeshKMwE3jV3Q7GFzwMpQZ322a7NHQP7l58U6s8Sk+gPiELlQGNG1v21Gt/SkYQyoz7YdUL657VHAStFW/vNRe8cBSpEgQYarWgLtKoTOAWNJ+eqmD4c1Nivc6WSKkvbBVJ8CHgeEjjN7ffqIzWqbBLo5KT/wrqFdZbZhEk+E2vW0OgYezprPmLfvPBoOkJbCCX/IowVZ9qQfbmdW1A3JAJ/LzYqlk+MRr8ZUIZzQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aI9A9SXUZjM2CR3SuatyKczrZlbAmBOJRVxTv4oVq8U=; b=nq2zU+E9RBOVcYWzkgNW/T4Rd9FuMlnBZ97xxrv8afahb0hZrW+fDRsRoYTyhrVgm69lbZKglHTPDYDvvnGHjHMAn3aXaojcYL7rA0vhBCFrlYdRTKAGnwuQWu9IpJq5A5v7O9Hr9HUFSY6xQ3cqAbo6mLwhNFgl4wOQCHPQZLw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6241.eurprd08.prod.outlook.com (2603:10a6:20b:281::21) by AM0PR08MB2964.eurprd08.prod.outlook.com (2603:10a6:208:5d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13; Wed, 29 Dec 2021 08:24:44 +0000 Received: from AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f]) by AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f%4]) with mapi id 15.20.4844.014; Wed, 29 Dec 2021 08:24:44 +0000 From: Vasily Averin Subject: [PATCH v3 2/3] nfs4: handle async processing of F_SETLK with FL_SLEEP To: Trond Myklebust , Anna Schumaker , "J. Bruce Fields" Cc: kernel@openvz.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chuck Lever References: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com> Message-ID: <00d1e0fa-55dd-82a5-2607-70d4552cc7f4@virtuozzo.com> Date: Wed, 29 Dec 2021 11:24:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com> Content-Language: en-US X-ClientProxiedBy: AS9PR06CA0077.eurprd06.prod.outlook.com (2603:10a6:20b:464::24) To AM9PR08MB6241.eurprd08.prod.outlook.com (2603:10a6:20b:281::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 335ad032-8c13-42b0-d944-08d9caa4aaf6 X-MS-TrafficTypeDiagnostic: AM0PR08MB2964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3276; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 76/Mct/1TfBjbdXovd9dkoSHnc55zExDXe+2juG7LLUdNoVMzBMyyiAD+StrpzFmGFg4D1Kd2YcenDr5zmAgGbyCOX8FunTylrhVx/DILfW2B+C6BiP6/O2akOsq+NrTVbBIaPMoYYtI6Tx/G+ghaFNVvNFD2AmvOkgq9QdoZxJvm1d/XlWIqwX0EO8ob2pqLBV2Md6zaO2ofuyWgQRoIxwVkfxBXW6hRjxnsFAp0HnYBbTtKlx5YSFZa4Ka53f3BdQJL9qjdu79hmLZQb9qXrukmruQhcOhImFSdkByTCVAZWkzyQMwWwl+VgMJzhnwBTF7Iuep1x/rZga6Cjah5WB0pWNHp3aO/AKb2lzWJLvE9isquCjP1JZDkWVaU/8KlLpd4+z5CZOggzUZiDNyyWJgJtSzxLaX1SVelTfRkLufYnMNW6O121xlcOonwa7AIy7dLE3L5AP7V4wjLSx3/b6PXr8MVJNCj/Q+Yp3vt3PaMhhYwgXxZQdQ4aSYZ9Y9bQuW0lGWiC4sP1c7pQ5cEUL059CKpoZJFHEBfgUQ9rAFhS7Jye7EOoFlcV9Dt+B6ykBgQdqRvDKuB2RQ6YUExSiR4fpQT9DDkCG35UKaqRdaKA8zUYxIZfbWI26UARQcMBmInZod1tUK42J391hiJOZZE+9EHxgK48wUfA0H1BwuMqAb3vx0IJhxFi1nReVE9k8Gc6ahghVQXhojsQHPjy/CRQJg4OdMwbaQId5yNkba1mYuhLc5c0C7cIYCUGS1eBRpvZIlvDTukrHOFslXpWaOrY/LYBamyGVc714igPEpFYZB0tk+awxhKJHTn9h+SlH4ExAtuLGMSqSDdnweHxsHCczhzDelwLec6EWxdu8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR08MB6241.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(38350700002)(38100700002)(2616005)(8936002)(6486002)(31696002)(2906002)(8676002)(6506007)(5660300002)(4326008)(86362001)(110136005)(83380400001)(66476007)(52116002)(66946007)(26005)(508600001)(966005)(66556008)(31686004)(36756003)(316002)(186003)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiS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dMOJekL2lzFZYz+s0RyC7ysVaXRanOw3VhgAW0qvJ+fk?= =?utf-8?q?eZYKOThB1DWs9BfI/thVmdEnQs0XdMr2qkl1XA/to+iVfxKKkx2jGMxaHPSveqk2X?= =?utf-8?q?etPkWIz/GWtMZbNn6bcqPRrNeDgqaWAhMsS8feeY1lwbnYrAoeNzWTdeMpGr4QRF3?= =?utf-8?q?KriUUFkVLJEWYvuYz1ph6JQYQRc+Ka+xWXWSRIrIaFPwqmpZJX6Zz6SCfwWCDel8B?= =?utf-8?q?gF2Cy3CvRJUwmuREmCgPWCMwE9bomP31NUTDayJrYr1J6cl9z9ALtev95CAsLG/Qy?= =?utf-8?q?zfz5sHg5FAoINytt0zSc1mAw/hcFxQHxhjCac1snKTXDvtTf+uwxRkdQBZCVcgLRr?= =?utf-8?q?EJupeazGG8h1VJX62nKROy0Wz3JfIQVqAiyYqu/lEOWrqEA8Avj1sW7WNekcc1jod?= =?utf-8?q?Z1baik9aYOw6eaDOuf+5qU5Ir1xVx8w0jOS8Qhy//bue9Pb2AyIjIRD6Utq2fw/qg?= =?utf-8?q?3nGHZ8OcuN07IfAckrnmkTG8knk/Ga56bJQTzX4a5OwmfN4EIB+9dtcGzlhdnb9EB?= =?utf-8?q?wIZBPa10Snxt5VDjRDTG52H2jjKxL4lS8KnOAH37plHYQm3fO5tFpOUZGCnCtYC8j?= =?utf-8?q?d5CQx4mNRzo/GzfosObqNbVCpFfRJJk8dgOrY8IPGLGCE10aIgFGid1L9bEj4tPsN?= =?utf-8?q?bzJpz6DSt11n9tpqkH0exH7n+O4clev2LzYXm2UzJgOKZrvw22UyeaU=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 335ad032-8c13-42b0-d944-08d9caa4aaf6 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6241.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Dec 2021 08:24:44.2480 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Od7vNk/x8AC4qbmW8wVG3tA/RvTYT8LJOtMbyZ5GCZZMdTfLO5d3QVaC2p9cLBNkVxCoVIqWoN6S0hG+tw23ww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2964 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org nfsd and lockd use F_SETLK cmd with the FL_SLEEP flag set to request asynchronous processing of blocking locks. Currently nfs4 use locks_lock_inode_wait() function which is blocked for such requests. To handle them correctly FL_SLEEP flag should be temporarily reset before executing the locks_lock_inode_wait() function. Additionally block flag is forced to set, to translate blocking lock to remote nfs server, expecting it supports async processing of the blocking locks too. https://bugzilla.kernel.org/show_bug.cgi?id=215383 Signed-off-by: Vasily Averin --- fs/nfs/nfs4proc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index ee3bc79f6ca3..9b1380c4223c 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7094,7 +7094,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f recovery_type == NFS_LOCK_NEW ? GFP_KERNEL : GFP_NOFS); if (data == NULL) return -ENOMEM; - if (IS_SETLKW(cmd)) + if (IS_SETLKW(cmd) || (fl->fl_flags & FL_SLEEP)) data->arg.block = 1; nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1, recovery_type > NFS_LOCK_NEW); @@ -7200,6 +7200,9 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock int status; request->fl_flags |= FL_ACCESS; + if (((fl_flags & FL_SLEEP_POSIX) == FL_SLEEP_POSIX) && IS_SETLK(cmd)) + request->fl_flags &= ~FL_SLEEP; + status = locks_lock_inode_wait(state->inode, request); if (status < 0) goto out; From patchwork Wed Dec 29 08:24:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12700793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49013C433F5 for ; Wed, 29 Dec 2021 08:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239287AbhL2IY5 (ORCPT ); Wed, 29 Dec 2021 03:24:57 -0500 Received: from mail-eopbgr50124.outbound.protection.outlook.com ([40.107.5.124]:37187 "EHLO EUR03-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S239288AbhL2IY4 (ORCPT ); Wed, 29 Dec 2021 03:24:56 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W/oeqWSIe1VtLmxkNF1YSx26nwrLByke0A7myNErp65NELw6tcgo/Ykf9pZFAKI7QAdueCuftjfH+M0x8nszBrbKEoMP5YZWI9dw24i7LLFq7XGqko/Fkx13zBL69r0wzAjUzj9IJWki73SSW1akvhWJ2Ou+KzM9X5+8iAelVxEYN3ojRF9oeQ6/VOw8An1AzlW4V+rGCudgY8eEgJn2uphYG3je7AuuHEESEH0I5A40c28pCdI2iMh3XmHQW6iv7WrQf0Pe0uxjOGxhI3JVUVE7J+IM9EYJ39TpbJ8gooey2Lr8g3oxwnx1XAqUiKOemvPsa0PULeGxwOcfJUHNHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dFtYv61gifHj2eYDE2zO5bD/6CRdCAwwtdrXtaH2uOI=; b=HfwyvuB4dHywF19yKgCvBOhz9g40gQYJ92kHMme2AxHD0pG/ntKzSFnnOCvO4QNdUWQEoSxEduu+41fGO8Klhe5TnTyq2P1VXsl4mBPsdDAOf1o1dfvpfruMUhzk/tYYvP7ZF1Yro3mYOcCWJN0K6rtGtC05pP9A4GNL6wIzBFshB30b5oFBtd5s//Lk2/31GAqqNTpFyDLliWqNZFSibY8FrEa74phoQLElKqVhAIiPtpASLaaOybOfNg1dk1Nt4MH0UFpNMDxLtccJGrlgh3L1pi8H6L/I7i2myb3niR2tqfgpn6oyYMOVtzuHzyTriwpADME2j00ZOz5sdg2G1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dFtYv61gifHj2eYDE2zO5bD/6CRdCAwwtdrXtaH2uOI=; b=FYff8gJCKHlrI6VqJTiW5cITuxrSvevsSlJSIj2RcntKVmtmhZggaq0Yw8k3Xu/B2Jy5mahYuXD2UBd6/FJiDSymkoA4RwIfABJe3j0vMVlp1lRcOF60Ag3DgtlCiNMOmzYHyl2K3ilSG9bZGO2Va0yaGBuZuSZqKbq3DbGcOwE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB6241.eurprd08.prod.outlook.com (2603:10a6:20b:281::21) by AM0PR08MB2964.eurprd08.prod.outlook.com (2603:10a6:208:5d::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.13; Wed, 29 Dec 2021 08:24:54 +0000 Received: from AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f]) by AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f%4]) with mapi id 15.20.4844.014; Wed, 29 Dec 2021 08:24:54 +0000 From: Vasily Averin Subject: [PATCH v3 3/3] nfs v2/3: nlmclnt_lock: handle async processing of F_SETLK with FL_SLEEP To: Trond Myklebust , Anna Schumaker , "J. Bruce Fields" Cc: kernel@openvz.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chuck Lever References: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com> Message-ID: Date: Wed, 29 Dec 2021 11:24:53 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com> Content-Language: en-US X-ClientProxiedBy: AS9PR06CA0066.eurprd06.prod.outlook.com (2603:10a6:20b:464::11) To AM9PR08MB6241.eurprd08.prod.outlook.com (2603:10a6:20b:281::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ca2f042-71bf-4f6c-561e-08d9caa4b132 X-MS-TrafficTypeDiagnostic: AM0PR08MB2964:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1775; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9O9+EkdgNSQfvTZc16ChL8KBeVAKUF3544epYl1d3v3kfszANKYO6C8XKKv5aQNUEszemNCcbGZjfGLUHnlyzWSdML27eddaQyaSfcHKX6xAYWjiPwMetimnJTVKMVDqjsbEcXLP3MY6KPrhWh7lGVVWWucGHulMb2v6SkxAE61kRSVogXZhmykdCbkHC+qRKMR1E16S72up3x8WeUTohNge3EbvnygCZM5wHwRB9x+gcvN3k02OmYx1zv47j6HBsQnTBGiFSckpZjaINmjlZxIBmlxyuZ62bsiV9OAyLC0KH9Qzsa/vnsmrS/OAGY63X2S6dw0RPL7pkdYKiW49mmsmQGdsqPFkB+FjbRD7bzsJrRpwsWAxANdiESVZ6wDAz/U973BqfQUhNwJb6Ae5kAL+RCcR/rJLfu3AyuLrroqjZjP6Perv1rxJ4mL4aCfcnvzRyg3wW02FIlByGexeDq2uWnWQ2UyH0m/E6wg5km264QKagFAzocIZtiBTT34k5U/2188Uzr6mrh6fTezOyndgZ7j+jyL4jEAgz231FCMv8fJyXlN8rhu6yC1VSkQAuZfKPgW90QMNOtmty8YNkTXBQX62U8AkxFpr8xoQ70PILHMvOO+Hfig8bK2bbUik/Xnomt3qgCa95aQ5oyMs1W1wgpXTgQLcYR3nkPf0wcG50ehyin486cEOQZReN6+p/tBKZzgEkVO1UAGOLQhXXaiyYH9qFpnIDhNbT3tZkIirP05+FQS5zMxbARXmZ2kdTZgOW67ea5AaXF/j8sNahQCPmUS+RiZ4ygiwncVeCreZB5kKWe33LVHtuVf+RmThww9nLG5DKF1od+Pzfe8fqyNBy3jU+8auhAfDmh3vqTc= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR08MB6241.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(38350700002)(38100700002)(2616005)(8936002)(6486002)(31696002)(2906002)(8676002)(6506007)(5660300002)(4326008)(86362001)(110136005)(83380400001)(66476007)(52116002)(66946007)(26005)(508600001)(966005)(66556008)(31686004)(36756003)(316002)(186003)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5Uuaxjjlfa1zyGYNqkcENyqs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?q?Gc5NSbeLITv9rHrRqTdh52BNGIdW95IC4pBOgTJ7seOF3h6fudvFK7/55XVIkLnk2?= =?utf-8?q?MygauJ9XgOQ87X5Q2KLUMFP7/RgQ7YgP9ypf79U4cdQG4fFc26FtkyCJt0i5zfSOc?= =?utf-8?q?xjr+c1EZEFIwtSe4XizCFwNNSC/eL+avAwT9I2L+f9Csyp+F4jo4fUIBvj8oMLeL5?= =?utf-8?q?eQ1pVFBUWasusHR2p0OgyW+bAmFtO062BBmDnArDIM7hOml/82e8wFdTorJbCTcAi?= =?utf-8?q?P2XAMeV11loAEYgI/hShBfOZBehdEZo9oCtyRprxW5BayZk3Yhke1CZmJDA1r6jEx?= =?utf-8?q?CqFFkwZUJY+u+GuMhRhD8XzH4sgTVCA5DsqXl1lZi4pW9uKWFOwWntzQbzQpM7v90?= =?utf-8?q?mFNBxSRIwDYYfZQG0nOUzvBnmHJubgwAgyTe9xhBnathbu5VXQ3Hf9PwWVaT9CBq9?= =?utf-8?q?VkGA+qFnUtlq4i6ItdK8LusYzUMK8x4cIvzHJM4n67mZ8l0YPWxR3UHdl2XK0XI06?= =?utf-8?q?c7pc+Lwyzf4fE72Us0HGhaEjBPz2uBngFcQMUHttqKNRqg6AC++NJAi7OmCCTHNvv?= =?utf-8?q?uRpVkKp+ELHoxCM2BxL8ckaXBkr13c6zqf4vD/0HTT3DP/agvaX2JzYVI9vmf7zaX?= =?utf-8?q?7vCsrb0d5rY3wL+VpYjzXp0J7n2k0PArGNOCFjKIET+Dh0zJHAGLJBc=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ca2f042-71bf-4f6c-561e-08d9caa4b132 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6241.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Dec 2021 08:24:54.6886 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: prgjBVC0Nv3DG/8oPhkuQPcPQkEUaeGBkA+RuBuEKd8TlaTROeRCbgWxQqMJ5VgaHsoXeybNOtIEE7NX6Xtwyw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB2964 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org nfsd and lockd use F_SETLK cmd with the FL_SLEEP flag set to request asynchronous processing of blocking locks. Currently nfs v2/3 handles such requests by using nlmclnt_lock() -> do_vfs_lock() -> locks_lock_inode_wait() function which is blocked if request have FL_SLEEP flag set. To handle them correctly FL_SLEEP flag should be temporarily reset before executing the locks_lock_inode_wait() function. Additionally block flag is forced to set, to translate blocking lock to remote nfs server, expecting it supports async processing of the blocking locks too. https://bugzilla.kernel.org/show_bug.cgi?id=215383 Signed-off-by: Vasily Averin --- fs/lockd/clntproc.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index 99fffc9cb958..5941aa7c9cc9 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -519,11 +519,18 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) unsigned char fl_flags = fl->fl_flags; unsigned char fl_type; int status = -ENOLCK; + bool async = false; if (nsm_monitor(host) < 0) goto out; req->a_args.state = nsm_local_state; + async = !req->a_args.block && + ((fl_flags & FL_SLEEP_POSIX) == FL_SLEEP_POSIX); + if (async) { + fl->fl_flags &= ~FL_SLEEP; + req->a_args.block = 1; + } fl->fl_flags |= FL_ACCESS; status = do_vfs_lock(fl); fl->fl_flags = fl_flags; @@ -573,8 +580,11 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) up_read(&host->h_rwsem); goto again; } - /* Ensure the resulting lock will get added to granted list */ - fl->fl_flags |= FL_SLEEP; + if (async) + fl->fl_flags &= ~FL_SLEEP; + else + /* Ensure the resulting lock will get added to granted list */ + fl->fl_flags |= FL_SLEEP; if (do_vfs_lock(fl) < 0) printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __func__); up_read(&host->h_rwsem);