From patchwork Wed Jan 31 23:01:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 195031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp83568dyc; Wed, 31 Jan 2024 15:14:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtQvJWhTMZwW1jWRraIdImebnu3c3pfYbHg8/lkkmVwHM52m/CpNH8hVLpYEZiCtUkXui3 X-Received: by 2002:a05:6a20:1b06:b0:19e:304c:5b57 with SMTP id ch6-20020a056a201b0600b0019e304c5b57mr2498495pzb.60.1706742889084; Wed, 31 Jan 2024 15:14:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742889; cv=pass; d=google.com; s=arc-20160816; b=lx5jo46mrn0vj1I+FPntJaKaLV0vpIHFSO1rSLqwq8yu/yIadXELKp4z63ig2QYzIb dYmdCxSLdWVahh/iL35cGrzJN1WbT05+a27sKf98zKsT5dxzljOG1VAFOHWSCmh34s5n myBgaezAd9SB9eUvvOTtjNg8Z88bV9p0DKG/EYUi3R1OHbM7QaLccfq3djLTGRGVj7aP 2+oOqPjW1J7ajqva2tvWaGFdnAVz9lt2RjXn8GCHq8kN8mQP8as/0emE/ZfgupF8k4Av sYiOM4mK88xNhhxMN1r+Kle0uIflhefmFYpBaPFco2jV+4aiDDqpKBkHH08bQPOMObQ4 qEdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=AYOCXWWxlsaDdtnpmjvpmcu+NJ3UZ/xj3avH+zWYXak=; fh=8DaGBNuoHKbUyAiloWTtSnzhaQYHzFUH7X2ePMm6u7E=; b=D5sX2dqxqDGyf1ocju0Kflc+8hAtZ4WLKcAROecBvAZBLJn1CToXmoWw4yNUq2HOTK wvgdRunl3Ay13k4MISMFF2U75NIELZCNhS2VLWfmqFruEgqxEcCrHOErGW9emChMGge0 QRQX+CXTGMBwe3rO/rRn0jFFdItIBZE4V6PIlkWPWdyXmlRQfzUGSN8WMNeNbZVuXzh2 yNzZ+aQVl/+azHcw1jPxyJrnk38UxKP3BtC+bJQzF0h03V21p5xH6W+IayxvHCE3ycGT xs1Pkd9PzZe50N19Bg+miI16GjCi4seZ5NzUXrZFBXU9fbxvs1ejyQSJiJBxGzt9DaFc fiiw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jPaJihUo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47300-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47300-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCUiV71HzKkw6LDKfAx0NMkph0IvAfA9Rhe+M1wzLljC8FrSroff1dwKbdwJs0DiJBt6wJvoIO4ZkZF9SKCmteYyyANUiw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q5-20020a656845000000b005d8e221d9f4si4460065pgt.77.2024.01.31.15.14.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:14:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47300-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jPaJihUo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47300-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47300-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A998E292664 for ; Wed, 31 Jan 2024 23:09:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B1A94CB41; Wed, 31 Jan 2024 23:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jPaJihUo" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77CE84A9BF; Wed, 31 Jan 2024 23:03:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742192; cv=none; b=rGfLpMD+Zb+fBNSTyAac6TbxT1aXJhdf/f+3OfcUvA8b3DwHdRquC4mhtcb862YTThPvapwLYsp1icOVq06OkDsjgo8apRkz4O4ArSZqOdk9gF2WcAoGAjo545y+oWG/oNBPw9KICqn+8LemiiZ6MXJ552klh2GsiKtIrlQpTqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742192; c=relaxed/simple; bh=sNOrCkTcYd2ehInJVAjwI61o+eqh8+BcNWvctRiFYlw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jvWh88l8qbwm5bqAvWMxZx9xMfSLNa3cF4iIfSmN9Qmd1Fzy6T+Uy8wxEn37rBtI+hGxwOLk9EnUHN66FN3cWlr5p2ZZFSuzpBF1MpgP9KLQnI1Ns7zrbYez6eL/D+pwcDQls7vrL9vVU5RnDQaRPxzXEUMnUMEg7x9dQc/efSQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jPaJihUo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3656AC43330; Wed, 31 Jan 2024 23:03:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742191; bh=sNOrCkTcYd2ehInJVAjwI61o+eqh8+BcNWvctRiFYlw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jPaJihUo28zQ6jJnl98vBQtGyyjGMtzVW5ofnzGXXU+QTRvh15v2RBIzVXnE2JFaO W1Cu7k+uH0yEh+e6pr4EIx+3m7Cmuu0iBVZvMwfVERr61y3TDefQNLlrBM2eqKa4FL kscevZqv+9C8H0SmoYtuM6o3cW5YxYYLT17q7Iah5phaEuTsvnRBb9bchyuRHcZB5N 5qxt/iEjtAf/z6JUO6qoQDD7icldKN+rA7J2YL/LOI0H1y8CiIqIXoR7t+EWxh1sAk aEOt5gPSJ3qqU/PmADYuY6BSwnL3Mej0uia1UEvudny2EEo7O+ehgLssIhfvbJASww QkNFb26yMDazw== From: Jeff Layton Date: Wed, 31 Jan 2024 18:01:55 -0500 Subject: [PATCH v3 14/47] smb/client: convert to using new filelock helpers Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240131-flsplit-v3-14-c6129007ee8d@kernel.org> References: <20240131-flsplit-v3-0-c6129007ee8d@kernel.org> In-Reply-To: <20240131-flsplit-v3-0-c6129007ee8d@kernel.org> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , Alexander Viro , Christian Brauner , Jan Kara , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Andreas Gruenbacher , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Miklos Szeredi Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2139; i=jlayton@kernel.org; h=from:subject:message-id; bh=sNOrCkTcYd2ehInJVAjwI61o+eqh8+BcNWvctRiFYlw=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFwEGvApQjLFywG5KR4PXw94xatGEobs6Txc 96xMWLF+iuJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRcAAKCRAADmhBGVaC FW/HD/9t/9RYMz4y8XwdaPmCmqiSG5Md5Xd11I35AaoOBOBMXwUeC3cIoizT7vcQHgG8OQQebCw NQOY+wmXxcYtqyJcbt9RiqqFybbWAQt4crYf6Bg5nKBHwm32QIdP6JJLMrFmAtbpp6hb2xWzHuz 5SvKSCIFWRslcz1JTSTnWgNed6rUapybXAi4K/adDvQTXEZuqB4vWFPXYkAR+sJ/2snfOgau0hR sMxvrdi/COJ7AepichAP3JvXKGu/elAe7g6lJ0MgLssb3b2olbt/Jl3XXdm4T4Q8+Odb/pJyP6M R2VBE9T3c8w/pVTEun2UStpcm1DH6U/tYHwaHK/Zq5zLT/d6NOIaftuaFxBMLqXVgVGggAc/5PM imB/qngELyOKiVRbx/KfMFtj6FOesJ3S7jZWWSu1uBwOlzvR5vS9btnKObUYgWfGgTOb7WW6lPp z+QjxOu+Byg8QBU4dhuT8w37Aulj/OeJ5p0xEsAebccb9B1JRie5m3LL2RkjVT6L2aihHdJL5sC GiHAJT7z+Qz0g8YhAk/jU9AlalNqbzGdxcIX7vh/6KsoNvwsjV/8MVwGSvfX8OYVBnYcQkexQbN h0VvHH7dz198ioRYLgTk60as7ToLb/qVHNxt+o5sTF/pQL6Iu6S2QAKlGgtres1FM9mSz9/wE8g pi2mqeC1DCCjf1A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789649631726579893 X-GMAIL-MSGID: 1789649631726579893 Convert to using the new file locking helper functions. Signed-off-by: Jeff Layton --- fs/smb/client/file.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index b75282c204da..27f9ef4e69a8 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -1409,7 +1409,7 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock) down_read(&cinode->lock_sem); posix_test_lock(file, flock); - if (flock->fl_type == F_UNLCK && !cinode->can_cache_brlcks) { + if (lock_is_unlock(flock) && !cinode->can_cache_brlcks) { flock->fl_type = saved_type; rc = 1; } @@ -1581,7 +1581,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) el = locks_to_send.next; spin_lock(&flctx->flc_lock); - list_for_each_entry(flock, &flctx->flc_posix, fl_list) { + for_each_file_lock(flock, &flctx->flc_posix) { if (el == &locks_to_send) { /* * The list ended. We don't have enough allocated @@ -1591,7 +1591,7 @@ cifs_push_posix_locks(struct cifsFileInfo *cfile) break; } length = cifs_flock_len(flock); - if (flock->fl_type == F_RDLCK || flock->fl_type == F_SHLCK) + if (lock_is_read(flock) || flock->fl_type == F_SHLCK) type = CIFS_RDLCK; else type = CIFS_WRLCK; @@ -1681,16 +1681,16 @@ cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock, cifs_dbg(FYI, "Unknown lock flags 0x%x\n", flock->fl_flags); *type = server->vals->large_lock_type; - if (flock->fl_type == F_WRLCK) { + if (lock_is_write(flock)) { cifs_dbg(FYI, "F_WRLCK\n"); *type |= server->vals->exclusive_lock_type; *lock = 1; - } else if (flock->fl_type == F_UNLCK) { + } else if (lock_is_unlock(flock)) { cifs_dbg(FYI, "F_UNLCK\n"); *type |= server->vals->unlock_lock_type; *unlock = 1; /* Check if unlock includes more than one lock range */ - } else if (flock->fl_type == F_RDLCK) { + } else if (lock_is_read(flock)) { cifs_dbg(FYI, "F_RDLCK\n"); *type |= server->vals->shared_lock_type; *lock = 1;