Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2501402pxb; Sun, 16 Jan 2022 22:55:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxfa76srZAo5YeyCaXbKdmvzPc4yumxR0Xu2XieiAWAvi9kpGC2bcErVF6uuPVZ7GlnXaCX X-Received: by 2002:a62:ed1a:0:b0:4ba:da1c:804c with SMTP id u26-20020a62ed1a000000b004bada1c804cmr19894055pfh.4.1642402556049; Sun, 16 Jan 2022 22:55:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1642402556; cv=pass; d=google.com; s=arc-20160816; b=duygNAUOccZb+OTtyb9FhnyYRSk1ke9eoLSllTo35umEfqspHejkhaWlfYKVer4Hkv fMPhAT5X+EoXzkp5JFQoOyS+o2jPGdA7GL/bAg2vIw6CZXWZEOWkSvoscjSxilAwJ+Sy tGzce3uuchW2rTN96poHvNMhCLkXYu/FYxXJ2Q7X0JKfZKzImafMx+bQdeYspxE8i98t j212C/BVgJiA7NXKeXe/2lJRv7boRO4Q2hECPIumaRm4jvL2R21qGAbIrk9uKs9btDIL JWEAGj7PZYB+XtzoTyMXAPwTQBe/ZTeVxBy5xLIoTl9gtFw88g4g6QvBIwEgDe9bn7Yx qlzA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:in-reply-to:user-agent:date:message-id:from :references:cc:to:subject:dkim-signature; bh=ZP2XgHmUwKjvysdgfOVYOroon6zM8QoTsYQQDn88Wdk=; b=gsLcYW8aSRahePx65wKvRxB/UpitaZfQzspSQ0pbZMbuac68/pbrlLLDBI+S9XOPrO 1rYxDfZk68VgsGwCLpdBaJsv9TnIrrPqmB3PM60YI+24/AdhwtwIpps31Bg7js+F92Z4 4udHRYs0rjjKO+o0jA2EGRpNdswz87RKcgpHH15RDLzDf4ubTO6477DGNpdPHAyvrIRQ 8bNcBR/o1NfJKz72DRQY/ydxK1uTV+1CZ9WwPsvpZE/33rXaJDeo/7JiWqbeZkuWFZrV v5GeipOCh9aIkHMT288Q0VojQY+xo4pw0VvWpWnKcsYFZxjUJejtEpy6K7z+I99tW38S TYRQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b=K+55VFgK; arc=pass (i=1 spf=pass spfdomain=virtuozzo.com dkim=pass dkdomain=virtuozzo.com dmarc=pass fromdomain=virtuozzo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si14786560plg.107.2022.01.16.22.55.44; Sun, 16 Jan 2022 22:55:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector2 header.b=K+55VFgK; arc=pass (i=1 spf=pass spfdomain=virtuozzo.com dkim=pass dkdomain=virtuozzo.com dmarc=pass fromdomain=virtuozzo.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232148AbiAPMZt (ORCPT + 99 others); Sun, 16 Jan 2022 07:25:49 -0500 Received: from mail-am6eur05on2128.outbound.protection.outlook.com ([40.107.22.128]:40160 "EHLO EUR05-AM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230117AbiAPMZs (ORCPT ); Sun, 16 Jan 2022 07:25:48 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lnG9dpXM6W8yHl9sPGP39nvz5s7AntO9ktjghUTS/86KDYCFRiUmgYFl2aL9CCsEDLIq3f8gmpQhbrI0iSxFttW8z9O57botqyJsu8BLT7WCa4IHLwQhmPazx0f2rQq+7LEcU80gkg2Hugbbjb4AFyxSCFgv5QmGW57CRx6IvDEvx8S0n2xWPnBv1sjqCy9A8GJxLEEFjiQuI9fL3i2dU46KjY0YSI1XKmufK9mZn2p8EkEOpJczdrYzuacsRfT4c1BbZ0Qkam0+il1Rxb2H8xMMPjBliavPsYBkmqwwqgNnsn/3JPyxR8PQOVSKodqfWMfXdizPKfUd3HNA6Tg6Ug== 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=ZP2XgHmUwKjvysdgfOVYOroon6zM8QoTsYQQDn88Wdk=; b=CVHQcW6TJussNO8HcKGN0Xk1Qe5RyfWNJhmuFKld2IsxQJjozsP2fTlMUM6mZAH4GBYu+49f7ehDQdZKPgxeMAa+CJ0Bend09HPgO+z5ahubC+0VlyiKipTvhIrrP/WJ8SIiNC4C1SIwXfzXEvkza/X122fq40LBOukaZVjQWZt72ThmcSqyj2HgodY8X6Hw6Jd1yPVFQvgj/Yr2tiMcRcv5EbE8gs+9wx6VWhPlhCqAWnswWi1bANY90DbolyRv534oz0FZGsnxmaIe41wx0DNuGyFNF/xPXlaxXjEXs2kBcMhoHGkCCpL4NywEJ7U6Td2+W4PM6dELzixHAL5rcA== 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=ZP2XgHmUwKjvysdgfOVYOroon6zM8QoTsYQQDn88Wdk=; b=K+55VFgKZi9p+FJ5y5rUObxT1YvxGNU7i0KT4mNgHqDavp5Agte9vUHDw0O0fSZVkSNqZEHX71yCEO+FsIzyGdoJqRyhDh9NMqQohmSW5VWeqyahB4E49ysE5jz+UK2k4WMOM4bzyLq39R3tl/7Fz/BPtP3yKB2ell0ZIBCZvb4= 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 PAXPR08MB6335.eurprd08.prod.outlook.com (2603:10a6:102:12c::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.10; Sun, 16 Jan 2022 12:25:45 +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.4888.013; Sun, 16 Jan 2022 12:25:45 +0000 Subject: Re: [PATCH v3 2/3] nfs4: handle async processing of F_SETLK with FL_SLEEP To: "J. Bruce Fields" Cc: Trond Myklebust , Anna Schumaker , kernel@openvz.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Chuck Lever References: <1f354cec-d2d6-ddf5-56e0-325c10fe26ee@virtuozzo.com> <00d1e0fa-55dd-82a5-2607-70d4552cc7f4@virtuozzo.com> <20220103194012.GF21514@fieldses.org> From: Vasily Averin Message-ID: Date: Sun, 16 Jan 2022 15:25:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 In-Reply-To: <20220103194012.GF21514@fieldses.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM6P193CA0061.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::38) 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: a7b068b6-de1c-44fd-45da-08d9d8eb51c2 X-MS-TrafficTypeDiagnostic: PAXPR08MB6335:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iZOfq/K+iAnrt6StjeDGBsuxjB2Sbb78y45D++Au/mHjXNvyP0Kz3KIHpJtsSPaF5hMvzbzGq51DxTWEeluGdFc+ix/BAgdiR2jW611x4DyAKi7CS5sZwbpTNgau7hH6niknLVtYHE6dGwRku9LS1IMyV1e4LFciJGQ1MMxf4HnZV0kE3hMczVLNjf5FV2EmQCb0jn0fcCQ97+DEfsuQLyYyUgkxYx3N59kcuIi1jD+reF0zzo0RhJDs6npVa4+cuXMhf/5jqv0NPSgyvwQjgF/F4WP4UgYUqtO6HAsRi41bHzaiLHc5I7IcXN8RQF1SboHHAwSdksS+kZoVCW9iw8w2AHv8XRrgwYvdadFT07bkE6etb4t38IaHrCrTZwj5LO8JTclouPBn8O3j1f8CjdtnWScuiqgx8d+yvfypT/vRU7/CWukP4jZIebCyTWKJBiJmBTufMNz+4c+x7mMHJtGChMMmqOeYoCWvAKnJi7mtGOrcYBd1v36yKsknhtgH+QsamC8xLopaPxVgfkUB0wR+GOQRoTuum8xBXo1/awepoKPRbW63zXExKRCgVogmy9u+MqlWMNTe0gUHiTFDRffOvlMCS9EqF8J7fYHQ0sx3dwiNsUobi6cLXDj0UcJqgrhVAkctMqQCX5SBeGiMqvW8WTsgdtsSiL7y4mZrPHb8auMMV3LachdZP4r0Z5q8PpJL7UeKzMuOiQzMHgDMQYXS6zf+Xgaesol8wcJ8CuYfAVu8I7OsRK3AyvQkDPR3zRFlEACAsNkh21yq3csx1/LtAq48hu4IkRX9ATiUyJkl62HzZu4g02DiwoEh1B/iYNFLg3CYHpJvjD7OcXY90vpy9dl9ZRzlBITaFhhXc1w= 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)(54906003)(316002)(8936002)(508600001)(53546011)(6506007)(8676002)(6512007)(86362001)(6916009)(2906002)(966005)(6486002)(31686004)(26005)(83380400001)(52116002)(38100700002)(38350700002)(66476007)(66556008)(66946007)(186003)(31696002)(36756003)(4326008)(2616005)(5660300002)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aGpkMUJacWhTSVFjdmRMcUZMRlRWSmg5RW9oR0FmQjBEdkxxd2lUNWVWODIz?= =?utf-8?B?cGgwQUVEK1RsSWE2aEI3SUpHMml3N3FKVm1kdWJkSGphSTV2TktrcmE2MEpr?= =?utf-8?B?Nngva2ttSm12NGxlREVxaGdnSFh1Um05NEdtanlnQ2RPZ1ZKZjB2SHd0cTNo?= =?utf-8?B?NlAwblRQZ1dtS29WdFJLUE9ka0x2R2x2dEljdDJhbUhWY3ZVbEdhV0x1TUxG?= =?utf-8?B?RWlPa3FkZHVRNEdKMzdqN0orK1JwQWpIY3p5R3graWl6Vyt3ZTF1WWRKWjNQ?= =?utf-8?B?S1VpN1FMcWQrSUNHZTNhVTVGZlltdFdqWlNBVE95N0d1MDA5YWlaZStpc1BZ?= =?utf-8?B?MEVQRElESER5VCtVYkxZaWJJajVYZ3hIcVhyOExBV2ZrajZEMmkvanhTUWE3?= =?utf-8?B?aDlpZkozL0VxcGNXNjdXO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Network-Message-Id: a7b068b6-de1c-44fd-45da-08d9d8eb51c2 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB6241.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2022 12:25:45.4286 (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: X8qA6MNI+348vOgGwHM7KLprs4kHv/55dtMoIbOAWTid8qDTHd++RmzyjBC14yHtvCanI575QqU3BjKpa87BZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6335 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.01.2022 22:40, J. Bruce Fields wrote: > On Wed, Dec 29, 2021 at 11:24:43AM +0300, Vasily Averin wrote: >> 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. > > Seems like an improvement, but is there some way to make this more > straightforward by just calling a function that doesn't sleep in the > first place? (posix_lock_inode(), maybe?) There are few problems: 1) posix_lock_inode() is static in fs/locks.c 2) exported posix_lock_file() used posix_lock_inode() inside requires file pointer, and I do not understand how to get it. 3) _nfs4_do_setlk() is called from do_setlk and handles flocks too, therefore any posix-only calls requires additional checks or branches. On the other hand all that is required to handle F_SETLK with FL_SLEEP correctly : to avoid blocking on exiting lock. We can reach this goal here by drop of FL_SLEEP flag before locks_lock_inode_wait() execution. Thank you, Vasily Averin PS I'm worry for a long delay with answer, in Russia we have long holidays after New Year, then I dealt with urgent tasks accumulated over the holidays then I forgot the context of this patch and I was need to spend some time to re-member the details. >> 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; >> -- >> 2.25.1