Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2283032ybl; Thu, 19 Dec 2019 10:59:27 -0800 (PST) X-Google-Smtp-Source: APXvYqxHO3Ml0ah5MHmda8Fni+k6Exc5kbEaGczALY3jqaCjERPGFC/dlNkizd/6Wp6xVowDWg2B X-Received: by 2002:a9d:21f4:: with SMTP id s107mr8279704otb.102.1576781967625; Thu, 19 Dec 2019 10:59:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576781967; cv=none; d=google.com; s=arc-20160816; b=A+sRvtdVbBorbRCH8wAYHQlj/jIJSQsAYiK+GrVDV2LQR1lhFDIV0DeKeuUYHux9iu gDsT/8aNwd+jJ842r5yzhFC//BAfJxvPE4g8GOPePlC4luS4x3NjSMkuUGGNrMfio/B/ mdzXIMKZlN2BOlXcoECo2NiLvLc10y0OfjeeDMV3WoSX1xky9/littE8RVquXi/XlckJ Nt55wJr1SmdtB7R7SzOMy2xVqRjZ4PqvrfmMv7bHhQfDtIjwYH23BSh3wUnZfVRDktyy g7x2omSbm4uN2esk88Focih0VxaIXAcSrqoVaY8Wgw4DVcV0sj5T1cGgVuOYgO78tVr8 GYkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wqp/Vsq3Ztp0jW35seHSZm8tzP55T+AbfDA28Mrpr6A=; b=Ekh208zVW/IxdrJS6PQ6Vr5YO7rZUohCkqZqV/MuapPwXNW8yEo/WW2bwkW/dcX/Pe iX5D3hj6hPyiI7Wao3YikJQFSmP2GVnG18AxtYZbBAtxOmoOskfKS7DaVAz4jhSuJ2Rp u3p0LWRgOtTgw1Clq0GvClis3Cb1QRg4gbKHwO98+W/HV9semLjVz6+KsZIcM2Slc1gp 5EQjyFwpig7ZL63gMNoN8vnI9thW0toUTPUbuDqCfluk1ZRahP/hkkiEfGoVhMb3l7q5 cJn91j/0c8/NvXJ2ovy+xj5AqY9bhICpQunwFs1w0xo0NYn/hYk3D/2dCmt0rSoKae24 GruQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DlwzA3Gl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si3822260otq.72.2019.12.19.10.59.15; Thu, 19 Dec 2019 10:59:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DlwzA3Gl; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727562AbfLSSzS (ORCPT + 99 others); Thu, 19 Dec 2019 13:55:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:51204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730650AbfLSSzQ (ORCPT ); Thu, 19 Dec 2019 13:55:16 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D1A35222C2; Thu, 19 Dec 2019 18:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576781716; bh=UB3CGPZLd0xN2deYoyv7WePnuiBmWN+ttNdJhj+RRmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DlwzA3GlHbUG7V4UCWB7f1wjx/1VliiWF2Sr7q0Q31GTR/n0hpXf2SywTc+pcfZHK KXpHyfTfAKcPmFivHTJAyoedkXIIc/QLBxtaOmtxUW8Q+AfSnmwOOpeHC/xsIM971J xgZcYT1Iz+BP1qufKZfdUG47Kfjw5mJVcEc2gjC4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Shilovsky , Steve French Subject: [PATCH 5.4 34/80] CIFS: Respect O_SYNC and O_DIRECT flags during reconnect Date: Thu, 19 Dec 2019 19:34:26 +0100 Message-Id: <20191219183106.565081059@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183031.278083125@linuxfoundation.org> References: <20191219183031.278083125@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Shilovsky commit 44805b0e62f15e90d233485420e1847133716bdc upstream. Currently the client translates O_SYNC and O_DIRECT flags into corresponding SMB create options when openning a file. The problem is that on reconnect when the file is being re-opened the client doesn't set those flags and it causes a server to reject re-open requests because create options don't match. The latter means that any subsequent system call against that open file fail until a share is re-mounted. Fix this by properly setting SMB create options when re-openning files after reconnects. Fixes: 1013e760d10e6: ("SMB3: Don't ignore O_SYNC/O_DSYNC and O_DIRECT flags") Cc: Stable Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/cifs/file.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -729,6 +729,13 @@ cifs_reopen_file(struct cifsFileInfo *cf if (backup_cred(cifs_sb)) create_options |= CREATE_OPEN_BACKUP_INTENT; + /* O_SYNC also has bit for O_DSYNC so following check picks up either */ + if (cfile->f_flags & O_SYNC) + create_options |= CREATE_WRITE_THROUGH; + + if (cfile->f_flags & O_DIRECT) + create_options |= CREATE_NO_BUFFER; + if (server->ops->get_lease_key) server->ops->get_lease_key(inode, &cfile->fid);