From patchwork Thu Aug 15 03:46:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 1972657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BBTlxu0f; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-cifs+bounces-2476-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wkrdw2JSGz1yXZ for ; Thu, 15 Aug 2024 13:46:44 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EDA0F1C2161A for ; Thu, 15 Aug 2024 03:46:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A4F4E3A1DB; Thu, 15 Aug 2024 03:46:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BBTlxu0f" X-Original-To: linux-cifs@vger.kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C365E374D1 for ; Thu, 15 Aug 2024 03:46:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723693591; cv=none; b=XEysFft3nMmn8gOMlPbDVsji1VljkHd/pS5m+6wB5NSOF86Wt3uin6HkdONoKMd8qm9wD3UUzCqjIxzmMSTafzxrGZykWM/dugUWyHdR6g/nsvgJlF/2jY/d2fmdjUO+vU+QAXiskIM0QR9G4WbHX8wz1jgmZoxV2j/c5waf9FA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723693591; c=relaxed/simple; bh=kPGwFclQIvtXy7MuavVzMMSi6JvaAH/hja/wgOwZdhY=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=px12dssJlUhJ/2enhPwR82p9tV2t/W5af5w0eZr9EmBQWf49Gd0kKsh5sqJp8j28ECBmHO28CIALTG0Z7IkYaTh0k3C5RsvPZB62AicRutEth6WiIvMvD5YApBPhAjL9qX0wj3feJ03WrlLFmkliWJWbIDffF6BlobUgeuEKXlU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BBTlxu0f; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-530d0882370so468098e87.3 for ; Wed, 14 Aug 2024 20:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723693588; x=1724298388; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=dR0E44D16CNR/7n2bVck4hf3eeDt0OXsN8Plq8P7udk=; b=BBTlxu0fj1YmrrwlFkZ7zA3p/t/zFq3AAtgqjUubHldC07rr6onIfKRSDZnaFHAxha PkDf1WZfe2UNcqsgIcEWxcJMyISMg15I48ADu1xIMDdJMVoUB6+WSC5Mp6L4uClEolPf PnmlRtL6sasfB9xDS/K+qrzB9shNuukdwzibrLkoR5L0rXgIgYGVuf+jTCa3qxSpvhah rKJm2b/bqYSEd8FenCj2SofHoHvw2czr0gytk7IIBkdyDyug3G2I8dwcCkA2h6MusMKH B7490mf3djCbyDg0hKwMuzc971eilZgOjot5Z+Pcry9kjrdo7cCnILuJvKMvFZNJyrr8 jUfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723693588; x=1724298388; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dR0E44D16CNR/7n2bVck4hf3eeDt0OXsN8Plq8P7udk=; b=jIznbB1vA5jakyagC8dodPwcfMasAPkCUYoMafH2vxaLNl87cnkdsoWsN9TJVRrJ6O 5HIyam/Nvwjn/bXLJ3dti1COsLEn7nfkHB8lxofk3pTKpnncRZnVyGenw68Vv4NQUvOb jCvIU37eLsG2RT5FtjVs3UHili0gOPO5R8dQr8DepLSNOYATCtOjsiRIwl1CUgeGRRZN 68/Cl6YUoaoRNg0P5KeqAY7SAeIOL2Bx8CxaFO3yBI3TQR/yKGIyvcI6y6TabYYP/ady Pk87niIS2MYc0GpwudVfePosWA5kcmIaP93587wFkm4YZRgSZmMZq90zj/NV7SwDrbyb PxQg== X-Forwarded-Encrypted: i=1; AJvYcCVt4rdF1p9YgGUJWh6S44m/UnmmOUhz5n73yeEKp8nGAs/w58yKQVW85bd7nYQcweX55m8oXgpJc/GDvLlDEKIXBLymk5cdb9AaPw== X-Gm-Message-State: AOJu0YxfxYBaXxQyOzX/KRPkai4YOSd2VzpUbhSh24PmEKynQCEEw4IV 4XdT+QyLwGhpjxcCXaktHtT+jg7s5BxUdl+xVmCBNgMPmJO4+Mnr/fLFTr2TI3GDM8erT9i1mUR b6o6olrQk2WFG6N9SGr2zy5ZlZ4LD5Vp0 X-Google-Smtp-Source: AGHT+IEW2SFVNYDn6XU+DFuDlo2rSnASqPiKMPZkL5bn/MbkO7KlOSE+RisWwGYJQ6mInJ3rb1+GTYpfMrrbSoJ2Kck= X-Received: by 2002:a05:6512:1310:b0:52d:b226:9428 with SMTP id 2adb3069b0e04-532eda8e621mr3579303e87.6.1723693587364; Wed, 14 Aug 2024 20:46:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Steve French Date: Wed, 14 Aug 2024 22:46:15 -0500 Message-ID: Subject: incorrect lock checks in cifs_writev() To: Paulo Alcantara , Shyam Prasad N , Bharath S M , David Howells , CIFS Cc: Andrew Bartlett In file.c we are checking for Windows style lock conflicts (even though this is Linux) for cached i/o which seems wrong (unless user mouns with "forcemandatorylock" which today is ignored for non-POSIX mounts) One obvious way to fix this would be to do something like this change: netfs_end_io_write(inode); Any opinions about which approach looks better? diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 45459af5044d..57f9d934eb4e 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -2753,6 +2753,7 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = file->f_mapping->host; struct cifsInodeInfo *cinode = CIFS_I(inode); struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; + struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); ssize_t rc; rc = netfs_start_io_write(inode); @@ -2769,12 +2770,16 @@ cifs_writev(struct kiocb *iocb, struct iov_iter *from) if (rc <= 0) goto out; - if (!cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from), + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)) + if (cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from), server->vals->exclusive_lock_type, 0, - NULL, CIFS_WRITE_OP)) - rc = netfs_buffered_write_iter_locked(iocb, from, NULL); - else - rc = -EACCES; + NULL, CIFS_WRITE_OP)) { + rc = -EACCES; + goto out; + } + + rc = netfs_buffered_write_iter_locked(iocb, from, NULL); + out: up_read(&cinode->lock_sem); netfs_end_io_write(inode);