From patchwork Tue Oct 11 22:34:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 9371837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4DCF16048F for ; Tue, 11 Oct 2016 22:34:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35E89290FC for ; Tue, 11 Oct 2016 22:34:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AA2229106; Tue, 11 Oct 2016 22:34:21 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 C227F290FC for ; Tue, 11 Oct 2016 22:34:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754616AbcJKWeU (ORCPT ); Tue, 11 Oct 2016 18:34:20 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36653 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754591AbcJKWeT (ORCPT ); Tue, 11 Oct 2016 18:34:19 -0400 Received: by mail-pf0-f193.google.com with SMTP id r16so1394344pfg.3 for ; Tue, 11 Oct 2016 15:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=j2LLz+qseKGd20vCUSbRY5cedRSYLdA6OQmHu1QZa1w=; b=BSWsLz/o4eNcFDsSDilBRHZIr8asjCzkjdx4socZd+oc067P7BOU0BBerHyCJPjvGt Z6n+uVet4GPb8ZP0MtYbsTnJFihthVxuy+1haAjX6ylMLhJ9XlGCZfCIxrfKmSxABcWr HD4OTFYAUFZbrQtMYX0WlwX/mnWSm0weY/qZbn09XJkmrolJWAUQY6NzBUkfCdjQgWqt QeHM3CT0y88oA/PNEWsrAbTqxR5ze5d+7rYmLmxzcBNavQRp8zCBNWMK7kETfTBAAYPA 7ioadcK2YDpT7M5ygdP8NEh6pvucVfK8FUqlKwqC2AFxOL4HxAo81gaScXTjnZLPPuCK IBvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=j2LLz+qseKGd20vCUSbRY5cedRSYLdA6OQmHu1QZa1w=; b=FVHVK+pt3bOFsZY6kLvDU9JDU/Kv0ifyT/K/R05N8cpiYVVKG/lOE7T0WsauLHrl9h DDAawhvZ1bDFpdIwQxlajD+bqbtVrzMb7+66BWj0S15W6Orxc4DTFxxCvE013dRHzSeK h7fEUzEyXScq/AhyzysyHNH84j1o0Z88WuUJIrWgb3b+mQQi1w0tUF1h081WR5z7DdXe jlWzn8SBS6hdfH1HYM69ZH+OBjyuG+rgqO3YPoG6SSb+awD8SfXGox/yPay+Ef6vtO+T I1w81T9vRP3km2FdR40RHJsz407aXrcoy6NHvFpSJD3bgiVeCLYHTMdqrww2KilIhhXz hn9g== X-Gm-Message-State: AA6/9RlVjKcNivhvrgT+O36aEwkBVVWZJK9sZEFBfLv3qE5rbbWeQLU4PQfcatIhWdvtlg== X-Received: by 10.99.144.74 with SMTP id a71mr4581665pge.101.1476225258869; Tue, 11 Oct 2016 15:34:18 -0700 (PDT) Received: from ubuntu-vm.corp.microsoft.com ([2001:4898:80e8:5::63b]) by smtp.gmail.com with ESMTPSA id o9sm265691pac.27.2016.10.11.15.34.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 11 Oct 2016 15:34:17 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs Subject: [PATCH 3/3] CIFS: Reset read oplock to NONE if we have mandatory locks after reopen Date: Tue, 11 Oct 2016 15:34:07 -0700 Message-Id: <1476225247-30177-3-git-send-email-piastryyy@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476225247-30177-1-git-send-email-piastryyy@gmail.com> References: <1476225247-30177-1-git-send-email-piastryyy@gmail.com> 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 From: Pavel Shilovsky We are already doing the same thing for an ordinary open case: we can't keep read oplock on a file if we have mandatory byte-range locks because pagereading can conflict with these locks on a server. Fix it by setting oplock level to NONE. Signed-off-by: Pavel Shilovsky --- fs/cifs/file.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 40b015b..16433a7 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -739,6 +739,15 @@ reopen_success: * to the server to get the new inode info. */ + /* + * If the server returned a read oplock and we have mandatory brlocks, + * set oplock level to None. + */ + if (server->ops->is_read_op(oplock) && cifs_has_mand_locks(cinode)) { + cifs_dbg(FYI, "Reset oplock val from read to None due to mand locks\n"); + oplock = 0; + } + server->ops->set_fid(cfile, &cfile->fid, oplock); if (oparms.reconnect) cifs_relock_file(cfile);