From patchwork Mon Dec 27 10:45:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12699685 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 13690C433EF for ; Mon, 27 Dec 2021 10:45:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233354AbhL0Kpb (ORCPT ); Mon, 27 Dec 2021 05:45:31 -0500 Received: from mail-eopbgr80101.outbound.protection.outlook.com ([40.107.8.101]:40007 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232742AbhL0Kpa (ORCPT ); Mon, 27 Dec 2021 05:45:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OSMELQUpO58wzwsPnTZsosp+uwCvW01ZOyTQAeuqW9Pbo9z6+qpEZAfe+HndUIrywpiJKbT9Wo0vXUbTweidOUAUl76tZpzMAXZKPvm9e0CJIMfQBkylxumrvUNZvVeHl/J+LzlMwwLX8xlcJcDTxgdDBrCOpzJ3Qe9Lj0MymCttgKDWfA4kycF0fELeQzGwO3bN367Ixr0BKMdDVN+UBu8eDzTEoJovCKRUDi6wCcAxWVHe63gJ+f1Arf6ctRHDHcFVJ0t6RrWSctOU35NxYIK4Sdpf4P+pOvZAiPNUEUw4z2DPPJmtps2oA5GdkrmSdVEVH3Og4FOAaCDQzAa+7g== 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=CwuVNDnGdJ1GcH41Cb+dIiiiXqbLuMn9P30NH0PFnJU=; b=JPsUrnIpggB6w7zPgwDK+yEOaN4m3NtmqW6wcaqlD1AU0TUGwuDtrRfCIEIJOkuig6gz0ElyWQTZF93oB+oAa+/ijAZmfNSUtBEskVyGO5/zFQlRb0FKdWNXv7kvwxMk1pqiQhjZh/D6skbDQU5sl0SV706rvHtvIyLw/X1xT7fV+2RN1Y3yzKKzslmB9vOF8XSjB9laTV0FZETcf+8ITh8uY226/G74SG4k2PbAIB6oPAloVQUGLPcw6y9gcgf8p+xxrlyRXuDXx7xBiepZIkAOZYVgoNxuPs5o33H/N3+iYhmH+O5nC1rDR0HWgeQNqp8bRqvdHIrRZKEfrIYp1g== 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=CwuVNDnGdJ1GcH41Cb+dIiiiXqbLuMn9P30NH0PFnJU=; b=H2TOufyr1BPb8BkamVl98cCfOpGh/3dZQvvvU4MEGeJWbxDrJHBr6lqigsihVyzqR+vK0jERMMnIlEdDtqAdVkhnRXVnxKcisAYNvAJViKwm8iFRMfNisdN0P+1S/iWwpz1ocB4+d2ED5HsGdN2NiPhMe+rCWceUH4gk4hBuHYg= 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 AM0PR08MB3554.eurprd08.prod.outlook.com (2603:10a6:208:e3::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4823.21; Mon, 27 Dec 2021 10:45:28 +0000 Received: from AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f]) by AM9PR08MB6241.eurprd08.prod.outlook.com ([fe80::f9ca:fe00:10da:a62f%5]) with mapi id 15.20.4823.022; Mon, 27 Dec 2021 10:45:27 +0000 From: Vasily Averin Subject: [PATCH] nfs: local_lock: handle async processing of F_SETLK with FL_SLEEP To: Trond Myklebust , Anna Schumaker Cc: kernel@openvz.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Message-ID: <6613b17b-43bd-07d0-2ca7-1581a39cdf7b@virtuozzo.com> Date: Mon, 27 Dec 2021 13:45:26 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 Content-Language: en-US X-ClientProxiedBy: AS9PR07CA0019.eurprd07.prod.outlook.com (2603:10a6:20b:46c::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: 0f5a6d7a-3c17-447e-3324-08d9c925feee X-MS-TrafficTypeDiagnostic: AM0PR08MB3554:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:923; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DcxXfAJ/zBCxWVz/tz8dnw591puCTZ8kRazA1JDCH3LVjRlJwBudMjqb/hIcIzUnUd45x8iSmYGsQDz1jSiPBEqQS897nDV+NnQw/bJL1sQ9PgJZybyHz+N+JNxAxEmws3YgfTuS1uUrDly9TMRdr57ry7hJ9qapAbYGPOloVGjPrg0Og9owwOdy8srs0fe+zs8aRxSuyFDJCB6kb6SjHiwXZlH5B6HgILxSSqs0FyvpyftE7jRM/qRuelZLzOLlxML5B7LtsJy1a3X2qk4/VYAsCy//DvCv5bPUstoOcj8IETMKLFk021QXd2xueJqht8gbzdaGE8KfFbS/dWxaoYCpnhnBvArUGIGXe7MtfAssHLjbLKCGdsNl0G51BkKJLF3XH+NvG+O6r6yOmgdBJKcVK3kUDshzCUalY7skO2SkpHNbqatbvT/okitaSVCT0FqI/aHw6/qQs2tsmmH6qYrtBcJbFCQAbKyVQxh8L6/95+t0lzU4VCZv7R1qGUwzEqlJe3wgPdebAlJa+D5IO+mn3Yq9o7MDG55lLyThonq5F50gfHKbCfqLBEWWP7YNRj7Mph+5+Zp5pLgjbY2n1AeWU5wIjkGDi0rUZaCgvzJZianNCLpifi84dZKEr3XADRvQxkhC9axJunaT8vImO3OB5GQSq42lUWOePGtrbPDM/nLtSekhcCPD1hLEWZV4vxCbwugkZssSrr0MqOAEP/Ryiwp+dTfLBjGx/KEaI+JCY2wGYHt7dbb2KQXnuVu4Pk5qysaw765gVFZvkPogMimU5PH6g3ziZFcLBXgxstOYnuIInxrur8sIkf/YMN1Nm+QYwqNWm6J52gdM5ZtqD0LwqZdEQYIxpsQJxnQTttM= 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)(4744005)(6506007)(186003)(5660300002)(6512007)(36756003)(4326008)(508600001)(26005)(966005)(52116002)(316002)(8936002)(2906002)(2616005)(8676002)(110136005)(38350700002)(86362001)(38100700002)(66476007)(31686004)(66946007)(6486002)(66556008)(31696002)(83380400001)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?zkLmi5doelBiB+vZr6PPtez0n7lw?= =?utf-8?q?2/R68iiAC6xPj814PxlCptgEKuF7rbnj9hm6iFK/QPQ+k86DN/3VBbUjlDfUUyum6?= =?utf-8?q?bDmRG+yqmpH/XK6cHVDMxV12VVmVDt/6I+HGf8HG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Uzb7YHtG?= =?utf-8?q?W/RI+tb++dIppl3FrVLG8C2nPcy7XiV7z5Qpcfnj31w5GOqnGjXfMYD6NiN90VivV?= =?utf-8?q?RxGrhGY2DQ8WHbZqyPMBSBS5Y7vnUT4TM4JScjQrmCmUDjSatKnRIFjHV0j4bF+s+?= =?utf-8?q?hjCdmpM37nBHlqEaQo0tzYkfdQAw3ryP7T6jKkh8Aar7glatPofwtgABS76jR399L?= =?utf-8?q?ZZalzybO8sfAfpnhYdwztDAJBB+lfDL1HzBvh5dsOK7mWaldv6kr/Avt81LY6/b1e?= =?utf-8?q?mBAtEEBBQFtwzanE2S4dW9mG+jVvKVnH4ySZbsx1I9w3qUsRIFJ1xPZxeFZ2nbp7D?= =?utf-8?q?IRExL8UYyOECslrAdVwVZ1vXSXxAyZ2KKi9FMfY1/an1q8zb+M4tT3MyG4Ol7+qxH?= =?utf-8?q?Rmlrgtjo9++fRqGMT5CdmEuTmq+ZoeNqVmHGmhcDCcGDVeMDik8Zq3yyNZSWbLy1U?= =?utf-8?q?Gp9kojtoM38YIl4i6F9i1ymFhJwXM/vi8Hw4YoHSABCG95rA6TZkvAUZsaTO/lsM2?= =?utf-8?q?bf3QM7WzR5EXC6PgsnHd3gRFwMDEc1G7iFj2IOl8D7tVRgjVBRjJ8ss=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f5a6d7a-3c17-447e-3324-08d9c925feee X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6241.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2021 10:45:27.9662 (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: AY4ssfyJZvKc775qTfKAghFdRbsVj55u80yWClyhx+MMRA+S0XPKQpr0C/03Yh3xFI61S3tBnt8F1QssuXDq/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3554 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 mounted with 'local_lock' option use locks_lock_file_wait() function blocked on such requests. To handle such requests properly, non-blocking posix_file_lock() function should be used instead. https://bugzilla.kernel.org/show_bug.cgi?id=215383 Signed-off-by: Vasily Averin Reported-by: kernel test robot Reported-by: kernel test robot Reported-by: Dan Carpenter --- fs/nfs/file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 24e7dccce355..c9c974ee2f43 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -769,9 +769,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 ((fl->fl_flags && FL_SLEEP) && 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; /*