From patchwork Thu Dec 23 18:00:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12698572 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 2C5FAC433EF for ; Thu, 23 Dec 2021 18:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349648AbhLWSAd (ORCPT ); Thu, 23 Dec 2021 13:00:33 -0500 Received: from mail-vi1eur05on2098.outbound.protection.outlook.com ([40.107.21.98]:7265 "EHLO EUR05-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1349657AbhLWSAc (ORCPT ); Thu, 23 Dec 2021 13:00:32 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VIi/ddSUIJuFJj8d5hJc7RdP/DRfiokkQujAPM7yVxaO6kf6pOlDzV9LcZAkCgzMWbTAkA5/rlwcl8XVCnWGedk+VLVwz6qKU5Ge1bmG2bRnfHP+8xdbvXkNPgb8VvZI+ayZJMkzN5BB3QJW/q3k0+Azm5KvAXdNkClQiifWRFwk1dW1c2Lsv2MGH6kTteYuVAYD9FQa0Tup3TeJuxIWvczyjJrjRhxfxJ0Z8PTwfic8k5VQT8LmPzamC0O0bkhQVwXEP9qwOBDWipuL0rGw6z+oMurtIX/8K809tgTnpkw7govyXqlE4jHBok6u7Z+rkJkTXiKf9i5Tos9ND0NrJQ== 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=0nDOju3WbJyXVzdVGZLZdo8dJOlw57gNAkDL5oyZrjY=; b=jkw/qnMEG9fVHX50X8LooCt9CRDw60muQkykE6iA5yzUEp4eaAfu1/DxpoRAyclz92isUTUkexibvzO/3zJ2wj+9U1wc6hIjYAqqbDO4mdyIb2pRmXXGCDSzBCwwKVnUkRixuyAtixmvc+mEB1S69E7S1ZrWJVGWj9fUnlGkPigjQ4gWJNJGzld7wrWGY54c5bdCP2N7x8SgYCeu2WTr7DNJz2+1XiCn2FCmU16bcZFww8K6HceQ2wopmy5262Y6A3Vucv1fEWTFgFOBjhO97Gmrfx8ZKtybwtUaupdBwhRaW73a+VUwFf1p0dgC5xGgcYcXQixRnW407GTIC0KA1Q== 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=0nDOju3WbJyXVzdVGZLZdo8dJOlw57gNAkDL5oyZrjY=; b=unMnnIi1eiWBF2gz5W1O3BF0wntmzMNrAmGApAXsMOssnH9H5pVyKLAav1E1OEnRF1pzLQHrdJimgToqcluRIlDLFWCfd1qBvn1gCOzgxF63fTwRRXKPObIPeaZKGKGxXAGuw8BbhAlsoizD/F4lZZ/bqqT4WNLig4OXslj/f5U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from DB9PR08MB6619.eurprd08.prod.outlook.com (2603:10a6:10:257::21) by DB6PR0801MB1749.eurprd08.prod.outlook.com (2603:10a6:4:3b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4801.17; Thu, 23 Dec 2021 18:00:30 +0000 Received: from DB9PR08MB6619.eurprd08.prod.outlook.com ([fe80::347f:d385:ec53:75aa]) by DB9PR08MB6619.eurprd08.prod.outlook.com ([fe80::347f:d385:ec53:75aa%7]) with mapi id 15.20.4823.019; Thu, 23 Dec 2021 18:00:30 +0000 From: Vasily Averin Subject: [PATCH] cifs: handle async processing of F_SETLK with FL_SLEEP flag To: Steve French Cc: kernel@openvz.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-kernel@vger.kernel.org Message-ID: Date: Thu, 23 Dec 2021 21:00:28 +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: AM7PR03CA0022.eurprd03.prod.outlook.com (2603:10a6:20b:130::32) To DB9PR08MB6619.eurprd08.prod.outlook.com (2603:10a6:10:257::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4162e596-febf-45fa-ab4b-08d9c63e1b47 X-MS-TrafficTypeDiagnostic: DB6PR0801MB1749:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6y26b/fVJqaKrsvXINLYfCJ8TUWGEzhbp/FE7oMAYZWUbrckWCZx6p8yn80ajgdORkESNqNglSe56sLHFxnB5K1ZBLb/RmDOoL2PnHdGU+2mjFu/tXoS6gler9xy9SS303PYaMWlZXaBE7L+05678xlpZpbgLo4kWZiUqj6WMYsTqoZp85BQaMIw4foDfxpK0xcNfhN4zPYhVUgYoJctIjLFVEpvd0t/ur+rlcN+lbEzrrQSzQhDgpmflBFgqON9wU/5QX2/K6QLDZyrNmirICBdigdaeIGUH94//CJXb7m/2hbdlEmJfTXM0VqFqgM1SZHBY/QbRPbchcJ7tDsP1L+0qxkAgFoL4exTmDfwsiVPDnbc7Yfm47s/cJNaUjJqLCFmzD2OeryBFYzWe0SAcCgXRm5J21LHHkWCriKyy7ls166VyikhbAgKj6Ru1nEveDu1XoBW+MpCfMSlgmvyti/gBJ1ejCzOa8cqad+4GLCrJrzWbOIHMGEi9NDSrFdJjjN8rhhmM6z6dw+W+SJ5NbrTxccz2xL2C+qKFtJklik3Gb5blVapG7zs0HM0NsRs/vbn4KZkB/tKpcoZjmOHl9P66jBO111cqFeSFhgjtRLQMsrtAPzWvOerAh2KcEfSFDzmSSpzlWyY39SKO2MqD2AGT9/xYqIQZIjE6leNsavDZuFf9KZwQVJAOZlgPGW6VnBxZ9pK/1r64c89yS5QYTFYCh1xjD2bZi/3pZcItPHi8wPVf590U65vpCTWKRgTMoFRecFCA4ljm8EpR0Zf9zSeaFdS43B2tSpeJG1svevFVi6o5fk+DoXSum5mqYbodmexX0fVyzz3U3cWWCpkyrmPDTOWPkhx5qxEV1q1Log= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB9PR08MB6619.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(4326008)(52116002)(186003)(38100700002)(66556008)(2616005)(6486002)(66476007)(38350700002)(2906002)(6512007)(26005)(8936002)(83380400001)(86362001)(966005)(31696002)(66946007)(316002)(5660300002)(36756003)(508600001)(31686004)(8676002)(6916009)(6506007)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?P0IyQu1lwpQ0z3bL/UyFVZGtgIU3?= =?utf-8?q?gZBBxjKBid0iRs2Sq1QHpy6yeqKGtJma50GCq4JyzmLmsb76KAIVqt9L34Qj/OJNZ?= =?utf-8?q?Qb+XjineLwPV0CT/HE/Qo5boYtrxT8AxOiy6xTMdBy5ZvMYmslmgRQ7Htv+wt6icF?= =?utf-8?q?NdGHRkCV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gRYPs5wNOv2UN7xJIgUtQAU9tLLw5QG6aqotUzesW1vYZkV802/1B?= =?utf-8?q?0pMcuFkxiQ5HMYQscpQfRw3MdlCi9ydLYBu6DpCu7K9wFVKIy50hNUvf9pUyM8BUv?= =?utf-8?q?kxh7Yh+pXU8J5ZJ8xpGhucppFhLf85JbHTIRjQO6QC0QngVd+vmLncJmS0w5kv+SI?= =?utf-8?q?Daxw0CYHLR/N0UCyPGxyu3dTgt7KGHbzI+awiEnBGiWOArAbBj7YVbjKTC8kUmfTf?= =?utf-8?q?l7Z8fDiIX1qgcUXOnCDNCrEA3b53zrYpY5nV9CMMup7IOqlO/6O4NwUGAzyDfsM0k?= =?utf-8?q?8fO9FIS+bfY0QXJlYNLjJtHa49B/SazGmbBZxdoX46H7h3wZFdLO8ILoDPgw8aHaM?= =?utf-8?q?hBO/cwkBSbWaXcg6TI1houes33i18nRy/wJBA+Lz2NW5JUqjreHh3G1FuPJUOHA/X?= =?utf-8?q?EYdBvKr2kjKffocdkVvR3ew5SCK3wtSUgzsU/mxc3s0LPDRw/opr+QyIwcSy9FusZ?= =?utf-8?q?s2/MlKYQsi0G6boKb61R/LgwDm7zeiF/ZVIXQm7w1ocuFG/ZF5QCCvE=3D?= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4162e596-febf-45fa-ab4b-08d9c63e1b47 X-MS-Exchange-CrossTenant-AuthSource: DB9PR08MB6619.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2021 18:00:29.9511 (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: XPgXvzh8kuaFHQvj3VlTqps/DHVUKZ5uHhZspaTalYq08lWoUuQwPni/QK3xXuJCXvEDDn55NUBlCfcfJliwGQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1749 Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org kernel export thread (nfsd/lockd/ksmbd) uses F_SETLK cmd with the FL_SLEEP flag set to request asynchronous processing of blocking locks. Currently cifs does not support such requests, it ignores F_SETLK cmd and handles the FL_SLEEP flag as an usual blocking lock request. To work around the problem let's detect such request, drop FL_SLEEP and wait_flag flags before cifs_setlk() execution. Dropped FL_SLEEP flag should be restored back because some calling function (nfsd4_lock) require it. https://bugzilla.kernel.org/show_bug.cgi?id=215383 Signed-off-by: Vasily Averin --- fs/cifs/file.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 9fee3af83a73..6835458ee845 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -1847,6 +1847,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock) int lock = 0, unlock = 0; bool wait_flag = false; bool posix_lck = false; + bool async = false; struct cifs_sb_info *cifs_sb; struct cifs_tcon *tcon; struct cifsFileInfo *cfile; @@ -1890,8 +1891,17 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock) return -EOPNOTSUPP; } + async = (flock->fl_flags & FL_SLEEP) && IS_SETLK(cmd); + if (async) { + flock->fl_flags &= ~FL_SLEEP; + wait_flag = false; + } + rc = cifs_setlk(file, flock, type, wait_flag, posix_lck, lock, unlock, xid); + if (async) + flock->fl_flags |= FL_SLEEP; + free_xid(xid); return rc; }