From patchwork Wed Dec 19 17:14:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Georgy Bystrenin X-Patchwork-Id: 10737813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F096E924 for ; Wed, 19 Dec 2018 17:21:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D49C82B629 for ; Wed, 19 Dec 2018 17:21:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8D342B654; Wed, 19 Dec 2018 17:21:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F8252B629 for ; Wed, 19 Dec 2018 17:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728571AbeLSRV1 (ORCPT ); Wed, 19 Dec 2018 12:21:27 -0500 Received: from air.basealt.ru ([194.107.17.39]:38030 "EHLO air.basealt.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727502AbeLSRV1 (ORCPT ); Wed, 19 Dec 2018 12:21:27 -0500 X-Greylist: delayed 374 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Dec 2018 12:21:25 EST Received: by air.basealt.ru (Postfix, from userid 490) id A383A589ADE; Wed, 19 Dec 2018 17:15:10 +0000 (UTC) Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by air.basealt.ru (Postfix) with ESMTPSA id 06308589ACD for ; Wed, 19 Dec 2018 17:15:06 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id l15-v6so18053721lja.9 for ; Wed, 19 Dec 2018 09:15:06 -0800 (PST) X-Gm-Message-State: AA+aEWZE7Y1fAKb6Q0ZerCphoS2kprlfcIwaCZJqa14zcNgMvuABIOYs /OLzZhxknHMWdERefN1R1feSKo+vRndweKTXVP4= X-Google-Smtp-Source: AFSGD/XYurAW9k2LB2FQWPrQ3F9jwOQvuG506ncEUnp9w3dfBU39ABJDV8wOurprqcF9nyosKLjQ1jf3ice7oG6wqD8= X-Received: by 2002:a2e:1bc5:: with SMTP id c66-v6mr13008541ljf.96.1545239705674; Wed, 19 Dec 2018 09:15:05 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Georgy Bystrenin Date: Wed, 19 Dec 2018 21:14:52 +0400 X-Gmail-Original-Message-ID: Message-ID: Subject: [PATCH] cifs: Fixed OFD locks do not conflict with eachother To: linux-cifs@vger.kernel.org Cc: Pavel Shilovskiy , Michael Shigorin , Evgeny Sinelnikov Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While resolving a bug with locks on samba shares found a strange behavior. When a file locked by one node and we trying to lock it from another node it fail with errno 5 (EIO) but in that case errno must be set to (EACCES | EAGAIN). This isn't happening when we try to lock file second time on same node. In this case it returns EACCES as expected. Also this issue not reproduces when we use SMB1 protocol (vers=1.0 in mount options). Further investigation showed that the mapping from status_to_posix_error is different for SMB1 and SMB2+ implementations. For SMB1 mapping is [NT_STATUS_LOCK_NOT_GRANTED to ERRlock] (https://github.com/torvalds/linux/blob/master/fs/cifs/netmisc.c#L66) but for SMB2+ mapping is [STATUS_LOCK_NOT_GRANTED to -EIO] (https://github.com/torvalds/linux/blob/master/fs/cifs/smb2maperror.c#L383) Quick changes in SMB2+ mapping from EIO to EACCES has fixed issue. BUG: https://bugzilla.kernel.org/show_bug.cgi?id=201971 Signed-off-by: Georgy A Bystrenin Reviewed-by: Pavel Shilovsky Signed-off-by: Georgy A Bystrenin --- fs/cifs/smb2maperror.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) "STATUS_CTL_FILE_NOT_SUPPORTED"}, -- 2.17.1 diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c index 62c88dfed57b..d7e839cb773f 100644 --- a/fs/cifs/smb2maperror.c +++ b/fs/cifs/smb2maperror.c @@ -378,8 +378,8 @@ static const struct status_to_posix_error smb2_error_map_table[] = { {STATUS_NONEXISTENT_EA_ENTRY, -EIO, "STATUS_NONEXISTENT_EA_ENTRY"}, {STATUS_NO_EAS_ON_FILE, -ENODATA, "STATUS_NO_EAS_ON_FILE"}, {STATUS_EA_CORRUPT_ERROR, -EIO, "STATUS_EA_CORRUPT_ERROR"}, - {STATUS_FILE_LOCK_CONFLICT, -EIO, "STATUS_FILE_LOCK_CONFLICT"}, - {STATUS_LOCK_NOT_GRANTED, -EIO, "STATUS_LOCK_NOT_GRANTED"}, + {STATUS_FILE_LOCK_CONFLICT, -EACCES, "STATUS_FILE_LOCK_CONFLICT"}, + {STATUS_LOCK_NOT_GRANTED, -EACCES, "STATUS_LOCK_NOT_GRANTED"}, {STATUS_DELETE_PENDING, -ENOENT, "STATUS_DELETE_PENDING"}, {STATUS_CTL_FILE_NOT_SUPPORTED, -ENOSYS,