From patchwork Tue Jan 16 19:45:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521094 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 46AF46A343; Tue, 16 Jan 2024 19:46:50 +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=1705434411; cv=none; b=EPDh47pLb8mUmPE3ew2h0XJGAtHcMh9ekvmQvJ8+loyN567dZVqk3Gp/vjYOaox2QAF3EMUoLLa/33HmKMG7XozgpS7lcRBIBIy9KUnw/rX6VmTgM1uG+/8snWUfMExm2yM7p6NAQ+u6hrsPn42ITIYO/iW3zZoOJthpqP8/DJA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434411; c=relaxed/simple; bh=YjY34dM1H484nLiPhaWW57Fe2QttFCAJUqyuIWnNlwk=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=NSYCohscd1I1IXFgwfzPGmpozHsjN+cO0IENNUOONGMs5KpfHT9/ZbQFr92vAn1UAXLoxcSQj7GNMk0pgnOFZ668gw5rRLtv1WPqdNgrepVeEROTrLmx2XqgB1pphRZYOAIyrti9eMpjSKHBLb8oJZJ7cwngsbyCW7ifplXqx9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cdIgnA3S; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cdIgnA3S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C20FC43394; Tue, 16 Jan 2024 19:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434410; bh=YjY34dM1H484nLiPhaWW57Fe2QttFCAJUqyuIWnNlwk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cdIgnA3S5spCJgft8bPEQ2cSRTib2CYHHHVTd9QZbp7rSSRir0PSNW/5pJArEoBOp CCG7ZV4Vty+k0+LnwzyzCXPuNbf/8D+kc0cn1XIGDhoEK0V9QjYdH3xj2RkTgSl2lb nKJxdH5EQfZYvkItb+H9yEGXstuSVAYobGuep5JUV2yLZ8cuGe8ISrjja2efG0L1CX eUBZRsaNMBemw6nMOEd0JDq6UsttMvH0N8yJg9jh2A5zGwnRNRN9QzvwuzO9M43y8K Epuiddlc0Ogss/9Cuf5AY5kKRT6sacFBhZXaU3FSGvGhrWvuz+Z1m0l7ChNftHZ5/j 4nucu9vZGs3EA== From: Jeff Layton Date: Tue, 16 Jan 2024 14:45:57 -0500 Subject: [PATCH 01/20] filelock: split common fields into struct file_lock_core Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-1-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1316; i=jlayton@kernel.org; h=from:subject:message-id; bh=YjY34dM1H484nLiPhaWW57Fe2QttFCAJUqyuIWnNlwk=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0grorncqc9kLnslpuIZeyPyWu2iH2b3i5B2 QhRt5u8LPSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIAAKCRAADmhBGVaC FbMvEACDnTZd0WkyKZFXw33wk0c2b7uo3MRrbTaAJ3SXB53MT5tXPsMrx/2rbi364MuRnoPP6bi Ys3m9vycKLXirGtEGtajbM2rYOPbebP7S9O+g1VFohLR1yLsN5joqExpg9aENC5dPj/lNHnSdr9 75WIVLpf7G0qyG78AxC9PJuPduxUntrA1wqjADiLA90eF1lozTSG9oLqgqpQ6VMOBwd0Kbs0a5i NDCVod8SRF0fiNddU9JOiAdT1FDgumShOCW9PUCd6uU5PV0N0dLx6JHt+7PTVPYoLT3lssNET7u VAWTej8G43paeJujEHZDrxniexM9BSVGH8c9xjv/H6lwcsOHrK2oYuNDvd7yDMty+3zHYgY62TT /hJ/tchNR3PxSGmvY+aeE4i7yty4fiJh0enq1fG/6/BPMvrpK0LqzHM/sLb4p8L0/7er89TolW/ 8m7NYvGWmzilgVDsLPfyaMzjOeP+YiFRh5XSrCh3Cq1tNsfW+6sr4MAucKQLcLXaxE2PQ/wXVP2 RVo6Q0PshEsg48lhuMGKOuyTjoKvVODmGMHNO92/xDemnCiZia4nc7lTSD8Px72ehl7408vGs6g amJflorwhY/bA5eWVETGdMDw7nt/06zb8dMl8qmXvG9sz/S54+3MvlnfNH842ZBqeaS3lrLhWLC n4OPtwY7WrvAqgw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 In a future patch, we're going to split file leases into their own structure. Since a lot of the underlying machinery uses the same fields move those into a new file_lock_core, and embed that inside struct file_lock. Signed-off-by: Jeff Layton --- include/linux/filelock.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/linux/filelock.h b/include/linux/filelock.h index 95e868e09e29..7825511c1c11 100644 --- a/include/linux/filelock.h +++ b/include/linux/filelock.h @@ -85,8 +85,9 @@ bool opens_in_grace(struct net *); * * Obviously, the last two criteria only matter for POSIX locks. */ -struct file_lock { - struct file_lock *fl_blocker; /* The lock, that is blocking us */ + +struct file_lock_core { + struct file_lock *fl_blocker; /* The lock that is blocking us */ struct list_head fl_list; /* link into file_lock_context */ struct hlist_node fl_link; /* node in global lists */ struct list_head fl_blocked_requests; /* list of requests with @@ -102,6 +103,10 @@ struct file_lock { int fl_link_cpu; /* what cpu's list is this on? */ wait_queue_head_t fl_wait; struct file *fl_file; +}; + +struct file_lock { + struct file_lock_core fl_core; loff_t fl_start; loff_t fl_end; From patchwork Tue Jan 16 19:45:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521095 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 D95186EB6D; Tue, 16 Jan 2024 19:46:54 +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=1705434415; cv=none; b=j5oz3xRz9Urwa+YTybpN4KwWTZJOCis62HqkCr3IZDw9KKkoddLjFX0gEzaNyeZMmo3hz/CupZvR5tuHFFgTmooAnkTrQq4RQ5CHYb5wFM5eyT0SDtvyfLp8ol1Px3hh8+9VylOdXPNZSWw4d3CRtT1sw8JFa1ggT6fiAsGq0sQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434415; c=relaxed/simple; bh=Zuc5pqQZA4yFDsa5+cs+KGgtjnisDfvU7E2gkuENnu0=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=j+Q2TyoXzdZsPg5DZdpAkEN71hsTDXQevqYdZOja873PoKglnxixPGsbBrNdFz7wIorNa85zzH4/LpgzTh1GIIDgMT6olTclH0W73ln9Qkpv2e7ZEoOyNbjQYR7BCaYWJsca42p+LkLlDdZM5pnPdkvTH6ML3rTr8AZqhpk+WiM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j2pWv0r7; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j2pWv0r7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A414C43142; Tue, 16 Jan 2024 19:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434414; bh=Zuc5pqQZA4yFDsa5+cs+KGgtjnisDfvU7E2gkuENnu0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=j2pWv0r7LdBzbHVH8+EBNEcNxIw97N3r8CjxZHjqsvtNyXBIjYaKYX/GPXLu38znn 3ThFK21AMa7tomaFHwkRZsWQFlBrkEscqE3uuJEV9tsAXMcH7myVMGNNfgfgxF7GpI MfPHetbc7OcD4B1wHTW1oxZ5hHnVzA1IUwlMFcsCIxx46Hih4dYOSxPFMFtYYRul5a u3TeRGziT+ZMaddafMzrmVRCXpAG0M5NrVUhiPbnmZt95ImoI3SqVcrm6W+bwUdT3F E0hONLbn7h4Mj4rmNxEZ190nq2Cu97DyaVswUZ9ePWFzTy7x/wMmMSQtep5jCt+r6j s8XpnZqa+lE1Q== From: Jeff Layton Date: Tue, 16 Jan 2024 14:45:58 -0500 Subject: [PATCH 02/20] filelock: add coccinelle scripts to move fields to struct file_lock_core Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-2-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3928; i=jlayton@kernel.org; h=from:subject:message-id; bh=Zuc5pqQZA4yFDsa5+cs+KGgtjnisDfvU7E2gkuENnu0=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0g8OD2WzitEXeN7LiiOMhKmguOki1VVqGqH ZmSsKqxGxeJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIAAKCRAADmhBGVaC FXSWD/9bZgoEqI8ZEftXS3u6TWrIG0t8R4wW2XlKcdNNKP6xtKYghCHQCiMP5Vww3T+3ZfIydtW kPZ3hfcd76g/khDE4o/055hlYgI9Rlq2py3uNweBQkxUdm+vWgXdoCsEoMANv2WXaGVMAla2JZh IV/aCqYSWUNDhQ5TY1UmU5d+cB81sRzK6PtIpLldoT7bHHq0M6EukLOGqI+Flt8ycuyhENil2t4 QjzGeCDniVnMWeeNF/+Ts5e5wKpw0TS+x5r+D7bI/brkW31m/5sDgC6MW/i7lpG0E0bm1l0Uha3 F2wx03gujaodVFAti5nCwC/gUw2vhowmFFixJLQyUk3FXl0ZWRFMjcdsUaec8zXyu0dpPeoIdEq llr8srK/yOFPUXnmhkUVeVPOJwdzf9czrAdn81unv1jHShSkKGIC1Qcok2lR1YuciiE4voYMpHo ofwia965HNSKIAGez3Raiz23QprdwsZcZo4mIU7PZDf2KocsUdsWLa+MpxfUTN54hZcA2AVoV90 jm+G7UttCVDuu2Uah4vZFA8luC5nZtD+STB1eD4vBswzHwLJ2ycJbImHkCvVDaVSbNJMmDoZnhq N6cf6IvnzL5L6yqu8KkHNagJUpRWKMOi1B9JOvaCQ9FQUFi3M0RmZ3r/DILyWq97icxunvB8gOo LDnH+Nylx5MxtDQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Add some coccinelle scripts to handle the move of several fields from struct file_lock to struct file_lock_core. Signed-off-by: Jeff Layton --- cocci/filelock.cocci | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ cocci/filelock2.cocci | 6 ++++ cocci/nlm.cocci | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) diff --git a/cocci/filelock.cocci b/cocci/filelock.cocci new file mode 100644 index 000000000000..b84151ba091a --- /dev/null +++ b/cocci/filelock.cocci @@ -0,0 +1,81 @@ +@@ +struct file_lock *fl; +@@ +( +- fl->fl_blocker ++ fl->fl_core.fl_blocker +| +- fl->fl_list ++ fl->fl_core.fl_list +| +- fl->fl_link ++ fl->fl_core.fl_link +| +- fl->fl_blocked_requests ++ fl->fl_core.fl_blocked_requests +| +- fl->fl_blocked_member ++ fl->fl_core.fl_blocked_member +| +- fl->fl_owner ++ fl->fl_core.fl_owner +| +- fl->fl_flags ++ fl->fl_core.fl_flags +| +- fl->fl_type ++ fl->fl_core.fl_type +| +- fl->fl_pid ++ fl->fl_core.fl_pid +| +- fl->fl_link_cpu ++ fl->fl_core.fl_link_cpu +| +- fl->fl_wait ++ fl->fl_core.fl_wait +| +- fl->fl_file ++ fl->fl_core.fl_file +) + +@@ +struct file_lock fl; +@@ +( +- fl.fl_blocker ++ fl.fl_core.fl_blocker +| +- fl.fl_list ++ fl.fl_core.fl_list +| +- fl.fl_link ++ fl.fl_core.fl_link +| +- fl.fl_blocked_requests ++ fl.fl_core.fl_blocked_requests +| +- fl.fl_blocked_member ++ fl.fl_core.fl_blocked_member +| +- fl.fl_owner ++ fl.fl_core.fl_owner +| +- fl.fl_flags ++ fl.fl_core.fl_flags +| +- fl.fl_type ++ fl.fl_core.fl_type +| +- fl.fl_pid ++ fl.fl_core.fl_pid +| +- fl.fl_link_cpu ++ fl.fl_core.fl_link_cpu +| +- fl.fl_wait ++ fl.fl_core.fl_wait +| +- fl.fl_file ++ fl.fl_core.fl_file +) diff --git a/cocci/filelock2.cocci b/cocci/filelock2.cocci new file mode 100644 index 000000000000..0154a14e81ca --- /dev/null +++ b/cocci/filelock2.cocci @@ -0,0 +1,6 @@ +@@ +struct file_lock *fl; +struct list_head *li; +@@ +- list_for_each_entry(fl, li, fl_list) ++ list_for_each_entry(fl, li, fl_core.fl_list) diff --git a/cocci/nlm.cocci b/cocci/nlm.cocci new file mode 100644 index 000000000000..8ec5d02871e1 --- /dev/null +++ b/cocci/nlm.cocci @@ -0,0 +1,81 @@ +@@ +struct nlm_lock *nlck; +@@ +( +- nlck->fl.fl_blocker ++ nlck->fl.fl_core.fl_blocker +| +- nlck->fl.fl_list ++ nlck->fl.fl_core.fl_list +| +- nlck->fl.fl_link ++ nlck->fl.fl_core.fl_link +| +- nlck->fl.fl_blocked_requests ++ nlck->fl.fl_core.fl_blocked_requests +| +- nlck->fl.fl_blocked_member ++ nlck->fl.fl_core.fl_blocked_member +| +- nlck->fl.fl_owner ++ nlck->fl.fl_core.fl_owner +| +- nlck->fl.fl_flags ++ nlck->fl.fl_core.fl_flags +| +- nlck->fl.fl_type ++ nlck->fl.fl_core.fl_type +| +- nlck->fl.fl_pid ++ nlck->fl.fl_core.fl_pid +| +- nlck->fl.fl_link_cpu ++ nlck->fl.fl_core.fl_link_cpu +| +- nlck->fl.fl_wait ++ nlck->fl.fl_core.fl_wait +| +- nlck->fl.fl_file ++ nlck->fl.fl_core.fl_file +) + +@@ +struct nlm_args *argp; +@@ +( +- argp->lock.fl.fl_blocker ++ argp->lock.fl.fl_core.fl_blocker +| +- argp->lock.fl.fl_list ++ argp->lock.fl.fl_core.fl_list +| +- argp->lock.fl.fl_link ++ argp->lock.fl.fl_core.fl_link +| +- argp->lock.fl.fl_blocked_requests ++ argp->lock.fl.fl_core.fl_blocked_requests +| +- argp->lock.fl.fl_blocked_member ++ argp->lock.fl.fl_core.fl_blocked_member +| +- argp->lock.fl.fl_owner ++ argp->lock.fl.fl_core.fl_owner +| +- argp->lock.fl.fl_flags ++ argp->lock.fl.fl_core.fl_flags +| +- argp->lock.fl.fl_type ++ argp->lock.fl.fl_core.fl_type +| +- argp->lock.fl.fl_pid ++ argp->lock.fl.fl_core.fl_pid +| +- argp->lock.fl.fl_link_cpu ++ argp->lock.fl.fl_core.fl_link_cpu +| +- argp->lock.fl.fl_wait ++ argp->lock.fl.fl_core.fl_wait +| +- argp->lock.fl.fl_file ++ argp->lock.fl.fl_core.fl_file +) From patchwork Tue Jan 16 19:45:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521096 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 3839B219EE; Tue, 16 Jan 2024 19:46:58 +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=1705434419; cv=none; b=dowaGwDE382/86l2cw7O9XFHIsKQiykwyDZXKWiFdvxNcR3dqIAB7xNxBEhWb8iUo3SQIPMCjA9ZEkoQLsFKkM9b/f0eJyQeTsU0wHKQiA1GmspU5lfLkCrR5+/k7sQIA0lhV33jVYP12xs0ur+UGEIn9LpP5/pfjI3ASJoER3I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434419; c=relaxed/simple; bh=UKZeng0Nh2Cr7vAO5ryEXgk+B53t1tD85GbEEkjKp9w=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=RixBnjL6Rax7eKckeItYRIPQN75cgu7flDJW+ikAvdBHPGKnKcMCi1+I2PheIG8ESNeVH8b/rYDgqjUzyVkR/QhcGqQ65kxG9DMT64mkrE7lPmlRA5OLk29saG2ovIYrKrUxD8s+aLe/Xbvj6xxArWVwm/t1UXLDKOVmur8aGj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fiK+Axk0; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fiK+Axk0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE13CC43143; Tue, 16 Jan 2024 19:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434418; bh=UKZeng0Nh2Cr7vAO5ryEXgk+B53t1tD85GbEEkjKp9w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fiK+Axk0A5N6AHHN8dtKlXeZHW3WlaWVYQNQWG79KzoyNKI7CNBT+SLopvZSAdY1+ Dv+GnfiTwJ/uO255UgQGt2tSApcWQlDrUgD2vIANrP885aUVIQ/6tYVI8M0i2xciYs P6XZiz5fKZZPjUCr7E6avzJ6aCQr9fLT8iJVxBYh2rskZ+P8coikIHVjj2/oRE9aqr oNapnPX4R4+H1g2xiiXXn/3dqGpQDsJmSzGbc6xEcb2SOQCShKKsNKbk6yyZsuqDbr NQ1KKJGq/p3uot4YDOmfYYFWGN/ara/Vd6IXF6mutx7jSxBleu/XOW9Uf83+XoBpgt Tlpl8shGN7Uvg== From: Jeff Layton Date: Tue, 16 Jan 2024 14:45:59 -0500 Subject: [PATCH 03/20] filelock: the results of the coccinelle conversion Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-3-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=130147; i=jlayton@kernel.org; h=from:subject:message-id; bh=UKZeng0Nh2Cr7vAO5ryEXgk+B53t1tD85GbEEkjKp9w=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0g1I5RRVtSH5LaL+3YeZmRc8zn3uZMjW8kv 4tJF/Irvw+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIAAKCRAADmhBGVaC FZGFD/9eJWsfaX4VYoXmsWQb4ocgMxOb0zljXBwXbTqNxxcrd4S7dNUQ1Byoz20/5Fq2WShpPL9 8PMdh5auVL6+VeQ7ncTyuYhedj71U9ZEYcsQMH8Vt8EMAdOmdyknyj/BZqR447u4az839cgCpqE MciWuDyLdrM1zST0IO7qeBxHXEf4Oz/bXxahZPC7/VFR5gwyiGKv1/j1RaFRw6PEWrcjs2900it fM85eKuBbASG1/nlTCFSROAYmhOESBlZelb7O1hl4xWNGnZH0KQAPp3TuGMPWCTOY47c6rB8EpH y6u1etU+/Sl6QsszFUvMqJ4fwdD1LaJ1A8Fk4gjH5moiu1GHqbWx4Z+Wifze8AHmGbnW4dA9BfP fy+6Ffgve71MaR/47Rz1nZUljLtnpEJZIbeiW8rIDPDzoteELYyK3SOT1hDh9VSRwPk5rUSLO7t xf2RKqmIhOYFc89LTD4gizh+fk6buYuvxtbblH0qmnz0R3SjGke4EVAotTp12/VTJTOGSuemXHq k6R3bilc/k9gFT8/wQ1UqmzuaIPSHiPiFGPC4AJ2M53lqAZHN/z81mHzxv7BSYD+E8eHUPtYy+X kw1jTKURV/s761b3/gHUyCgmdiA8AtSBP04GpP/x6HPM2o7DRmFoDc+WWqYw/MmrW6YbSosqyjF zZVZeCn4MQlJY4A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 This is the direct result of the changes generated by coccinelle. There is still about 1/4 of the callsites that need to be touched by hand here. Signed-off-by: Jeff Layton Acked-by: Chuck Lever --- fs/9p/vfs_file.c | 38 ++--- fs/afs/flock.c | 55 +++--- fs/ceph/locks.c | 66 +++---- fs/dlm/plock.c | 44 ++--- fs/fuse/file.c | 14 +- fs/gfs2/file.c | 16 +- fs/lockd/clnt4xdr.c | 6 +- fs/lockd/clntlock.c | 2 +- fs/lockd/clntproc.c | 60 ++++--- fs/lockd/clntxdr.c | 6 +- fs/lockd/svclock.c | 10 +- fs/lockd/svcsubs.c | 20 +-- fs/lockd/xdr.c | 6 +- fs/lockd/xdr4.c | 6 +- fs/locks.c | 406 +++++++++++++++++++++++--------------------- fs/nfs/delegation.c | 2 +- fs/nfs/file.c | 22 +-- fs/nfs/nfs3proc.c | 2 +- fs/nfs/nfs4proc.c | 35 ++-- fs/nfs/nfs4state.c | 4 +- fs/nfs/nfs4xdr.c | 8 +- fs/nfs/write.c | 4 +- fs/nfsd/filecache.c | 4 +- fs/nfsd/nfs4layouts.c | 15 +- fs/nfsd/nfs4state.c | 73 ++++---- fs/ocfs2/locks.c | 12 +- fs/ocfs2/stack_user.c | 2 +- fs/smb/client/cifssmb.c | 8 +- fs/smb/client/file.c | 72 ++++---- fs/smb/client/smb2file.c | 2 +- fs/smb/server/smb2pdu.c | 44 ++--- fs/smb/server/vfs.c | 12 +- include/linux/lockd/lockd.h | 8 +- 33 files changed, 554 insertions(+), 530 deletions(-) diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 11cd8d23f6f2..f35ac7cb782e 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c @@ -107,7 +107,7 @@ static int v9fs_file_lock(struct file *filp, int cmd, struct file_lock *fl) p9_debug(P9_DEBUG_VFS, "filp: %p lock: %p\n", filp, fl); - if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_core.fl_type != F_UNLCK) { filemap_write_and_wait(inode->i_mapping); invalidate_mapping_pages(&inode->i_data, 0, -1); } @@ -127,7 +127,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) fid = filp->private_data; BUG_ON(fid == NULL); - BUG_ON((fl->fl_flags & FL_POSIX) != FL_POSIX); + BUG_ON((fl->fl_core.fl_flags & FL_POSIX) != FL_POSIX); res = locks_lock_file_wait(filp, fl); if (res < 0) @@ -136,7 +136,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) /* convert posix lock to p9 tlock args */ memset(&flock, 0, sizeof(flock)); /* map the lock type */ - switch (fl->fl_type) { + switch (fl->fl_core.fl_type) { case F_RDLCK: flock.type = P9_LOCK_TYPE_RDLCK; break; @@ -152,7 +152,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) flock.length = 0; else flock.length = fl->fl_end - fl->fl_start + 1; - flock.proc_id = fl->fl_pid; + flock.proc_id = fl->fl_core.fl_pid; flock.client_id = fid->clnt->name; if (IS_SETLKW(cmd)) flock.flags = P9_LOCK_FLAGS_BLOCK; @@ -207,12 +207,12 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl) * incase server returned error for lock request, revert * it locally */ - if (res < 0 && fl->fl_type != F_UNLCK) { - fl_type = fl->fl_type; - fl->fl_type = F_UNLCK; + if (res < 0 && fl->fl_core.fl_type != F_UNLCK) { + fl_type = fl->fl_core.fl_type; + fl->fl_core.fl_type = F_UNLCK; /* Even if this fails we want to return the remote error */ locks_lock_file_wait(filp, fl); - fl->fl_type = fl_type; + fl->fl_core.fl_type = fl_type; } if (flock.client_id != fid->clnt->name) kfree(flock.client_id); @@ -234,7 +234,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) * if we have a conflicting lock locally, no need to validate * with server */ - if (fl->fl_type != F_UNLCK) + if (fl->fl_core.fl_type != F_UNLCK) return res; /* convert posix lock to p9 tgetlock args */ @@ -245,7 +245,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) glock.length = 0; else glock.length = fl->fl_end - fl->fl_start + 1; - glock.proc_id = fl->fl_pid; + glock.proc_id = fl->fl_core.fl_pid; glock.client_id = fid->clnt->name; res = p9_client_getlock_dotl(fid, &glock); @@ -254,13 +254,13 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) /* map 9p lock type to os lock type */ switch (glock.type) { case P9_LOCK_TYPE_RDLCK: - fl->fl_type = F_RDLCK; + fl->fl_core.fl_type = F_RDLCK; break; case P9_LOCK_TYPE_WRLCK: - fl->fl_type = F_WRLCK; + fl->fl_core.fl_type = F_WRLCK; break; case P9_LOCK_TYPE_UNLCK: - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; break; } if (glock.type != P9_LOCK_TYPE_UNLCK) { @@ -269,7 +269,7 @@ static int v9fs_file_getlock(struct file *filp, struct file_lock *fl) fl->fl_end = OFFSET_MAX; else fl->fl_end = glock.start + glock.length - 1; - fl->fl_pid = -glock.proc_id; + fl->fl_core.fl_pid = -glock.proc_id; } out: if (glock.client_id != fid->clnt->name) @@ -293,7 +293,7 @@ static int v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl) p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n", filp, cmd, fl, filp); - if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_core.fl_type != F_UNLCK) { filemap_write_and_wait(inode->i_mapping); invalidate_mapping_pages(&inode->i_data, 0, -1); } @@ -324,16 +324,16 @@ static int v9fs_file_flock_dotl(struct file *filp, int cmd, p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n", filp, cmd, fl, filp); - if (!(fl->fl_flags & FL_FLOCK)) + if (!(fl->fl_core.fl_flags & FL_FLOCK)) goto out_err; - if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) { + if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_core.fl_type != F_UNLCK) { filemap_write_and_wait(inode->i_mapping); invalidate_mapping_pages(&inode->i_data, 0, -1); } /* Convert flock to posix lock */ - fl->fl_flags |= FL_POSIX; - fl->fl_flags ^= FL_FLOCK; + fl->fl_core.fl_flags |= FL_POSIX; + fl->fl_core.fl_flags ^= FL_FLOCK; if (IS_SETLK(cmd) | IS_SETLKW(cmd)) ret = v9fs_file_do_lock(filp, cmd, fl); diff --git a/fs/afs/flock.c b/fs/afs/flock.c index 9c6dea3139f5..212cca72c061 100644 --- a/fs/afs/flock.c +++ b/fs/afs/flock.c @@ -93,13 +93,13 @@ static void afs_grant_locks(struct afs_vnode *vnode) bool exclusive = (vnode->lock_type == AFS_LOCK_WRITE); list_for_each_entry_safe(p, _p, &vnode->pending_locks, fl_u.afs.link) { - if (!exclusive && p->fl_type == F_WRLCK) + if (!exclusive && p->fl_core.fl_type == F_WRLCK) continue; list_move_tail(&p->fl_u.afs.link, &vnode->granted_locks); p->fl_u.afs.state = AFS_LOCK_GRANTED; trace_afs_flock_op(vnode, p, afs_flock_op_grant); - wake_up(&p->fl_wait); + wake_up(&p->fl_core.fl_wait); } } @@ -121,16 +121,16 @@ static void afs_next_locker(struct afs_vnode *vnode, int error) list_for_each_entry_safe(p, _p, &vnode->pending_locks, fl_u.afs.link) { if (error && - p->fl_type == fl_type && - afs_file_key(p->fl_file) == key) { + p->fl_core.fl_type == fl_type && + afs_file_key(p->fl_core.fl_file) == key) { list_del_init(&p->fl_u.afs.link); p->fl_u.afs.state = error; - wake_up(&p->fl_wait); + wake_up(&p->fl_core.fl_wait); } /* Select the next locker to hand off to. */ if (next && - (next->fl_type == F_WRLCK || p->fl_type == F_RDLCK)) + (next->fl_core.fl_type == F_WRLCK || p->fl_core.fl_type == F_RDLCK)) continue; next = p; } @@ -142,7 +142,7 @@ static void afs_next_locker(struct afs_vnode *vnode, int error) afs_set_lock_state(vnode, AFS_VNODE_LOCK_SETTING); next->fl_u.afs.state = AFS_LOCK_YOUR_TRY; trace_afs_flock_op(vnode, next, afs_flock_op_wake); - wake_up(&next->fl_wait); + wake_up(&next->fl_core.fl_wait); } else { afs_set_lock_state(vnode, AFS_VNODE_LOCK_NONE); trace_afs_flock_ev(vnode, NULL, afs_flock_no_lockers, 0); @@ -166,7 +166,7 @@ static void afs_kill_lockers_enoent(struct afs_vnode *vnode) struct file_lock, fl_u.afs.link); list_del_init(&p->fl_u.afs.link); p->fl_u.afs.state = -ENOENT; - wake_up(&p->fl_wait); + wake_up(&p->fl_core.fl_wait); } key_put(vnode->lock_key); @@ -464,14 +464,14 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl) _enter("{%llx:%llu},%llu-%llu,%u,%u", vnode->fid.vid, vnode->fid.vnode, - fl->fl_start, fl->fl_end, fl->fl_type, mode); + fl->fl_start, fl->fl_end, fl->fl_core.fl_type, mode); fl->fl_ops = &afs_lock_ops; INIT_LIST_HEAD(&fl->fl_u.afs.link); fl->fl_u.afs.state = AFS_LOCK_PENDING; partial = (fl->fl_start != 0 || fl->fl_end != OFFSET_MAX); - type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; + type = (fl->fl_core.fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; if (mode == afs_flock_mode_write && partial) type = AFS_LOCK_WRITE; @@ -524,7 +524,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl) } if (vnode->lock_state == AFS_VNODE_LOCK_NONE && - !(fl->fl_flags & FL_SLEEP)) { + !(fl->fl_core.fl_flags & FL_SLEEP)) { ret = -EAGAIN; if (type == AFS_LOCK_READ) { if (vnode->status.lock_count == -1) @@ -621,7 +621,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl) return 0; lock_is_contended: - if (!(fl->fl_flags & FL_SLEEP)) { + if (!(fl->fl_core.fl_flags & FL_SLEEP)) { list_del_init(&fl->fl_u.afs.link); afs_next_locker(vnode, 0); ret = -EAGAIN; @@ -641,7 +641,7 @@ static int afs_do_setlk(struct file *file, struct file_lock *fl) spin_unlock(&vnode->lock); trace_afs_flock_ev(vnode, fl, afs_flock_waiting, 0); - ret = wait_event_interruptible(fl->fl_wait, + ret = wait_event_interruptible(fl->fl_core.fl_wait, fl->fl_u.afs.state != AFS_LOCK_PENDING); trace_afs_flock_ev(vnode, fl, afs_flock_waited, ret); @@ -704,7 +704,8 @@ static int afs_do_unlk(struct file *file, struct file_lock *fl) struct afs_vnode *vnode = AFS_FS_I(file_inode(file)); int ret; - _enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode, fl->fl_type); + _enter("{%llx:%llu},%u", vnode->fid.vid, vnode->fid.vnode, + fl->fl_core.fl_type); trace_afs_flock_op(vnode, fl, afs_flock_op_unlock); @@ -730,11 +731,11 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl) if (vnode->lock_state == AFS_VNODE_LOCK_DELETED) return -ENOENT; - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; /* check local lock records first */ posix_test_lock(file, fl); - if (fl->fl_type == F_UNLCK) { + if (fl->fl_core.fl_type == F_UNLCK) { /* no local locks; consult the server */ ret = afs_fetch_status(vnode, key, false, NULL); if (ret < 0) @@ -743,18 +744,18 @@ static int afs_do_getlk(struct file *file, struct file_lock *fl) lock_count = READ_ONCE(vnode->status.lock_count); if (lock_count != 0) { if (lock_count > 0) - fl->fl_type = F_RDLCK; + fl->fl_core.fl_type = F_RDLCK; else - fl->fl_type = F_WRLCK; + fl->fl_core.fl_type = F_WRLCK; fl->fl_start = 0; fl->fl_end = OFFSET_MAX; - fl->fl_pid = 0; + fl->fl_core.fl_pid = 0; } } ret = 0; error: - _leave(" = %d [%hd]", ret, fl->fl_type); + _leave(" = %d [%hd]", ret, fl->fl_core.fl_type); return ret; } @@ -769,7 +770,7 @@ int afs_lock(struct file *file, int cmd, struct file_lock *fl) _enter("{%llx:%llu},%d,{t=%x,fl=%x,r=%Ld:%Ld}", vnode->fid.vid, vnode->fid.vnode, cmd, - fl->fl_type, fl->fl_flags, + fl->fl_core.fl_type, fl->fl_core.fl_flags, (long long) fl->fl_start, (long long) fl->fl_end); if (IS_GETLK(cmd)) @@ -778,7 +779,7 @@ int afs_lock(struct file *file, int cmd, struct file_lock *fl) fl->fl_u.afs.debug_id = atomic_inc_return(&afs_file_lock_debug_id); trace_afs_flock_op(vnode, fl, afs_flock_op_lock); - if (fl->fl_type == F_UNLCK) + if (fl->fl_core.fl_type == F_UNLCK) ret = afs_do_unlk(file, fl); else ret = afs_do_setlk(file, fl); @@ -804,7 +805,7 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl) _enter("{%llx:%llu},%d,{t=%x,fl=%x}", vnode->fid.vid, vnode->fid.vnode, cmd, - fl->fl_type, fl->fl_flags); + fl->fl_core.fl_type, fl->fl_core.fl_flags); /* * No BSD flocks over NFS allowed. @@ -813,14 +814,14 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl) * Not sure whether that would be unique, though, or whether * that would break in other places. */ - if (!(fl->fl_flags & FL_FLOCK)) + if (!(fl->fl_core.fl_flags & FL_FLOCK)) return -ENOLCK; fl->fl_u.afs.debug_id = atomic_inc_return(&afs_file_lock_debug_id); trace_afs_flock_op(vnode, fl, afs_flock_op_flock); /* we're simulating flock() locks using posix locks on the server */ - if (fl->fl_type == F_UNLCK) + if (fl->fl_core.fl_type == F_UNLCK) ret = afs_do_unlk(file, fl); else ret = afs_do_setlk(file, fl); @@ -843,7 +844,7 @@ int afs_flock(struct file *file, int cmd, struct file_lock *fl) */ static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl) { - struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_file)); + struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_core.fl_file)); _enter(""); @@ -861,7 +862,7 @@ static void afs_fl_copy_lock(struct file_lock *new, struct file_lock *fl) */ static void afs_fl_release_private(struct file_lock *fl) { - struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_file)); + struct afs_vnode *vnode = AFS_FS_I(file_inode(fl->fl_core.fl_file)); _enter(""); diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c index e07ad29ff8b9..ee12f9864980 100644 --- a/fs/ceph/locks.c +++ b/fs/ceph/locks.c @@ -33,7 +33,7 @@ void __init ceph_flock_init(void) static void ceph_fl_copy_lock(struct file_lock *dst, struct file_lock *src) { - struct inode *inode = file_inode(dst->fl_file); + struct inode *inode = file_inode(dst->fl_core.fl_file); atomic_inc(&ceph_inode(inode)->i_filelock_ref); dst->fl_u.ceph.inode = igrab(inode); } @@ -110,17 +110,18 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode, else length = fl->fl_end - fl->fl_start + 1; - owner = secure_addr(fl->fl_owner); + owner = secure_addr(fl->fl_core.fl_owner); doutc(cl, "rule: %d, op: %d, owner: %llx, pid: %llu, " "start: %llu, length: %llu, wait: %d, type: %d\n", - (int)lock_type, (int)operation, owner, (u64)fl->fl_pid, - fl->fl_start, length, wait, fl->fl_type); + (int)lock_type, (int)operation, owner, + (u64) fl->fl_core.fl_pid, + fl->fl_start, length, wait, fl->fl_core.fl_type); req->r_args.filelock_change.rule = lock_type; req->r_args.filelock_change.type = cmd; req->r_args.filelock_change.owner = cpu_to_le64(owner); - req->r_args.filelock_change.pid = cpu_to_le64((u64)fl->fl_pid); + req->r_args.filelock_change.pid = cpu_to_le64((u64) fl->fl_core.fl_pid); req->r_args.filelock_change.start = cpu_to_le64(fl->fl_start); req->r_args.filelock_change.length = cpu_to_le64(length); req->r_args.filelock_change.wait = wait; @@ -130,13 +131,13 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode, err = ceph_mdsc_wait_request(mdsc, req, wait ? ceph_lock_wait_for_completion : NULL); if (!err && operation == CEPH_MDS_OP_GETFILELOCK) { - fl->fl_pid = -le64_to_cpu(req->r_reply_info.filelock_reply->pid); + fl->fl_core.fl_pid = -le64_to_cpu(req->r_reply_info.filelock_reply->pid); if (CEPH_LOCK_SHARED == req->r_reply_info.filelock_reply->type) - fl->fl_type = F_RDLCK; + fl->fl_core.fl_type = F_RDLCK; else if (CEPH_LOCK_EXCL == req->r_reply_info.filelock_reply->type) - fl->fl_type = F_WRLCK; + fl->fl_core.fl_type = F_WRLCK; else - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; fl->fl_start = le64_to_cpu(req->r_reply_info.filelock_reply->start); length = le64_to_cpu(req->r_reply_info.filelock_reply->start) + @@ -150,8 +151,8 @@ static int ceph_lock_message(u8 lock_type, u16 operation, struct inode *inode, ceph_mdsc_put_request(req); doutc(cl, "rule: %d, op: %d, pid: %llu, start: %llu, " "length: %llu, wait: %d, type: %d, err code %d\n", - (int)lock_type, (int)operation, (u64)fl->fl_pid, - fl->fl_start, length, wait, fl->fl_type, err); + (int)lock_type, (int)operation, (u64) fl->fl_core.fl_pid, + fl->fl_start, length, wait, fl->fl_core.fl_type, err); return err; } @@ -227,10 +228,10 @@ static int ceph_lock_wait_for_completion(struct ceph_mds_client *mdsc, static int try_unlock_file(struct file *file, struct file_lock *fl) { int err; - unsigned int orig_flags = fl->fl_flags; - fl->fl_flags |= FL_EXISTS; + unsigned int orig_flags = fl->fl_core.fl_flags; + fl->fl_core.fl_flags |= FL_EXISTS; err = locks_lock_file_wait(file, fl); - fl->fl_flags = orig_flags; + fl->fl_core.fl_flags = orig_flags; if (err == -ENOENT) { if (!(orig_flags & FL_EXISTS)) err = 0; @@ -253,13 +254,13 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl) u8 wait = 0; u8 lock_cmd; - if (!(fl->fl_flags & FL_POSIX)) + if (!(fl->fl_core.fl_flags & FL_POSIX)) return -ENOLCK; if (ceph_inode_is_shutdown(inode)) return -ESTALE; - doutc(cl, "fl_owner: %p\n", fl->fl_owner); + doutc(cl, "fl_owner: %p\n", fl->fl_core.fl_owner); /* set wait bit as appropriate, then make command as Ceph expects it*/ if (IS_GETLK(cmd)) @@ -273,19 +274,19 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl) } spin_unlock(&ci->i_ceph_lock); if (err < 0) { - if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_type) + if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_core.fl_type) posix_lock_file(file, fl, NULL); return err; } - if (F_RDLCK == fl->fl_type) + if (F_RDLCK == fl->fl_core.fl_type) lock_cmd = CEPH_LOCK_SHARED; - else if (F_WRLCK == fl->fl_type) + else if (F_WRLCK == fl->fl_core.fl_type) lock_cmd = CEPH_LOCK_EXCL; else lock_cmd = CEPH_LOCK_UNLOCK; - if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_type) { + if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_core.fl_type) { err = try_unlock_file(file, fl); if (err <= 0) return err; @@ -293,7 +294,7 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl) err = ceph_lock_message(CEPH_LOCK_FCNTL, op, inode, lock_cmd, wait, fl); if (!err) { - if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK != fl->fl_type) { + if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK != fl->fl_core.fl_type) { doutc(cl, "locking locally\n"); err = posix_lock_file(file, fl, NULL); if (err) { @@ -319,13 +320,13 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) u8 wait = 0; u8 lock_cmd; - if (!(fl->fl_flags & FL_FLOCK)) + if (!(fl->fl_core.fl_flags & FL_FLOCK)) return -ENOLCK; if (ceph_inode_is_shutdown(inode)) return -ESTALE; - doutc(cl, "fl_file: %p\n", fl->fl_file); + doutc(cl, "fl_file: %p\n", fl->fl_core.fl_file); spin_lock(&ci->i_ceph_lock); if (ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) { @@ -333,7 +334,7 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) } spin_unlock(&ci->i_ceph_lock); if (err < 0) { - if (F_UNLCK == fl->fl_type) + if (F_UNLCK == fl->fl_core.fl_type) locks_lock_file_wait(file, fl); return err; } @@ -341,14 +342,14 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) if (IS_SETLKW(cmd)) wait = 1; - if (F_RDLCK == fl->fl_type) + if (F_RDLCK == fl->fl_core.fl_type) lock_cmd = CEPH_LOCK_SHARED; - else if (F_WRLCK == fl->fl_type) + else if (F_WRLCK == fl->fl_core.fl_type) lock_cmd = CEPH_LOCK_EXCL; else lock_cmd = CEPH_LOCK_UNLOCK; - if (F_UNLCK == fl->fl_type) { + if (F_UNLCK == fl->fl_core.fl_type) { err = try_unlock_file(file, fl); if (err <= 0) return err; @@ -356,7 +357,7 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) err = ceph_lock_message(CEPH_LOCK_FLOCK, CEPH_MDS_OP_SETFILELOCK, inode, lock_cmd, wait, fl); - if (!err && F_UNLCK != fl->fl_type) { + if (!err && F_UNLCK != fl->fl_core.fl_type) { err = locks_lock_file_wait(file, fl); if (err) { ceph_lock_message(CEPH_LOCK_FLOCK, @@ -408,10 +409,10 @@ static int lock_to_ceph_filelock(struct inode *inode, cephlock->start = cpu_to_le64(lock->fl_start); cephlock->length = cpu_to_le64(lock->fl_end - lock->fl_start + 1); cephlock->client = cpu_to_le64(0); - cephlock->pid = cpu_to_le64((u64)lock->fl_pid); - cephlock->owner = cpu_to_le64(secure_addr(lock->fl_owner)); + cephlock->pid = cpu_to_le64((u64) lock->fl_core.fl_pid); + cephlock->owner = cpu_to_le64(secure_addr(lock->fl_core.fl_owner)); - switch (lock->fl_type) { + switch (lock->fl_core.fl_type) { case F_RDLCK: cephlock->type = CEPH_LOCK_SHARED; break; @@ -422,7 +423,8 @@ static int lock_to_ceph_filelock(struct inode *inode, cephlock->type = CEPH_LOCK_UNLOCK; break; default: - doutc(cl, "Have unknown lock type %d\n", lock->fl_type); + doutc(cl, "Have unknown lock type %d\n", + lock->fl_core.fl_type); err = -EINVAL; } diff --git a/fs/dlm/plock.c b/fs/dlm/plock.c index d814c5121367..e98d09c06f57 100644 --- a/fs/dlm/plock.c +++ b/fs/dlm/plock.c @@ -138,14 +138,14 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file, } op->info.optype = DLM_PLOCK_OP_LOCK; - op->info.pid = fl->fl_pid; - op->info.ex = (fl->fl_type == F_WRLCK); - op->info.wait = !!(fl->fl_flags & FL_SLEEP); + op->info.pid = fl->fl_core.fl_pid; + op->info.ex = (fl->fl_core.fl_type == F_WRLCK); + op->info.wait = !!(fl->fl_core.fl_flags & FL_SLEEP); op->info.fsid = ls->ls_global_id; op->info.number = number; op->info.start = fl->fl_start; op->info.end = fl->fl_end; - op->info.owner = (__u64)(long)fl->fl_owner; + op->info.owner = (__u64)(long) fl->fl_core.fl_owner; /* async handling */ if (fl->fl_lmops && fl->fl_lmops->lm_grant) { op_data = kzalloc(sizeof(*op_data), GFP_NOFS); @@ -258,7 +258,7 @@ static int dlm_plock_callback(struct plock_op *op) } /* got fs lock; bookkeep locally as well: */ - flc->fl_flags &= ~FL_SLEEP; + flc->fl_core.fl_flags &= ~FL_SLEEP; if (posix_lock_file(file, flc, NULL)) { /* * This can only happen in the case of kmalloc() failure. @@ -291,7 +291,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file, struct dlm_ls *ls; struct plock_op *op; int rv; - unsigned char fl_flags = fl->fl_flags; + unsigned char fl_flags = fl->fl_core.fl_flags; ls = dlm_find_lockspace_local(lockspace); if (!ls) @@ -304,7 +304,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file, } /* cause the vfs unlock to return ENOENT if lock is not found */ - fl->fl_flags |= FL_EXISTS; + fl->fl_core.fl_flags |= FL_EXISTS; rv = locks_lock_file_wait(file, fl); if (rv == -ENOENT) { @@ -317,14 +317,14 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file, } op->info.optype = DLM_PLOCK_OP_UNLOCK; - op->info.pid = fl->fl_pid; + op->info.pid = fl->fl_core.fl_pid; op->info.fsid = ls->ls_global_id; op->info.number = number; op->info.start = fl->fl_start; op->info.end = fl->fl_end; - op->info.owner = (__u64)(long)fl->fl_owner; + op->info.owner = (__u64)(long) fl->fl_core.fl_owner; - if (fl->fl_flags & FL_CLOSE) { + if (fl->fl_core.fl_flags & FL_CLOSE) { op->info.flags |= DLM_PLOCK_FL_CLOSE; send_op(op); rv = 0; @@ -345,7 +345,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file, dlm_release_plock_op(op); out: dlm_put_lockspace(ls); - fl->fl_flags = fl_flags; + fl->fl_core.fl_flags = fl_flags; return rv; } EXPORT_SYMBOL_GPL(dlm_posix_unlock); @@ -375,14 +375,14 @@ int dlm_posix_cancel(dlm_lockspace_t *lockspace, u64 number, struct file *file, return -EINVAL; memset(&info, 0, sizeof(info)); - info.pid = fl->fl_pid; - info.ex = (fl->fl_type == F_WRLCK); + info.pid = fl->fl_core.fl_pid; + info.ex = (fl->fl_core.fl_type == F_WRLCK); info.fsid = ls->ls_global_id; dlm_put_lockspace(ls); info.number = number; info.start = fl->fl_start; info.end = fl->fl_end; - info.owner = (__u64)(long)fl->fl_owner; + info.owner = (__u64)(long) fl->fl_core.fl_owner; rv = do_lock_cancel(&info); switch (rv) { @@ -437,13 +437,13 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file, } op->info.optype = DLM_PLOCK_OP_GET; - op->info.pid = fl->fl_pid; - op->info.ex = (fl->fl_type == F_WRLCK); + op->info.pid = fl->fl_core.fl_pid; + op->info.ex = (fl->fl_core.fl_type == F_WRLCK); op->info.fsid = ls->ls_global_id; op->info.number = number; op->info.start = fl->fl_start; op->info.end = fl->fl_end; - op->info.owner = (__u64)(long)fl->fl_owner; + op->info.owner = (__u64)(long) fl->fl_core.fl_owner; send_op(op); wait_event(recv_wq, (op->done != 0)); @@ -455,16 +455,16 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file, rv = op->info.rv; - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; if (rv == -ENOENT) rv = 0; else if (rv > 0) { locks_init_lock(fl); - fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK; - fl->fl_flags = FL_POSIX; - fl->fl_pid = op->info.pid; + fl->fl_core.fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK; + fl->fl_core.fl_flags = FL_POSIX; + fl->fl_core.fl_pid = op->info.pid; if (op->info.nodeid != dlm_our_nodeid()) - fl->fl_pid = -fl->fl_pid; + fl->fl_core.fl_pid = -fl->fl_core.fl_pid; fl->fl_start = op->info.start; fl->fl_end = op->info.end; rv = 0; diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 148a71b8b4d0..13c38696074d 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2509,14 +2509,14 @@ static int convert_fuse_file_lock(struct fuse_conn *fc, * translate it into the caller's pid namespace. */ rcu_read_lock(); - fl->fl_pid = pid_nr_ns(find_pid_ns(ffl->pid, fc->pid_ns), &init_pid_ns); + fl->fl_core.fl_pid = pid_nr_ns(find_pid_ns(ffl->pid, fc->pid_ns), &init_pid_ns); rcu_read_unlock(); break; default: return -EIO; } - fl->fl_type = ffl->type; + fl->fl_core.fl_type = ffl->type; return 0; } @@ -2530,10 +2530,10 @@ static void fuse_lk_fill(struct fuse_args *args, struct file *file, memset(inarg, 0, sizeof(*inarg)); inarg->fh = ff->fh; - inarg->owner = fuse_lock_owner_id(fc, fl->fl_owner); + inarg->owner = fuse_lock_owner_id(fc, fl->fl_core.fl_owner); inarg->lk.start = fl->fl_start; inarg->lk.end = fl->fl_end; - inarg->lk.type = fl->fl_type; + inarg->lk.type = fl->fl_core.fl_type; inarg->lk.pid = pid; if (flock) inarg->lk_flags |= FUSE_LK_FLOCK; @@ -2570,8 +2570,8 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) struct fuse_mount *fm = get_fuse_mount(inode); FUSE_ARGS(args); struct fuse_lk_in inarg; - int opcode = (fl->fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; - struct pid *pid = fl->fl_type != F_UNLCK ? task_tgid(current) : NULL; + int opcode = (fl->fl_core.fl_flags & FL_SLEEP) ? FUSE_SETLKW : FUSE_SETLK; + struct pid *pid = fl->fl_core.fl_type != F_UNLCK ? task_tgid(current) : NULL; pid_t pid_nr = pid_nr_ns(pid, fm->fc->pid_ns); int err; @@ -2581,7 +2581,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) } /* Unlock on close is handled by the flush method */ - if ((fl->fl_flags & FL_CLOSE_POSIX) == FL_CLOSE_POSIX) + if ((fl->fl_core.fl_flags & FL_CLOSE_POSIX) == FL_CLOSE_POSIX) return 0; fuse_lk_fill(&args, file, fl, opcode, pid_nr, flock, &inarg); diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 992ca4effb50..fdcd29583cc8 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -1440,10 +1440,10 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) struct gfs2_sbd *sdp = GFS2_SB(file->f_mapping->host); struct lm_lockstruct *ls = &sdp->sd_lockstruct; - if (!(fl->fl_flags & FL_POSIX)) + if (!(fl->fl_core.fl_flags & FL_POSIX)) return -ENOLCK; if (gfs2_withdrawing_or_withdrawn(sdp)) { - if (fl->fl_type == F_UNLCK) + if (fl->fl_core.fl_type == F_UNLCK) locks_lock_file_wait(file, fl); return -EIO; } @@ -1451,7 +1451,7 @@ static int gfs2_lock(struct file *file, int cmd, struct file_lock *fl) return dlm_posix_cancel(ls->ls_dlm, ip->i_no_addr, file, fl); else if (IS_GETLK(cmd)) return dlm_posix_get(ls->ls_dlm, ip->i_no_addr, file, fl); - else if (fl->fl_type == F_UNLCK) + else if (fl->fl_core.fl_type == F_UNLCK) return dlm_posix_unlock(ls->ls_dlm, ip->i_no_addr, file, fl); else return dlm_posix_lock(ls->ls_dlm, ip->i_no_addr, file, cmd, fl); @@ -1483,7 +1483,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) int error = 0; int sleeptime; - state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; + state = (fl->fl_core.fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; flags = GL_EXACT | GL_NOPID; if (!IS_SETLKW(cmd)) flags |= LM_FLAG_TRY_1CB; @@ -1495,8 +1495,8 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) if (fl_gh->gh_state == state) goto out; locks_init_lock(&request); - request.fl_type = F_UNLCK; - request.fl_flags = FL_FLOCK; + request.fl_core.fl_type = F_UNLCK; + request.fl_core.fl_flags = FL_FLOCK; locks_lock_file_wait(file, &request); gfs2_glock_dq(fl_gh); gfs2_holder_reinit(state, flags, fl_gh); @@ -1557,10 +1557,10 @@ static void do_unflock(struct file *file, struct file_lock *fl) static int gfs2_flock(struct file *file, int cmd, struct file_lock *fl) { - if (!(fl->fl_flags & FL_FLOCK)) + if (!(fl->fl_core.fl_flags & FL_FLOCK)) return -ENOLCK; - if (fl->fl_type == F_UNLCK) { + if (fl->fl_core.fl_type == F_UNLCK) { do_unflock(file, fl); return 0; } else { diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c index 8161667c976f..ed00bd2869a7 100644 --- a/fs/lockd/clnt4xdr.c +++ b/fs/lockd/clnt4xdr.c @@ -270,7 +270,7 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) goto out_overflow; exclusive = be32_to_cpup(p++); lock->svid = be32_to_cpup(p); - fl->fl_pid = (pid_t)lock->svid; + fl->fl_core.fl_pid = (pid_t)lock->svid; error = decode_netobj(xdr, &lock->oh); if (unlikely(error)) @@ -280,8 +280,8 @@ static int decode_nlm4_holder(struct xdr_stream *xdr, struct nlm_res *result) if (unlikely(p == NULL)) goto out_overflow; - fl->fl_flags = FL_POSIX; - fl->fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK; + fl->fl_core.fl_flags = FL_POSIX; + fl->fl_core.fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK; p = xdr_decode_hyper(p, &l_offset); xdr_decode_hyper(p, &l_len); nlm4svc_set_file_lock_range(fl, l_offset, l_len); diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 5d85715be763..c15a6d5f1acf 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c @@ -185,7 +185,7 @@ __be32 nlmclnt_grant(const struct sockaddr *addr, const struct nlm_lock *lock) continue; if (!rpc_cmp_addr(nlm_addr(block->b_host), addr)) continue; - if (nfs_compare_fh(NFS_FH(file_inode(fl_blocked->fl_file)), fh) != 0) + if (nfs_compare_fh(NFS_FH(file_inode(fl_blocked->fl_core.fl_file)), fh) != 0) continue; /* Alright, we found a lock. Set the return status * and wake up the caller diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index fba6c7fa7474..ac1d07034346 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -133,7 +133,8 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) char *nodename = req->a_host->h_rpcclnt->cl_nodename; nlmclnt_next_cookie(&argp->cookie); - memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_file)), sizeof(struct nfs_fh)); + memcpy(&lock->fh, NFS_FH(file_inode(fl->fl_core.fl_file)), + sizeof(struct nfs_fh)); lock->caller = nodename; lock->oh.data = req->a_owner; lock->oh.len = snprintf(req->a_owner, sizeof(req->a_owner), "%u@%s", @@ -142,7 +143,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) lock->svid = fl->fl_u.nfs_fl.owner->pid; lock->fl.fl_start = fl->fl_start; lock->fl.fl_end = fl->fl_end; - lock->fl.fl_type = fl->fl_type; + lock->fl.fl_type = fl->fl_core.fl_type; } static void nlmclnt_release_lockargs(struct nlm_rqst *req) @@ -182,7 +183,7 @@ int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl, void *dat call->a_callback_data = data; if (IS_SETLK(cmd) || IS_SETLKW(cmd)) { - if (fl->fl_type != F_UNLCK) { + if (fl->fl_core.fl_type != F_UNLCK) { call->a_args.block = IS_SETLKW(cmd) ? 1 : 0; status = nlmclnt_lock(call, fl); } else @@ -432,13 +433,14 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) { int status; - status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_TEST); + status = nlmclnt_call(nfs_file_cred(fl->fl_core.fl_file), req, + NLMPROC_TEST); if (status < 0) goto out; switch (req->a_res.status) { case nlm_granted: - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; break; case nlm_lck_denied: /* @@ -446,8 +448,8 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) */ fl->fl_start = req->a_res.lock.fl.fl_start; fl->fl_end = req->a_res.lock.fl.fl_end; - fl->fl_type = req->a_res.lock.fl.fl_type; - fl->fl_pid = -req->a_res.lock.fl.fl_pid; + fl->fl_core.fl_type = req->a_res.lock.fl.fl_type; + fl->fl_core.fl_pid = -req->a_res.lock.fl.fl_pid; break; default: status = nlm_stat_to_errno(req->a_res.status); @@ -485,14 +487,15 @@ static const struct file_lock_operations nlmclnt_lock_ops = { static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host) { fl->fl_u.nfs_fl.state = 0; - fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host, fl->fl_owner); + fl->fl_u.nfs_fl.owner = nlmclnt_find_lockowner(host, + fl->fl_core.fl_owner); INIT_LIST_HEAD(&fl->fl_u.nfs_fl.list); fl->fl_ops = &nlmclnt_lock_ops; } static int do_vfs_lock(struct file_lock *fl) { - return locks_lock_file_wait(fl->fl_file, fl); + return locks_lock_file_wait(fl->fl_core.fl_file, fl); } /* @@ -518,11 +521,11 @@ static int do_vfs_lock(struct file_lock *fl) static int nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) { - const struct cred *cred = nfs_file_cred(fl->fl_file); + const struct cred *cred = nfs_file_cred(fl->fl_core.fl_file); struct nlm_host *host = req->a_host; struct nlm_res *resp = &req->a_res; struct nlm_wait block; - unsigned char fl_flags = fl->fl_flags; + unsigned char fl_flags = fl->fl_core.fl_flags; unsigned char fl_type; __be32 b_status; int status = -ENOLCK; @@ -531,9 +534,9 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) goto out; req->a_args.state = nsm_local_state; - fl->fl_flags |= FL_ACCESS; + fl->fl_core.fl_flags |= FL_ACCESS; status = do_vfs_lock(fl); - fl->fl_flags = fl_flags; + fl->fl_core.fl_flags = fl_flags; if (status < 0) goto out; @@ -591,11 +594,11 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) goto again; } /* Ensure the resulting lock will get added to granted list */ - fl->fl_flags |= FL_SLEEP; + fl->fl_core.fl_flags |= FL_SLEEP; if (do_vfs_lock(fl) < 0) printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __func__); up_read(&host->h_rwsem); - fl->fl_flags = fl_flags; + fl->fl_core.fl_flags = fl_flags; status = 0; } if (status < 0) @@ -622,13 +625,13 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl) req->a_host->h_addrlen, req->a_res.status); dprintk("lockd: lock attempt ended in fatal error.\n" " Attempting to unlock.\n"); - fl_type = fl->fl_type; - fl->fl_type = F_UNLCK; + fl_type = fl->fl_core.fl_type; + fl->fl_core.fl_type = F_UNLCK; down_read(&host->h_rwsem); do_vfs_lock(fl); up_read(&host->h_rwsem); - fl->fl_type = fl_type; - fl->fl_flags = fl_flags; + fl->fl_core.fl_type = fl_type; + fl->fl_core.fl_flags = fl_flags; nlmclnt_async_call(cred, req, NLMPROC_UNLOCK, &nlmclnt_unlock_ops); return status; } @@ -651,12 +654,13 @@ nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl, nlmclnt_setlockargs(req, fl); req->a_args.reclaim = 1; - status = nlmclnt_call(nfs_file_cred(fl->fl_file), req, NLMPROC_LOCK); + status = nlmclnt_call(nfs_file_cred(fl->fl_core.fl_file), req, + NLMPROC_LOCK); if (status >= 0 && req->a_res.status == nlm_granted) return 0; printk(KERN_WARNING "lockd: failed to reclaim lock for pid %d " - "(errno %d, status %d)\n", fl->fl_pid, + "(errno %d, status %d)\n", fl->fl_core.fl_pid, status, ntohl(req->a_res.status)); /* @@ -683,26 +687,26 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl) struct nlm_host *host = req->a_host; struct nlm_res *resp = &req->a_res; int status; - unsigned char fl_flags = fl->fl_flags; + unsigned char fl_flags = fl->fl_core.fl_flags; /* * Note: the server is supposed to either grant us the unlock * request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either * case, we want to unlock. */ - fl->fl_flags |= FL_EXISTS; + fl->fl_core.fl_flags |= FL_EXISTS; down_read(&host->h_rwsem); status = do_vfs_lock(fl); up_read(&host->h_rwsem); - fl->fl_flags = fl_flags; + fl->fl_core.fl_flags = fl_flags; if (status == -ENOENT) { status = 0; goto out; } refcount_inc(&req->a_count); - status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, - NLMPROC_UNLOCK, &nlmclnt_unlock_ops); + status = nlmclnt_async_call(nfs_file_cred(fl->fl_core.fl_file), req, + NLMPROC_UNLOCK, &nlmclnt_unlock_ops); if (status < 0) goto out; @@ -795,8 +799,8 @@ static int nlmclnt_cancel(struct nlm_host *host, int block, struct file_lock *fl req->a_args.block = block; refcount_inc(&req->a_count); - status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req, - NLMPROC_CANCEL, &nlmclnt_cancel_ops); + status = nlmclnt_async_call(nfs_file_cred(fl->fl_core.fl_file), req, + NLMPROC_CANCEL, &nlmclnt_cancel_ops); if (status == 0 && req->a_res.status == nlm_lck_denied) status = -ENOLCK; nlmclnt_release_call(req); diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c index 4df62f635529..b0b87a00cd81 100644 --- a/fs/lockd/clntxdr.c +++ b/fs/lockd/clntxdr.c @@ -265,7 +265,7 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) goto out_overflow; exclusive = be32_to_cpup(p++); lock->svid = be32_to_cpup(p); - fl->fl_pid = (pid_t)lock->svid; + fl->fl_core.fl_pid = (pid_t)lock->svid; error = decode_netobj(xdr, &lock->oh); if (unlikely(error)) @@ -275,8 +275,8 @@ static int decode_nlm_holder(struct xdr_stream *xdr, struct nlm_res *result) if (unlikely(p == NULL)) goto out_overflow; - fl->fl_flags = FL_POSIX; - fl->fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK; + fl->fl_core.fl_flags = FL_POSIX; + fl->fl_core.fl_type = exclusive != 0 ? F_WRLCK : F_RDLCK; l_offset = be32_to_cpup(p++); l_len = be32_to_cpup(p); end = l_offset + l_len - 1; diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 2dc10900ad1c..520886a4b57e 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -157,9 +157,9 @@ nlmsvc_lookup_block(struct nlm_file *file, struct nlm_lock *lock) list_for_each_entry(block, &nlm_blocked, b_list) { fl = &block->b_call->a_args.lock.fl; dprintk("lockd: check f=%p pd=%d %Ld-%Ld ty=%d cookie=%s\n", - block->b_file, fl->fl_pid, + block->b_file, fl->fl_core.fl_pid, (long long)fl->fl_start, - (long long)fl->fl_end, fl->fl_type, + (long long)fl->fl_end, fl->fl_core.fl_type, nlmdbg_cookie2a(&block->b_call->a_args.cookie)); if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) { kref_get(&block->b_count); @@ -409,7 +409,7 @@ nlmsvc_release_lockowner(struct nlm_lock *lock) void nlmsvc_locks_init_private(struct file_lock *fl, struct nlm_host *host, pid_t pid) { - fl->fl_owner = nlmsvc_find_lockowner(host, pid); + fl->fl_core.fl_owner = nlmsvc_find_lockowner(host, pid); } /* @@ -993,8 +993,8 @@ nlmsvc_grant_reply(struct nlm_cookie *cookie, __be32 status) /* Client doesn't want it, just unlock it */ nlmsvc_unlink_block(block); fl = &block->b_call->a_args.lock.fl; - fl->fl_type = F_UNLCK; - error = vfs_lock_file(fl->fl_file, F_SETLK, fl, NULL); + fl->fl_core.fl_type = F_UNLCK; + error = vfs_lock_file(fl->fl_core.fl_file, F_SETLK, fl, NULL); if (error) pr_warn("lockd: unable to unlock lock rejected by client!\n"); break; diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index e3b6229e7ae5..61b5c7ef8a12 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -73,7 +73,7 @@ static inline unsigned int file_hash(struct nfs_fh *f) int lock_to_openmode(struct file_lock *lock) { - return (lock->fl_type == F_WRLCK) ? O_WRONLY : O_RDONLY; + return (lock->fl_core.fl_type == F_WRLCK) ? O_WRONLY : O_RDONLY; } /* @@ -181,18 +181,18 @@ static int nlm_unlock_files(struct nlm_file *file, const struct file_lock *fl) struct file_lock lock; locks_init_lock(&lock); - lock.fl_type = F_UNLCK; + lock.fl_core.fl_type = F_UNLCK; lock.fl_start = 0; lock.fl_end = OFFSET_MAX; - lock.fl_owner = fl->fl_owner; - lock.fl_pid = fl->fl_pid; - lock.fl_flags = FL_POSIX; + lock.fl_core.fl_owner = fl->fl_core.fl_owner; + lock.fl_core.fl_pid = fl->fl_core.fl_pid; + lock.fl_core.fl_flags = FL_POSIX; - lock.fl_file = file->f_file[O_RDONLY]; - if (lock.fl_file && vfs_lock_file(lock.fl_file, F_SETLK, &lock, NULL)) + lock.fl_core.fl_file = file->f_file[O_RDONLY]; + if (lock.fl_core.fl_file && vfs_lock_file(lock.fl_core.fl_file, F_SETLK, &lock, NULL)) goto out_err; - lock.fl_file = file->f_file[O_WRONLY]; - if (lock.fl_file && vfs_lock_file(lock.fl_file, F_SETLK, &lock, NULL)) + lock.fl_core.fl_file = file->f_file[O_WRONLY]; + if (lock.fl_core.fl_file && vfs_lock_file(lock.fl_core.fl_file, F_SETLK, &lock, NULL)) goto out_err; return 0; out_err: @@ -225,7 +225,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file, /* update current lock count */ file->f_locks++; - lockhost = ((struct nlm_lockowner *)fl->fl_owner)->host; + lockhost = ((struct nlm_lockowner *) fl->fl_core.fl_owner)->host; if (match(lockhost, host)) { spin_unlock(&flctx->flc_lock); diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index 2fb5748dae0c..4a676a51eb6c 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c @@ -88,8 +88,8 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) return false; locks_init_lock(fl); - fl->fl_flags = FL_POSIX; - fl->fl_type = F_RDLCK; + fl->fl_core.fl_flags = FL_POSIX; + fl->fl_core.fl_type = F_RDLCK; end = start + len - 1; fl->fl_start = s32_to_loff_t(start); if (len == 0 || end < 0) @@ -107,7 +107,7 @@ svcxdr_encode_holder(struct xdr_stream *xdr, const struct nlm_lock *lock) s32 start, len; /* exclusive */ - if (xdr_stream_encode_bool(xdr, fl->fl_type != F_RDLCK) < 0) + if (xdr_stream_encode_bool(xdr, fl->fl_core.fl_type != F_RDLCK) < 0) return false; if (xdr_stream_encode_u32(xdr, lock->svid) < 0) return false; diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c index 5fcbf30cd275..67e53f91717a 100644 --- a/fs/lockd/xdr4.c +++ b/fs/lockd/xdr4.c @@ -89,8 +89,8 @@ svcxdr_decode_lock(struct xdr_stream *xdr, struct nlm_lock *lock) return false; locks_init_lock(fl); - fl->fl_flags = FL_POSIX; - fl->fl_type = F_RDLCK; + fl->fl_core.fl_flags = FL_POSIX; + fl->fl_core.fl_type = F_RDLCK; nlm4svc_set_file_lock_range(fl, lock->lock_start, lock->lock_len); return true; } @@ -102,7 +102,7 @@ svcxdr_encode_holder(struct xdr_stream *xdr, const struct nlm_lock *lock) s64 start, len; /* exclusive */ - if (xdr_stream_encode_bool(xdr, fl->fl_type != F_RDLCK) < 0) + if (xdr_stream_encode_bool(xdr, fl->fl_core.fl_type != F_RDLCK) < 0) return false; if (xdr_stream_encode_u32(xdr, lock->svid) < 0) return false; diff --git a/fs/locks.c b/fs/locks.c index cc7c117ee192..cd6ffa22a1ce 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -78,16 +78,16 @@ static bool lease_breaking(struct file_lock *fl) { - return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); + return fl->fl_core.fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); } static int target_leasetype(struct file_lock *fl) { - if (fl->fl_flags & FL_UNLOCK_PENDING) + if (fl->fl_core.fl_flags & FL_UNLOCK_PENDING) return F_UNLCK; - if (fl->fl_flags & FL_DOWNGRADE_PENDING) + if (fl->fl_core.fl_flags & FL_DOWNGRADE_PENDING) return F_RDLCK; - return fl->fl_type; + return fl->fl_core.fl_type; } static int leases_enable = 1; @@ -207,7 +207,9 @@ locks_dump_ctx_list(struct list_head *list, char *list_type) struct file_lock *fl; list_for_each_entry(fl, list, fl_list) { - pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, fl->fl_owner, fl->fl_flags, fl->fl_type, fl->fl_pid); + pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, + fl->fl_core.fl_owner, fl->fl_core.fl_flags, + fl->fl_core.fl_type, fl->fl_core.fl_pid); } } @@ -236,12 +238,13 @@ locks_check_ctx_file_list(struct file *filp, struct list_head *list, struct inode *inode = file_inode(filp); list_for_each_entry(fl, list, fl_list) - if (fl->fl_file == filp) + if (fl->fl_core.fl_file == filp) pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx " " fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev), inode->i_ino, - fl->fl_owner, fl->fl_flags, fl->fl_type, fl->fl_pid); + fl->fl_core.fl_owner, fl->fl_core.fl_flags, + fl->fl_core.fl_type, fl->fl_core.fl_pid); } void @@ -257,11 +260,11 @@ locks_free_lock_context(struct inode *inode) static void locks_init_lock_heads(struct file_lock *fl) { - INIT_HLIST_NODE(&fl->fl_link); - INIT_LIST_HEAD(&fl->fl_list); - INIT_LIST_HEAD(&fl->fl_blocked_requests); - INIT_LIST_HEAD(&fl->fl_blocked_member); - init_waitqueue_head(&fl->fl_wait); + INIT_HLIST_NODE(&fl->fl_core.fl_link); + INIT_LIST_HEAD(&fl->fl_core.fl_list); + INIT_LIST_HEAD(&fl->fl_core.fl_blocked_requests); + INIT_LIST_HEAD(&fl->fl_core.fl_blocked_member); + init_waitqueue_head(&fl->fl_core.fl_wait); } /* Allocate an empty lock structure. */ @@ -278,11 +281,11 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock); void locks_release_private(struct file_lock *fl) { - BUG_ON(waitqueue_active(&fl->fl_wait)); - BUG_ON(!list_empty(&fl->fl_list)); - BUG_ON(!list_empty(&fl->fl_blocked_requests)); - BUG_ON(!list_empty(&fl->fl_blocked_member)); - BUG_ON(!hlist_unhashed(&fl->fl_link)); + BUG_ON(waitqueue_active(&fl->fl_core.fl_wait)); + BUG_ON(!list_empty(&fl->fl_core.fl_list)); + BUG_ON(!list_empty(&fl->fl_core.fl_blocked_requests)); + BUG_ON(!list_empty(&fl->fl_core.fl_blocked_member)); + BUG_ON(!hlist_unhashed(&fl->fl_core.fl_link)); if (fl->fl_ops) { if (fl->fl_ops->fl_release_private) @@ -292,8 +295,8 @@ void locks_release_private(struct file_lock *fl) if (fl->fl_lmops) { if (fl->fl_lmops->lm_put_owner) { - fl->fl_lmops->lm_put_owner(fl->fl_owner); - fl->fl_owner = NULL; + fl->fl_lmops->lm_put_owner(fl->fl_core.fl_owner); + fl->fl_core.fl_owner = NULL; } fl->fl_lmops = NULL; } @@ -316,9 +319,9 @@ bool locks_owner_has_blockers(struct file_lock_context *flctx, spin_lock(&flctx->flc_lock); list_for_each_entry(fl, &flctx->flc_posix, fl_list) { - if (fl->fl_owner != owner) + if (fl->fl_core.fl_owner != owner) continue; - if (!list_empty(&fl->fl_blocked_requests)) { + if (!list_empty(&fl->fl_core.fl_blocked_requests)) { spin_unlock(&flctx->flc_lock); return true; } @@ -343,7 +346,7 @@ locks_dispose_list(struct list_head *dispose) while (!list_empty(dispose)) { fl = list_first_entry(dispose, struct file_lock, fl_list); - list_del_init(&fl->fl_list); + list_del_init(&fl->fl_core.fl_list); locks_free_lock(fl); } } @@ -360,11 +363,11 @@ EXPORT_SYMBOL(locks_init_lock); */ void locks_copy_conflock(struct file_lock *new, struct file_lock *fl) { - new->fl_owner = fl->fl_owner; - new->fl_pid = fl->fl_pid; - new->fl_file = NULL; - new->fl_flags = fl->fl_flags; - new->fl_type = fl->fl_type; + new->fl_core.fl_owner = fl->fl_core.fl_owner; + new->fl_core.fl_pid = fl->fl_core.fl_pid; + new->fl_core.fl_file = NULL; + new->fl_core.fl_flags = fl->fl_core.fl_flags; + new->fl_core.fl_type = fl->fl_core.fl_type; new->fl_start = fl->fl_start; new->fl_end = fl->fl_end; new->fl_lmops = fl->fl_lmops; @@ -372,7 +375,7 @@ void locks_copy_conflock(struct file_lock *new, struct file_lock *fl) if (fl->fl_lmops) { if (fl->fl_lmops->lm_get_owner) - fl->fl_lmops->lm_get_owner(fl->fl_owner); + fl->fl_lmops->lm_get_owner(fl->fl_core.fl_owner); } } EXPORT_SYMBOL(locks_copy_conflock); @@ -384,7 +387,7 @@ void locks_copy_lock(struct file_lock *new, struct file_lock *fl) locks_copy_conflock(new, fl); - new->fl_file = fl->fl_file; + new->fl_core.fl_file = fl->fl_core.fl_file; new->fl_ops = fl->fl_ops; if (fl->fl_ops) { @@ -403,12 +406,14 @@ static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) * ->fl_blocked_requests, so we don't need a lock to check if it * is empty. */ - if (list_empty(&fl->fl_blocked_requests)) + if (list_empty(&fl->fl_core.fl_blocked_requests)) return; spin_lock(&blocked_lock_lock); - list_splice_init(&fl->fl_blocked_requests, &new->fl_blocked_requests); - list_for_each_entry(f, &new->fl_blocked_requests, fl_blocked_member) - f->fl_blocker = new; + list_splice_init(&fl->fl_core.fl_blocked_requests, + &new->fl_core.fl_blocked_requests); + list_for_each_entry(f, &new->fl_core.fl_blocked_requests, + fl_blocked_member) + f->fl_core.fl_blocker = new; spin_unlock(&blocked_lock_lock); } @@ -429,11 +434,11 @@ static void flock_make_lock(struct file *filp, struct file_lock *fl, int type) { locks_init_lock(fl); - fl->fl_file = filp; - fl->fl_owner = filp; - fl->fl_pid = current->tgid; - fl->fl_flags = FL_FLOCK; - fl->fl_type = type; + fl->fl_core.fl_file = filp; + fl->fl_core.fl_owner = filp; + fl->fl_core.fl_pid = current->tgid; + fl->fl_core.fl_flags = FL_FLOCK; + fl->fl_core.fl_type = type; fl->fl_end = OFFSET_MAX; } @@ -443,7 +448,7 @@ static int assign_type(struct file_lock *fl, int type) case F_RDLCK: case F_WRLCK: case F_UNLCK: - fl->fl_type = type; + fl->fl_core.fl_type = type; break; default: return -EINVAL; @@ -488,10 +493,10 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, } else fl->fl_end = OFFSET_MAX; - fl->fl_owner = current->files; - fl->fl_pid = current->tgid; - fl->fl_file = filp; - fl->fl_flags = FL_POSIX; + fl->fl_core.fl_owner = current->files; + fl->fl_core.fl_pid = current->tgid; + fl->fl_core.fl_file = filp; + fl->fl_core.fl_flags = FL_POSIX; fl->fl_ops = NULL; fl->fl_lmops = NULL; @@ -525,7 +530,7 @@ lease_break_callback(struct file_lock *fl) static void lease_setup(struct file_lock *fl, void **priv) { - struct file *filp = fl->fl_file; + struct file *filp = fl->fl_core.fl_file; struct fasync_struct *fa = *priv; /* @@ -553,11 +558,11 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl) if (assign_type(fl, type) != 0) return -EINVAL; - fl->fl_owner = filp; - fl->fl_pid = current->tgid; + fl->fl_core.fl_owner = filp; + fl->fl_core.fl_pid = current->tgid; - fl->fl_file = filp; - fl->fl_flags = FL_LEASE; + fl->fl_core.fl_file = filp; + fl->fl_core.fl_flags = FL_LEASE; fl->fl_start = 0; fl->fl_end = OFFSET_MAX; fl->fl_ops = NULL; @@ -595,7 +600,7 @@ static inline int locks_overlap(struct file_lock *fl1, struct file_lock *fl2) */ static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2) { - return fl1->fl_owner == fl2->fl_owner; + return fl1->fl_core.fl_owner == fl2->fl_core.fl_owner; } /* Must be called with the flc_lock held! */ @@ -606,8 +611,8 @@ static void locks_insert_global_locks(struct file_lock *fl) percpu_rwsem_assert_held(&file_rwsem); spin_lock(&fll->lock); - fl->fl_link_cpu = smp_processor_id(); - hlist_add_head(&fl->fl_link, &fll->hlist); + fl->fl_core.fl_link_cpu = smp_processor_id(); + hlist_add_head(&fl->fl_core.fl_link, &fll->hlist); spin_unlock(&fll->lock); } @@ -623,33 +628,34 @@ static void locks_delete_global_locks(struct file_lock *fl) * is done while holding the flc_lock, and new insertions into the list * also require that it be held. */ - if (hlist_unhashed(&fl->fl_link)) + if (hlist_unhashed(&fl->fl_core.fl_link)) return; - fll = per_cpu_ptr(&file_lock_list, fl->fl_link_cpu); + fll = per_cpu_ptr(&file_lock_list, fl->fl_core.fl_link_cpu); spin_lock(&fll->lock); - hlist_del_init(&fl->fl_link); + hlist_del_init(&fl->fl_core.fl_link); spin_unlock(&fll->lock); } static unsigned long posix_owner_key(struct file_lock *fl) { - return (unsigned long)fl->fl_owner; + return (unsigned long) fl->fl_core.fl_owner; } static void locks_insert_global_blocked(struct file_lock *waiter) { lockdep_assert_held(&blocked_lock_lock); - hash_add(blocked_hash, &waiter->fl_link, posix_owner_key(waiter)); + hash_add(blocked_hash, &waiter->fl_core.fl_link, + posix_owner_key(waiter)); } static void locks_delete_global_blocked(struct file_lock *waiter) { lockdep_assert_held(&blocked_lock_lock); - hash_del(&waiter->fl_link); + hash_del(&waiter->fl_core.fl_link); } /* Remove waiter from blocker's block list. @@ -660,28 +666,28 @@ static void locks_delete_global_blocked(struct file_lock *waiter) static void __locks_delete_block(struct file_lock *waiter) { locks_delete_global_blocked(waiter); - list_del_init(&waiter->fl_blocked_member); + list_del_init(&waiter->fl_core.fl_blocked_member); } static void __locks_wake_up_blocks(struct file_lock *blocker) { - while (!list_empty(&blocker->fl_blocked_requests)) { + while (!list_empty(&blocker->fl_core.fl_blocked_requests)) { struct file_lock *waiter; - waiter = list_first_entry(&blocker->fl_blocked_requests, + waiter = list_first_entry(&blocker->fl_core.fl_blocked_requests, struct file_lock, fl_blocked_member); __locks_delete_block(waiter); if (waiter->fl_lmops && waiter->fl_lmops->lm_notify) waiter->fl_lmops->lm_notify(waiter); else - wake_up(&waiter->fl_wait); + wake_up(&waiter->fl_core.fl_wait); /* * The setting of fl_blocker to NULL marks the "done" * point in deleting a block. Paired with acquire at the top * of locks_delete_block(). */ - smp_store_release(&waiter->fl_blocker, NULL); + smp_store_release(&waiter->fl_core.fl_blocker, NULL); } } @@ -716,12 +722,12 @@ int locks_delete_block(struct file_lock *waiter) * no new locks can be inserted into its fl_blocked_requests list, and * can avoid doing anything further if the list is empty. */ - if (!smp_load_acquire(&waiter->fl_blocker) && - list_empty(&waiter->fl_blocked_requests)) + if (!smp_load_acquire(&waiter->fl_core.fl_blocker) && + list_empty(&waiter->fl_core.fl_blocked_requests)) return status; spin_lock(&blocked_lock_lock); - if (waiter->fl_blocker) + if (waiter->fl_core.fl_blocker) status = 0; __locks_wake_up_blocks(waiter); __locks_delete_block(waiter); @@ -730,7 +736,7 @@ int locks_delete_block(struct file_lock *waiter) * The setting of fl_blocker to NULL marks the "done" point in deleting * a block. Paired with acquire at the top of this function. */ - smp_store_release(&waiter->fl_blocker, NULL); + smp_store_release(&waiter->fl_core.fl_blocker, NULL); spin_unlock(&blocked_lock_lock); return status; } @@ -757,16 +763,18 @@ static void __locks_insert_block(struct file_lock *blocker, struct file_lock *)) { struct file_lock *fl; - BUG_ON(!list_empty(&waiter->fl_blocked_member)); + BUG_ON(!list_empty(&waiter->fl_core.fl_blocked_member)); new_blocker: - list_for_each_entry(fl, &blocker->fl_blocked_requests, fl_blocked_member) + list_for_each_entry(fl, &blocker->fl_core.fl_blocked_requests, + fl_blocked_member) if (conflict(fl, waiter)) { blocker = fl; goto new_blocker; } - waiter->fl_blocker = blocker; - list_add_tail(&waiter->fl_blocked_member, &blocker->fl_blocked_requests); + waiter->fl_core.fl_blocker = blocker; + list_add_tail(&waiter->fl_core.fl_blocked_member, + &blocker->fl_core.fl_blocked_requests); if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) locks_insert_global_blocked(waiter); @@ -802,7 +810,7 @@ static void locks_wake_up_blocks(struct file_lock *blocker) * fl_blocked_requests list does not require the flc_lock, so we must * recheck list_empty() after acquiring the blocked_lock_lock. */ - if (list_empty(&blocker->fl_blocked_requests)) + if (list_empty(&blocker->fl_core.fl_blocked_requests)) return; spin_lock(&blocked_lock_lock); @@ -813,7 +821,7 @@ static void locks_wake_up_blocks(struct file_lock *blocker) static void locks_insert_lock_ctx(struct file_lock *fl, struct list_head *before) { - list_add_tail(&fl->fl_list, before); + list_add_tail(&fl->fl_core.fl_list, before); locks_insert_global_locks(fl); } @@ -821,7 +829,7 @@ static void locks_unlink_lock_ctx(struct file_lock *fl) { locks_delete_global_locks(fl); - list_del_init(&fl->fl_list); + list_del_init(&fl->fl_core.fl_list); locks_wake_up_blocks(fl); } @@ -830,7 +838,7 @@ locks_delete_lock_ctx(struct file_lock *fl, struct list_head *dispose) { locks_unlink_lock_ctx(fl); if (dispose) - list_add(&fl->fl_list, dispose); + list_add(&fl->fl_core.fl_list, dispose); else locks_free_lock(fl); } @@ -841,9 +849,9 @@ locks_delete_lock_ctx(struct file_lock *fl, struct list_head *dispose) static bool locks_conflict(struct file_lock *caller_fl, struct file_lock *sys_fl) { - if (sys_fl->fl_type == F_WRLCK) + if (sys_fl->fl_core.fl_type == F_WRLCK) return true; - if (caller_fl->fl_type == F_WRLCK) + if (caller_fl->fl_core.fl_type == F_WRLCK) return true; return false; } @@ -874,7 +882,7 @@ static bool posix_test_locks_conflict(struct file_lock *caller_fl, struct file_lock *sys_fl) { /* F_UNLCK checks any locks on the same fd. */ - if (caller_fl->fl_type == F_UNLCK) { + if (caller_fl->fl_core.fl_type == F_UNLCK) { if (!posix_same_owner(caller_fl, sys_fl)) return false; return locks_overlap(caller_fl, sys_fl); @@ -891,7 +899,7 @@ static bool flock_locks_conflict(struct file_lock *caller_fl, /* FLOCK locks referring to the same filp do not conflict with * each other. */ - if (caller_fl->fl_file == sys_fl->fl_file) + if (caller_fl->fl_core.fl_file == sys_fl->fl_core.fl_file) return false; return locks_conflict(caller_fl, sys_fl); @@ -908,7 +916,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl) ctx = locks_inode_context(inode); if (!ctx || list_empty_careful(&ctx->flc_posix)) { - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; return; } @@ -930,7 +938,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl) locks_copy_conflock(fl, cfl); goto out; } - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; out: spin_unlock(&ctx->flc_lock); return; @@ -979,8 +987,8 @@ static struct file_lock *what_owner_is_waiting_for(struct file_lock *block_fl) hash_for_each_possible(blocked_hash, fl, fl_link, posix_owner_key(block_fl)) { if (posix_same_owner(fl, block_fl)) { - while (fl->fl_blocker) - fl = fl->fl_blocker; + while (fl->fl_core.fl_blocker) + fl = fl->fl_core.fl_blocker; return fl; } } @@ -1027,14 +1035,14 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) bool found = false; LIST_HEAD(dispose); - ctx = locks_get_lock_context(inode, request->fl_type); + ctx = locks_get_lock_context(inode, request->fl_core.fl_type); if (!ctx) { - if (request->fl_type != F_UNLCK) + if (request->fl_core.fl_type != F_UNLCK) return -ENOMEM; - return (request->fl_flags & FL_EXISTS) ? -ENOENT : 0; + return (request->fl_core.fl_flags & FL_EXISTS) ? -ENOENT : 0; } - if (!(request->fl_flags & FL_ACCESS) && (request->fl_type != F_UNLCK)) { + if (!(request->fl_core.fl_flags & FL_ACCESS) && (request->fl_core.fl_type != F_UNLCK)) { new_fl = locks_alloc_lock(); if (!new_fl) return -ENOMEM; @@ -1042,21 +1050,21 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); - if (request->fl_flags & FL_ACCESS) + if (request->fl_core.fl_flags & FL_ACCESS) goto find_conflict; list_for_each_entry(fl, &ctx->flc_flock, fl_list) { - if (request->fl_file != fl->fl_file) + if (request->fl_core.fl_file != fl->fl_core.fl_file) continue; - if (request->fl_type == fl->fl_type) + if (request->fl_core.fl_type == fl->fl_core.fl_type) goto out; found = true; locks_delete_lock_ctx(fl, &dispose); break; } - if (request->fl_type == F_UNLCK) { - if ((request->fl_flags & FL_EXISTS) && !found) + if (request->fl_core.fl_type == F_UNLCK) { + if ((request->fl_core.fl_flags & FL_EXISTS) && !found) error = -ENOENT; goto out; } @@ -1066,13 +1074,13 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) if (!flock_locks_conflict(request, fl)) continue; error = -EAGAIN; - if (!(request->fl_flags & FL_SLEEP)) + if (!(request->fl_core.fl_flags & FL_SLEEP)) goto out; error = FILE_LOCK_DEFERRED; locks_insert_block(fl, request, flock_locks_conflict); goto out; } - if (request->fl_flags & FL_ACCESS) + if (request->fl_core.fl_flags & FL_ACCESS) goto out; locks_copy_lock(new_fl, request); locks_move_blocks(new_fl, request); @@ -1105,9 +1113,9 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, void *owner; void (*func)(void); - ctx = locks_get_lock_context(inode, request->fl_type); + ctx = locks_get_lock_context(inode, request->fl_core.fl_type); if (!ctx) - return (request->fl_type == F_UNLCK) ? 0 : -ENOMEM; + return (request->fl_core.fl_type == F_UNLCK) ? 0 : -ENOMEM; /* * We may need two file_lock structures for this operation, @@ -1115,8 +1123,8 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, * * In some cases we can be sure, that no new locks will be needed */ - if (!(request->fl_flags & FL_ACCESS) && - (request->fl_type != F_UNLCK || + if (!(request->fl_core.fl_flags & FL_ACCESS) && + (request->fl_core.fl_type != F_UNLCK || request->fl_start != 0 || request->fl_end != OFFSET_MAX)) { new_fl = locks_alloc_lock(); new_fl2 = locks_alloc_lock(); @@ -1130,7 +1138,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, * there are any, either return error or put the request on the * blocker's list of waiters and the global blocked_hash. */ - if (request->fl_type != F_UNLCK) { + if (request->fl_core.fl_type != F_UNLCK) { list_for_each_entry(fl, &ctx->flc_posix, fl_list) { if (!posix_locks_conflict(request, fl)) continue; @@ -1148,7 +1156,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, if (conflock) locks_copy_conflock(conflock, fl); error = -EAGAIN; - if (!(request->fl_flags & FL_SLEEP)) + if (!(request->fl_core.fl_flags & FL_SLEEP)) goto out; /* * Deadlock detection and insertion into the blocked @@ -1173,7 +1181,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, /* If we're just looking for a conflict, we're done. */ error = 0; - if (request->fl_flags & FL_ACCESS) + if (request->fl_core.fl_flags & FL_ACCESS) goto out; /* Find the first old lock with the same owner as the new lock */ @@ -1188,7 +1196,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, break; /* Detect adjacent or overlapping regions (if same lock type) */ - if (request->fl_type == fl->fl_type) { + if (request->fl_core.fl_type == fl->fl_core.fl_type) { /* In all comparisons of start vs end, use * "start - 1" rather than "end + 1". If end * is OFFSET_MAX, end + 1 will become negative. @@ -1228,7 +1236,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, continue; if (fl->fl_start > request->fl_end) break; - if (request->fl_type == F_UNLCK) + if (request->fl_core.fl_type == F_UNLCK) added = true; if (fl->fl_start < request->fl_start) left = fl; @@ -1261,7 +1269,8 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, locks_move_blocks(new_fl, request); request = new_fl; new_fl = NULL; - locks_insert_lock_ctx(request, &fl->fl_list); + locks_insert_lock_ctx(request, + &fl->fl_core.fl_list); locks_delete_lock_ctx(fl, &dispose); added = true; } @@ -1279,8 +1288,8 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, error = 0; if (!added) { - if (request->fl_type == F_UNLCK) { - if (request->fl_flags & FL_EXISTS) + if (request->fl_core.fl_type == F_UNLCK) { + if (request->fl_core.fl_flags & FL_EXISTS) error = -ENOENT; goto out; } @@ -1291,7 +1300,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, } locks_copy_lock(new_fl, request); locks_move_blocks(new_fl, request); - locks_insert_lock_ctx(new_fl, &fl->fl_list); + locks_insert_lock_ctx(new_fl, &fl->fl_core.fl_list); fl = new_fl; new_fl = NULL; } @@ -1303,7 +1312,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, left = new_fl2; new_fl2 = NULL; locks_copy_lock(left, right); - locks_insert_lock_ctx(left, &fl->fl_list); + locks_insert_lock_ctx(left, &fl->fl_core.fl_list); } right->fl_start = request->fl_end + 1; locks_wake_up_blocks(right); @@ -1364,8 +1373,8 @@ static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl) error = posix_lock_inode(inode, fl, NULL); if (error != FILE_LOCK_DEFERRED) break; - error = wait_event_interruptible(fl->fl_wait, - list_empty(&fl->fl_blocked_member)); + error = wait_event_interruptible(fl->fl_core.fl_wait, + list_empty(&fl->fl_core.fl_blocked_member)); if (error) break; } @@ -1377,10 +1386,10 @@ static void lease_clear_pending(struct file_lock *fl, int arg) { switch (arg) { case F_UNLCK: - fl->fl_flags &= ~FL_UNLOCK_PENDING; + fl->fl_core.fl_flags &= ~FL_UNLOCK_PENDING; fallthrough; case F_RDLCK: - fl->fl_flags &= ~FL_DOWNGRADE_PENDING; + fl->fl_core.fl_flags &= ~FL_DOWNGRADE_PENDING; } } @@ -1394,11 +1403,11 @@ int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) lease_clear_pending(fl, arg); locks_wake_up_blocks(fl); if (arg == F_UNLCK) { - struct file *filp = fl->fl_file; + struct file *filp = fl->fl_core.fl_file; f_delown(filp); filp->f_owner.signum = 0; - fasync_helper(0, fl->fl_file, 0, &fl->fl_fasync); + fasync_helper(0, fl->fl_core.fl_file, 0, &fl->fl_fasync); if (fl->fl_fasync != NULL) { printk(KERN_ERR "locks_delete_lock: fasync == %p\n", fl->fl_fasync); fl->fl_fasync = NULL; @@ -1440,11 +1449,11 @@ static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker) if (lease->fl_lmops->lm_breaker_owns_lease && lease->fl_lmops->lm_breaker_owns_lease(lease)) return false; - if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT)) { + if ((breaker->fl_core.fl_flags & FL_LAYOUT) != (lease->fl_core.fl_flags & FL_LAYOUT)) { rc = false; goto trace; } - if ((breaker->fl_flags & FL_DELEG) && (lease->fl_flags & FL_LEASE)) { + if ((breaker->fl_core.fl_flags & FL_DELEG) && (lease->fl_core.fl_flags & FL_LEASE)) { rc = false; goto trace; } @@ -1495,7 +1504,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); if (IS_ERR(new_fl)) return PTR_ERR(new_fl); - new_fl->fl_flags = type; + new_fl->fl_core.fl_flags = type; /* typically we will check that ctx is non-NULL before calling */ ctx = locks_inode_context(inode); @@ -1523,14 +1532,14 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) if (!leases_conflict(fl, new_fl)) continue; if (want_write) { - if (fl->fl_flags & FL_UNLOCK_PENDING) + if (fl->fl_core.fl_flags & FL_UNLOCK_PENDING) continue; - fl->fl_flags |= FL_UNLOCK_PENDING; + fl->fl_core.fl_flags |= FL_UNLOCK_PENDING; fl->fl_break_time = break_time; } else { if (lease_breaking(fl)) continue; - fl->fl_flags |= FL_DOWNGRADE_PENDING; + fl->fl_core.fl_flags |= FL_DOWNGRADE_PENDING; fl->fl_downgrade_time = break_time; } if (fl->fl_lmops->lm_break(fl)) @@ -1559,9 +1568,9 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) percpu_up_read(&file_rwsem); locks_dispose_list(&dispose); - error = wait_event_interruptible_timeout(new_fl->fl_wait, - list_empty(&new_fl->fl_blocked_member), - break_time); + error = wait_event_interruptible_timeout(new_fl->fl_core.fl_wait, + list_empty(&new_fl->fl_core.fl_blocked_member), + break_time); percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); @@ -1608,7 +1617,7 @@ void lease_get_mtime(struct inode *inode, struct timespec64 *time) spin_lock(&ctx->flc_lock); fl = list_first_entry_or_null(&ctx->flc_lease, struct file_lock, fl_list); - if (fl && (fl->fl_type == F_WRLCK)) + if (fl && (fl->fl_core.fl_type == F_WRLCK)) has_lease = true; spin_unlock(&ctx->flc_lock); } @@ -1655,7 +1664,7 @@ int fcntl_getlease(struct file *filp) spin_lock(&ctx->flc_lock); time_out_leases(inode, &dispose); list_for_each_entry(fl, &ctx->flc_lease, fl_list) { - if (fl->fl_file != filp) + if (fl->fl_core.fl_file != filp) continue; type = target_leasetype(fl); break; @@ -1720,7 +1729,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri struct file_lock *fl, *my_fl = NULL, *lease; struct inode *inode = file_inode(filp); struct file_lock_context *ctx; - bool is_deleg = (*flp)->fl_flags & FL_DELEG; + bool is_deleg = (*flp)->fl_core.fl_flags & FL_DELEG; int error; LIST_HEAD(dispose); @@ -1746,7 +1755,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); time_out_leases(inode, &dispose); - error = check_conflicting_open(filp, arg, lease->fl_flags); + error = check_conflicting_open(filp, arg, lease->fl_core.fl_flags); if (error) goto out; @@ -1760,8 +1769,8 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri */ error = -EAGAIN; list_for_each_entry(fl, &ctx->flc_lease, fl_list) { - if (fl->fl_file == filp && - fl->fl_owner == lease->fl_owner) { + if (fl->fl_core.fl_file == filp && + fl->fl_core.fl_owner == lease->fl_core.fl_owner) { my_fl = fl; continue; } @@ -1776,7 +1785,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri * Modifying our existing lease is OK, but no getting a * new lease if someone else is opening for write: */ - if (fl->fl_flags & FL_UNLOCK_PENDING) + if (fl->fl_core.fl_flags & FL_UNLOCK_PENDING) goto out; } @@ -1803,7 +1812,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri * precedes these checks. */ smp_mb(); - error = check_conflicting_open(filp, arg, lease->fl_flags); + error = check_conflicting_open(filp, arg, lease->fl_core.fl_flags); if (error) { locks_unlink_lock_ctx(lease); goto out; @@ -1840,8 +1849,8 @@ static int generic_delete_lease(struct file *filp, void *owner) percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); list_for_each_entry(fl, &ctx->flc_lease, fl_list) { - if (fl->fl_file == filp && - fl->fl_owner == owner) { + if (fl->fl_core.fl_file == filp && + fl->fl_core.fl_owner == owner) { victim = fl; break; } @@ -2017,8 +2026,8 @@ static int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl) error = flock_lock_inode(inode, fl); if (error != FILE_LOCK_DEFERRED) break; - error = wait_event_interruptible(fl->fl_wait, - list_empty(&fl->fl_blocked_member)); + error = wait_event_interruptible(fl->fl_core.fl_wait, + list_empty(&fl->fl_core.fl_blocked_member)); if (error) break; } @@ -2036,7 +2045,7 @@ static int flock_lock_inode_wait(struct inode *inode, struct file_lock *fl) int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl) { int res = 0; - switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) { + switch (fl->fl_core.fl_flags & (FL_POSIX|FL_FLOCK)) { case FL_POSIX: res = posix_lock_inode_wait(inode, fl); break; @@ -2098,13 +2107,13 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) flock_make_lock(f.file, &fl, type); - error = security_file_lock(f.file, fl.fl_type); + error = security_file_lock(f.file, fl.fl_core.fl_type); if (error) goto out_putf; can_sleep = !(cmd & LOCK_NB); if (can_sleep) - fl.fl_flags |= FL_SLEEP; + fl.fl_core.fl_flags |= FL_SLEEP; if (f.file->f_op->flock) error = f.file->f_op->flock(f.file, @@ -2130,7 +2139,7 @@ SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd) */ int vfs_test_lock(struct file *filp, struct file_lock *fl) { - WARN_ON_ONCE(filp != fl->fl_file); + WARN_ON_ONCE(filp != fl->fl_core.fl_file); if (filp->f_op->lock) return filp->f_op->lock(filp, F_GETLK, fl); posix_test_lock(filp, fl); @@ -2153,17 +2162,17 @@ static pid_t locks_translate_pid(struct file_lock *fl, struct pid_namespace *ns) if (IS_OFDLCK(fl)) return -1; if (IS_REMOTELCK(fl)) - return fl->fl_pid; + return fl->fl_core.fl_pid; /* * If the flock owner process is dead and its pid has been already * freed, the translation below won't work, but we still want to show * flock owner pid number in init pidns. */ if (ns == &init_pid_ns) - return (pid_t)fl->fl_pid; + return (pid_t) fl->fl_core.fl_pid; rcu_read_lock(); - pid = find_pid_ns(fl->fl_pid, &init_pid_ns); + pid = find_pid_ns(fl->fl_core.fl_pid, &init_pid_ns); vnr = pid_nr_ns(pid, ns); rcu_read_unlock(); return vnr; @@ -2186,7 +2195,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : fl->fl_end - fl->fl_start + 1; flock->l_whence = 0; - flock->l_type = fl->fl_type; + flock->l_type = fl->fl_core.fl_type; return 0; } @@ -2198,7 +2207,7 @@ static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : fl->fl_end - fl->fl_start + 1; flock->l_whence = 0; - flock->l_type = fl->fl_type; + flock->l_type = fl->fl_core.fl_type; } #endif @@ -2227,16 +2236,16 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock *flock) if (flock->l_pid != 0) goto out; - fl->fl_flags |= FL_OFDLCK; - fl->fl_owner = filp; + fl->fl_core.fl_flags |= FL_OFDLCK; + fl->fl_core.fl_owner = filp; } error = vfs_test_lock(filp, fl); if (error) goto out; - flock->l_type = fl->fl_type; - if (fl->fl_type != F_UNLCK) { + flock->l_type = fl->fl_core.fl_type; + if (fl->fl_core.fl_type != F_UNLCK) { error = posix_lock_to_flock(flock, fl); if (error) goto out; @@ -2283,7 +2292,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock *flock) */ int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) { - WARN_ON_ONCE(filp != fl->fl_file); + WARN_ON_ONCE(filp != fl->fl_core.fl_file); if (filp->f_op->lock) return filp->f_op->lock(filp, cmd, fl); else @@ -2296,7 +2305,7 @@ static int do_lock_file_wait(struct file *filp, unsigned int cmd, { int error; - error = security_file_lock(filp, fl->fl_type); + error = security_file_lock(filp, fl->fl_core.fl_type); if (error) return error; @@ -2304,8 +2313,8 @@ static int do_lock_file_wait(struct file *filp, unsigned int cmd, error = vfs_lock_file(filp, cmd, fl, NULL); if (error != FILE_LOCK_DEFERRED) break; - error = wait_event_interruptible(fl->fl_wait, - list_empty(&fl->fl_blocked_member)); + error = wait_event_interruptible(fl->fl_core.fl_wait, + list_empty(&fl->fl_core.fl_blocked_member)); if (error) break; } @@ -2318,13 +2327,13 @@ static int do_lock_file_wait(struct file *filp, unsigned int cmd, static int check_fmode_for_setlk(struct file_lock *fl) { - switch (fl->fl_type) { + switch (fl->fl_core.fl_type) { case F_RDLCK: - if (!(fl->fl_file->f_mode & FMODE_READ)) + if (!(fl->fl_core.fl_file->f_mode & FMODE_READ)) return -EBADF; break; case F_WRLCK: - if (!(fl->fl_file->f_mode & FMODE_WRITE)) + if (!(fl->fl_core.fl_file->f_mode & FMODE_WRITE)) return -EBADF; } return 0; @@ -2363,8 +2372,8 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, goto out; cmd = F_SETLK; - file_lock->fl_flags |= FL_OFDLCK; - file_lock->fl_owner = filp; + file_lock->fl_core.fl_flags |= FL_OFDLCK; + file_lock->fl_core.fl_owner = filp; break; case F_OFD_SETLKW: error = -EINVAL; @@ -2372,11 +2381,11 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, goto out; cmd = F_SETLKW; - file_lock->fl_flags |= FL_OFDLCK; - file_lock->fl_owner = filp; + file_lock->fl_core.fl_flags |= FL_OFDLCK; + file_lock->fl_core.fl_owner = filp; fallthrough; case F_SETLKW: - file_lock->fl_flags |= FL_SLEEP; + file_lock->fl_core.fl_flags |= FL_SLEEP; } error = do_lock_file_wait(filp, cmd, file_lock); @@ -2386,8 +2395,8 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, * lock that was just acquired. There is no need to do that when we're * unlocking though, or for OFD locks. */ - if (!error && file_lock->fl_type != F_UNLCK && - !(file_lock->fl_flags & FL_OFDLCK)) { + if (!error && file_lock->fl_core.fl_type != F_UNLCK && + !(file_lock->fl_core.fl_flags & FL_OFDLCK)) { struct files_struct *files = current->files; /* * We need that spin_lock here - it prevents reordering between @@ -2398,7 +2407,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, f = files_lookup_fd_locked(files, fd); spin_unlock(&files->file_lock); if (f != filp) { - file_lock->fl_type = F_UNLCK; + file_lock->fl_core.fl_type = F_UNLCK; error = do_lock_file_wait(filp, cmd, file_lock); WARN_ON_ONCE(error); error = -EBADF; @@ -2437,16 +2446,16 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 *flock) if (flock->l_pid != 0) goto out; - fl->fl_flags |= FL_OFDLCK; - fl->fl_owner = filp; + fl->fl_core.fl_flags |= FL_OFDLCK; + fl->fl_core.fl_owner = filp; } error = vfs_test_lock(filp, fl); if (error) goto out; - flock->l_type = fl->fl_type; - if (fl->fl_type != F_UNLCK) + flock->l_type = fl->fl_core.fl_type; + if (fl->fl_core.fl_type != F_UNLCK) posix_lock_to_flock64(flock, fl); out: @@ -2486,8 +2495,8 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, goto out; cmd = F_SETLK64; - file_lock->fl_flags |= FL_OFDLCK; - file_lock->fl_owner = filp; + file_lock->fl_core.fl_flags |= FL_OFDLCK; + file_lock->fl_core.fl_owner = filp; break; case F_OFD_SETLKW: error = -EINVAL; @@ -2495,11 +2504,11 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, goto out; cmd = F_SETLKW64; - file_lock->fl_flags |= FL_OFDLCK; - file_lock->fl_owner = filp; + file_lock->fl_core.fl_flags |= FL_OFDLCK; + file_lock->fl_core.fl_owner = filp; fallthrough; case F_SETLKW64: - file_lock->fl_flags |= FL_SLEEP; + file_lock->fl_core.fl_flags |= FL_SLEEP; } error = do_lock_file_wait(filp, cmd, file_lock); @@ -2509,8 +2518,8 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, * lock that was just acquired. There is no need to do that when we're * unlocking though, or for OFD locks. */ - if (!error && file_lock->fl_type != F_UNLCK && - !(file_lock->fl_flags & FL_OFDLCK)) { + if (!error && file_lock->fl_core.fl_type != F_UNLCK && + !(file_lock->fl_core.fl_flags & FL_OFDLCK)) { struct files_struct *files = current->files; /* * We need that spin_lock here - it prevents reordering between @@ -2521,7 +2530,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, f = files_lookup_fd_locked(files, fd); spin_unlock(&files->file_lock); if (f != filp) { - file_lock->fl_type = F_UNLCK; + file_lock->fl_core.fl_type = F_UNLCK; error = do_lock_file_wait(filp, cmd, file_lock); WARN_ON_ONCE(error); error = -EBADF; @@ -2555,13 +2564,13 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner) return; locks_init_lock(&lock); - lock.fl_type = F_UNLCK; - lock.fl_flags = FL_POSIX | FL_CLOSE; + lock.fl_core.fl_type = F_UNLCK; + lock.fl_core.fl_flags = FL_POSIX | FL_CLOSE; lock.fl_start = 0; lock.fl_end = OFFSET_MAX; - lock.fl_owner = owner; - lock.fl_pid = current->tgid; - lock.fl_file = filp; + lock.fl_core.fl_owner = owner; + lock.fl_core.fl_pid = current->tgid; + lock.fl_core.fl_file = filp; lock.fl_ops = NULL; lock.fl_lmops = NULL; @@ -2584,7 +2593,7 @@ locks_remove_flock(struct file *filp, struct file_lock_context *flctx) return; flock_make_lock(filp, &fl, F_UNLCK); - fl.fl_flags |= FL_CLOSE; + fl.fl_core.fl_flags |= FL_CLOSE; if (filp->f_op->flock) filp->f_op->flock(filp, F_SETLKW, &fl); @@ -2608,7 +2617,7 @@ locks_remove_lease(struct file *filp, struct file_lock_context *ctx) percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) - if (filp == fl->fl_file) + if (filp == fl->fl_core.fl_file) lease_modify(fl, F_UNLCK, &dispose); spin_unlock(&ctx->flc_lock); percpu_up_read(&file_rwsem); @@ -2652,7 +2661,7 @@ void locks_remove_file(struct file *filp) */ int vfs_cancel_lock(struct file *filp, struct file_lock *fl) { - WARN_ON_ONCE(filp != fl->fl_file); + WARN_ON_ONCE(filp != fl->fl_core.fl_file); if (filp->f_op->lock) return filp->f_op->lock(filp, F_CANCELLK, fl); return 0; @@ -2706,8 +2715,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, * init_pid_ns to get saved lock pid value. */ - if (fl->fl_file != NULL) - inode = file_inode(fl->fl_file); + if (fl->fl_core.fl_file != NULL) + inode = file_inode(fl->fl_core.fl_file); seq_printf(f, "%lld: ", id); @@ -2715,7 +2724,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, seq_printf(f, "%*s", repeat - 1 + (int)strlen(pfx), pfx); if (IS_POSIX(fl)) { - if (fl->fl_flags & FL_ACCESS) + if (fl->fl_core.fl_flags & FL_ACCESS) seq_puts(f, "ACCESS"); else if (IS_OFDLCK(fl)) seq_puts(f, "OFDLCK"); @@ -2727,21 +2736,21 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, } else if (IS_FLOCK(fl)) { seq_puts(f, "FLOCK ADVISORY "); } else if (IS_LEASE(fl)) { - if (fl->fl_flags & FL_DELEG) + if (fl->fl_core.fl_flags & FL_DELEG) seq_puts(f, "DELEG "); else seq_puts(f, "LEASE "); if (lease_breaking(fl)) seq_puts(f, "BREAKING "); - else if (fl->fl_file) + else if (fl->fl_core.fl_file) seq_puts(f, "ACTIVE "); else seq_puts(f, "BREAKER "); } else { seq_puts(f, "UNKNOWN UNKNOWN "); } - type = IS_LEASE(fl) ? target_leasetype(fl) : fl->fl_type; + type = IS_LEASE(fl) ? target_leasetype(fl) : fl->fl_core.fl_type; seq_printf(f, "%s ", (type == F_WRLCK) ? "WRITE" : (type == F_RDLCK) ? "READ" : "UNLCK"); @@ -2768,12 +2777,12 @@ static struct file_lock *get_next_blocked_member(struct file_lock *node) struct file_lock *tmp; /* NULL node or root node */ - if (node == NULL || node->fl_blocker == NULL) + if (node == NULL || node->fl_core.fl_blocker == NULL) return NULL; /* Next member in the linked list could be itself */ tmp = list_next_entry(node, fl_blocked_member); - if (list_entry_is_head(tmp, &node->fl_blocker->fl_blocked_requests, fl_blocked_member) + if (list_entry_is_head(tmp, &node->fl_core.fl_blocker->fl_blocked_requests, fl_blocked_member) || tmp == node) { return NULL; } @@ -2804,17 +2813,18 @@ static int locks_show(struct seq_file *f, void *v) else lock_get_status(f, cur, iter->li_pos, "", level); - if (!list_empty(&cur->fl_blocked_requests)) { + if (!list_empty(&cur->fl_core.fl_blocked_requests)) { /* Turn left */ - cur = list_first_entry_or_null(&cur->fl_blocked_requests, - struct file_lock, fl_blocked_member); + cur = list_first_entry_or_null(&cur->fl_core.fl_blocked_requests, + struct file_lock, + fl_blocked_member); level++; } else { /* Turn right */ tmp = get_next_blocked_member(cur); /* Fall back to parent node */ - while (tmp == NULL && cur->fl_blocker != NULL) { - cur = cur->fl_blocker; + while (tmp == NULL && cur->fl_core.fl_blocker != NULL) { + cur = cur->fl_core.fl_blocker; level--; tmp = get_next_blocked_member(cur); } @@ -2833,10 +2843,10 @@ static void __show_fd_locks(struct seq_file *f, list_for_each_entry(fl, head, fl_list) { - if (filp != fl->fl_file) + if (filp != fl->fl_core.fl_file) continue; - if (fl->fl_owner != files && - fl->fl_owner != filp) + if (fl->fl_core.fl_owner != files && + fl->fl_core.fl_owner != filp) continue; (*id)++; diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index fa1a14def45c..31741967ab95 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -157,7 +157,7 @@ static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_state spin_lock(&flctx->flc_lock); restart: list_for_each_entry(fl, list, fl_list) { - if (nfs_file_open_context(fl->fl_file)->state != state) + if (nfs_file_open_context(fl->fl_core.fl_file)->state != state) continue; spin_unlock(&flctx->flc_lock); status = nfs4_lock_delegation_recall(fl, state, stateid); diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 8577ccf621f5..94c56c3d9177 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -720,15 +720,15 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) { struct inode *inode = filp->f_mapping->host; int status = 0; - unsigned int saved_type = fl->fl_type; + unsigned int saved_type = fl->fl_core.fl_type; /* Try local locking first */ posix_test_lock(filp, fl); - if (fl->fl_type != F_UNLCK) { + if (fl->fl_core.fl_type != F_UNLCK) { /* found a conflict */ goto out; } - fl->fl_type = saved_type; + fl->fl_core.fl_type = saved_type; if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) goto out_noconflict; @@ -740,7 +740,7 @@ do_getlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) out: return status; out_noconflict: - fl->fl_type = F_UNLCK; + fl->fl_core.fl_type = F_UNLCK; goto out; } @@ -765,7 +765,7 @@ do_unlk(struct file *filp, int cmd, struct file_lock *fl, int is_local) * If we're signalled while cleaning up locks on process exit, we * still need to complete the unlock. */ - if (status < 0 && !(fl->fl_flags & FL_CLOSE)) + if (status < 0 && !(fl->fl_core.fl_flags & FL_CLOSE)) return status; } @@ -832,12 +832,12 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) int is_local = 0; dprintk("NFS: lock(%pD2, t=%x, fl=%x, r=%lld:%lld)\n", - filp, fl->fl_type, fl->fl_flags, + filp, fl->fl_core.fl_type, fl->fl_core.fl_flags, (long long)fl->fl_start, (long long)fl->fl_end); nfs_inc_stats(inode, NFSIOS_VFSLOCK); - if (fl->fl_flags & FL_RECLAIM) + if (fl->fl_core.fl_flags & FL_RECLAIM) return -ENOGRACE; if (NFS_SERVER(inode)->flags & NFS_MOUNT_LOCAL_FCNTL) @@ -851,7 +851,7 @@ int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) if (IS_GETLK(cmd)) ret = do_getlk(filp, cmd, fl, is_local); - else if (fl->fl_type == F_UNLCK) + else if (fl->fl_core.fl_type == F_UNLCK) ret = do_unlk(filp, cmd, fl, is_local); else ret = do_setlk(filp, cmd, fl, is_local); @@ -869,16 +869,16 @@ int nfs_flock(struct file *filp, int cmd, struct file_lock *fl) int is_local = 0; dprintk("NFS: flock(%pD2, t=%x, fl=%x)\n", - filp, fl->fl_type, fl->fl_flags); + filp, fl->fl_core.fl_type, fl->fl_core.fl_flags); - if (!(fl->fl_flags & FL_FLOCK)) + if (!(fl->fl_core.fl_flags & FL_FLOCK)) return -ENOLCK; if (NFS_SERVER(inode)->flags & NFS_MOUNT_LOCAL_FLOCK) is_local = 1; /* We're simulating flock() locks using posix locks on the server */ - if (fl->fl_type == F_UNLCK) + if (fl->fl_core.fl_type == F_UNLCK) return do_unlk(filp, cmd, fl, is_local); return do_setlk(filp, cmd, fl, is_local); } diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index 2de66e4e8280..d6d8900d8d83 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -963,7 +963,7 @@ nfs3_proc_lock(struct file *filp, int cmd, struct file_lock *fl) struct nfs_open_context *ctx = nfs_file_open_context(filp); int status; - if (fl->fl_flags & FL_CLOSE) { + if (fl->fl_core.fl_flags & FL_CLOSE) { l_ctx = nfs_get_lock_context(ctx); if (IS_ERR(l_ctx)) l_ctx = NULL; diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 23819a756508..a5596007b4d9 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -6800,7 +6800,7 @@ static int _nfs4_proc_getlk(struct nfs4_state *state, int cmd, struct file_lock status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1); switch (status) { case 0: - request->fl_type = F_UNLCK; + request->fl_core.fl_type = F_UNLCK; break; case -NFS4ERR_DENIED: status = 0; @@ -7018,8 +7018,8 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl, /* Ensure this is an unlock - when canceling a lock, the * canceled lock is passed in, and it won't be an unlock. */ - fl->fl_type = F_UNLCK; - if (fl->fl_flags & FL_CLOSE) + fl->fl_core.fl_type = F_UNLCK; + if (fl->fl_core.fl_flags & FL_CLOSE) set_bit(NFS_CONTEXT_UNLOCK, &ctx->flags); data = nfs4_alloc_unlockdata(fl, ctx, lsp, seqid); @@ -7045,11 +7045,11 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * struct rpc_task *task; struct nfs_seqid *(*alloc_seqid)(struct nfs_seqid_counter *, gfp_t); int status = 0; - unsigned char fl_flags = request->fl_flags; + unsigned char fl_flags = request->fl_core.fl_flags; status = nfs4_set_lock_state(state, request); /* Unlock _before_ we do the RPC call */ - request->fl_flags |= FL_EXISTS; + request->fl_core.fl_flags |= FL_EXISTS; /* Exclude nfs_delegation_claim_locks() */ mutex_lock(&sp->so_delegreturn_mutex); /* Exclude nfs4_reclaim_open_stateid() - note nesting! */ @@ -7073,14 +7073,16 @@ static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock * status = -ENOMEM; if (IS_ERR(seqid)) goto out; - task = nfs4_do_unlck(request, nfs_file_open_context(request->fl_file), lsp, seqid); + task = nfs4_do_unlck(request, + nfs_file_open_context(request->fl_core.fl_file), + lsp, seqid); status = PTR_ERR(task); if (IS_ERR(task)) goto out; status = rpc_wait_for_completion_task(task); rpc_put_task(task); out: - request->fl_flags = fl_flags; + request->fl_core.fl_flags = fl_flags; trace_nfs4_unlock(request, state, F_SETLK, status); return status; } @@ -7191,7 +7193,7 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata) renew_lease(NFS_SERVER(d_inode(data->ctx->dentry)), data->timestamp); if (data->arg.new_lock && !data->cancelled) { - data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS); + data->fl.fl_core.fl_flags &= ~(FL_SLEEP | FL_ACCESS); if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0) goto out_restart; } @@ -7292,7 +7294,8 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f if (nfs_server_capable(state->inode, NFS_CAP_MOVEABLE)) task_setup_data.flags |= RPC_TASK_MOVEABLE; - data = nfs4_alloc_lockdata(fl, nfs_file_open_context(fl->fl_file), + data = nfs4_alloc_lockdata(fl, + nfs_file_open_context(fl->fl_core.fl_file), fl->fl_u.nfs4_fl.owner, GFP_KERNEL); if (data == NULL) return -ENOMEM; @@ -7398,10 +7401,10 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock { struct nfs_inode *nfsi = NFS_I(state->inode); struct nfs4_state_owner *sp = state->owner; - unsigned char fl_flags = request->fl_flags; + unsigned char fl_flags = request->fl_core.fl_flags; int status; - request->fl_flags |= FL_ACCESS; + request->fl_core.fl_flags |= FL_ACCESS; status = locks_lock_inode_wait(state->inode, request); if (status < 0) goto out; @@ -7410,7 +7413,7 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock if (test_bit(NFS_DELEGATED_STATE, &state->flags)) { /* Yes: cache locks! */ /* ...but avoid races with delegation recall... */ - request->fl_flags = fl_flags & ~FL_SLEEP; + request->fl_core.fl_flags = fl_flags & ~FL_SLEEP; status = locks_lock_inode_wait(state->inode, request); up_read(&nfsi->rwsem); mutex_unlock(&sp->so_delegreturn_mutex); @@ -7420,7 +7423,7 @@ static int _nfs4_proc_setlk(struct nfs4_state *state, int cmd, struct file_lock mutex_unlock(&sp->so_delegreturn_mutex); status = _nfs4_do_setlk(state, cmd, request, NFS_LOCK_NEW); out: - request->fl_flags = fl_flags; + request->fl_core.fl_flags = fl_flags; return status; } @@ -7562,7 +7565,7 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) if (!(IS_SETLK(cmd) || IS_SETLKW(cmd))) return -EINVAL; - if (request->fl_type == F_UNLCK) { + if (request->fl_core.fl_type == F_UNLCK) { if (state != NULL) return nfs4_proc_unlck(state, cmd, request); return 0; @@ -7571,7 +7574,7 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) if (state == NULL) return -ENOLCK; - if ((request->fl_flags & FL_POSIX) && + if ((request->fl_core.fl_flags & FL_POSIX) && !test_bit(NFS_STATE_POSIX_LOCKS, &state->flags)) return -ENOLCK; @@ -7579,7 +7582,7 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request) * Don't rely on the VFS having checked the file open mode, * since it won't do this for flock() locks. */ - switch (request->fl_type) { + switch (request->fl_core.fl_type) { case F_RDLCK: if (!(filp->f_mode & FMODE_READ)) return -EBADF; diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 9a5d911a7edc..a148b6ac4713 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -980,7 +980,7 @@ int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl) if (fl->fl_ops != NULL) return 0; - lsp = nfs4_get_lock_state(state, fl->fl_owner); + lsp = nfs4_get_lock_state(state, fl->fl_core.fl_owner); if (lsp == NULL) return -ENOMEM; fl->fl_u.nfs4_fl.owner = lsp; @@ -1530,7 +1530,7 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ spin_lock(&flctx->flc_lock); restart: list_for_each_entry(fl, list, fl_list) { - if (nfs_file_open_context(fl->fl_file)->state != state) + if (nfs_file_open_context(fl->fl_core.fl_file)->state != state) continue; spin_unlock(&flctx->flc_lock); status = ops->recover_lock(state, fl); diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index 69406e60f391..25964af5bb80 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -1305,7 +1305,7 @@ static void encode_link(struct xdr_stream *xdr, const struct qstr *name, struct static inline int nfs4_lock_type(struct file_lock *fl, int block) { - if (fl->fl_type == F_RDLCK) + if (fl->fl_core.fl_type == F_RDLCK) return block ? NFS4_READW_LT : NFS4_READ_LT; return block ? NFS4_WRITEW_LT : NFS4_WRITE_LT; } @@ -5052,10 +5052,10 @@ static int decode_lock_denied (struct xdr_stream *xdr, struct file_lock *fl) fl->fl_end = fl->fl_start + (loff_t)length - 1; if (length == ~(uint64_t)0) fl->fl_end = OFFSET_MAX; - fl->fl_type = F_WRLCK; + fl->fl_core.fl_type = F_WRLCK; if (type & 1) - fl->fl_type = F_RDLCK; - fl->fl_pid = 0; + fl->fl_core.fl_type = F_RDLCK; + fl->fl_core.fl_pid = 0; } p = xdr_decode_hyper(p, &clientid); /* read 8 bytes */ namelen = be32_to_cpup(p); /* read 4 bytes */ /* have read all 32 bytes now */ diff --git a/fs/nfs/write.c b/fs/nfs/write.c index bb79d3a886ae..a096c84c4678 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1301,7 +1301,7 @@ static bool is_whole_file_wrlock(struct file_lock *fl) { return fl->fl_start == 0 && fl->fl_end == OFFSET_MAX && - fl->fl_type == F_WRLCK; + fl->fl_core.fl_type == F_WRLCK; } /* If we know the page is up to date, and we're not using byte range locks (or @@ -1341,7 +1341,7 @@ static int nfs_can_extend_write(struct file *file, struct folio *folio, } else if (!list_empty(&flctx->flc_flock)) { fl = list_first_entry(&flctx->flc_flock, struct file_lock, fl_list); - if (fl->fl_type == F_WRLCK) + if (fl->fl_core.fl_type == F_WRLCK) ret = 1; } spin_unlock(&flctx->flc_lock); diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index 9cb7f0c33df5..0300dae3e11f 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -662,8 +662,8 @@ nfsd_file_lease_notifier_call(struct notifier_block *nb, unsigned long arg, struct file_lock *fl = data; /* Only close files for F_SETLEASE leases */ - if (fl->fl_flags & FL_LEASE) - nfsd_file_close_inode(file_inode(fl->fl_file)); + if (fl->fl_core.fl_flags & FL_LEASE) + nfsd_file_close_inode(file_inode(fl->fl_core.fl_file)); return 0; } diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index 5e8096bc5eaa..4bef3349bd90 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -193,14 +193,15 @@ nfsd4_layout_setlease(struct nfs4_layout_stateid *ls) return -ENOMEM; locks_init_lock(fl); fl->fl_lmops = &nfsd4_layouts_lm_ops; - fl->fl_flags = FL_LAYOUT; - fl->fl_type = F_RDLCK; + fl->fl_core.fl_flags = FL_LAYOUT; + fl->fl_core.fl_type = F_RDLCK; fl->fl_end = OFFSET_MAX; - fl->fl_owner = ls; - fl->fl_pid = current->tgid; - fl->fl_file = ls->ls_file->nf_file; + fl->fl_core.fl_owner = ls; + fl->fl_core.fl_pid = current->tgid; + fl->fl_core.fl_file = ls->ls_file->nf_file; - status = vfs_setlease(fl->fl_file, fl->fl_type, &fl, NULL); + status = vfs_setlease(fl->fl_core.fl_file, fl->fl_core.fl_type, &fl, + NULL); if (status) { locks_free_lock(fl); return status; @@ -731,7 +732,7 @@ nfsd4_layout_lm_break(struct file_lock *fl) * in time: */ fl->fl_break_time = 0; - nfsd4_recall_file_layout(fl->fl_owner); + nfsd4_recall_file_layout(fl->fl_core.fl_owner); return false; } diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2fa54cfd4882..a6089dbcee9d 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4924,7 +4924,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) static bool nfsd_break_deleg_cb(struct file_lock *fl) { - struct nfs4_delegation *dp = (struct nfs4_delegation *)fl->fl_owner; + struct nfs4_delegation *dp = (struct nfs4_delegation *) fl->fl_core.fl_owner; struct nfs4_file *fp = dp->dl_stid.sc_file; struct nfs4_client *clp = dp->dl_stid.sc_client; struct nfsd_net *nn; @@ -4962,7 +4962,7 @@ nfsd_break_deleg_cb(struct file_lock *fl) */ static bool nfsd_breaker_owns_lease(struct file_lock *fl) { - struct nfs4_delegation *dl = fl->fl_owner; + struct nfs4_delegation *dl = fl->fl_core.fl_owner; struct svc_rqst *rqst; struct nfs4_client *clp; @@ -4980,7 +4980,7 @@ static int nfsd_change_deleg_cb(struct file_lock *onlist, int arg, struct list_head *dispose) { - struct nfs4_delegation *dp = (struct nfs4_delegation *)onlist->fl_owner; + struct nfs4_delegation *dp = (struct nfs4_delegation *) onlist->fl_core.fl_owner; struct nfs4_client *clp = dp->dl_stid.sc_client; if (arg & F_UNLCK) { @@ -5340,12 +5340,12 @@ static struct file_lock *nfs4_alloc_init_lease(struct nfs4_delegation *dp, if (!fl) return NULL; fl->fl_lmops = &nfsd_lease_mng_ops; - fl->fl_flags = FL_DELEG; - fl->fl_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK; + fl->fl_core.fl_flags = FL_DELEG; + fl->fl_core.fl_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK; fl->fl_end = OFFSET_MAX; - fl->fl_owner = (fl_owner_t)dp; - fl->fl_pid = current->tgid; - fl->fl_file = dp->dl_stid.sc_file->fi_deleg_file->nf_file; + fl->fl_core.fl_owner = (fl_owner_t)dp; + fl->fl_core.fl_pid = current->tgid; + fl->fl_core.fl_file = dp->dl_stid.sc_file->fi_deleg_file->nf_file; return fl; } @@ -5533,7 +5533,8 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, if (!fl) goto out_clnt_odstate; - status = vfs_setlease(fp->fi_deleg_file->nf_file, fl->fl_type, &fl, NULL); + status = vfs_setlease(fp->fi_deleg_file->nf_file, fl->fl_core.fl_type, + &fl, NULL); if (fl) locks_free_lock(fl); if (status) @@ -7149,7 +7150,7 @@ nfsd4_lm_put_owner(fl_owner_t owner) static bool nfsd4_lm_lock_expirable(struct file_lock *cfl) { - struct nfs4_lockowner *lo = (struct nfs4_lockowner *)cfl->fl_owner; + struct nfs4_lockowner *lo = (struct nfs4_lockowner *) cfl->fl_core.fl_owner; struct nfs4_client *clp = lo->lo_owner.so_client; struct nfsd_net *nn; @@ -7171,7 +7172,7 @@ nfsd4_lm_expire_lock(void) static void nfsd4_lm_notify(struct file_lock *fl) { - struct nfs4_lockowner *lo = (struct nfs4_lockowner *)fl->fl_owner; + struct nfs4_lockowner *lo = (struct nfs4_lockowner *) fl->fl_core.fl_owner; struct net *net = lo->lo_owner.so_client->net; struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct nfsd4_blocked_lock *nbl = container_of(fl, @@ -7208,7 +7209,7 @@ nfs4_set_lock_denied(struct file_lock *fl, struct nfsd4_lock_denied *deny) struct nfs4_lockowner *lo; if (fl->fl_lmops == &nfsd_posix_mng_ops) { - lo = (struct nfs4_lockowner *) fl->fl_owner; + lo = (struct nfs4_lockowner *) fl->fl_core.fl_owner; xdr_netobj_dup(&deny->ld_owner, &lo->lo_owner.so_owner, GFP_KERNEL); if (!deny->ld_owner.data) @@ -7227,7 +7228,7 @@ nfs4_set_lock_denied(struct file_lock *fl, struct nfsd4_lock_denied *deny) if (fl->fl_end != NFS4_MAX_UINT64) deny->ld_length = fl->fl_end - fl->fl_start + 1; deny->ld_type = NFS4_READ_LT; - if (fl->fl_type != F_RDLCK) + if (fl->fl_core.fl_type != F_RDLCK) deny->ld_type = NFS4_WRITE_LT; } @@ -7615,11 +7616,11 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, } file_lock = &nbl->nbl_lock; - file_lock->fl_type = fl_type; - file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(&lock_sop->lo_owner)); - file_lock->fl_pid = current->tgid; - file_lock->fl_file = nf->nf_file; - file_lock->fl_flags = fl_flags; + file_lock->fl_core.fl_type = fl_type; + file_lock->fl_core.fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(&lock_sop->lo_owner)); + file_lock->fl_core.fl_pid = current->tgid; + file_lock->fl_core.fl_file = nf->nf_file; + file_lock->fl_core.fl_flags = fl_flags; file_lock->fl_lmops = &nfsd_posix_mng_ops; file_lock->fl_start = lock->lk_offset; file_lock->fl_end = last_byte_offset(lock->lk_offset, lock->lk_length); @@ -7737,9 +7738,9 @@ static __be32 nfsd_test_lock(struct svc_rqst *rqstp, struct svc_fh *fhp, struct err = nfserrno(nfsd_open_break_lease(inode, NFSD_MAY_READ)); if (err) goto out; - lock->fl_file = nf->nf_file; + lock->fl_core.fl_file = nf->nf_file; err = nfserrno(vfs_test_lock(nf->nf_file, lock)); - lock->fl_file = NULL; + lock->fl_core.fl_file = NULL; out: inode_unlock(inode); nfsd_file_put(nf); @@ -7784,11 +7785,11 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, switch (lockt->lt_type) { case NFS4_READ_LT: case NFS4_READW_LT: - file_lock->fl_type = F_RDLCK; + file_lock->fl_core.fl_type = F_RDLCK; break; case NFS4_WRITE_LT: case NFS4_WRITEW_LT: - file_lock->fl_type = F_WRLCK; + file_lock->fl_core.fl_type = F_WRLCK; break; default: dprintk("NFSD: nfs4_lockt: bad lock type!\n"); @@ -7798,9 +7799,9 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, lo = find_lockowner_str(cstate->clp, &lockt->lt_owner); if (lo) - file_lock->fl_owner = (fl_owner_t)lo; - file_lock->fl_pid = current->tgid; - file_lock->fl_flags = FL_POSIX; + file_lock->fl_core.fl_owner = (fl_owner_t)lo; + file_lock->fl_core.fl_pid = current->tgid; + file_lock->fl_core.fl_flags = FL_POSIX; file_lock->fl_start = lockt->lt_offset; file_lock->fl_end = last_byte_offset(lockt->lt_offset, lockt->lt_length); @@ -7811,7 +7812,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, if (status) goto out; - if (file_lock->fl_type != F_UNLCK) { + if (file_lock->fl_core.fl_type != F_UNLCK) { status = nfserr_denied; nfs4_set_lock_denied(file_lock, &lockt->lt_denied); } @@ -7867,11 +7868,11 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, goto put_file; } - file_lock->fl_type = F_UNLCK; - file_lock->fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); - file_lock->fl_pid = current->tgid; - file_lock->fl_file = nf->nf_file; - file_lock->fl_flags = FL_POSIX; + file_lock->fl_core.fl_type = F_UNLCK; + file_lock->fl_core.fl_owner = (fl_owner_t)lockowner(nfs4_get_stateowner(stp->st_stateowner)); + file_lock->fl_core.fl_pid = current->tgid; + file_lock->fl_core.fl_file = nf->nf_file; + file_lock->fl_core.fl_flags = FL_POSIX; file_lock->fl_lmops = &nfsd_posix_mng_ops; file_lock->fl_start = locku->lu_offset; @@ -7927,7 +7928,7 @@ check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner) if (flctx && !list_empty_careful(&flctx->flc_posix)) { spin_lock(&flctx->flc_lock); list_for_each_entry(fl, &flctx->flc_posix, fl_list) { - if (fl->fl_owner == (fl_owner_t)lowner) { + if (fl->fl_core.fl_owner == (fl_owner_t)lowner) { status = true; break; } @@ -8456,7 +8457,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) return 0; spin_lock(&ctx->flc_lock); list_for_each_entry(fl, &ctx->flc_lease, fl_list) { - if (fl->fl_flags == FL_LAYOUT) + if (fl->fl_core.fl_flags == FL_LAYOUT) continue; if (fl->fl_lmops != &nfsd_lease_mng_ops) { /* @@ -8464,12 +8465,12 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) * we are done; there isn't any write delegation * on this inode */ - if (fl->fl_type == F_RDLCK) + if (fl->fl_core.fl_type == F_RDLCK) break; goto break_lease; } - if (fl->fl_type == F_WRLCK) { - dp = fl->fl_owner; + if (fl->fl_core.fl_type == F_WRLCK) { + dp = fl->fl_core.fl_owner; if (dp->dl_recall.cb_clp == *(rqstp->rq_lease_breaker)) { spin_unlock(&ctx->flc_lock); return 0; diff --git a/fs/ocfs2/locks.c b/fs/ocfs2/locks.c index f37174e79fad..30f7af75d18d 100644 --- a/fs/ocfs2/locks.c +++ b/fs/ocfs2/locks.c @@ -27,7 +27,7 @@ static int ocfs2_do_flock(struct file *file, struct inode *inode, struct ocfs2_file_private *fp = file->private_data; struct ocfs2_lock_res *lockres = &fp->fp_flock; - if (fl->fl_type == F_WRLCK) + if (fl->fl_core.fl_type == F_WRLCK) level = 1; if (!IS_SETLKW(cmd)) trylock = 1; @@ -53,8 +53,8 @@ static int ocfs2_do_flock(struct file *file, struct inode *inode, */ locks_init_lock(&request); - request.fl_type = F_UNLCK; - request.fl_flags = FL_FLOCK; + request.fl_core.fl_type = F_UNLCK; + request.fl_core.fl_flags = FL_FLOCK; locks_lock_file_wait(file, &request); ocfs2_file_unlock(file); @@ -100,14 +100,14 @@ int ocfs2_flock(struct file *file, int cmd, struct file_lock *fl) struct inode *inode = file->f_mapping->host; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); - if (!(fl->fl_flags & FL_FLOCK)) + if (!(fl->fl_core.fl_flags & FL_FLOCK)) return -ENOLCK; if ((osb->s_mount_opt & OCFS2_MOUNT_LOCALFLOCKS) || ocfs2_mount_local(osb)) return locks_lock_file_wait(file, fl); - if (fl->fl_type == F_UNLCK) + if (fl->fl_core.fl_type == F_UNLCK) return ocfs2_do_funlock(file, cmd, fl); else return ocfs2_do_flock(file, inode, cmd, fl); @@ -118,7 +118,7 @@ int ocfs2_lock(struct file *file, int cmd, struct file_lock *fl) struct inode *inode = file->f_mapping->host; struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); - if (!(fl->fl_flags & FL_POSIX)) + if (!(fl->fl_core.fl_flags & FL_POSIX)) return -ENOLCK; return ocfs2_plock(osb->cconn, OCFS2_I(inode)->ip_blkno, file, cmd, fl); diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index 9b76ee66aeb2..c66a688dea96 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c @@ -744,7 +744,7 @@ static int user_plock(struct ocfs2_cluster_connection *conn, return dlm_posix_cancel(conn->cc_lockspace, ino, file, fl); else if (IS_GETLK(cmd)) return dlm_posix_get(conn->cc_lockspace, ino, file, fl); - else if (fl->fl_type == F_UNLCK) + else if (fl->fl_core.fl_type == F_UNLCK) return dlm_posix_unlock(conn->cc_lockspace, ino, file, fl); else return dlm_posix_lock(conn->cc_lockspace, ino, file, cmd, fl); diff --git a/fs/smb/client/cifssmb.c b/fs/smb/client/cifssmb.c index 01e89070df5a..7140c2baa652 100644 --- a/fs/smb/client/cifssmb.c +++ b/fs/smb/client/cifssmb.c @@ -2066,20 +2066,20 @@ CIFSSMBPosixLock(const unsigned int xid, struct cifs_tcon *tcon, parm_data = (struct cifs_posix_lock *) ((char *)&pSMBr->hdr.Protocol + data_offset); if (parm_data->lock_type == cpu_to_le16(CIFS_UNLCK)) - pLockData->fl_type = F_UNLCK; + pLockData->fl_core.fl_type = F_UNLCK; else { if (parm_data->lock_type == cpu_to_le16(CIFS_RDLCK)) - pLockData->fl_type = F_RDLCK; + pLockData->fl_core.fl_type = F_RDLCK; else if (parm_data->lock_type == cpu_to_le16(CIFS_WRLCK)) - pLockData->fl_type = F_WRLCK; + pLockData->fl_core.fl_type = F_WRLCK; pLockData->fl_start = le64_to_cpu(parm_data->start); pLockData->fl_end = pLockData->fl_start + (le64_to_cpu(parm_data->length) ? le64_to_cpu(parm_data->length) - 1 : 0); - pLockData->fl_pid = -le32_to_cpu(parm_data->pid); + pLockData->fl_core.fl_pid = -le32_to_cpu(parm_data->pid); } } diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 1b4262aff8fa..1305183842fd 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -1312,20 +1312,20 @@ cifs_lock_test(struct cifsFileInfo *cfile, __u64 offset, __u64 length, down_read(&cinode->lock_sem); exist = cifs_find_lock_conflict(cfile, offset, length, type, - flock->fl_flags, &conf_lock, + flock->fl_core.fl_flags, &conf_lock, CIFS_LOCK_OP); if (exist) { flock->fl_start = conf_lock->offset; flock->fl_end = conf_lock->offset + conf_lock->length - 1; - flock->fl_pid = conf_lock->pid; + flock->fl_core.fl_pid = conf_lock->pid; if (conf_lock->type & server->vals->shared_lock_type) - flock->fl_type = F_RDLCK; + flock->fl_core.fl_type = F_RDLCK; else - flock->fl_type = F_WRLCK; + flock->fl_core.fl_type = F_WRLCK; } else if (!cinode->can_cache_brlcks) rc = 1; else - flock->fl_type = F_UNLCK; + flock->fl_core.fl_type = F_UNLCK; up_read(&cinode->lock_sem); return rc; @@ -1401,16 +1401,16 @@ cifs_posix_lock_test(struct file *file, struct file_lock *flock) { int rc = 0; struct cifsInodeInfo *cinode = CIFS_I(file_inode(file)); - unsigned char saved_type = flock->fl_type; + unsigned char saved_type = flock->fl_core.fl_type; - if ((flock->fl_flags & FL_POSIX) == 0) + if ((flock->fl_core.fl_flags & FL_POSIX) == 0) return 1; down_read(&cinode->lock_sem); posix_test_lock(file, flock); - if (flock->fl_type == F_UNLCK && !cinode->can_cache_brlcks) { - flock->fl_type = saved_type; + if (flock->fl_core.fl_type == F_UNLCK && !cinode->can_cache_brlcks) { + flock->fl_core.fl_type = saved_type; rc = 1; } @@ -1431,7 +1431,7 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock) struct cifsInodeInfo *cinode = CIFS_I(file_inode(file)); int rc = FILE_LOCK_DEFERRED + 1; - if ((flock->fl_flags & FL_POSIX) == 0) + if ((flock->fl_core.fl_flags & FL_POSIX) == 0) return rc; cifs_down_write(&cinode->lock_sem); @@ -1591,12 +1591,12 @@ 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 (flock->fl_core.fl_type == F_RDLCK || flock->fl_core.fl_type == F_SHLCK) type = CIFS_RDLCK; else type = CIFS_WRLCK; lck = list_entry(el, struct lock_to_push, llist); - lck->pid = hash_lockowner(flock->fl_owner); + lck->pid = hash_lockowner(flock->fl_core.fl_owner); lck->netfid = cfile->fid.netfid; lck->length = length; lck->type = type; @@ -1663,42 +1663,43 @@ static void cifs_read_flock(struct file_lock *flock, __u32 *type, int *lock, int *unlock, bool *wait_flag, struct TCP_Server_Info *server) { - if (flock->fl_flags & FL_POSIX) + if (flock->fl_core.fl_flags & FL_POSIX) cifs_dbg(FYI, "Posix\n"); - if (flock->fl_flags & FL_FLOCK) + if (flock->fl_core.fl_flags & FL_FLOCK) cifs_dbg(FYI, "Flock\n"); - if (flock->fl_flags & FL_SLEEP) { + if (flock->fl_core.fl_flags & FL_SLEEP) { cifs_dbg(FYI, "Blocking lock\n"); *wait_flag = true; } - if (flock->fl_flags & FL_ACCESS) + if (flock->fl_core.fl_flags & FL_ACCESS) cifs_dbg(FYI, "Process suspended by mandatory locking - not implemented yet\n"); - if (flock->fl_flags & FL_LEASE) + if (flock->fl_core.fl_flags & FL_LEASE) cifs_dbg(FYI, "Lease on file - not implemented yet\n"); - if (flock->fl_flags & + if (flock->fl_core.fl_flags & (~(FL_POSIX | FL_FLOCK | FL_SLEEP | FL_ACCESS | FL_LEASE | FL_CLOSE | FL_OFDLCK))) - cifs_dbg(FYI, "Unknown lock flags 0x%x\n", flock->fl_flags); + cifs_dbg(FYI, "Unknown lock flags 0x%x\n", + flock->fl_core.fl_flags); *type = server->vals->large_lock_type; - if (flock->fl_type == F_WRLCK) { + if (flock->fl_core.fl_type == F_WRLCK) { cifs_dbg(FYI, "F_WRLCK\n"); *type |= server->vals->exclusive_lock_type; *lock = 1; - } else if (flock->fl_type == F_UNLCK) { + } else if (flock->fl_core.fl_type == F_UNLCK) { 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 (flock->fl_core.fl_type == F_RDLCK) { cifs_dbg(FYI, "F_RDLCK\n"); *type |= server->vals->shared_lock_type; *lock = 1; - } else if (flock->fl_type == F_EXLCK) { + } else if (flock->fl_core.fl_type == F_EXLCK) { cifs_dbg(FYI, "F_EXLCK\n"); *type |= server->vals->exclusive_lock_type; *lock = 1; - } else if (flock->fl_type == F_SHLCK) { + } else if (flock->fl_core.fl_type == F_SHLCK) { cifs_dbg(FYI, "F_SHLCK\n"); *type |= server->vals->shared_lock_type; *lock = 1; @@ -1730,7 +1731,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, else posix_lock_type = CIFS_WRLCK; rc = CIFSSMBPosixLock(xid, tcon, netfid, - hash_lockowner(flock->fl_owner), + hash_lockowner(flock->fl_core.fl_owner), flock->fl_start, length, flock, posix_lock_type, wait_flag); return rc; @@ -1747,7 +1748,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, if (rc == 0) { rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type, 0, 1, false); - flock->fl_type = F_UNLCK; + flock->fl_core.fl_type = F_UNLCK; if (rc != 0) cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n", rc); @@ -1755,7 +1756,7 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, } if (type & server->vals->shared_lock_type) { - flock->fl_type = F_WRLCK; + flock->fl_core.fl_type = F_WRLCK; return 0; } @@ -1767,12 +1768,12 @@ cifs_getlk(struct file *file, struct file_lock *flock, __u32 type, if (rc == 0) { rc = server->ops->mand_lock(xid, cfile, flock->fl_start, length, type | server->vals->shared_lock_type, 0, 1, false); - flock->fl_type = F_RDLCK; + flock->fl_core.fl_type = F_RDLCK; if (rc != 0) cifs_dbg(VFS, "Error unlocking previously locked range %d during test of lock\n", rc); } else - flock->fl_type = F_WRLCK; + flock->fl_core.fl_type = F_WRLCK; return 0; } @@ -1940,7 +1941,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, posix_lock_type = CIFS_UNLCK; rc = CIFSSMBPosixLock(xid, tcon, cfile->fid.netfid, - hash_lockowner(flock->fl_owner), + hash_lockowner(flock->fl_core.fl_owner), flock->fl_start, length, NULL, posix_lock_type, wait_flag); goto out; @@ -1950,7 +1951,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, struct cifsLockInfo *lock; lock = cifs_lock_init(flock->fl_start, length, type, - flock->fl_flags); + flock->fl_core.fl_flags); if (!lock) return -ENOMEM; @@ -1989,7 +1990,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, rc = server->ops->mand_unlock_range(cfile, flock, xid); out: - if ((flock->fl_flags & FL_POSIX) || (flock->fl_flags & FL_FLOCK)) { + if ((flock->fl_core.fl_flags & FL_POSIX) || (flock->fl_core.fl_flags & FL_FLOCK)) { /* * If this is a request to remove all locks because we * are closing the file, it doesn't matter if the @@ -1998,7 +1999,7 @@ cifs_setlk(struct file *file, struct file_lock *flock, __u32 type, */ if (rc) { cifs_dbg(VFS, "%s failed rc=%d\n", __func__, rc); - if (!(flock->fl_flags & FL_CLOSE)) + if (!(flock->fl_core.fl_flags & FL_CLOSE)) return rc; } rc = locks_lock_file_wait(file, flock); @@ -2019,7 +2020,7 @@ int cifs_flock(struct file *file, int cmd, struct file_lock *fl) xid = get_xid(); - if (!(fl->fl_flags & FL_FLOCK)) { + if (!(fl->fl_core.fl_flags & FL_FLOCK)) { rc = -ENOLCK; free_xid(xid); return rc; @@ -2070,7 +2071,8 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock) xid = get_xid(); cifs_dbg(FYI, "%s: %pD2 cmd=0x%x type=0x%x flags=0x%x r=%lld:%lld\n", __func__, file, cmd, - flock->fl_flags, flock->fl_type, (long long)flock->fl_start, + flock->fl_core.fl_flags, flock->fl_core.fl_type, + (long long)flock->fl_start, (long long)flock->fl_end); cfile = (struct cifsFileInfo *)file->private_data; diff --git a/fs/smb/client/smb2file.c b/fs/smb/client/smb2file.c index e0ee96d69d49..39262617f551 100644 --- a/fs/smb/client/smb2file.c +++ b/fs/smb/client/smb2file.c @@ -228,7 +228,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock, * flock and OFD lock are associated with an open * file description, not the process. */ - if (!(flock->fl_flags & (FL_FLOCK | FL_OFDLCK))) + if (!(flock->fl_core.fl_flags & (FL_FLOCK | FL_OFDLCK))) continue; if (cinode->can_cache_brlcks) { /* diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 3143819935dc..439f68cee402 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -6748,10 +6748,10 @@ struct file_lock *smb_flock_init(struct file *f) locks_init_lock(fl); - fl->fl_owner = f; - fl->fl_pid = current->tgid; - fl->fl_file = f; - fl->fl_flags = FL_POSIX; + fl->fl_core.fl_owner = f; + fl->fl_core.fl_pid = current->tgid; + fl->fl_core.fl_file = f; + fl->fl_core.fl_flags = FL_POSIX; fl->fl_ops = NULL; fl->fl_lmops = NULL; @@ -6768,30 +6768,30 @@ static int smb2_set_flock_flags(struct file_lock *flock, int flags) case SMB2_LOCKFLAG_SHARED: ksmbd_debug(SMB, "received shared request\n"); cmd = F_SETLKW; - flock->fl_type = F_RDLCK; - flock->fl_flags |= FL_SLEEP; + flock->fl_core.fl_type = F_RDLCK; + flock->fl_core.fl_flags |= FL_SLEEP; break; case SMB2_LOCKFLAG_EXCLUSIVE: ksmbd_debug(SMB, "received exclusive request\n"); cmd = F_SETLKW; - flock->fl_type = F_WRLCK; - flock->fl_flags |= FL_SLEEP; + flock->fl_core.fl_type = F_WRLCK; + flock->fl_core.fl_flags |= FL_SLEEP; break; case SMB2_LOCKFLAG_SHARED | SMB2_LOCKFLAG_FAIL_IMMEDIATELY: ksmbd_debug(SMB, "received shared & fail immediately request\n"); cmd = F_SETLK; - flock->fl_type = F_RDLCK; + flock->fl_core.fl_type = F_RDLCK; break; case SMB2_LOCKFLAG_EXCLUSIVE | SMB2_LOCKFLAG_FAIL_IMMEDIATELY: ksmbd_debug(SMB, "received exclusive & fail immediately request\n"); cmd = F_SETLK; - flock->fl_type = F_WRLCK; + flock->fl_core.fl_type = F_WRLCK; break; case SMB2_LOCKFLAG_UNLOCK: ksmbd_debug(SMB, "received unlock request\n"); - flock->fl_type = F_UNLCK; + flock->fl_core.fl_type = F_UNLCK; cmd = F_SETLK; break; } @@ -6829,13 +6829,13 @@ static void smb2_remove_blocked_lock(void **argv) struct file_lock *flock = (struct file_lock *)argv[0]; ksmbd_vfs_posix_lock_unblock(flock); - wake_up(&flock->fl_wait); + wake_up(&flock->fl_core.fl_wait); } static inline bool lock_defer_pending(struct file_lock *fl) { /* check pending lock waiters */ - return waitqueue_active(&fl->fl_wait); + return waitqueue_active(&fl->fl_core.fl_wait); } /** @@ -6926,8 +6926,8 @@ int smb2_lock(struct ksmbd_work *work) list_for_each_entry(cmp_lock, &lock_list, llist) { if (cmp_lock->fl->fl_start <= flock->fl_start && cmp_lock->fl->fl_end >= flock->fl_end) { - if (cmp_lock->fl->fl_type != F_UNLCK && - flock->fl_type != F_UNLCK) { + if (cmp_lock->fl->fl_core.fl_type != F_UNLCK && + flock->fl_core.fl_type != F_UNLCK) { pr_err("conflict two locks in one request\n"); err = -EINVAL; locks_free_lock(flock); @@ -6975,12 +6975,12 @@ int smb2_lock(struct ksmbd_work *work) list_for_each_entry(conn, &conn_list, conns_list) { spin_lock(&conn->llist_lock); list_for_each_entry_safe(cmp_lock, tmp2, &conn->lock_list, clist) { - if (file_inode(cmp_lock->fl->fl_file) != - file_inode(smb_lock->fl->fl_file)) + if (file_inode(cmp_lock->fl->fl_core.fl_file) != + file_inode(smb_lock->fl->fl_core.fl_file)) continue; - if (smb_lock->fl->fl_type == F_UNLCK) { - if (cmp_lock->fl->fl_file == smb_lock->fl->fl_file && + if (smb_lock->fl->fl_core.fl_type == F_UNLCK) { + if (cmp_lock->fl->fl_core.fl_file == smb_lock->fl->fl_core.fl_file && cmp_lock->start == smb_lock->start && cmp_lock->end == smb_lock->end && !lock_defer_pending(cmp_lock->fl)) { @@ -6997,7 +6997,7 @@ int smb2_lock(struct ksmbd_work *work) continue; } - if (cmp_lock->fl->fl_file == smb_lock->fl->fl_file) { + if (cmp_lock->fl->fl_core.fl_file == smb_lock->fl->fl_core.fl_file) { if (smb_lock->flags & SMB2_LOCKFLAG_SHARED) continue; } else { @@ -7039,7 +7039,7 @@ int smb2_lock(struct ksmbd_work *work) } up_read(&conn_list_lock); out_check_cl: - if (smb_lock->fl->fl_type == F_UNLCK && nolock) { + if (smb_lock->fl->fl_core.fl_type == F_UNLCK && nolock) { pr_err("Try to unlock nolocked range\n"); rsp->hdr.Status = STATUS_RANGE_NOT_LOCKED; goto out; @@ -7163,7 +7163,7 @@ int smb2_lock(struct ksmbd_work *work) struct file_lock *rlock = NULL; rlock = smb_flock_init(filp); - rlock->fl_type = F_UNLCK; + rlock->fl_core.fl_type = F_UNLCK; rlock->fl_start = smb_lock->start; rlock->fl_end = smb_lock->end; diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c index a6961bfe3e13..f7bb6f19492b 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -340,15 +340,15 @@ static int check_lock_range(struct file *filp, loff_t start, loff_t end, list_for_each_entry(flock, &ctx->flc_posix, fl_list) { /* check conflict locks */ if (flock->fl_end >= start && end >= flock->fl_start) { - if (flock->fl_type == F_RDLCK) { + if (flock->fl_core.fl_type == F_RDLCK) { if (type == WRITE) { pr_err("not allow write by shared lock\n"); error = 1; goto out; } - } else if (flock->fl_type == F_WRLCK) { + } else if (flock->fl_core.fl_type == F_WRLCK) { /* check owner in lock */ - if (flock->fl_file != filp) { + if (flock->fl_core.fl_file != filp) { error = 1; pr_err("not allow rw access by exclusive lock from other opens\n"); goto out; @@ -1837,13 +1837,13 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work, void ksmbd_vfs_posix_lock_wait(struct file_lock *flock) { - wait_event(flock->fl_wait, !flock->fl_blocker); + wait_event(flock->fl_core.fl_wait, !flock->fl_core.fl_blocker); } int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout) { - return wait_event_interruptible_timeout(flock->fl_wait, - !flock->fl_blocker, + return wait_event_interruptible_timeout(flock->fl_core.fl_wait, + !flock->fl_core.fl_blocker, timeout); } diff --git a/include/linux/lockd/lockd.h b/include/linux/lockd/lockd.h index 9f565416d186..c4b9faa261f7 100644 --- a/include/linux/lockd/lockd.h +++ b/include/linux/lockd/lockd.h @@ -375,12 +375,12 @@ static inline int nlm_privileged_requester(const struct svc_rqst *rqstp) static inline int nlm_compare_locks(const struct file_lock *fl1, const struct file_lock *fl2) { - return file_inode(fl1->fl_file) == file_inode(fl2->fl_file) - && fl1->fl_pid == fl2->fl_pid - && fl1->fl_owner == fl2->fl_owner + return file_inode(fl1->fl_core.fl_file) == file_inode(fl2->fl_core.fl_file) + && fl1->fl_core.fl_pid == fl2->fl_core.fl_pid + && fl1->fl_core.fl_owner == fl2->fl_core.fl_owner && fl1->fl_start == fl2->fl_start && fl1->fl_end == fl2->fl_end - &&(fl1->fl_type == fl2->fl_type || fl2->fl_type == F_UNLCK); + &&(fl1->fl_core.fl_type == fl2->fl_core.fl_type || fl2->fl_core.fl_type == F_UNLCK); } extern const struct lock_manager_operations nlmsvc_lock_operations; From patchwork Tue Jan 16 19:46:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521097 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 316E577638; Tue, 16 Jan 2024 19:47:02 +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=1705434423; cv=none; b=TR1HtH3PwLzj38MVjqgxN3cgiXkVCV9kUG77sn5KWwU80mzhHmqvdjeGc+dfbOamS7aKgLrFzqK8cIHxQ5/nry0tMrHuaAEJjjSJR1EybxomhaNjYEtcOm+75Gf/u+pOnui0QHQYtMO25ZH70h1hKN78FdtLPU/RJ8IqGMc4RPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434423; c=relaxed/simple; bh=sNgqF4g3YkfoRNDeTqn9koZ5jWcSEtfwfxCLcnzjt9A=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=s3W7ml2DPsq7DzTlAU29nKhtJM2ivx1pAjphLLZXV28cs+3+beHzamdH34AkLGxlZgNlkWpmWn882DWxe2dLRUglo3wSrD2nwQpJyKMOPQNWauJxL5GxY9iVydLYFsTMXxdYjKKwEFW8Bw4WNL0tR3zCUMCWDZqmGmdJb2UM1Kg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UXwWGUVN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UXwWGUVN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 114B1C43142; Tue, 16 Jan 2024 19:46:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434422; bh=sNgqF4g3YkfoRNDeTqn9koZ5jWcSEtfwfxCLcnzjt9A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UXwWGUVNLOyImBi0FwLHW/af8BuSJv1rz7Rmtr6qrI+NacZ7B8xX8sOV9XNaZbHuR 1AcIzdTy9jBSzTqnRlwlu41UzwdSAhIY+iXdB703ICxG3uEGAud+2A3if464k3IhTU JBxMAd7nwTp8ma2o8s50j6GG9wYiwKT4mkclH7nWm19VB8zAxYuOKWXl8os7W+SE4a GAHbcECajDB/aTB+gFQTykB0/T9P8BQ7MTFS7Sl8/2oMc4aREyfNdwf+KFjNl4OPWP 3h9V8A5xLDnD8BcpkoNb7ZsxUoQ60mOzfS3atHc857MMvZ4kgOIYdmlf3D317Hhl+0 7uk/bL8h/h97A== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:00 -0500 Subject: [PATCH 04/20] filelock: fixups after the coccinelle changes Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-4-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=38946; i=jlayton@kernel.org; h=from:subject:message-id; bh=sNgqF4g3YkfoRNDeTqn9koZ5jWcSEtfwfxCLcnzjt9A=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0gpBf4It/+V2rYmGOh2ir8HoKcSwmbdR1q5 jnSMPw0hXqJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIAAKCRAADmhBGVaC FQvAEADCgtHOozUXGOG5N2es6Qe/qzhVNiQOSWtMJxZcse7A9rPs4E1E/63QSZW+6lLgNp5Vhiv B15honhTrDA1OmwjhTx4R450ntsd2nnxcjkDSMApkW3GvKE35Pya/jFEifSRYolwtvOv4j4U822 pMLxtuYRPkpLCU0eRGgDNpeQ/NmLuVNyGs+laopzq3g7JeOqSLJ4Vxabz50iK6de0yLIXI1bwyW zFPllupxo/M9QOoSD5Je2XkL3kiQSWiXuUOGFh2tdrFv1S9Nd9Fi8fIvJT4KaC9F8OZGg0ymMWt wj0og9Hk3UldQctvQtHdsEsg4frH/GhKeZCvXUec41fhCkaFRalyb32lEzzQKB0ygvoZhWZLzQ5 7YSfPU6HOpnjufjI1TOI+sGFplnK3SnT1Pl5cHUzAZefypAIotOiFuyVmqVn6dwIgXebZLToyG9 aEVySSISURDoP8ctYDMKq8rbbUXqU8XDepr6DIMONs/0knZ3wNQiHaQw40bM+ai7KK7gGfK/Ioy ekK91j/jH1f1xPGuXFZnqBT4apkyNjctX10zzZLyYewzg2YxyNqOwj3fBViatZDkdN8cgQ429wr 3RMQKMjdTXZpqNx4F8Oy+78Ix4rE62kUo+fKfHyTzcnwGMmqqHg2Ejm1sY3b67O/qaavSXr1uwp FbtfdeOJFsogPqg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 The coccinelle script doesn't catch quite everythng (particularly with embedded structs). These are some by-hand fixups after the split of common fields into struct file_lock_core. Signed-off-by: Jeff Layton Acked-by: Chuck Lever --- fs/ceph/locks.c | 8 ++--- fs/lockd/clnt4xdr.c | 8 ++--- fs/lockd/clntproc.c | 6 ++-- fs/lockd/clntxdr.c | 8 ++--- fs/lockd/svc4proc.c | 10 +++--- fs/lockd/svclock.c | 54 +++++++++++++++++---------------- fs/lockd/svcproc.c | 10 +++--- fs/lockd/svcsubs.c | 4 +-- fs/lockd/xdr.c | 8 ++--- fs/lockd/xdr4.c | 8 ++--- fs/locks.c | 67 +++++++++++++++++++++-------------------- fs/nfs/delegation.c | 2 +- fs/nfs/nfs4state.c | 2 +- fs/nfs/nfs4trace.h | 4 +-- fs/nfs/write.c | 4 +-- fs/nfsd/nfs4callback.c | 2 +- fs/nfsd/nfs4state.c | 4 +-- fs/smb/client/file.c | 2 +- fs/smb/server/vfs.c | 2 +- include/trace/events/afs.h | 4 +-- include/trace/events/filelock.h | 32 ++++++++++---------- 21 files changed, 126 insertions(+), 123 deletions(-) diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c index ee12f9864980..55be5d231e38 100644 --- a/fs/ceph/locks.c +++ b/fs/ceph/locks.c @@ -386,9 +386,9 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count) ctx = locks_inode_context(inode); if (ctx) { spin_lock(&ctx->flc_lock); - list_for_each_entry(lock, &ctx->flc_posix, fl_list) + list_for_each_entry(lock, &ctx->flc_posix, fl_core.fl_list) ++(*fcntl_count); - list_for_each_entry(lock, &ctx->flc_flock, fl_list) + list_for_each_entry(lock, &ctx->flc_flock, fl_core.fl_list) ++(*flock_count); spin_unlock(&ctx->flc_lock); } @@ -455,7 +455,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, return 0; spin_lock(&ctx->flc_lock); - list_for_each_entry(lock, &ctx->flc_posix, fl_list) { + list_for_each_entry(lock, &ctx->flc_posix, fl_core.fl_list) { ++seen_fcntl; if (seen_fcntl > num_fcntl_locks) { err = -ENOSPC; @@ -466,7 +466,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, goto fail; ++l; } - list_for_each_entry(lock, &ctx->flc_flock, fl_list) { + list_for_each_entry(lock, &ctx->flc_flock, fl_core.fl_list) { ++seen_flock; if (seen_flock > num_flock_locks) { err = -ENOSPC; diff --git a/fs/lockd/clnt4xdr.c b/fs/lockd/clnt4xdr.c index ed00bd2869a7..083a3b1bf288 100644 --- a/fs/lockd/clnt4xdr.c +++ b/fs/lockd/clnt4xdr.c @@ -243,7 +243,7 @@ static void encode_nlm4_holder(struct xdr_stream *xdr, u64 l_offset, l_len; __be32 *p; - encode_bool(xdr, lock->fl.fl_type == F_RDLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_RDLCK); encode_int32(xdr, lock->svid); encode_netobj(xdr, lock->oh.data, lock->oh.len); @@ -357,7 +357,7 @@ static void nlm4_xdr_enc_testargs(struct rpc_rqst *req, const struct nlm_lock *lock = &args->lock; encode_cookie(xdr, &args->cookie); - encode_bool(xdr, lock->fl.fl_type == F_WRLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_WRLCK); encode_nlm4_lock(xdr, lock); } @@ -380,7 +380,7 @@ static void nlm4_xdr_enc_lockargs(struct rpc_rqst *req, encode_cookie(xdr, &args->cookie); encode_bool(xdr, args->block); - encode_bool(xdr, lock->fl.fl_type == F_WRLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_WRLCK); encode_nlm4_lock(xdr, lock); encode_bool(xdr, args->reclaim); encode_int32(xdr, args->state); @@ -403,7 +403,7 @@ static void nlm4_xdr_enc_cancargs(struct rpc_rqst *req, encode_cookie(xdr, &args->cookie); encode_bool(xdr, args->block); - encode_bool(xdr, lock->fl.fl_type == F_WRLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_WRLCK); encode_nlm4_lock(xdr, lock); } diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index ac1d07034346..15461e8952b4 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -143,7 +143,7 @@ static void nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) lock->svid = fl->fl_u.nfs_fl.owner->pid; lock->fl.fl_start = fl->fl_start; lock->fl.fl_end = fl->fl_end; - lock->fl.fl_type = fl->fl_core.fl_type; + lock->fl.fl_core.fl_type = fl->fl_core.fl_type; } static void nlmclnt_release_lockargs(struct nlm_rqst *req) @@ -448,8 +448,8 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) */ fl->fl_start = req->a_res.lock.fl.fl_start; fl->fl_end = req->a_res.lock.fl.fl_end; - fl->fl_core.fl_type = req->a_res.lock.fl.fl_type; - fl->fl_core.fl_pid = -req->a_res.lock.fl.fl_pid; + fl->fl_core.fl_type = req->a_res.lock.fl.fl_core.fl_type; + fl->fl_core.fl_pid = -req->a_res.lock.fl.fl_core.fl_pid; break; default: status = nlm_stat_to_errno(req->a_res.status); diff --git a/fs/lockd/clntxdr.c b/fs/lockd/clntxdr.c index b0b87a00cd81..6823e2d3bf75 100644 --- a/fs/lockd/clntxdr.c +++ b/fs/lockd/clntxdr.c @@ -238,7 +238,7 @@ static void encode_nlm_holder(struct xdr_stream *xdr, u32 l_offset, l_len; __be32 *p; - encode_bool(xdr, lock->fl.fl_type == F_RDLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_RDLCK); encode_int32(xdr, lock->svid); encode_netobj(xdr, lock->oh.data, lock->oh.len); @@ -357,7 +357,7 @@ static void nlm_xdr_enc_testargs(struct rpc_rqst *req, const struct nlm_lock *lock = &args->lock; encode_cookie(xdr, &args->cookie); - encode_bool(xdr, lock->fl.fl_type == F_WRLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_WRLCK); encode_nlm_lock(xdr, lock); } @@ -380,7 +380,7 @@ static void nlm_xdr_enc_lockargs(struct rpc_rqst *req, encode_cookie(xdr, &args->cookie); encode_bool(xdr, args->block); - encode_bool(xdr, lock->fl.fl_type == F_WRLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_WRLCK); encode_nlm_lock(xdr, lock); encode_bool(xdr, args->reclaim); encode_int32(xdr, args->state); @@ -403,7 +403,7 @@ static void nlm_xdr_enc_cancargs(struct rpc_rqst *req, encode_cookie(xdr, &args->cookie); encode_bool(xdr, args->block); - encode_bool(xdr, lock->fl.fl_type == F_WRLCK); + encode_bool(xdr, lock->fl.fl_core.fl_type == F_WRLCK); encode_nlm_lock(xdr, lock); } diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index b72023a6b4c1..fc98c3c74da8 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -52,16 +52,16 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, *filp = file; /* Set up the missing parts of the file_lock structure */ - lock->fl.fl_flags = FL_POSIX; - lock->fl.fl_file = file->f_file[mode]; - lock->fl.fl_pid = current->tgid; + lock->fl.fl_core.fl_flags = FL_POSIX; + lock->fl.fl_core.fl_file = file->f_file[mode]; + lock->fl.fl_core.fl_pid = current->tgid; lock->fl.fl_start = (loff_t)lock->lock_start; lock->fl.fl_end = lock->lock_len ? (loff_t)(lock->lock_start + lock->lock_len - 1) : OFFSET_MAX; lock->fl.fl_lmops = &nlmsvc_lock_operations; nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid); - if (!lock->fl.fl_owner) { + if (!lock->fl.fl_core.fl_owner) { /* lockowner allocation has failed */ nlmsvc_release_host(host); return nlm_lck_denied_nolocks; @@ -106,7 +106,7 @@ __nlm4svc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp) if ((resp->status = nlm4svc_retrieve_args(rqstp, argp, &host, &file))) return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - test_owner = argp->lock.fl.fl_owner; + test_owner = argp->lock.fl.fl_core.fl_owner; /* Now check for conflicting locks */ resp->status = nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie); if (resp->status == nlm_drop_reply) diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index 520886a4b57e..59973f9d0406 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -150,9 +150,10 @@ nlmsvc_lookup_block(struct nlm_file *file, struct nlm_lock *lock) struct file_lock *fl; dprintk("lockd: nlmsvc_lookup_block f=%p pd=%d %Ld-%Ld ty=%d\n", - file, lock->fl.fl_pid, + file, lock->fl.fl_core.fl_pid, (long long)lock->fl.fl_start, - (long long)lock->fl.fl_end, lock->fl.fl_type); + (long long)lock->fl.fl_end, + lock->fl.fl_core.fl_type); spin_lock(&nlm_blocked_lock); list_for_each_entry(block, &nlm_blocked, b_list) { fl = &block->b_call->a_args.lock.fl; @@ -244,7 +245,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_host *host, goto failed_free; /* Set notifier function for VFS, and init args */ - call->a_args.lock.fl.fl_flags |= FL_SLEEP; + call->a_args.lock.fl.fl_core.fl_flags |= FL_SLEEP; call->a_args.lock.fl.fl_lmops = &nlmsvc_lock_operations; nlmclnt_next_cookie(&call->a_args.cookie); @@ -402,8 +403,8 @@ static struct nlm_lockowner *nlmsvc_find_lockowner(struct nlm_host *host, pid_t void nlmsvc_release_lockowner(struct nlm_lock *lock) { - if (lock->fl.fl_owner) - nlmsvc_put_lockowner(lock->fl.fl_owner); + if (lock->fl.fl_core.fl_owner) + nlmsvc_put_lockowner(lock->fl.fl_core.fl_owner); } void nlmsvc_locks_init_private(struct file_lock *fl, struct nlm_host *host, @@ -425,7 +426,7 @@ static int nlmsvc_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock) /* set default data area */ call->a_args.lock.oh.data = call->a_owner; - call->a_args.lock.svid = ((struct nlm_lockowner *)lock->fl.fl_owner)->pid; + call->a_args.lock.svid = ((struct nlm_lockowner *) lock->fl.fl_core.fl_owner)->pid; if (lock->oh.len > NLMCLNT_OHSIZE) { void *data = kmalloc(lock->oh.len, GFP_KERNEL); @@ -489,7 +490,8 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, dprintk("lockd: nlmsvc_lock(%s/%ld, ty=%d, pi=%d, %Ld-%Ld, bl=%d)\n", inode->i_sb->s_id, inode->i_ino, - lock->fl.fl_type, lock->fl.fl_pid, + lock->fl.fl_core.fl_type, + lock->fl.fl_core.fl_pid, (long long)lock->fl.fl_start, (long long)lock->fl.fl_end, wait); @@ -512,7 +514,7 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, goto out; lock = &block->b_call->a_args.lock; } else - lock->fl.fl_flags &= ~FL_SLEEP; + lock->fl.fl_core.fl_flags &= ~FL_SLEEP; if (block->b_flags & B_QUEUED) { dprintk("lockd: nlmsvc_lock deferred block %p flags %d\n", @@ -560,10 +562,10 @@ nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, spin_unlock(&nlm_blocked_lock); if (!wait) - lock->fl.fl_flags &= ~FL_SLEEP; + lock->fl.fl_core.fl_flags &= ~FL_SLEEP; mode = lock_to_openmode(&lock->fl); error = vfs_lock_file(file->f_file[mode], F_SETLK, &lock->fl, NULL); - lock->fl.fl_flags &= ~FL_SLEEP; + lock->fl.fl_core.fl_flags &= ~FL_SLEEP; dprintk("lockd: vfs_lock_file returned %d\n", error); switch (error) { @@ -616,7 +618,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, dprintk("lockd: nlmsvc_testlock(%s/%ld, ty=%d, %Ld-%Ld)\n", nlmsvc_file_inode(file)->i_sb->s_id, nlmsvc_file_inode(file)->i_ino, - lock->fl.fl_type, + lock->fl.fl_core.fl_type, (long long)lock->fl.fl_start, (long long)lock->fl.fl_end); @@ -636,19 +638,19 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file, goto out; } - if (lock->fl.fl_type == F_UNLCK) { + if (lock->fl.fl_core.fl_type == F_UNLCK) { ret = nlm_granted; goto out; } dprintk("lockd: conflicting lock(ty=%d, %Ld-%Ld)\n", - lock->fl.fl_type, (long long)lock->fl.fl_start, + lock->fl.fl_core.fl_type, (long long)lock->fl.fl_start, (long long)lock->fl.fl_end); conflock->caller = "somehost"; /* FIXME */ conflock->len = strlen(conflock->caller); conflock->oh.len = 0; /* don't return OH info */ - conflock->svid = lock->fl.fl_pid; - conflock->fl.fl_type = lock->fl.fl_type; + conflock->svid = lock->fl.fl_core.fl_pid; + conflock->fl.fl_core.fl_type = lock->fl.fl_core.fl_type; conflock->fl.fl_start = lock->fl.fl_start; conflock->fl.fl_end = lock->fl.fl_end; locks_release_private(&lock->fl); @@ -673,21 +675,21 @@ nlmsvc_unlock(struct net *net, struct nlm_file *file, struct nlm_lock *lock) dprintk("lockd: nlmsvc_unlock(%s/%ld, pi=%d, %Ld-%Ld)\n", nlmsvc_file_inode(file)->i_sb->s_id, nlmsvc_file_inode(file)->i_ino, - lock->fl.fl_pid, + lock->fl.fl_core.fl_pid, (long long)lock->fl.fl_start, (long long)lock->fl.fl_end); /* First, cancel any lock that might be there */ nlmsvc_cancel_blocked(net, file, lock); - lock->fl.fl_type = F_UNLCK; - lock->fl.fl_file = file->f_file[O_RDONLY]; - if (lock->fl.fl_file) - error = vfs_lock_file(lock->fl.fl_file, F_SETLK, + lock->fl.fl_core.fl_type = F_UNLCK; + lock->fl.fl_core.fl_file = file->f_file[O_RDONLY]; + if (lock->fl.fl_core.fl_file) + error = vfs_lock_file(lock->fl.fl_core.fl_file, F_SETLK, &lock->fl, NULL); - lock->fl.fl_file = file->f_file[O_WRONLY]; - if (lock->fl.fl_file) - error |= vfs_lock_file(lock->fl.fl_file, F_SETLK, + lock->fl.fl_core.fl_file = file->f_file[O_WRONLY]; + if (lock->fl.fl_core.fl_file) + error |= vfs_lock_file(lock->fl.fl_core.fl_file, F_SETLK, &lock->fl, NULL); return (error < 0)? nlm_lck_denied_nolocks : nlm_granted; @@ -710,7 +712,7 @@ nlmsvc_cancel_blocked(struct net *net, struct nlm_file *file, struct nlm_lock *l dprintk("lockd: nlmsvc_cancel(%s/%ld, pi=%d, %Ld-%Ld)\n", nlmsvc_file_inode(file)->i_sb->s_id, nlmsvc_file_inode(file)->i_ino, - lock->fl.fl_pid, + lock->fl.fl_core.fl_pid, (long long)lock->fl.fl_start, (long long)lock->fl.fl_end); @@ -863,12 +865,12 @@ nlmsvc_grant_blocked(struct nlm_block *block) /* vfs_lock_file() can mangle fl_start and fl_end, but we need * them unchanged for the GRANT_MSG */ - lock->fl.fl_flags |= FL_SLEEP; + lock->fl.fl_core.fl_flags |= FL_SLEEP; fl_start = lock->fl.fl_start; fl_end = lock->fl.fl_end; mode = lock_to_openmode(&lock->fl); error = vfs_lock_file(file->f_file[mode], F_SETLK, &lock->fl, NULL); - lock->fl.fl_flags &= ~FL_SLEEP; + lock->fl.fl_core.fl_flags &= ~FL_SLEEP; lock->fl.fl_start = fl_start; lock->fl.fl_end = fl_end; diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 32784f508c81..1809a1055e1e 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -77,12 +77,12 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp, /* Set up the missing parts of the file_lock structure */ mode = lock_to_openmode(&lock->fl); - lock->fl.fl_flags = FL_POSIX; - lock->fl.fl_file = file->f_file[mode]; - lock->fl.fl_pid = current->tgid; + lock->fl.fl_core.fl_flags = FL_POSIX; + lock->fl.fl_core.fl_file = file->f_file[mode]; + lock->fl.fl_core.fl_pid = current->tgid; lock->fl.fl_lmops = &nlmsvc_lock_operations; nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid); - if (!lock->fl.fl_owner) { + if (!lock->fl.fl_core.fl_owner) { /* lockowner allocation has failed */ nlmsvc_release_host(host); return nlm_lck_denied_nolocks; @@ -127,7 +127,7 @@ __nlmsvc_proc_test(struct svc_rqst *rqstp, struct nlm_res *resp) if ((resp->status = nlmsvc_retrieve_args(rqstp, argp, &host, &file))) return resp->status == nlm_drop_reply ? rpc_drop_reply :rpc_success; - test_owner = argp->lock.fl.fl_owner; + test_owner = argp->lock.fl.fl_core.fl_owner; /* Now check for conflicting locks */ resp->status = cast_status(nlmsvc_testlock(rqstp, file, host, &argp->lock, &resp->lock, &resp->cookie)); diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index 61b5c7ef8a12..f7e7ec6ac6df 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -218,7 +218,7 @@ nlm_traverse_locks(struct nlm_host *host, struct nlm_file *file, again: file->f_locks = 0; spin_lock(&flctx->flc_lock); - list_for_each_entry(fl, &flctx->flc_posix, fl_list) { + list_for_each_entry(fl, &flctx->flc_posix, fl_core.fl_list) { if (fl->fl_lmops != &nlmsvc_lock_operations) continue; @@ -272,7 +272,7 @@ nlm_file_inuse(struct nlm_file *file) if (flctx && !list_empty_careful(&flctx->flc_posix)) { spin_lock(&flctx->flc_lock); - list_for_each_entry(fl, &flctx->flc_posix, fl_list) { + list_for_each_entry(fl, &flctx->flc_posix, fl_core.fl_list) { if (fl->fl_lmops == &nlmsvc_lock_operations) { spin_unlock(&flctx->flc_lock); return 1; diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index 4a676a51eb6c..91611a909ad4 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c @@ -164,7 +164,7 @@ nlmsvc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; if (exclusive) - argp->lock.fl.fl_type = F_WRLCK; + argp->lock.fl.fl_core.fl_type = F_WRLCK; return true; } @@ -184,7 +184,7 @@ nlmsvc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; if (exclusive) - argp->lock.fl.fl_type = F_WRLCK; + argp->lock.fl.fl_core.fl_type = F_WRLCK; if (xdr_stream_decode_bool(xdr, &argp->reclaim) < 0) return false; if (xdr_stream_decode_u32(xdr, &argp->state) < 0) @@ -209,7 +209,7 @@ nlmsvc_decode_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; if (exclusive) - argp->lock.fl.fl_type = F_WRLCK; + argp->lock.fl.fl_core.fl_type = F_WRLCK; return true; } @@ -223,7 +223,7 @@ nlmsvc_decode_unlockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) return false; if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; - argp->lock.fl.fl_type = F_UNLCK; + argp->lock.fl.fl_core.fl_type = F_UNLCK; return true; } diff --git a/fs/lockd/xdr4.c b/fs/lockd/xdr4.c index 67e53f91717a..ba0206d28457 100644 --- a/fs/lockd/xdr4.c +++ b/fs/lockd/xdr4.c @@ -159,7 +159,7 @@ nlm4svc_decode_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; if (exclusive) - argp->lock.fl.fl_type = F_WRLCK; + argp->lock.fl.fl_core.fl_type = F_WRLCK; return true; } @@ -179,7 +179,7 @@ nlm4svc_decode_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; if (exclusive) - argp->lock.fl.fl_type = F_WRLCK; + argp->lock.fl.fl_core.fl_type = F_WRLCK; if (xdr_stream_decode_bool(xdr, &argp->reclaim) < 0) return false; if (xdr_stream_decode_u32(xdr, &argp->state) < 0) @@ -204,7 +204,7 @@ nlm4svc_decode_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; if (exclusive) - argp->lock.fl.fl_type = F_WRLCK; + argp->lock.fl.fl_core.fl_type = F_WRLCK; return true; } @@ -218,7 +218,7 @@ nlm4svc_decode_unlockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) return false; if (!svcxdr_decode_lock(xdr, &argp->lock)) return false; - argp->lock.fl.fl_type = F_UNLCK; + argp->lock.fl.fl_core.fl_type = F_UNLCK; return true; } diff --git a/fs/locks.c b/fs/locks.c index cd6ffa22a1ce..afe6e82a6207 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -70,11 +70,11 @@ #include -#define IS_POSIX(fl) (fl->fl_flags & FL_POSIX) -#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK) -#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) -#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK) -#define IS_REMOTELCK(fl) (fl->fl_pid <= 0) +#define IS_POSIX(fl) (fl->fl_core.fl_flags & FL_POSIX) +#define IS_FLOCK(fl) (fl->fl_core.fl_flags & FL_FLOCK) +#define IS_LEASE(fl) (fl->fl_core.fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) +#define IS_OFDLCK(fl) (fl->fl_core.fl_flags & FL_OFDLCK) +#define IS_REMOTELCK(fl) (fl->fl_core.fl_pid <= 0) static bool lease_breaking(struct file_lock *fl) { @@ -206,7 +206,7 @@ locks_dump_ctx_list(struct list_head *list, char *list_type) { struct file_lock *fl; - list_for_each_entry(fl, list, fl_list) { + list_for_each_entry(fl, list, fl_core.fl_list) { pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, fl->fl_core.fl_owner, fl->fl_core.fl_flags, fl->fl_core.fl_type, fl->fl_core.fl_pid); @@ -237,7 +237,7 @@ locks_check_ctx_file_list(struct file *filp, struct list_head *list, struct file_lock *fl; struct inode *inode = file_inode(filp); - list_for_each_entry(fl, list, fl_list) + list_for_each_entry(fl, list, fl_core.fl_list) if (fl->fl_core.fl_file == filp) pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx " " fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", @@ -318,7 +318,7 @@ bool locks_owner_has_blockers(struct file_lock_context *flctx, struct file_lock *fl; spin_lock(&flctx->flc_lock); - list_for_each_entry(fl, &flctx->flc_posix, fl_list) { + list_for_each_entry(fl, &flctx->flc_posix, fl_core.fl_list) { if (fl->fl_core.fl_owner != owner) continue; if (!list_empty(&fl->fl_core.fl_blocked_requests)) { @@ -345,7 +345,7 @@ locks_dispose_list(struct list_head *dispose) struct file_lock *fl; while (!list_empty(dispose)) { - fl = list_first_entry(dispose, struct file_lock, fl_list); + fl = list_first_entry(dispose, struct file_lock, fl_core.fl_list); list_del_init(&fl->fl_core.fl_list); locks_free_lock(fl); } @@ -412,7 +412,7 @@ static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) list_splice_init(&fl->fl_core.fl_blocked_requests, &new->fl_core.fl_blocked_requests); list_for_each_entry(f, &new->fl_core.fl_blocked_requests, - fl_blocked_member) + fl_core.fl_blocked_member) f->fl_core.fl_blocker = new; spin_unlock(&blocked_lock_lock); } @@ -675,7 +675,7 @@ static void __locks_wake_up_blocks(struct file_lock *blocker) struct file_lock *waiter; waiter = list_first_entry(&blocker->fl_core.fl_blocked_requests, - struct file_lock, fl_blocked_member); + struct file_lock, fl_core.fl_blocked_member); __locks_delete_block(waiter); if (waiter->fl_lmops && waiter->fl_lmops->lm_notify) waiter->fl_lmops->lm_notify(waiter); @@ -767,7 +767,7 @@ static void __locks_insert_block(struct file_lock *blocker, new_blocker: list_for_each_entry(fl, &blocker->fl_core.fl_blocked_requests, - fl_blocked_member) + fl_core.fl_blocked_member) if (conflict(fl, waiter)) { blocker = fl; goto new_blocker; @@ -922,7 +922,7 @@ posix_test_lock(struct file *filp, struct file_lock *fl) retry: spin_lock(&ctx->flc_lock); - list_for_each_entry(cfl, &ctx->flc_posix, fl_list) { + list_for_each_entry(cfl, &ctx->flc_posix, fl_core.fl_list) { if (!posix_test_locks_conflict(fl, cfl)) continue; if (cfl->fl_lmops && cfl->fl_lmops->lm_lock_expirable @@ -985,7 +985,7 @@ static struct file_lock *what_owner_is_waiting_for(struct file_lock *block_fl) { struct file_lock *fl; - hash_for_each_possible(blocked_hash, fl, fl_link, posix_owner_key(block_fl)) { + hash_for_each_possible(blocked_hash, fl, fl_core.fl_link, posix_owner_key(block_fl)) { if (posix_same_owner(fl, block_fl)) { while (fl->fl_core.fl_blocker) fl = fl->fl_core.fl_blocker; @@ -1053,7 +1053,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) if (request->fl_core.fl_flags & FL_ACCESS) goto find_conflict; - list_for_each_entry(fl, &ctx->flc_flock, fl_list) { + list_for_each_entry(fl, &ctx->flc_flock, fl_core.fl_list) { if (request->fl_core.fl_file != fl->fl_core.fl_file) continue; if (request->fl_core.fl_type == fl->fl_core.fl_type) @@ -1070,7 +1070,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) } find_conflict: - list_for_each_entry(fl, &ctx->flc_flock, fl_list) { + list_for_each_entry(fl, &ctx->flc_flock, fl_core.fl_list) { if (!flock_locks_conflict(request, fl)) continue; error = -EAGAIN; @@ -1139,7 +1139,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, * blocker's list of waiters and the global blocked_hash. */ if (request->fl_core.fl_type != F_UNLCK) { - list_for_each_entry(fl, &ctx->flc_posix, fl_list) { + list_for_each_entry(fl, &ctx->flc_posix, fl_core.fl_list) { if (!posix_locks_conflict(request, fl)) continue; if (fl->fl_lmops && fl->fl_lmops->lm_lock_expirable @@ -1185,13 +1185,13 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, goto out; /* Find the first old lock with the same owner as the new lock */ - list_for_each_entry(fl, &ctx->flc_posix, fl_list) { + list_for_each_entry(fl, &ctx->flc_posix, fl_core.fl_list) { if (posix_same_owner(request, fl)) break; } /* Process locks with this owner. */ - list_for_each_entry_safe_from(fl, tmp, &ctx->flc_posix, fl_list) { + list_for_each_entry_safe_from(fl, tmp, &ctx->flc_posix, fl_core.fl_list) { if (!posix_same_owner(request, fl)) break; @@ -1433,7 +1433,7 @@ static void time_out_leases(struct inode *inode, struct list_head *dispose) lockdep_assert_held(&ctx->flc_lock); - list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) { + list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_core.fl_list) { trace_time_out_leases(inode, fl); if (past_time(fl->fl_downgrade_time)) lease_modify(fl, F_RDLCK, dispose); @@ -1472,7 +1472,7 @@ any_leases_conflict(struct inode *inode, struct file_lock *breaker) lockdep_assert_held(&ctx->flc_lock); - list_for_each_entry(fl, &ctx->flc_lease, fl_list) { + list_for_each_entry(fl, &ctx->flc_lease, fl_core.fl_list) { if (leases_conflict(fl, breaker)) return true; } @@ -1528,7 +1528,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) break_time++; /* so that 0 means no break time */ } - list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) { + list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_core.fl_list) { if (!leases_conflict(fl, new_fl)) continue; if (want_write) { @@ -1556,7 +1556,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) } restart: - fl = list_first_entry(&ctx->flc_lease, struct file_lock, fl_list); + fl = list_first_entry(&ctx->flc_lease, struct file_lock, fl_core.fl_list); break_time = fl->fl_break_time; if (break_time != 0) break_time -= jiffies; @@ -1616,7 +1616,7 @@ void lease_get_mtime(struct inode *inode, struct timespec64 *time) if (ctx && !list_empty_careful(&ctx->flc_lease)) { spin_lock(&ctx->flc_lock); fl = list_first_entry_or_null(&ctx->flc_lease, - struct file_lock, fl_list); + struct file_lock, fl_core.fl_list); if (fl && (fl->fl_core.fl_type == F_WRLCK)) has_lease = true; spin_unlock(&ctx->flc_lock); @@ -1663,7 +1663,7 @@ int fcntl_getlease(struct file *filp) percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); time_out_leases(inode, &dispose); - list_for_each_entry(fl, &ctx->flc_lease, fl_list) { + list_for_each_entry(fl, &ctx->flc_lease, fl_core.fl_list) { if (fl->fl_core.fl_file != filp) continue; type = target_leasetype(fl); @@ -1768,7 +1768,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri * except for this filp. */ error = -EAGAIN; - list_for_each_entry(fl, &ctx->flc_lease, fl_list) { + list_for_each_entry(fl, &ctx->flc_lease, fl_core.fl_list) { if (fl->fl_core.fl_file == filp && fl->fl_core.fl_owner == lease->fl_core.fl_owner) { my_fl = fl; @@ -1848,7 +1848,7 @@ static int generic_delete_lease(struct file *filp, void *owner) percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); - list_for_each_entry(fl, &ctx->flc_lease, fl_list) { + list_for_each_entry(fl, &ctx->flc_lease, fl_core.fl_list) { if (fl->fl_core.fl_file == filp && fl->fl_core.fl_owner == owner) { victim = fl; @@ -2616,7 +2616,7 @@ locks_remove_lease(struct file *filp, struct file_lock_context *ctx) percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); - list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_list) + list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_core.fl_list) if (filp == fl->fl_core.fl_file) lease_modify(fl, F_UNLCK, &dispose); spin_unlock(&ctx->flc_lock); @@ -2781,8 +2781,9 @@ static struct file_lock *get_next_blocked_member(struct file_lock *node) return NULL; /* Next member in the linked list could be itself */ - tmp = list_next_entry(node, fl_blocked_member); - if (list_entry_is_head(tmp, &node->fl_core.fl_blocker->fl_blocked_requests, fl_blocked_member) + tmp = list_next_entry(node, fl_core.fl_blocked_member); + if (list_entry_is_head(tmp, &node->fl_core.fl_blocker->fl_core.fl_blocked_requests, + fl_core.fl_blocked_member) || tmp == node) { return NULL; } @@ -2797,7 +2798,7 @@ static int locks_show(struct seq_file *f, void *v) struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)->i_sb); int level = 0; - cur = hlist_entry(v, struct file_lock, fl_link); + cur = hlist_entry(v, struct file_lock, fl_core.fl_link); if (locks_translate_pid(cur, proc_pidns) == 0) return 0; @@ -2817,7 +2818,7 @@ static int locks_show(struct seq_file *f, void *v) /* Turn left */ cur = list_first_entry_or_null(&cur->fl_core.fl_blocked_requests, struct file_lock, - fl_blocked_member); + fl_core.fl_blocked_member); level++; } else { /* Turn right */ @@ -2841,7 +2842,7 @@ static void __show_fd_locks(struct seq_file *f, { struct file_lock *fl; - list_for_each_entry(fl, head, fl_list) { + list_for_each_entry(fl, head, fl_core.fl_list) { if (filp != fl->fl_core.fl_file) continue; diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c index 31741967ab95..8c7c31d846a0 100644 --- a/fs/nfs/delegation.c +++ b/fs/nfs/delegation.c @@ -156,7 +156,7 @@ static int nfs_delegation_claim_locks(struct nfs4_state *state, const nfs4_state list = &flctx->flc_posix; spin_lock(&flctx->flc_lock); restart: - list_for_each_entry(fl, list, fl_list) { + list_for_each_entry(fl, list, fl_core.fl_list) { if (nfs_file_open_context(fl->fl_core.fl_file)->state != state) continue; spin_unlock(&flctx->flc_lock); diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index a148b6ac4713..2d51523be647 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1529,7 +1529,7 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_ down_write(&nfsi->rwsem); spin_lock(&flctx->flc_lock); restart: - list_for_each_entry(fl, list, fl_list) { + list_for_each_entry(fl, list, fl_core.fl_list) { if (nfs_file_open_context(fl->fl_core.fl_file)->state != state) continue; spin_unlock(&flctx->flc_lock); diff --git a/fs/nfs/nfs4trace.h b/fs/nfs/nfs4trace.h index d27919d7241d..41fbbc626cc3 100644 --- a/fs/nfs/nfs4trace.h +++ b/fs/nfs/nfs4trace.h @@ -699,7 +699,7 @@ DECLARE_EVENT_CLASS(nfs4_lock_event, __entry->error = error < 0 ? -error : 0; __entry->cmd = cmd; - __entry->type = request->fl_type; + __entry->type = request->fl_core.fl_type; __entry->start = request->fl_start; __entry->end = request->fl_end; __entry->dev = inode->i_sb->s_dev; @@ -771,7 +771,7 @@ TRACE_EVENT(nfs4_set_lock, __entry->error = error < 0 ? -error : 0; __entry->cmd = cmd; - __entry->type = request->fl_type; + __entry->type = request->fl_core.fl_type; __entry->start = request->fl_start; __entry->end = request->fl_end; __entry->dev = inode->i_sb->s_dev; diff --git a/fs/nfs/write.c b/fs/nfs/write.c index a096c84c4678..b2a6c8c3078d 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1335,12 +1335,12 @@ static int nfs_can_extend_write(struct file *file, struct folio *folio, spin_lock(&flctx->flc_lock); if (!list_empty(&flctx->flc_posix)) { fl = list_first_entry(&flctx->flc_posix, struct file_lock, - fl_list); + fl_core.fl_list); if (is_whole_file_wrlock(fl)) ret = 1; } else if (!list_empty(&flctx->flc_flock)) { fl = list_first_entry(&flctx->flc_flock, struct file_lock, - fl_list); + fl_core.fl_list); if (fl->fl_core.fl_type == F_WRLCK) ret = 1; } diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 926c29879c6a..e32ad2492eb1 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -674,7 +674,7 @@ static void nfs4_xdr_enc_cb_notify_lock(struct rpc_rqst *req, const struct nfsd4_callback *cb = data; const struct nfsd4_blocked_lock *nbl = container_of(cb, struct nfsd4_blocked_lock, nbl_cb); - struct nfs4_lockowner *lo = (struct nfs4_lockowner *)nbl->nbl_lock.fl_owner; + struct nfs4_lockowner *lo = (struct nfs4_lockowner *)nbl->nbl_lock.fl_core.fl_owner; struct nfs4_cb_compound_hdr hdr = { .ident = 0, .minorversion = cb->cb_clp->cl_minorversion, diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index a6089dbcee9d..cf5d0b3a553f 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -7927,7 +7927,7 @@ check_for_locks(struct nfs4_file *fp, struct nfs4_lockowner *lowner) if (flctx && !list_empty_careful(&flctx->flc_posix)) { spin_lock(&flctx->flc_lock); - list_for_each_entry(fl, &flctx->flc_posix, fl_list) { + list_for_each_entry(fl, &flctx->flc_posix, fl_core.fl_list) { if (fl->fl_core.fl_owner == (fl_owner_t)lowner) { status = true; break; @@ -8456,7 +8456,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) if (!ctx) return 0; spin_lock(&ctx->flc_lock); - list_for_each_entry(fl, &ctx->flc_lease, fl_list) { + list_for_each_entry(fl, &ctx->flc_lease, fl_core.fl_list) { if (fl->fl_core.fl_flags == FL_LAYOUT) continue; if (fl->fl_lmops != &nfsd_lease_mng_ops) { diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 1305183842fd..024afd3a81d4 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -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) { + list_for_each_entry(flock, &flctx->flc_posix, fl_core.fl_list) { if (el == &locks_to_send) { /* * The list ended. We don't have enough allocated diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c index f7bb6f19492b..c2abb9b6100d 100644 --- a/fs/smb/server/vfs.c +++ b/fs/smb/server/vfs.c @@ -337,7 +337,7 @@ static int check_lock_range(struct file *filp, loff_t start, loff_t end, return 0; spin_lock(&ctx->flc_lock); - list_for_each_entry(flock, &ctx->flc_posix, fl_list) { + list_for_each_entry(flock, &ctx->flc_posix, fl_core.fl_list) { /* check conflict locks */ if (flock->fl_end >= start && end >= flock->fl_start) { if (flock->fl_core.fl_type == F_RDLCK) { diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h index 5194b7e6dc8d..bd6cf09856b3 100644 --- a/include/trace/events/afs.h +++ b/include/trace/events/afs.h @@ -1195,8 +1195,8 @@ TRACE_EVENT(afs_flock_op, __entry->from = fl->fl_start; __entry->len = fl->fl_end - fl->fl_start + 1; __entry->op = op; - __entry->type = fl->fl_type; - __entry->flags = fl->fl_flags; + __entry->type = fl->fl_core.fl_type; + __entry->flags = fl->fl_core.fl_flags; __entry->debug_id = fl->fl_u.afs.debug_id; ), diff --git a/include/trace/events/filelock.h b/include/trace/events/filelock.h index 1646dadd7f37..92ed07544f94 100644 --- a/include/trace/events/filelock.h +++ b/include/trace/events/filelock.h @@ -82,11 +82,11 @@ DECLARE_EVENT_CLASS(filelock_lock, __entry->fl = fl ? fl : NULL; __entry->s_dev = inode->i_sb->s_dev; __entry->i_ino = inode->i_ino; - __entry->fl_blocker = fl ? fl->fl_blocker : NULL; - __entry->fl_owner = fl ? fl->fl_owner : NULL; - __entry->fl_pid = fl ? fl->fl_pid : 0; - __entry->fl_flags = fl ? fl->fl_flags : 0; - __entry->fl_type = fl ? fl->fl_type : 0; + __entry->fl_blocker = fl ? fl->fl_core.fl_blocker : NULL; + __entry->fl_owner = fl ? fl->fl_core.fl_owner : NULL; + __entry->fl_pid = fl ? fl->fl_core.fl_pid : 0; + __entry->fl_flags = fl ? fl->fl_core.fl_flags : 0; + __entry->fl_type = fl ? fl->fl_core.fl_type : 0; __entry->fl_start = fl ? fl->fl_start : 0; __entry->fl_end = fl ? fl->fl_end : 0; __entry->ret = ret; @@ -137,10 +137,10 @@ DECLARE_EVENT_CLASS(filelock_lease, __entry->fl = fl ? fl : NULL; __entry->s_dev = inode->i_sb->s_dev; __entry->i_ino = inode->i_ino; - __entry->fl_blocker = fl ? fl->fl_blocker : NULL; - __entry->fl_owner = fl ? fl->fl_owner : NULL; - __entry->fl_flags = fl ? fl->fl_flags : 0; - __entry->fl_type = fl ? fl->fl_type : 0; + __entry->fl_blocker = fl ? fl->fl_core.fl_blocker : NULL; + __entry->fl_owner = fl ? fl->fl_core.fl_owner : NULL; + __entry->fl_flags = fl ? fl->fl_core.fl_flags : 0; + __entry->fl_type = fl ? fl->fl_core.fl_type : 0; __entry->fl_break_time = fl ? fl->fl_break_time : 0; __entry->fl_downgrade_time = fl ? fl->fl_downgrade_time : 0; ), @@ -190,9 +190,9 @@ TRACE_EVENT(generic_add_lease, __entry->wcount = atomic_read(&inode->i_writecount); __entry->rcount = atomic_read(&inode->i_readcount); __entry->icount = atomic_read(&inode->i_count); - __entry->fl_owner = fl->fl_owner; - __entry->fl_flags = fl->fl_flags; - __entry->fl_type = fl->fl_type; + __entry->fl_owner = fl->fl_core.fl_owner; + __entry->fl_flags = fl->fl_core.fl_flags; + __entry->fl_type = fl->fl_core.fl_type; ), TP_printk("dev=0x%x:0x%x ino=0x%lx wcount=%d rcount=%d icount=%d fl_owner=%p fl_flags=%s fl_type=%s", @@ -220,11 +220,11 @@ TRACE_EVENT(leases_conflict, TP_fast_assign( __entry->lease = lease; - __entry->l_fl_flags = lease->fl_flags; - __entry->l_fl_type = lease->fl_type; + __entry->l_fl_flags = lease->fl_core.fl_flags; + __entry->l_fl_type = lease->fl_core.fl_type; __entry->breaker = breaker; - __entry->b_fl_flags = breaker->fl_flags; - __entry->b_fl_type = breaker->fl_type; + __entry->b_fl_flags = breaker->fl_core.fl_flags; + __entry->b_fl_type = breaker->fl_core.fl_type; __entry->conflict = conflict; ), From patchwork Tue Jan 16 19:46:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521098 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 D232E7E774; Tue, 16 Jan 2024 19:47:06 +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=1705434427; cv=none; b=Hq1UaIhdFFFdiExriD9dV4QF59kt1ZjcQW4TrGKQK0hyQo3notZc0nyv29q26PDHL2YL1wL76eImc7FXAl/GStDLT76dGGM+ADd/y6PKRJTjbTDuiCLH/zEBqo1H+bej7QbiJE4H+gfhdG/3/8cCiathX5gbaAKxA/vjzH5FFG4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434427; c=relaxed/simple; bh=yDsuU1Zw9gxCujhD8xa64udMU/oaPFDr1SbUE7U7jIE=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=Gm5XytrZXJE5w3odaqk5Mo5ElW4TDCCIXpF/e4SziN325Iq1MSN3o+WhS4AnDyHDfXdLxyKK91ZUP0BUzTkSfzend3zDXmvT23mhheOeOroN8ZvuJpinfWBykbUUvzOIppRLDOVy/4YDF2Lvid3BuMb3fn8v4pS+YHV6FX4eQH4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VHwTTmLI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VHwTTmLI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02D0EC433B2; Tue, 16 Jan 2024 19:47:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434426; bh=yDsuU1Zw9gxCujhD8xa64udMU/oaPFDr1SbUE7U7jIE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VHwTTmLIU5WtY7YZEJ2Ur6v7Bc2ZO+L1BCAmSHvG3hHBEdwUCECGl2SJV8aBJvx3N v/Debi9V8tv6BQtgxHaOUxHee6rmDUHnYs+8gMn1l5ImaiTQGludKNR0jNBoz+XLq6 g3grmjkpLmcStczkUuKYNMxNdHLf4gVUWD1A41xHYZfAAlMW2R6LDdGVhcZzt03++a C5iqveKFWqbVdu1TxuzWNT/RK6kfECrS6Rw4ayUSwjX5hRtxq7BLLbaIwzl5aB5ewK qbCgX0XpEI9IPmfuVImexA+tUOCKKmQBbsqRHkP5Vag1lcVDjyVzJFtfjJrX4ZlznG WokiLMswsbsMw== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:01 -0500 Subject: [PATCH 05/20] filelock: convert some internal functions to use file_lock_core instead Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-5-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1655; i=jlayton@kernel.org; h=from:subject:message-id; bh=yDsuU1Zw9gxCujhD8xa64udMU/oaPFDr1SbUE7U7jIE=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0gVcrXW2g/TK7GdwhFc0QwsV1CF3i6HJklQ lY6mK00vy6JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIAAKCRAADmhBGVaC FUDwD/0W6sL9ycLrZsOaPzmRJdLOqA0UnNIsgyMABRAU9sMIKmGthsGs45uq3K4T6agyWoD6VJK VSypAHRxBZQQYwJNhZrGy5oQ4M1vheZK/uCLxUmZoHVsSluowKgeDURi3UZW0WGSR7LD6mxEB6h OUFMMarXNOjcKJPK81g8RX4RqG8fMz4u5SYy2tzwwKxBFhCwFz09yTbz9BDZwoZgWbNMYcqpRSk uhGEVNUfKx3yWIs9mva9QL3wlzUm4GD3T+DS/ukCdxtRAl2YVIpAzPc5bNvzWehP2uVwG+HK7qB Halx0h+4TVBQLFcp4saLYx0ujQ0D+H/6G7l0/Gxx6Rw2aB3A7KX8z6yO78dnRO5ZrD6ocU76GDZ PtelVsqxVFxIOvisTjXdUMPyfw72AU7tc9eRDV8jLdpgta2U2V+UPBl/mg4rNEabfJI4qbst3+0 MuTAOQVIiRkrBd7uXHLnfZF0oSeqpoz659Vazg5Y6NeHRACxf07kXSJ1AqDNnCcvZCc+XqOBY0U ZKuLL1c+2c0gLjTQqAzbgUwPwe69JrA8hMO5avGsjuB808lw+YW53U8gNLEWyrZT+LFm4CyUCbu pfrKAIOtsH3h/mKbBFybrByDWokTbO2YXB9ySd5qgD/gqgniIMSLgG3kmfhTENkNyHT4RM8pH7s sTXiDx4/HahrMKA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Convert some internal fs/locks.c function to take and deal with struct file_lock_core instead of struct file_lock: - locks_init_lock_heads - locks_alloc_lock - locks_init_lock Signed-off-by: Jeff Layton --- fs/locks.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index afe6e82a6207..42221cecd331 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -258,13 +258,13 @@ locks_free_lock_context(struct inode *inode) } } -static void locks_init_lock_heads(struct file_lock *fl) +static void locks_init_lock_heads(struct file_lock_core *flc) { - INIT_HLIST_NODE(&fl->fl_core.fl_link); - INIT_LIST_HEAD(&fl->fl_core.fl_list); - INIT_LIST_HEAD(&fl->fl_core.fl_blocked_requests); - INIT_LIST_HEAD(&fl->fl_core.fl_blocked_member); - init_waitqueue_head(&fl->fl_core.fl_wait); + INIT_HLIST_NODE(&flc->fl_link); + INIT_LIST_HEAD(&flc->fl_list); + INIT_LIST_HEAD(&flc->fl_blocked_requests); + INIT_LIST_HEAD(&flc->fl_blocked_member); + init_waitqueue_head(&flc->fl_wait); } /* Allocate an empty lock structure. */ @@ -273,7 +273,7 @@ struct file_lock *locks_alloc_lock(void) struct file_lock *fl = kmem_cache_zalloc(filelock_cache, GFP_KERNEL); if (fl) - locks_init_lock_heads(fl); + locks_init_lock_heads(&fl->fl_core); return fl; } @@ -354,7 +354,7 @@ locks_dispose_list(struct list_head *dispose) void locks_init_lock(struct file_lock *fl) { memset(fl, 0, sizeof(struct file_lock)); - locks_init_lock_heads(fl); + locks_init_lock_heads(&fl->fl_core); } EXPORT_SYMBOL(locks_init_lock); From patchwork Tue Jan 16 19:46:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521099 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 B8E5680024; Tue, 16 Jan 2024 19:47:10 +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=1705434430; cv=none; b=ifEKMbJ71U5n1VTVNVvH+Ivy/DHA7DovLTSwF9PBLkEzAV29j14C3EVU6vsSre7hcUoOdodrNLq/dNdFNCj9w8wOw0ZCiQMicA8VG+AWq4gHfm3fsceDH4XatdjYbl3yDkRO3IqACFCHtXkBahcbyRjAKFjyrd9nKSWRpUz7448= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434430; c=relaxed/simple; bh=6eZQeCkW4iFcfnmfrvJdpykOJoNW9gO68mk12ueOnn4=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=JLzLxKdTNcmRrkEYPOWYksq1yoLi3SjHfdr0U4nbWfneQ2hJmentjDmIlAOhO6+XpQyLRb04uGWPnaYfb1nJbMoq9jXK2SBbL2FRpfrnAjES4VYB1LpXTEs/vwmK/DMyfhdv27sCv3Z8gxvFYc+eKXyiJDxVSx6LMMPseTTG0S0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nvh7q0/E; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nvh7q0/E" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E23F4C433A6; Tue, 16 Jan 2024 19:47:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434430; bh=6eZQeCkW4iFcfnmfrvJdpykOJoNW9gO68mk12ueOnn4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nvh7q0/E/N1JdPaGP+XEcUQn5mCYgXxCoGrhjxk6Kb0D9r/51nGWx6/aDB9wBIYHu s9qa29A/KTsKjOhA6OKdYhlj2AJa9nMDFjXQmyXI3HbbnY5jgloUDPYqhgx48rj/qc TlNZo+LkVLzS0KgoQzolooH03sN55F71hdUqX8KGZLuAyrQ/x92D/2KVRqT1Yh+rj4 fCMWdxQxkazjEn7IGYo8E1G7vrTtoAqno28mcV2jUUlCY2+81wM4eHJRM9GZXY4oIQ 5pJEFzbOr0Z8RJApCVNEDBEX2liSWEYiUsjnox29KTkhcAJtgGqcUHpqyYOpz86f88 O4neXmD/Hw97A== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:02 -0500 Subject: [PATCH 06/20] filelock: convert more internal functions to use file_lock_core Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-6-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3974; i=jlayton@kernel.org; h=from:subject:message-id; bh=6eZQeCkW4iFcfnmfrvJdpykOJoNW9gO68mk12ueOnn4=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0gkbCGP0TGVDiqaY92qso6UdDDYYNPcitPS wLpQSH+Mq6JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIAAKCRAADmhBGVaC FQmtD/43Ok262HrU0nw5Im/yax8UeF7kPSqEzTjHJ4xF2CIjFS64ejnI5j3Q3SWvO0dPXdMZGHo q63T2n6CXQNzXurtakLNezxz86Grqj0SloTEaNrFKAYLynEUriP9le4R6f7sOfWVEx8fQtKIcII CBiL3qfFJaP5er8DXgeNe4xNQX38KfNMNIZzuDvZVfaV/2MMM/mOk7MUVD8esu0vYvtu+65MwK3 BHU+g6KilT4YmpUY8eSvYIzTDqyhUxyDjB8EYn5MV+ynur5nGC0vLgV40QFBRPHTG9kUrFn0IXy fnWwrhOub7sY39kI/5abRiSTTGM9WqLrt7lTUDTxsdkg/Zf1j6WqNrvNbWcUh/0Gq5F7Ogp9rlu ywIOk+docNI0n17CnXEv1/5c8FktZORSOXzHWD7DtF8Lj2CW5TS3HYb7Fa9eusG7+Uj/BMOhO6G UXZT07l+7ub1+MJdKBeuOkxZ6sX2+6aRyuqlJ2fkIxGDVw23TiY8Tbp6icWrdb6hEJWRc2Ksjrl FiOfJWhJTCStUs6lg6EpaqzMBRiZ3WGt8mfnmLdsSvxqTmNmr/mJYB0J3Qf+8oPbFrlq7zDhW2n TFkMkykikEug4Rk1etGrNoD9ROFn8olB8bDuPiSInOtyF0yYLMzNDegwWkWtbRzDntELWxdWKeg RbC7jCLbvfsyRVQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Convert more internal fs/locks.c functions to take and deal with struct file_lock_core instead of struct file_lock: - locks_dump_ctx_list - locks_check_ctx_file_list - locks_release_private - locks_owner_has_blockers Signed-off-by: Jeff Layton --- fs/locks.c | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 42221cecd331..e09920cc9da2 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -204,13 +204,12 @@ locks_get_lock_context(struct inode *inode, int type) static void locks_dump_ctx_list(struct list_head *list, char *list_type) { - struct file_lock *fl; + struct file_lock_core *flc; - list_for_each_entry(fl, list, fl_core.fl_list) { - pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, - fl->fl_core.fl_owner, fl->fl_core.fl_flags, - fl->fl_core.fl_type, fl->fl_core.fl_pid); - } + list_for_each_entry(flc, list, fl_list) + pr_warn("%s: fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", + list_type, flc->fl_owner, flc->fl_flags, + flc->fl_type, flc->fl_pid); } static void @@ -231,20 +230,19 @@ locks_check_ctx_lists(struct inode *inode) } static void -locks_check_ctx_file_list(struct file *filp, struct list_head *list, - char *list_type) +locks_check_ctx_file_list(struct file *filp, struct list_head *list, char *list_type) { - struct file_lock *fl; + struct file_lock_core *flc; struct inode *inode = file_inode(filp); - list_for_each_entry(fl, list, fl_core.fl_list) - if (fl->fl_core.fl_file == filp) + list_for_each_entry(flc, list, fl_list) + if (flc->fl_file == filp) pr_warn("Leaked %s lock on dev=0x%x:0x%x ino=0x%lx " " fl_owner=%p fl_flags=0x%x fl_type=0x%x fl_pid=%u\n", list_type, MAJOR(inode->i_sb->s_dev), MINOR(inode->i_sb->s_dev), inode->i_ino, - fl->fl_core.fl_owner, fl->fl_core.fl_flags, - fl->fl_core.fl_type, fl->fl_core.fl_pid); + flc->fl_owner, flc->fl_flags, + flc->fl_type, flc->fl_pid); } void @@ -281,11 +279,13 @@ EXPORT_SYMBOL_GPL(locks_alloc_lock); void locks_release_private(struct file_lock *fl) { - BUG_ON(waitqueue_active(&fl->fl_core.fl_wait)); - BUG_ON(!list_empty(&fl->fl_core.fl_list)); - BUG_ON(!list_empty(&fl->fl_core.fl_blocked_requests)); - BUG_ON(!list_empty(&fl->fl_core.fl_blocked_member)); - BUG_ON(!hlist_unhashed(&fl->fl_core.fl_link)); + struct file_lock_core *flc = &fl->fl_core; + + BUG_ON(waitqueue_active(&flc->fl_wait)); + BUG_ON(!list_empty(&flc->fl_list)); + BUG_ON(!list_empty(&flc->fl_blocked_requests)); + BUG_ON(!list_empty(&flc->fl_blocked_member)); + BUG_ON(!hlist_unhashed(&flc->fl_link)); if (fl->fl_ops) { if (fl->fl_ops->fl_release_private) @@ -295,8 +295,8 @@ void locks_release_private(struct file_lock *fl) if (fl->fl_lmops) { if (fl->fl_lmops->lm_put_owner) { - fl->fl_lmops->lm_put_owner(fl->fl_core.fl_owner); - fl->fl_core.fl_owner = NULL; + fl->fl_lmops->lm_put_owner(flc->fl_owner); + flc->fl_owner = NULL; } fl->fl_lmops = NULL; } @@ -312,16 +312,15 @@ EXPORT_SYMBOL_GPL(locks_release_private); * %true: @owner has at least one blocker * %false: @owner has no blockers */ -bool locks_owner_has_blockers(struct file_lock_context *flctx, - fl_owner_t owner) +bool locks_owner_has_blockers(struct file_lock_context *flctx, fl_owner_t owner) { - struct file_lock *fl; + struct file_lock_core *flc; spin_lock(&flctx->flc_lock); - list_for_each_entry(fl, &flctx->flc_posix, fl_core.fl_list) { - if (fl->fl_core.fl_owner != owner) + list_for_each_entry(flc, &flctx->flc_posix, fl_list) { + if (flc->fl_owner != owner) continue; - if (!list_empty(&fl->fl_core.fl_blocked_requests)) { + if (!list_empty(&flc->fl_blocked_requests)) { spin_unlock(&flctx->flc_lock); return true; } From patchwork Tue Jan 16 19:46:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521100 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 A920F36119; Tue, 16 Jan 2024 19:47:14 +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=1705434434; cv=none; b=CGJ0GDRbT9WL2UtiPRthq4Xii94OERl7kd1Qb0uBdviERF8brmgcUUbtAwc8fFRrVB9jUIKHXB2dsHCHgfEzKivN4Mb6BQkrmCqWyr04qmQYI0Tpig4W5TKV+gx3Rpga/sM8Qw72yVxH/+3oecgpdeMFAS/busM0mhPH1anQMSw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434434; c=relaxed/simple; bh=L8KWqCV+F6kRLVRE9vKyR+AlpShZquRypPwqDG+IUPM=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=BjxrJXXvOfjprA94HjGEnBXFTTlEA4LzWxw+xEP7icwnYjv2u6LvEBTZrsr9iL9OCLINnwf/2ct0Rj+dvEx3BKdzkVsOqL42PFU2NoRlNyks5S7TZU/7I13EEtwCqr4yksBKZRF37EmiHN6UiDq/XENGU6PFhgxQ5bEXBU90chs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tHlGAQGr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tHlGAQGr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCD8CC433F1; Tue, 16 Jan 2024 19:47:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434434; bh=L8KWqCV+F6kRLVRE9vKyR+AlpShZquRypPwqDG+IUPM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tHlGAQGrdtJ1Sj0SUi5L5S89CQlL0SpIdzwZdxA6LL1v4X4qpvY8yfkHTLCDGvZ6B iQw0f1rVJuJMQVeb+rmA8w7NCI1hRrlzlMDU9AitgqnFebgxldWy+dVvzzDAq/Tm+6 RtIpLlTNl+355Z7Uiyu3jOEv+5gGs0G3n8FOUB92TKxkpDK10G20h2BJwrgO7o5sDn NhszLst+TbXIn1affBO0arej+72uIINXLf6hlFHxL8KR3HkClwMJQJ39eDjH+LU3Qv QCpHYUurT888QMUqqK3lyW7KNFaTyWLktOijU87T08uSxo+0pMpuTi0LCNaoksrLxp H31zCSvGwjWEQ== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:03 -0500 Subject: [PATCH 07/20] filelock: make posix_same_owner take file_lock_core pointers Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-7-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2980; i=jlayton@kernel.org; h=from:subject:message-id; bh=L8KWqCV+F6kRLVRE9vKyR+AlpShZquRypPwqDG+IUPM=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0hKHK+H6Wkmd5yy5pmBcEetzKB2FUGxYvp+ 5WYVbVWJ0+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIQAKCRAADmhBGVaC FfuDEAC1pXoqFjMnpCKnUAWdI7HObvstTJBvHYUMBv0MiYVuPTUFjyy5BpzewkqsX7tDPL/HeZv 4lapZ+H2O5NFTp8NU2u5rNdf0G5TVcdxVMlTVbpi1uk52G26ChpIXgopPFS36u3ySx55EK/OotB ZB7gOiGnE7ymo5ma/cv9NuY92Z8QUb2UqX9Wl8GRewVeZzDcUr9N9c6Btdaqr0AwVYx1yx+D7rT WTG2NZ1jWAt+bKNgJmCOuGX++dbMf0MygG+DKr5kcYV+AhkKR6FF34WF5S84v2mbrPSAT3PBRJx qpauTEIq0+ae7frYtnoZFGeeZuFjSUyHsEq9BYCJUtTDWiVtqYHBKgzbDScB34MnlmBKrmAV/WR i/A2C63TP0hdSEaZAukKlsdIsSQuzhyLIjeikc4xxbVubS0RJkBJdQNm9qSNXGdjNTV+WJtbcxc KVDkGSYC+X01uU18pCKbj1onAe0DjPzJg/Tf4yCuRjcCaG913ZF9mH5VMNnqcVzKc0hJqtFq/Pb qlf2oi4fUYyGbKL4xjVAxz0Ysrj98g/Bpi+1P2jcFUfKXyzdmzTMqonkCP7ZlY1lKKp/oBCPp9U 5ZJA97fX57PuqWUugyvEE04bash6Pjuzo52Ci4GAcOf4wZh2X4j8rlKdmVkpwhkTE2MqiS5yPsh eyktM/o+0wCzteQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Change posix_same_owner to take struct file_lock_core pointers, and convert the callers to pass those in. Signed-off-by: Jeff Layton --- fs/locks.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index e09920cc9da2..0c47497eb1a4 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -597,9 +597,9 @@ static inline int locks_overlap(struct file_lock *fl1, struct file_lock *fl2) /* * Check whether two locks have the same owner. */ -static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2) +static int posix_same_owner(struct file_lock_core *fl1, struct file_lock_core *fl2) { - return fl1->fl_core.fl_owner == fl2->fl_core.fl_owner; + return fl1->fl_owner == fl2->fl_owner; } /* Must be called with the flc_lock held! */ @@ -864,7 +864,7 @@ static bool posix_locks_conflict(struct file_lock *caller_fl, /* POSIX locks owned by the same process do not conflict with * each other. */ - if (posix_same_owner(caller_fl, sys_fl)) + if (posix_same_owner(&caller_fl->fl_core, &sys_fl->fl_core)) return false; /* Check whether they overlap */ @@ -882,7 +882,7 @@ static bool posix_test_locks_conflict(struct file_lock *caller_fl, { /* F_UNLCK checks any locks on the same fd. */ if (caller_fl->fl_core.fl_type == F_UNLCK) { - if (!posix_same_owner(caller_fl, sys_fl)) + if (!posix_same_owner(&caller_fl->fl_core, &sys_fl->fl_core)) return false; return locks_overlap(caller_fl, sys_fl); } @@ -985,7 +985,7 @@ static struct file_lock *what_owner_is_waiting_for(struct file_lock *block_fl) struct file_lock *fl; hash_for_each_possible(blocked_hash, fl, fl_core.fl_link, posix_owner_key(block_fl)) { - if (posix_same_owner(fl, block_fl)) { + if (posix_same_owner(&fl->fl_core, &block_fl->fl_core)) { while (fl->fl_core.fl_blocker) fl = fl->fl_core.fl_blocker; return fl; @@ -1012,7 +1012,7 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, while ((block_fl = what_owner_is_waiting_for(block_fl))) { if (i++ > MAX_DEADLK_ITERATIONS) return 0; - if (posix_same_owner(caller_fl, block_fl)) + if (posix_same_owner(&caller_fl->fl_core, &block_fl->fl_core)) return 1; } return 0; @@ -1185,13 +1185,13 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, /* Find the first old lock with the same owner as the new lock */ list_for_each_entry(fl, &ctx->flc_posix, fl_core.fl_list) { - if (posix_same_owner(request, fl)) + if (posix_same_owner(&request->fl_core, &fl->fl_core)) break; } /* Process locks with this owner. */ list_for_each_entry_safe_from(fl, tmp, &ctx->flc_posix, fl_core.fl_list) { - if (!posix_same_owner(request, fl)) + if (!posix_same_owner(&request->fl_core, &fl->fl_core)) break; /* Detect adjacent or overlapping regions (if same lock type) */ From patchwork Tue Jan 16 19:46:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521101 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 DCBD37A710; Tue, 16 Jan 2024 19:47:18 +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=1705434439; cv=none; b=kFNiPad7veTFyXx4olAT5dGGZ2UIOQh6nXNKjDLPJSV6DS+EfMN33leAgM7T1HBLJ4h+FxKjs02MGa0Hdu7IplIWnz3hcih/RknPX09r74SdMZupWRcGaI9N1Dn4PKaUyY9CyGBmh8P4sLWeCaIGGkqUbJ/xWhbAzOyofSIkIa0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434439; c=relaxed/simple; bh=WIy21odrljEB/8swbFzVsTPOFgQ6www6fvkeNvY4iqY=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=Yfi8G7ghwnMznsd0WZZfrth1FC5Re3LuKKlKL+8+4rsHWKyKiX22VSW5K/WxWcqWlfR3w18q7SSE/Iv41PKe5gWvDuoL5TINxte8KU2XfI+GVJuH1ugEd8HWGd7rgzxehX8rym933XO+CDnYWqEZQQJgHG8ioAjVwa+HbNZJTLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dGt5MOni; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dGt5MOni" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9E2AC43601; Tue, 16 Jan 2024 19:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434438; bh=WIy21odrljEB/8swbFzVsTPOFgQ6www6fvkeNvY4iqY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dGt5MOniA8nfT85OoK0KWNQ4NT9/XemjVhwDT+efQCLEjfiTLRnvIj7LiZt02k3EW 17NTxfrGKdCg43vu+P4kGL0hBVy/91aq4gKXgjT1FFFXSay+dVliMzxcGsFeFEdvuE raPX8KnHP9y0VvGADbWlAN2WTaGMTmjHg4nsQItG044lqNNC0zxhMWEupvVVkNIlcJ O/alVqebMPNpY3guN5B7+na+zWXhepZ95j9mwR8uwv72nPfJ0h5ISqHB1nC2T0AdmV rYLUoLQFvcxEJjiQY875sCy+bo6iq5DdWI1gcLG5A2OzA8P0xm5WjWwO40k6SaHVJC JLEOkl2Iu4B0Q== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:04 -0500 Subject: [PATCH 08/20] filelock: convert posix_owner_key to take file_lock_core arg Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-8-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1521; i=jlayton@kernel.org; h=from:subject:message-id; bh=WIy21odrljEB/8swbFzVsTPOFgQ6www6fvkeNvY4iqY=; b=kA0DAAgBAA5oQRlWghUByyZiAGWm3SHI8HlRl76pu2TSIazqmfWFiBENf9VKaxrnEIZCTfeT4 okCMwQAAQgAHRYhBEvA17JEcbKhhOr10wAOaEEZVoIVBQJlpt0hAAoJEAAOaEEZVoIViQUQAKxb +b9el1PF/VmfJamuXgUyj19YbaXbVQKO6E9pjWNjQskJL75ddlMjtr/y744PPDGj9H4ju0pIWNh sqUSybtawT3M//aDvubTbkntkfvR4H0nySFl+vjiUI9p1/0DOAyz6ATkQhWQUMx3/tabewpUuUk iDBVltVkaiou7x8enWO23IUKYzeFAwK9j3gMvebdeYYcq9qDKH8kTSmXkHuyYUbaJ2rf0FrZWSW V4d5VyKbfzrNC8ghF4jG4sCiUycWCspWtx4EDvpE2F6FGEZ2tZomyZx1WEwbJea3jnf36JafysI DO3lpxuv39GLe5qUA6BV6H5e/PgRo01V2YsHIMgizY+rRheXglPhPQ+m+hKxJ6KtJ59X7BNsIHI SaHMZ4l42DhK04tsSRjtW1YUidY3i0wNJ4mRU667+oToOvzPs5SxGNZRhscsTc/YbphZcPQETyk YaMgKjO3AqFvdvvx8GOA448/IKYA1UAaaIFOXbO8ZalbMlp+73fSz4lIhg8d19zMfVZIk4vlRdW oqNJWTbFE7Wp4J/IVsYpedrJWOzAaiBftTtGNhANyWJsqJN33mkmkJumIuDG0Z8dqu1kizBGXN1 3ETLW5FK7hnpj9pfc/YAaRCYCyLO8ZaTzl/yvQEW5pYRAVwFvRCfV2TVl4rbCfuW90M1KG9qOEB qzYZR X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Convert posix_owner_key to take struct file_lock_core pointer, and fix up the callers to pass one in. Signed-off-by: Jeff Layton --- fs/locks.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 0c47497eb1a4..6432bcfb55a0 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -637,9 +637,9 @@ static void locks_delete_global_locks(struct file_lock *fl) } static unsigned long -posix_owner_key(struct file_lock *fl) +posix_owner_key(struct file_lock_core *flc) { - return (unsigned long) fl->fl_core.fl_owner; + return (unsigned long) flc->fl_owner; } static void locks_insert_global_blocked(struct file_lock *waiter) @@ -647,7 +647,7 @@ static void locks_insert_global_blocked(struct file_lock *waiter) lockdep_assert_held(&blocked_lock_lock); hash_add(blocked_hash, &waiter->fl_core.fl_link, - posix_owner_key(waiter)); + posix_owner_key(&waiter->fl_core)); } static void locks_delete_global_blocked(struct file_lock *waiter) @@ -984,7 +984,7 @@ static struct file_lock *what_owner_is_waiting_for(struct file_lock *block_fl) { struct file_lock *fl; - hash_for_each_possible(blocked_hash, fl, fl_core.fl_link, posix_owner_key(block_fl)) { + hash_for_each_possible(blocked_hash, fl, fl_core.fl_link, posix_owner_key(&block_fl->fl_core)) { if (posix_same_owner(&fl->fl_core, &block_fl->fl_core)) { while (fl->fl_core.fl_blocker) fl = fl->fl_core.fl_blocker; From patchwork Tue Jan 16 19:46:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521102 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 7BCFF21A13; Tue, 16 Jan 2024 19:47:22 +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=1705434442; cv=none; b=iHV08Vm7ohmOFFqSbQrN7ws1ko6yTJWd2MZwG7D7zT2a9JW/wcWX/kKexwoyc7IDgPsrPK6yGG3qDe++0hFCRAj57CK9m9Yk0KDC734sDJJeQRpF6PcOAbvYCMg4XB1/fQI/2cBXJ2yz780gjiJ93ZEDamUcMyIv7VEft/HxKsE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434442; c=relaxed/simple; bh=lyhSP5HzeA0ph/whZtydwjXJ8veikzHXxSTgaLspo7s=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=l0oMNL8JpxLf5dhE+PScMGl8ezeFKq58ASAKdVkhAVp7SuREJBaMgWUGYW329PRU6POqZB4nZYQOTmviC7/bs/NpZuPJfJ5Dbj7yfZpj7TcmDb8UXo3B18r+pNpLTt4i1ij5ExsOx92t+7Q3aR2tiE4JPhPkClz2VQ/diPDe3LM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Z3Roeunt; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Z3Roeunt" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4C87C43390; Tue, 16 Jan 2024 19:47:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434442; bh=lyhSP5HzeA0ph/whZtydwjXJ8veikzHXxSTgaLspo7s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Z3RoeuntzeKcYRnwrOeyfzDfHrTbafuIVNtokBNKPYnLbxpquCCGkbRE54bmxCMdP zUT1NjRDe5bk5bRh0mXfLpmtcUmhmeuh5eoqPdzqOP3TaoMx/sV6Lm/3ef8rPR0yWi sGSzzZM8trRr5wUaZINMwa9jCvz3DmgjFL+AzLYFdrQ4+Z4RJx1hx3OMpxR9KqlN3w 65bmHvEcbqOzfqYXYye8w1xIT3mBPsoVriqq6ckMkDGz6nepq7wWOwf+K9SitNyPBt l6v/HE/DXZAX7h24J+K7Pb+mUSrg7P2bhb2D9APZeBF/EVns9Bf4qENSIFQvhhvNXh BSC12xLkllPvA== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:05 -0500 Subject: [PATCH 09/20] filelock: make locks_{insert,delete}_global_locks take file_lock_core arg Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-9-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2249; i=jlayton@kernel.org; h=from:subject:message-id; bh=lyhSP5HzeA0ph/whZtydwjXJ8veikzHXxSTgaLspo7s=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0hz1Ko0HqQBzrZ/7Hx3siPwo6L37SNYA3Wx p/570vr4B2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIQAKCRAADmhBGVaC FRnDD/9vyfqWXL7+QxBzzsMwaHgDFWjgRUcBj6KcaxIxXKrTh52QtoRwHc0kjuBbcTuSRsWtULp Xdweq1h4P/ng7LluanZRzSHFUXoV9tIIDGq+vrXGsn2vm1U2ClzZ95nwP1j7+kuQvmzTdFve8X8 FriQhEXfxg8xnvIPDg/hie+7n/lTJHdIVPrycU0FWd/YkM4kHA5O6IJoChB5GtjhDVggeN64jGC E/tz8qLYwaY3jOY8jR6kp00CCxbFmK5fYH9lX7S3K24pPw1NYIO/x2Vsr9hJhB46TZ2xgMoUora itaIOxnxJAwbg98WuOjg8vV96Jpd3g6b7fr+kS00ZjlEpmo/YkGNxSxpaHWNgIRFpe+X3jHz+Xi kV9wH2ZBi7hExCvRLJMi9AT9VO/iyO3YmB8JAMjSNOFDPCNv+WlEBScgBpKvhU4YFooDexJV6By Gecje1jtMb3112xFqhWWC2/2p1wQL8KhuZpBFE7eIRykNEttkwvpWCRlB4Co6DtYbt67EfaRg55 m57z7XXJ3Xff80/L7NNrtSNdZVVjG7SsCBI6oHxSx+LNNFFvenFybi5sYxw5fAi3i3rlXIRpUjF w9w9M97hVus/hh7GImpOmOujIsjrELVG+O7+T8HIBKH6mwk+laWdHC5YmjMfJzASRIXSEmo/bOe N/vgaPByfpQn6MA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Convert these functions to take a file_lock_core instead of a file_lock. Signed-off-by: Jeff Layton --- fs/locks.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 6432bcfb55a0..5fe54f48b9c1 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -603,20 +603,20 @@ static int posix_same_owner(struct file_lock_core *fl1, struct file_lock_core *f } /* Must be called with the flc_lock held! */ -static void locks_insert_global_locks(struct file_lock *fl) +static void locks_insert_global_locks(struct file_lock_core *flc) { struct file_lock_list_struct *fll = this_cpu_ptr(&file_lock_list); percpu_rwsem_assert_held(&file_rwsem); spin_lock(&fll->lock); - fl->fl_core.fl_link_cpu = smp_processor_id(); - hlist_add_head(&fl->fl_core.fl_link, &fll->hlist); + flc->fl_link_cpu = smp_processor_id(); + hlist_add_head(&flc->fl_link, &fll->hlist); spin_unlock(&fll->lock); } /* Must be called with the flc_lock held! */ -static void locks_delete_global_locks(struct file_lock *fl) +static void locks_delete_global_locks(struct file_lock_core *flc) { struct file_lock_list_struct *fll; @@ -627,12 +627,12 @@ static void locks_delete_global_locks(struct file_lock *fl) * is done while holding the flc_lock, and new insertions into the list * also require that it be held. */ - if (hlist_unhashed(&fl->fl_core.fl_link)) + if (hlist_unhashed(&flc->fl_link)) return; - fll = per_cpu_ptr(&file_lock_list, fl->fl_core.fl_link_cpu); + fll = per_cpu_ptr(&file_lock_list, flc->fl_link_cpu); spin_lock(&fll->lock); - hlist_del_init(&fl->fl_core.fl_link); + hlist_del_init(&flc->fl_link); spin_unlock(&fll->lock); } @@ -821,13 +821,13 @@ static void locks_insert_lock_ctx(struct file_lock *fl, struct list_head *before) { list_add_tail(&fl->fl_core.fl_list, before); - locks_insert_global_locks(fl); + locks_insert_global_locks(&fl->fl_core); } static void locks_unlink_lock_ctx(struct file_lock *fl) { - locks_delete_global_locks(fl); + locks_delete_global_locks(&fl->fl_core); list_del_init(&fl->fl_core.fl_list); locks_wake_up_blocks(fl); } From patchwork Tue Jan 16 19:46:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521103 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 6694E37719; Tue, 16 Jan 2024 19:47:26 +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=1705434446; cv=none; b=MImqtbtvBbpoTW8ukNFTDqYxLzOARcUD2Jhg4dO/jxMaiVKvNZEgARXdyk3J/BUPu2TtkdoLueX6zy1nUnLxDaYufv8nBW/rQ3XRGTwesTAcxYtKqiBdQJeEJvFBTvQNbM+UhRWgBjNYUdZvIiTnjp8hGPOsYPlTbQrvknCH8PA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434446; c=relaxed/simple; bh=66rpBBxRF2rJb303Mt/pEYvt97DkJ3vkW26GZ/SUUu8=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=ZEpaDpvNhGz86FUCZr8mmI/PUg5hEjnR0luvLl43BtzvGab7p9OWS6QjPoySaMOMMBWZ6HP/F4V0A9SEVcg8x2E1joLvEtqzP5d1IU4q2+4uffhFvXQeLYxI9UMpiD/zcXIo+4Sj9sR8M3JZKm4btVYTxq9wE6HkRWB+eXG3mEs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tFfTZRBl; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tFfTZRBl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F4F6C43399; Tue, 16 Jan 2024 19:47:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434446; bh=66rpBBxRF2rJb303Mt/pEYvt97DkJ3vkW26GZ/SUUu8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tFfTZRBlkiCk9Eab2eEQSMGmc8OV/LJsjXpZlKXSKlldgNFXLvc7bC4usSVlvaW9i Gkg6WfRCh4Olf6lZcfwtO+XwV+irXRZQ+Y6ZxIlWrG2+VLXv0aJYjPdJAXoNIpjKXn dgeDVmNkhzPt282Zja4kOLVK+mylOvOUy/lLahMNq5K/YV4NU7mquEmoMeVy50mZSv fK8klBfP3WI8Hphmx/ooWaS75ivWuPXCb3UTg3hFTlCOFxgRzaod9pKbtjbVsbgrM9 U/yi/ERcULhVKac/eILSgveCKb8IkiBAk+5CWmQi6TL0pxwSyZrSP673CqT95KZdSO sGheVeaPna3EQ== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:06 -0500 Subject: [PATCH 10/20] filelock: convert locks_{insert,delete}_global_blocked Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-10-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1939; i=jlayton@kernel.org; h=from:subject:message-id; bh=66rpBBxRF2rJb303Mt/pEYvt97DkJ3vkW26GZ/SUUu8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0hPQuRA/Abxngx548TLejvptzB1l9nP03DR GO9Nuqe4y2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIQAKCRAADmhBGVaC FQUSD/9S5nDMSLzIoBx9vB361eiaIcOC3TmbdtceOtF+KCiAi9eWXt4DhFqbNtdbqC9rpx+3IfC mLhS6/Zw4mAZqZBPGcURkFfRoVmhyYCzug5fY+rVF1MyrrNkaDNSOcz05S9bmJ9wITmBnfEYZjb sM6jHMAaYV5xpLQBGgWvfVaZLK83fi8FqNXgW2DG7qoAvvzIFfPD5bM0aQQ0Pqj27m3W6YmvObC uoJbVbWj8pq/ZETS5jQiQ4zsqlNb2ZyQEgJmkrcTZ/XiXng62F03RXAay1dDJ5/8l2qN96Lo+qO 96PGNAOfmuRcdJ+us2i4GxlR1JYpfGR2TkoTJH87evlOXL8h2GPijHylqikofsvPulBK7/N6ABi RjbWHWgeBNspA7JR0yTo4yYy+iChvBMbnCEGPBGNIeaR9Z4UNFOjjIpdfA/5hmp4yXksPPmAdwF g9qc89zKVTHrYh8NHS4MdyOVSFeSFn9HBsM79eH7BQcZSFJOMcJrBEcq8ZJZhmTD51FbhVNnqeo X/4w9YASaRiLmBARrAg6RvXwBjENPIg5lu0iZu/UOCokCgi+F4qDGNUXfL/uTT5Cxw4i7KsduQi m9ZOIiArcBNp765MHY8i4z+pdh4K1jQdLgw/lKAcYqzNUs11fbNKTSljL7FwC9SWzTUN9zzQmIg 0W+NZaNYeCIrsZw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Have locks_insert_global_blocked and locks_delete_global_blocked take a struct file_lock_core pointer. Signed-off-by: Jeff Layton --- fs/locks.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 5fe54f48b9c1..770aaa5809ba 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -642,19 +642,18 @@ posix_owner_key(struct file_lock_core *flc) return (unsigned long) flc->fl_owner; } -static void locks_insert_global_blocked(struct file_lock *waiter) +static void locks_insert_global_blocked(struct file_lock_core *waiter) { lockdep_assert_held(&blocked_lock_lock); - hash_add(blocked_hash, &waiter->fl_core.fl_link, - posix_owner_key(&waiter->fl_core)); + hash_add(blocked_hash, &waiter->fl_link, posix_owner_key(waiter)); } -static void locks_delete_global_blocked(struct file_lock *waiter) +static void locks_delete_global_blocked(struct file_lock_core *waiter) { lockdep_assert_held(&blocked_lock_lock); - hash_del(&waiter->fl_core.fl_link); + hash_del(&waiter->fl_link); } /* Remove waiter from blocker's block list. @@ -664,7 +663,7 @@ static void locks_delete_global_blocked(struct file_lock *waiter) */ static void __locks_delete_block(struct file_lock *waiter) { - locks_delete_global_blocked(waiter); + locks_delete_global_blocked(&waiter->fl_core); list_del_init(&waiter->fl_core.fl_blocked_member); } @@ -775,7 +774,7 @@ static void __locks_insert_block(struct file_lock *blocker, list_add_tail(&waiter->fl_core.fl_blocked_member, &blocker->fl_core.fl_blocked_requests); if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) - locks_insert_global_blocked(waiter); + locks_insert_global_blocked(&waiter->fl_core); /* The requests in waiter->fl_blocked are known to conflict with * waiter, but might not conflict with blocker, or the requests From patchwork Tue Jan 16 19:46:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521104 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 51B3F7C090; Tue, 16 Jan 2024 19:47:30 +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=1705434450; cv=none; b=sz9dLmM+TWpNoP6Gkk3d05TSiiQ6S20DkYRqnDO9mK1QP2iMnrK1TpxovFjthvyadTA+i1IZ+rx9/PhgjZPRFM5E7oTIq8oF4LAy6INYQogf0lWKG5wpJ70i1EyjCJp/kyEVKvYkY2BOKPbJnPtNxJ9JwRD4ZCDd+Z0poOWmMAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434450; c=relaxed/simple; bh=hDNBllLWV7rE28a4tOW8PqqKsyO/cQNheeJo5XTQ5lQ=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=f0QuNc4RgukpEp8zkrstK3AJoT9jKriX4rRrCC3ZR+bInF+ki36h7SAMkBa8lBbmZW4G/GtqUoBN/kTAA9hQFvGZk7bNOqmG2M4Logzu2Y1yQZ+LX2D3u7s9EA6V4Agon5UlvN5FIN6SNgtaxjieo+cO+1k+gjI3APLbR8OjTvQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kzcsdZNn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kzcsdZNn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A334C43609; Tue, 16 Jan 2024 19:47:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434450; bh=hDNBllLWV7rE28a4tOW8PqqKsyO/cQNheeJo5XTQ5lQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kzcsdZNnwtOwDz+0ScxdCgLnAXucXNw7pUfdtWDuahWCJ7bHfkRUMtfY6tW9uFCRv 0Xtqh8iUkDN13I8l8shnWGlj+o+zcpmjyOpb1sgBdGn7Y3ZyL/ulTeR5AuqnDEe7j0 xT+TxTRPGklIuXvF/YYUpO0joYz4Dp/+pQpfOr/GK1QG/XkciN2+QNWytsueK4FCPi r7iqT5aCProcxW19BTUCkdfn4U3HnjrCJvDQUnVTu7ZdHG96LkSDYX1CMcMvf2ThBE MAnnPuenyKlNFCUf1jJQA0xj/bvMxMk3FETk6Fja7sdct35OA6hb+BaEvrhZPXMAX4 oPdHxej0qesCA== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:07 -0500 Subject: [PATCH 11/20] filelock: convert the IS_* macros to take file_lock_core Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-11-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4374; i=jlayton@kernel.org; h=from:subject:message-id; bh=hDNBllLWV7rE28a4tOW8PqqKsyO/cQNheeJo5XTQ5lQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0h/L8At3nBU2VgP+pUsnh2pXoFcx9uKIWpb Hqa7gddCUGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIQAKCRAADmhBGVaC FYM9D/4/y07BKDV0bDKK4dYeYFXbGjF1XoU54+6uRIu/8Wtx0wBs9naTPAB/E6sCv7BGMv9W+x1 b1wcPq336mQ8WcP8VafWXEQa6y9kffgjyqsFmcaSXYxPWp3ulvEUAUtni0gfT5isyVIt9oYooyA qYrYbKllZHg46JotkIK/E0cX2zHl2/kaWWxuufxRFPItIQ1Oet34OZKF5hkQFqlwCGcTAfZIDnz urWXdczSOzfxHf7XDY9H4Lv8qNROKN95Fl82IJ+31zTIoM17iI+vzxyBjKX5yCiUL6bzlgwNIBb fZvAYQ3mNJtJwXD+am8GOFC++hBSMEZbkOhgiUy1zBH/4F7rjkUJH5Rv8jiq+2syNyIS6ffo/8A 9xW+8ANWLZ+ASuPDGI7psXJCwhT944/Afp1pjfUTH66dd+dvNqq95m26KxYlKLizNMYTi8L8AtW H5pDBZlFt30Y6jZkmwyMPfLEq6mCWCVMKBjpVYPx2AAFjDu928AMd3SECwfdF3NEEys/eX4Vo4M vcyItUEyGVwpXH9HOeNuyCpYMXq2sH4ZzY71JpDYuZxYbA7MncxxewQXScLup3Rv2fe5Ij9F4Mi ZXFaATkQE9c4mvpn8IMRbuyGsmrJPM3xSi6ZKqzTeaI4+6clsh1Jl8/OILx0h5MG8pTP8WdZwS1 wThFLIR2rQGY4Hw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 I couldn't get them to work properly as macros, so convert them to static inlines instead (which is probably better for the type safety anyway). Signed-off-by: Jeff Layton --- fs/locks.c | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 770aaa5809ba..eddf4d767d5d 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -70,10 +70,26 @@ #include -#define IS_POSIX(fl) (fl->fl_core.fl_flags & FL_POSIX) -#define IS_FLOCK(fl) (fl->fl_core.fl_flags & FL_FLOCK) -#define IS_LEASE(fl) (fl->fl_core.fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) -#define IS_OFDLCK(fl) (fl->fl_core.fl_flags & FL_OFDLCK) +static inline bool IS_POSIX(struct file_lock_core *flc) +{ + return flc->fl_flags & FL_POSIX; +} + +static inline bool IS_FLOCK(struct file_lock_core *flc) +{ + return flc->fl_flags & FL_FLOCK; +} + +static inline bool IS_OFDLCK(struct file_lock_core *flc) +{ + return flc->fl_flags & FL_OFDLCK; +} + +static inline bool IS_LEASE(struct file_lock_core *flc) +{ + return flc->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT); +} + #define IS_REMOTELCK(fl) (fl->fl_core.fl_pid <= 0) static bool lease_breaking(struct file_lock *fl) @@ -761,6 +777,7 @@ static void __locks_insert_block(struct file_lock *blocker, struct file_lock *)) { struct file_lock *fl; + struct file_lock_core *bflc; BUG_ON(!list_empty(&waiter->fl_core.fl_blocked_member)); new_blocker: @@ -773,7 +790,9 @@ static void __locks_insert_block(struct file_lock *blocker, waiter->fl_core.fl_blocker = blocker; list_add_tail(&waiter->fl_core.fl_blocked_member, &blocker->fl_core.fl_blocked_requests); - if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) + + bflc = &blocker->fl_core; + if (IS_POSIX(bflc) && !IS_OFDLCK(bflc)) locks_insert_global_blocked(&waiter->fl_core); /* The requests in waiter->fl_blocked are known to conflict with @@ -998,6 +1017,7 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, struct file_lock *block_fl) { int i = 0; + struct file_lock_core *flc = &caller_fl->fl_core; lockdep_assert_held(&blocked_lock_lock); @@ -1005,7 +1025,7 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, * This deadlock detector can't reasonably detect deadlocks with * FL_OFDLCK locks, since they aren't owned by a process, per-se. */ - if (IS_OFDLCK(caller_fl)) + if (IS_OFDLCK(flc)) return 0; while ((block_fl = what_owner_is_waiting_for(block_fl))) { @@ -2157,7 +2177,7 @@ static pid_t locks_translate_pid(struct file_lock *fl, struct pid_namespace *ns) pid_t vnr; struct pid *pid; - if (IS_OFDLCK(fl)) + if (IS_OFDLCK(&fl->fl_core)) return -1; if (IS_REMOTELCK(fl)) return fl->fl_core.fl_pid; @@ -2721,19 +2741,19 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, if (repeat) seq_printf(f, "%*s", repeat - 1 + (int)strlen(pfx), pfx); - if (IS_POSIX(fl)) { + if (IS_POSIX(&fl->fl_core)) { if (fl->fl_core.fl_flags & FL_ACCESS) seq_puts(f, "ACCESS"); - else if (IS_OFDLCK(fl)) + else if (IS_OFDLCK(&fl->fl_core)) seq_puts(f, "OFDLCK"); else seq_puts(f, "POSIX "); seq_printf(f, " %s ", (inode == NULL) ? "*NOINODE*" : "ADVISORY "); - } else if (IS_FLOCK(fl)) { + } else if (IS_FLOCK(&fl->fl_core)) { seq_puts(f, "FLOCK ADVISORY "); - } else if (IS_LEASE(fl)) { + } else if (IS_LEASE(&fl->fl_core)) { if (fl->fl_core.fl_flags & FL_DELEG) seq_puts(f, "DELEG "); else @@ -2748,7 +2768,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, } else { seq_puts(f, "UNKNOWN UNKNOWN "); } - type = IS_LEASE(fl) ? target_leasetype(fl) : fl->fl_core.fl_type; + type = IS_LEASE(&fl->fl_core) ? target_leasetype(fl) : fl->fl_core.fl_type; seq_printf(f, "%s ", (type == F_WRLCK) ? "WRITE" : (type == F_RDLCK) ? "READ" : "UNLCK"); @@ -2760,7 +2780,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, } else { seq_printf(f, "%d :0 ", fl_pid); } - if (IS_POSIX(fl)) { + if (IS_POSIX(&fl->fl_core)) { if (fl->fl_end == OFFSET_MAX) seq_printf(f, "%Ld EOF\n", fl->fl_start); else From patchwork Tue Jan 16 19:46:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521105 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 92F597CF16; Tue, 16 Jan 2024 19:47:34 +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=1705434454; cv=none; b=JJQzhtZMS04IkrGJFFzFPp7YWBhWiDl94AiEajsdZzwV3Nzfpnh3uQ2z9gQOi7XG/j8/ZKNTE6UdQHssjTtF9/Mo0xPPCR4Sw/IpmBMP7bLgcu5H6l3l5q7KfNbEQ7moWaH7a0l2NGrkxO1/2/xnuMueD55f35FebCXYgshxKsQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434454; c=relaxed/simple; bh=AkiTCb6wI/I7afKxVR9W5K0pvQ6+tRl16zAHjb4fgIA=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=hG+Xxl/3rNFVnEqnNWX/Yoom4AAlsreif+FAVQhGu0km1mppxd5MRbA23nepLPwfJwo81zocCZawyw/dZGQc6z1K3OycmSxiZsJozjCzX6IdqecID+s0lk3npTFxBcxCK1J+qIrEpVZdow2IJtPNtZ1OIBJRT1+YSQyVT+PewPE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QEhrTykK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QEhrTykK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64D62C433F1; Tue, 16 Jan 2024 19:47:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434454; bh=AkiTCb6wI/I7afKxVR9W5K0pvQ6+tRl16zAHjb4fgIA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QEhrTykKlwOGz5IuTVNR5SOUJoPTi1MlovOZyLg/e5ggi+VPJokYrXvWLP0FM0CmF UciNRXb8LAHsbDcH7RnDxPNl456DEp5vNTqNKqS3Zll1Bm/UKxtmm0C6WW5hZKpIxt quhzwRalKlVZNzA+Y83mkDs74ua4fL/hk5TRUc+QIlB+DzneVrkaBYzn3rR9mdBrR1 gXy4IF/J+EaHEkLb0tJ/Fgrx9suZljHU9xEdLnl9umNAXRMIjVNqmVxLTVpTsox4EL 5YD/uGpJhclwCMziD6w93ypv+5XjDqsVUPSwKUacl+oHEX5LAI7YjFHM0Fam/2eh33 ltxJXjI9mbukA== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:08 -0500 Subject: [PATCH 12/20] filelock: make __locks_delete_block and __locks_wake_up_blocks take file_lock_core Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-12-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4069; i=jlayton@kernel.org; h=from:subject:message-id; bh=AkiTCb6wI/I7afKxVR9W5K0pvQ6+tRl16zAHjb4fgIA=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0h5QYo2Mzczjq3QvKNi1KSMPpywliqQ0U92 SG1Z2SOvF2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIQAKCRAADmhBGVaC FaY2D/4rwgL7811zt1zhBumpeY4uAeYPfPfqjMV7b5bI8BhMtPvnC7XrU4EUKDt+cJYJbGa6TJI gc4apK+Bt2ih3DLCgFlWrcK5iM8fIcbgwMK8r01AZK0jzHVF+1b0CS2Nu/LhrRqM4XIWnztPXt1 7tipdDp4tBL6O+Fhv9GaHJZBGBVS52ThJmjemF1a+LZRw5qqOipyu1R5evakULxCX6PhsllNMTT XrB5H3McvLNHE2mYC7Fon0ilA96p2kKzW8jLe+KR8mp5MDBx7G+ttZ1gPb8FMT7kIcNeCrvE9S5 m7CeaQ+o4zmtpXvtsWdLPUS7nQIul9Rcwtdgr7BvI0aIMnQ1Szmp8sicKVblSxBSVOqx7hmizRs mnbQ1sgavpwWDJ1I9hofCOd7EYPNm1aFE7mngQX45DCOd9A3Opkw2oI3a8autiEd17ofuzb4pTB kOO/7K3/Dugnq5UW589/4O2WbawsSkzXUdVe+XSrJHJ/Uq05RrjaxLYElWRSFb/Fj/8YDxntP1V wJcZnSdtK1XZjTKlY0Z9bRJhxjs1UoAm7427TQug4LUjGx1fOajuOLQoHQzGNqFlEhCN3CGLlmo 56gyESKLCL619gAE80X899aNbVw5SrNibMs3zCs+MhAlnR2H+ul6CizW0dRDnKE/MWgNEaDoGcE 1fTJDFYiDK6yu9g== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Convert __locks_delete_block and __locks_wake_up_blocks to take a struct file_lock_core pointer. Note that to accomodate this, we need to add a new file_lock() wrapper to go from file_lock_core to file_lock. Signed-off-by: Jeff Layton --- fs/locks.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index eddf4d767d5d..6b8e8820dec9 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -92,6 +92,11 @@ static inline bool IS_LEASE(struct file_lock_core *flc) #define IS_REMOTELCK(fl) (fl->fl_core.fl_pid <= 0) +struct file_lock *file_lock(struct file_lock_core *flc) +{ + return container_of(flc, struct file_lock, fl_core); +} + static bool lease_breaking(struct file_lock *fl) { return fl->fl_core.fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); @@ -677,31 +682,35 @@ static void locks_delete_global_blocked(struct file_lock_core *waiter) * * Must be called with blocked_lock_lock held. */ -static void __locks_delete_block(struct file_lock *waiter) +static void __locks_delete_block(struct file_lock_core *waiter) { - locks_delete_global_blocked(&waiter->fl_core); - list_del_init(&waiter->fl_core.fl_blocked_member); + locks_delete_global_blocked(waiter); + list_del_init(&waiter->fl_blocked_member); } -static void __locks_wake_up_blocks(struct file_lock *blocker) +static void __locks_wake_up_blocks(struct file_lock_core *blocker) { - while (!list_empty(&blocker->fl_core.fl_blocked_requests)) { - struct file_lock *waiter; + while (!list_empty(&blocker->fl_blocked_requests)) { + struct file_lock_core *waiter; + struct file_lock *fl; + + waiter = list_first_entry(&blocker->fl_blocked_requests, + struct file_lock_core, fl_blocked_member); - waiter = list_first_entry(&blocker->fl_core.fl_blocked_requests, - struct file_lock, fl_core.fl_blocked_member); + fl = file_lock(waiter); __locks_delete_block(waiter); - if (waiter->fl_lmops && waiter->fl_lmops->lm_notify) - waiter->fl_lmops->lm_notify(waiter); + if ((IS_POSIX(waiter) || IS_FLOCK(waiter)) && + fl->fl_lmops && fl->fl_lmops->lm_notify) + fl->fl_lmops->lm_notify(fl); else - wake_up(&waiter->fl_core.fl_wait); + wake_up(&waiter->fl_wait); /* * The setting of fl_blocker to NULL marks the "done" * point in deleting a block. Paired with acquire at the top * of locks_delete_block(). */ - smp_store_release(&waiter->fl_core.fl_blocker, NULL); + smp_store_release(&waiter->fl_blocker, NULL); } } @@ -743,8 +752,8 @@ int locks_delete_block(struct file_lock *waiter) spin_lock(&blocked_lock_lock); if (waiter->fl_core.fl_blocker) status = 0; - __locks_wake_up_blocks(waiter); - __locks_delete_block(waiter); + __locks_wake_up_blocks(&waiter->fl_core); + __locks_delete_block(&waiter->fl_core); /* * The setting of fl_blocker to NULL marks the "done" point in deleting @@ -799,7 +808,7 @@ static void __locks_insert_block(struct file_lock *blocker, * waiter, but might not conflict with blocker, or the requests * and lock which block it. So they all need to be woken. */ - __locks_wake_up_blocks(waiter); + __locks_wake_up_blocks(&waiter->fl_core); } /* Must be called with flc_lock held. */ @@ -831,7 +840,7 @@ static void locks_wake_up_blocks(struct file_lock *blocker) return; spin_lock(&blocked_lock_lock); - __locks_wake_up_blocks(blocker); + __locks_wake_up_blocks(&blocker->fl_core); spin_unlock(&blocked_lock_lock); } @@ -1186,7 +1195,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, * Ensure that we don't find any locks blocked on this * request during deadlock detection. */ - __locks_wake_up_blocks(request); + __locks_wake_up_blocks(&request->fl_core); if (likely(!posix_locks_deadlock(request, fl))) { error = FILE_LOCK_DEFERRED; __locks_insert_block(fl, request, From patchwork Tue Jan 16 19:46:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521106 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 7DFFA7CF3E; Tue, 16 Jan 2024 19:47:38 +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=1705434458; cv=none; b=S6AaqkBEngVBHE6URGtK+U8Ynf6BtpzBZjoF5L4h6FbUUgA962NgeLPyw2Se5h5x6enYN2cbkaMASs2rO1KwWurNcf3CjturlefH/XMVbgfNHHcaxMISfWVKuV4aUyR7qnO+MYdT4iTI1XO4nFAZ3xIWlYkFs24k2Lv5ugU28pI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434458; c=relaxed/simple; bh=pwXKsOLMA39qGe1pWMGJ+cEJ/IOGKFqtfcRpJaO4ADs=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=uPE6CzsE8GmvGWbJ6zj3KAu2cF+wOR5RJQbpSgVaRkTPwl8QBaHdiywzeWF6dPG3HmaNJbL8zDxx5+cuSeN6pUqzWjYvCkkPTKT4kLnSGVcopNw+sDzqfrOQIywY5l+Ss35dOVxslY2QTPpOWUS7a6Im/dUZQtClkvN/LsQJ9nE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KX8LQhaG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KX8LQhaG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 50558C43390; Tue, 16 Jan 2024 19:47:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434458; bh=pwXKsOLMA39qGe1pWMGJ+cEJ/IOGKFqtfcRpJaO4ADs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KX8LQhaG7gcLIN8wB5hcLNWMPpZkdBfa5pQuw3JMkaLkY3p5HVP3riXhXktFNgcav uNplozIrYQPkL8OE67thPoA4PLrmYTC4yVaSAUXWEi97QkcAOfqhMYNv1TuBphhOHM LrZqUYXOskQkCM9XfNTL7KWPpw9CCIKED12EbN5OnlQrckAMzzq0FPreIr7L1ajCAK ef8edYI5YFSLlXZUXbuZV5iSFnBXGdK4iSr6U+AmYMhCiHahVnYmV5ny1a37BGWloa qHAqQnJKcpA28je/tpx8M+v0bUQzO3wqox6VgfK/XI7H1CTlobiCgRKOvMSQsDRmdo 0eAWhGnNTrMcg== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:09 -0500 Subject: [PATCH 13/20] filelock: convert __locks_insert_block, conflict and deadlock checks to use file_lock_core Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-13-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=10881; i=jlayton@kernel.org; h=from:subject:message-id; bh=pwXKsOLMA39qGe1pWMGJ+cEJ/IOGKFqtfcRpJaO4ADs=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0hs8i3UlSny6JLQMGxbpqdfGCP/rIswXMio dcEEduC982JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIQAKCRAADmhBGVaC FQ9tD/41k11ICXk15Y9Te7Z3HUZHaJn4udDfFN0uHj75kXGXAIHblmPG8U8xiAMtkiIVBJFEXUu jgmjAhkUcoHTIeLH7uijcwJI8VvMSWwf2icK7y1CarU114iJED/NJT9EqPYY29v+flqDTZ6walz W/m15lnn3XhUKVpICHpR5ywmJ0rrBxIG7zbFKTW86qPrQknIuTeQNziZUTTO1j7kKF1SwxzR5N/ gB2/qIHhGvcfNnyl64TfkyJg47o5XdzlpZn1ha35O5T+Ji+UXFG27gTXMhlywhxJ4HPO3Izo8iE 0AzAItP3wRARdJBbc3L+pd8xKZUdCe0XhNDDm9LABfOmPCMa/EyDMwdeFa3bNKeQG2UCMB61SJz /pjR0OrV/Upu39irnotDryYb3MJ9WsuI6j91J5di9veTfin3lqCbRosQ41UE2dB0tO331TGuJIx S8Vi1wwV+OwmcXPfSR4UuVnyTsx6GHeHzQ5+KJQkSueoBsC70bLRhXfNF0p6nHEk+9FwM6iCHKi VYiBz92ICl47NBkgG3xjMyJSVxkvZaoZJD2uOVP+2d+nJzxxhytMoBMXDOHk9wc/5RVw+Dxe3M5 YNklTNCWQ1YFmIm6ylavX+/JfEGIgNWSP1yj9xKbrbxh3zCLN9GkHIAK9RMwNtZyM4k44n8l8U+ L7mvGHfF9WiChBA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Have both __locks_insert_block and the deadlock and conflict checking functions take a struct file_lock_core pointer instead of a struct file_lock one. Also, change posix_locks_deadlock to return bool. Signed-off-by: Jeff Layton --- fs/locks.c | 132 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 70 insertions(+), 62 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 6b8e8820dec9..280149860d5e 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -780,42 +780,41 @@ EXPORT_SYMBOL(locks_delete_block); * waiters, and add beneath any waiter that blocks the new waiter. * Thus wakeups don't happen until needed. */ -static void __locks_insert_block(struct file_lock *blocker, - struct file_lock *waiter, - bool conflict(struct file_lock *, - struct file_lock *)) +static void __locks_insert_block(struct file_lock *blocker_fl, + struct file_lock *waiter_fl, + bool conflict(struct file_lock_core *, + struct file_lock_core *)) { - struct file_lock *fl; - struct file_lock_core *bflc; - BUG_ON(!list_empty(&waiter->fl_core.fl_blocked_member)); + struct file_lock_core *blocker = &blocker_fl->fl_core; + struct file_lock_core *waiter = &waiter_fl->fl_core; + struct file_lock_core *flc; + BUG_ON(!list_empty(&waiter->fl_blocked_member)); new_blocker: - list_for_each_entry(fl, &blocker->fl_core.fl_blocked_requests, - fl_core.fl_blocked_member) - if (conflict(fl, waiter)) { - blocker = fl; + list_for_each_entry(flc, &blocker->fl_blocked_requests, fl_blocked_member) + if (conflict(flc, waiter)) { + blocker = flc; goto new_blocker; } - waiter->fl_core.fl_blocker = blocker; - list_add_tail(&waiter->fl_core.fl_blocked_member, - &blocker->fl_core.fl_blocked_requests); + waiter->fl_blocker = file_lock(blocker); + list_add_tail(&waiter->fl_blocked_member, + &blocker->fl_blocked_requests); - bflc = &blocker->fl_core; - if (IS_POSIX(bflc) && !IS_OFDLCK(bflc)) - locks_insert_global_blocked(&waiter->fl_core); + if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) + locks_insert_global_blocked(waiter); /* The requests in waiter->fl_blocked are known to conflict with * waiter, but might not conflict with blocker, or the requests * and lock which block it. So they all need to be woken. */ - __locks_wake_up_blocks(&waiter->fl_core); + __locks_wake_up_blocks(waiter); } /* Must be called with flc_lock held. */ static void locks_insert_block(struct file_lock *blocker, struct file_lock *waiter, - bool conflict(struct file_lock *, - struct file_lock *)) + bool conflict(struct file_lock_core *, + struct file_lock_core *)) { spin_lock(&blocked_lock_lock); __locks_insert_block(blocker, waiter, conflict); @@ -872,12 +871,12 @@ locks_delete_lock_ctx(struct file_lock *fl, struct list_head *dispose) /* Determine if lock sys_fl blocks lock caller_fl. Common functionality * checks for shared/exclusive status of overlapping locks. */ -static bool locks_conflict(struct file_lock *caller_fl, - struct file_lock *sys_fl) +static bool locks_conflict(struct file_lock_core *caller_fl, + struct file_lock_core *sys_fl) { - if (sys_fl->fl_core.fl_type == F_WRLCK) + if (sys_fl->fl_type == F_WRLCK) return true; - if (caller_fl->fl_core.fl_type == F_WRLCK) + if (caller_fl->fl_type == F_WRLCK) return true; return false; } @@ -885,20 +884,23 @@ static bool locks_conflict(struct file_lock *caller_fl, /* Determine if lock sys_fl blocks lock caller_fl. POSIX specific * checking before calling the locks_conflict(). */ -static bool posix_locks_conflict(struct file_lock *caller_fl, - struct file_lock *sys_fl) +static bool posix_locks_conflict(struct file_lock_core *caller_flc, + struct file_lock_core *sys_flc) { + struct file_lock *caller_fl = file_lock(caller_flc); + struct file_lock *sys_fl = file_lock(sys_flc); + /* POSIX locks owned by the same process do not conflict with * each other. */ - if (posix_same_owner(&caller_fl->fl_core, &sys_fl->fl_core)) + if (posix_same_owner(caller_flc, sys_flc)) return false; /* Check whether they overlap */ if (!locks_overlap(caller_fl, sys_fl)) return false; - return locks_conflict(caller_fl, sys_fl); + return locks_conflict(caller_flc, sys_flc); } /* Determine if lock sys_fl blocks lock caller_fl. Used on xx_GETLK @@ -907,28 +909,31 @@ static bool posix_locks_conflict(struct file_lock *caller_fl, static bool posix_test_locks_conflict(struct file_lock *caller_fl, struct file_lock *sys_fl) { + struct file_lock_core *caller = &caller_fl->fl_core; + struct file_lock_core *sys = &sys_fl->fl_core; + /* F_UNLCK checks any locks on the same fd. */ - if (caller_fl->fl_core.fl_type == F_UNLCK) { - if (!posix_same_owner(&caller_fl->fl_core, &sys_fl->fl_core)) + if (caller->fl_type == F_UNLCK) { + if (!posix_same_owner(caller, sys)) return false; return locks_overlap(caller_fl, sys_fl); } - return posix_locks_conflict(caller_fl, sys_fl); + return posix_locks_conflict(caller, sys); } /* Determine if lock sys_fl blocks lock caller_fl. FLOCK specific * checking before calling the locks_conflict(). */ -static bool flock_locks_conflict(struct file_lock *caller_fl, - struct file_lock *sys_fl) +static bool flock_locks_conflict(struct file_lock_core *caller_flc, + struct file_lock_core *sys_flc) { /* FLOCK locks referring to the same filp do not conflict with * each other. */ - if (caller_fl->fl_core.fl_file == sys_fl->fl_core.fl_file) + if (caller_flc->fl_file == sys_flc->fl_file) return false; - return locks_conflict(caller_fl, sys_fl); + return locks_conflict(caller_flc, sys_flc); } void @@ -1006,27 +1011,28 @@ EXPORT_SYMBOL(posix_test_lock); #define MAX_DEADLK_ITERATIONS 10 -/* Find a lock that the owner of the given block_fl is blocking on. */ -static struct file_lock *what_owner_is_waiting_for(struct file_lock *block_fl) +/* Find a lock that the owner of the given @blocker is blocking on. */ +static struct file_lock_core *what_owner_is_waiting_for(struct file_lock_core *blocker) { - struct file_lock *fl; + struct file_lock_core *flc; - hash_for_each_possible(blocked_hash, fl, fl_core.fl_link, posix_owner_key(&block_fl->fl_core)) { - if (posix_same_owner(&fl->fl_core, &block_fl->fl_core)) { - while (fl->fl_core.fl_blocker) - fl = fl->fl_core.fl_blocker; - return fl; + hash_for_each_possible(blocked_hash, flc, fl_link, posix_owner_key(blocker)) { + if (posix_same_owner(flc, blocker)) { + while (flc->fl_blocker) + flc = &flc->fl_blocker->fl_core; + return flc; } } return NULL; } /* Must be called with the blocked_lock_lock held! */ -static int posix_locks_deadlock(struct file_lock *caller_fl, - struct file_lock *block_fl) +static bool posix_locks_deadlock(struct file_lock *caller_fl, + struct file_lock *block_fl) { + struct file_lock_core *caller = &caller_fl->fl_core; + struct file_lock_core *blocker = &block_fl->fl_core; int i = 0; - struct file_lock_core *flc = &caller_fl->fl_core; lockdep_assert_held(&blocked_lock_lock); @@ -1034,16 +1040,16 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, * This deadlock detector can't reasonably detect deadlocks with * FL_OFDLCK locks, since they aren't owned by a process, per-se. */ - if (IS_OFDLCK(flc)) + if (IS_OFDLCK(caller)) return 0; - while ((block_fl = what_owner_is_waiting_for(block_fl))) { + while ((blocker = what_owner_is_waiting_for(blocker))) { if (i++ > MAX_DEADLK_ITERATIONS) - return 0; - if (posix_same_owner(&caller_fl->fl_core, &block_fl->fl_core)) - return 1; + return false; + if (posix_same_owner(caller, blocker)) + return true; } - return 0; + return false; } /* Try to create a FLOCK lock on filp. We always insert new FLOCK locks @@ -1098,7 +1104,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) find_conflict: list_for_each_entry(fl, &ctx->flc_flock, fl_core.fl_list) { - if (!flock_locks_conflict(request, fl)) + if (!flock_locks_conflict(&request->fl_core, &fl->fl_core)) continue; error = -EAGAIN; if (!(request->fl_core.fl_flags & FL_SLEEP)) @@ -1167,7 +1173,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, */ if (request->fl_core.fl_type != F_UNLCK) { list_for_each_entry(fl, &ctx->flc_posix, fl_core.fl_list) { - if (!posix_locks_conflict(request, fl)) + if (!posix_locks_conflict(&request->fl_core, &fl->fl_core)) continue; if (fl->fl_lmops && fl->fl_lmops->lm_lock_expirable && (*fl->fl_lmops->lm_lock_expirable)(fl)) { @@ -1469,23 +1475,25 @@ static void time_out_leases(struct inode *inode, struct list_head *dispose) } } -static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker) +static bool leases_conflict(struct file_lock_core *lc, struct file_lock_core *bc) { bool rc; + struct file_lock *lease = file_lock(lc); + struct file_lock *breaker = file_lock(bc); if (lease->fl_lmops->lm_breaker_owns_lease && lease->fl_lmops->lm_breaker_owns_lease(lease)) return false; - if ((breaker->fl_core.fl_flags & FL_LAYOUT) != (lease->fl_core.fl_flags & FL_LAYOUT)) { + if ((bc->fl_flags & FL_LAYOUT) != (lc->fl_flags & FL_LAYOUT)) { rc = false; goto trace; } - if ((breaker->fl_core.fl_flags & FL_DELEG) && (lease->fl_core.fl_flags & FL_LEASE)) { + if ((bc->fl_flags & FL_DELEG) && (lc->fl_flags & FL_LEASE)) { rc = false; goto trace; } - rc = locks_conflict(breaker, lease); + rc = locks_conflict(bc, lc); trace: trace_leases_conflict(rc, lease, breaker); return rc; @@ -1495,12 +1503,12 @@ static bool any_leases_conflict(struct inode *inode, struct file_lock *breaker) { struct file_lock_context *ctx = inode->i_flctx; - struct file_lock *fl; + struct file_lock_core *flc; lockdep_assert_held(&ctx->flc_lock); - list_for_each_entry(fl, &ctx->flc_lease, fl_core.fl_list) { - if (leases_conflict(fl, breaker)) + list_for_each_entry(flc, &ctx->flc_lease, fl_list) { + if (leases_conflict(flc, &breaker->fl_core)) return true; } return false; @@ -1556,7 +1564,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) } list_for_each_entry_safe(fl, tmp, &ctx->flc_lease, fl_core.fl_list) { - if (!leases_conflict(fl, new_fl)) + if (!leases_conflict(&fl->fl_core, &new_fl->fl_core)) continue; if (want_write) { if (fl->fl_core.fl_flags & FL_UNLOCK_PENDING) From patchwork Tue Jan 16 19:46:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521107 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 60A88383AD; Tue, 16 Jan 2024 19:47:42 +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=1705434462; cv=none; b=u6UWl9uTCrE6qL9lUoJh3+steppdPHL+kYBmxuBDX4vT13U4Hg4z9doY1kvE0xiYaRGq7hZdgYHLe9CbMJTiRLzats6gs03v1GsVUEbU+YvZ5k4xaVoVDo501sS4uxBbQXaWVtQHq4yVVgs/SIb65soqkPRZe8B0QCV/AJZ27ow= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434462; c=relaxed/simple; bh=fYY43RLFfrMis4alODV6T2k0xaAJFT9jD2ide0mIsXs=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=s7SuhagS8ELPHnHO5t2a+2iZ9alMJHzWcYSy1dHiLaXpj7dv+5DHViu5krROO9O0TSEe2s7O27TAtKRAG3YTypHtvwsnWg5f1GWWJurTvBDF4ndPiFIJRA6z+c9zmEJtG4hLFLhzy06JvLKfMGxmIZc+7W+oM9CUe7EXxLBW1tw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E9K/g2/U; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E9K/g2/U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BC6AC43399; Tue, 16 Jan 2024 19:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434461; bh=fYY43RLFfrMis4alODV6T2k0xaAJFT9jD2ide0mIsXs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=E9K/g2/Uujn8sF4y5x9MJzMzz2PEd5Rn9wEiISpzdi/vEdTEaRvV2+345ln3I4QT6 S+xA63XiEaTBptaQBpePSLoub+Oa+1ALyB0yAtMhzHeAUxSeTYLgzb38dtL3y1U+ah YHbYNva6TYAY4PqArADjl8q4k7mA7TLzN3y8ZlTgIbR2wcYUX5R01o0YSSpkDOYYoi 2S8DVhIXomHO+y3dsRGa/ZsFKCokm6sYT0X6dJAT/hRHp95zLhSHuD8WqVdQLY1gCS spM1y5YNJhnM8LtEl1+7/eo9NeDjG207jeZlpLfRp9CS6D3DsgdBFn416VZKwbkUZ8 wj44QP8Tv17vQ== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:10 -0500 Subject: [PATCH 14/20] filelock: convert fl_blocker to file_lock_core Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-14-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3870; i=jlayton@kernel.org; h=from:subject:message-id; bh=fYY43RLFfrMis4alODV6T2k0xaAJFT9jD2ide0mIsXs=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0ilMjBo06ufTIrd2YjGuDyXSZtTiexLCJGw IEuHMWfSXiJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIgAKCRAADmhBGVaC FdGmD/9/BFsdqNGxoBF3TSst8XehQYZpsJpLMeV7rWEBUb+HK/HlexsQekx1jL6VcceVvcPBrix wHvCFscaL6cEa7avBmrjjt4fGef95N0hD1Rrr2sHXIpO9DxEC61VpRu0iUoenjj6VpC/S/mm8/Q LfyJdXX7+mdgvSpQ7kTaVpOfZqF/erECj/erJEsv0ckfNpgAW4QePOxfEO3oBnR+qvr9gpMqTj1 qUNXj2om72ihHksJVJpQNP6QX0S155pjeQyxe/Ztp/89TXBtW2LZkgvud3p67Uyi3h3PFNkF1kJ 9FIYKqx6w5Od+yMutA8U3pIvBVsuaYLdLXlwjAIXAZvG4TpXfb9N6kPSJvYQxIVgzOqM5W/a+n1 oWQHwUbyqOflWa7YkPu3CiSXfSGQWwrptv3kej1jJkkBf0fsV3hQ7MmL2I+Hp0EM3eZxB0yA5ZK uiRTzTkdDHRr8rj/q5Cpv6W1fw2vO5YEwgmgUKhIuHka1tVuz7NKUbr3uUdlFujXTl26pXlYJxG AqOLgRxk5lckyF21EtHYR9xkbmLWsahdhgghJ22Uk1kgPmqxREchyhjBNhotFVl9Ei7jI23RGim DFfnA8aUa57SuTGLOD5b8bn3Mint96LsZNi9xPDEaXA02jQxljB40wnuxtGzg95IRBQ6P9EOP7A ZOKHvKvPVfO9OFQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Both locks and leases deal with fl_blocker. Switch the fl_blocker pointer in struct file_lock_core to point to the file_lock_core of the blocker instead of a file_lock structure. Signed-off-by: Jeff Layton --- fs/locks.c | 10 +++++----- include/linux/filelock.h | 2 +- include/trace/events/filelock.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 280149860d5e..1bc69a96b96d 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -433,7 +433,7 @@ static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) &new->fl_core.fl_blocked_requests); list_for_each_entry(f, &new->fl_core.fl_blocked_requests, fl_core.fl_blocked_member) - f->fl_core.fl_blocker = new; + f->fl_core.fl_blocker = &new->fl_core; spin_unlock(&blocked_lock_lock); } @@ -796,7 +796,7 @@ static void __locks_insert_block(struct file_lock *blocker_fl, blocker = flc; goto new_blocker; } - waiter->fl_blocker = file_lock(blocker); + waiter->fl_blocker = blocker; list_add_tail(&waiter->fl_blocked_member, &blocker->fl_blocked_requests); @@ -1019,7 +1019,7 @@ static struct file_lock_core *what_owner_is_waiting_for(struct file_lock_core *b hash_for_each_possible(blocked_hash, flc, fl_link, posix_owner_key(blocker)) { if (posix_same_owner(flc, blocker)) { while (flc->fl_blocker) - flc = &flc->fl_blocker->fl_core; + flc = flc->fl_blocker; return flc; } } @@ -2817,7 +2817,7 @@ static struct file_lock *get_next_blocked_member(struct file_lock *node) /* Next member in the linked list could be itself */ tmp = list_next_entry(node, fl_core.fl_blocked_member); - if (list_entry_is_head(tmp, &node->fl_core.fl_blocker->fl_core.fl_blocked_requests, + if (list_entry_is_head(tmp, &node->fl_core.fl_blocker->fl_blocked_requests, fl_core.fl_blocked_member) || tmp == node) { return NULL; @@ -2860,7 +2860,7 @@ static int locks_show(struct seq_file *f, void *v) tmp = get_next_blocked_member(cur); /* Fall back to parent node */ while (tmp == NULL && cur->fl_core.fl_blocker != NULL) { - cur = cur->fl_core.fl_blocker; + cur = file_lock(cur->fl_core.fl_blocker); level--; tmp = get_next_blocked_member(cur); } diff --git a/include/linux/filelock.h b/include/linux/filelock.h index 7825511c1c11..9cf1ee3efeda 100644 --- a/include/linux/filelock.h +++ b/include/linux/filelock.h @@ -87,7 +87,7 @@ bool opens_in_grace(struct net *); */ struct file_lock_core { - struct file_lock *fl_blocker; /* The lock that is blocking us */ + struct file_lock_core *fl_blocker; /* The lock that is blocking us */ struct list_head fl_list; /* link into file_lock_context */ struct hlist_node fl_link; /* node in global lists */ struct list_head fl_blocked_requests; /* list of requests with diff --git a/include/trace/events/filelock.h b/include/trace/events/filelock.h index 92ed07544f94..49263b69215e 100644 --- a/include/trace/events/filelock.h +++ b/include/trace/events/filelock.h @@ -68,7 +68,7 @@ DECLARE_EVENT_CLASS(filelock_lock, __field(struct file_lock *, fl) __field(unsigned long, i_ino) __field(dev_t, s_dev) - __field(struct file_lock *, fl_blocker) + __field(struct file_lock_core *, fl_blocker) __field(fl_owner_t, fl_owner) __field(unsigned int, fl_pid) __field(unsigned int, fl_flags) @@ -125,7 +125,7 @@ DECLARE_EVENT_CLASS(filelock_lease, __field(struct file_lock *, fl) __field(unsigned long, i_ino) __field(dev_t, s_dev) - __field(struct file_lock *, fl_blocker) + __field(struct file_lock_core *, fl_blocker) __field(fl_owner_t, fl_owner) __field(unsigned int, fl_flags) __field(unsigned char, fl_type) From patchwork Tue Jan 16 19:46:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521108 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 F05D622327; Tue, 16 Jan 2024 19:47:45 +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=1705434466; cv=none; b=PFYJFyAtn3D3rwT9PY8Hx5oimjeVTimj67gRI28PGTiKY3BfcyakUUoJ0xm7Ed5q9uUef+GNaE40PuR6gOoOiDllAM7oFOgKCa+n6+A2CGQ7yOU6Wy1yxkrexxSXvael7fYYy6ndzPxV09sOHpb8bjVIz+YQPwezgRXm7Pxqp78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434466; c=relaxed/simple; bh=k31YYXg5FDv3rraEGkSgE9ZS/UMoQf+Bn2AlHkK2D+Y=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=p/olZxMfataSKoL8Sh0IPAhSoBCDj8x3kyU/DeXt8aznzxecTxFD+1jQ9YM04l7BHR552qzt8c4D4k0qsMcmK5AIlNXAozoqBBJzjEsbVguXtO9OY39RAmDvTCm/FUhkz1hE7+ylNCHVMZGGbmCkdbpEodTlisclrZfWnWyVYgo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Euy8jp42; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Euy8jp42" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2588BC43142; Tue, 16 Jan 2024 19:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434465; bh=k31YYXg5FDv3rraEGkSgE9ZS/UMoQf+Bn2AlHkK2D+Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Euy8jp42XA5XpHnPXHrVkcKDXDfmeE85YbvjbgSQgcf4LbN9g/kxZDRvpau1jA1He f3KDRyqlNMHDpklXXBduM0sjx+2jzV2R2Lz5IP3ItkgKlGdq1NE2sHQBgDMZP+9aZZ E+BFXJxcg2sDonqdLfOG7sNjRhZ/sLdEUH8RBHt+PJ3Jusba6yLMFUloE4Er+9xKN6 39ri7F5c3CWMxFP8m4XuT5e8FY/4FYS5gywMgABTg1dzODxsYG9TK/Bl69axIxzfca xsDL6egBAH5pHVleqfMBauOtlV9UE3o/bV3ryjSGiHpJkDmVJ0lximdd46YaCprENE zdu5t3B3TsOTQ== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:11 -0500 Subject: [PATCH 15/20] filelock: clean up locks_delete_block internals Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-15-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1881; i=jlayton@kernel.org; h=from:subject:message-id; bh=k31YYXg5FDv3rraEGkSgE9ZS/UMoQf+Bn2AlHkK2D+Y=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0iOaoejNGmyUHU5TWqFozQu5KOWFSGI/C7u k7MmzGMzSGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIgAKCRAADmhBGVaC FUKPEAC5Vb2188d7pEqtHBFUx21aU2oHLqH8KgcTxbFjDoYS6uTISygh9vaZ/BxicnDFRUFlAf4 UUzvWZwqlF2JreutIWvZ8/3vkumPFfPIBuKP2ghif6h4eOswePI+WKe9wIpM3M06SEBaVb+aWay IUcrFcG0XzDKBUpwr55kP5CDYXNsjQHTLgrUVtoCK6A6OuzRbh4WE0ILtek4g5c4MwO00WiL5vi kVXb7e6AMqLJoZwkbIeN5bV/DZTIvrI71HfnenLai2sHVtDUfC1bO3gR4Z8He20hXE3wgTJe7xY IrYp0A9FCcjxv1iMHNuQaT+lQQw1XkilxuYAXZ6qdnsx2GXMk3MHUvuBpxiZYzt5djBv+Oo1+K5 2wINec6lLFIj/rYyTeBWdMuOCWXSANwXVyEl9XckkRmJUVG3rTx7oIEhtDa5S9bK3nd1Pq6e+DH Nrx2Gzbt9CwR4KJEy90sLDTtKEduiUgpln57bMJgTBgrguYzODQZqajizQh5vmjWo83RSvQQJOU W74f/b92sAJwGAsz2vxdrnZZsKYGVIUWz226rRSQ/pZS+gmJ+h5EHX5efWmrbpLP6M/HV/0a78E 7AZyluCCd7LDYNaHNZ4ucfc+sD4aGJGnR3nw6QABf3XRuVPFG7Kw8lQCECLdVH9yufmN/H1nHJL TvrKQKYa7K1yGIQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Rework the internals of locks_delete_block to use struct file_lock_core (mostly just for clarity's sake). The prototype is not changed. Signed-off-by: Jeff Layton --- fs/locks.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 1bc69a96b96d..3a028a8aafeb 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -720,9 +720,10 @@ static void __locks_wake_up_blocks(struct file_lock_core *blocker) * * lockd/nfsd need to disconnect the lock while working on it. */ -int locks_delete_block(struct file_lock *waiter) +int locks_delete_block(struct file_lock *waiter_fl) { int status = -ENOENT; + struct file_lock_core *waiter = &waiter_fl->fl_core; /* * If fl_blocker is NULL, it won't be set again as this thread "owns" @@ -745,21 +746,21 @@ int locks_delete_block(struct file_lock *waiter) * no new locks can be inserted into its fl_blocked_requests list, and * can avoid doing anything further if the list is empty. */ - if (!smp_load_acquire(&waiter->fl_core.fl_blocker) && - list_empty(&waiter->fl_core.fl_blocked_requests)) + if (!smp_load_acquire(&waiter->fl_blocker) && + list_empty(&waiter->fl_blocked_requests)) return status; spin_lock(&blocked_lock_lock); - if (waiter->fl_core.fl_blocker) + if (waiter->fl_blocker) status = 0; - __locks_wake_up_blocks(&waiter->fl_core); - __locks_delete_block(&waiter->fl_core); + __locks_wake_up_blocks(waiter); + __locks_delete_block(waiter); /* * The setting of fl_blocker to NULL marks the "done" point in deleting * a block. Paired with acquire at the top of this function. */ - smp_store_release(&waiter->fl_core.fl_blocker, NULL); + smp_store_release(waiter->fl_blocker, NULL); spin_unlock(&blocked_lock_lock); return status; } From patchwork Tue Jan 16 19:46:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521238 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 2DA038120B; Tue, 16 Jan 2024 19:47:49 +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=1705434470; cv=none; b=Af+W+Voru5FhpGiqtYRHT7pELBc/X8kbxvO/wjJsUg9akVDdjtRDVrUEyxExoqSVK6fhFZSxM3eEneT2gDSEhQxaf+kcB+1AiJNWvbSRhsFcqOQipiM6U6l6475MxHyV54yY467lYPwjl0VvcrghcVhGWI80AuJaMKKmgasINZg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434470; c=relaxed/simple; bh=kls0ou0CepUaWcmG52kQ6qFEQcCGT2zxwwb8Xgjj51M=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=ea3cVl1iKqq9hjBZj2mY5osBku19UcHEojOzx2Hj64WfKTPCNZY1OwemhwpucKDPq5oDPxjh7LhXgjy41Bk3zl41EAh1oDhdqDqEDrrzIfGKrQD0HHAEm5EXC5SrADqVPhtRqvSSsRRSPhK9rS/hknZ/Iw/ylGJJdXSjoDoLTYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JB/SitUh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JB/SitUh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FFD6C433F1; Tue, 16 Jan 2024 19:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434469; bh=kls0ou0CepUaWcmG52kQ6qFEQcCGT2zxwwb8Xgjj51M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JB/SitUhJfUwFnpyXYd9dt1UNVn2wpH3+LaieI2QKP1DW6mOOWviEEDRZrtrYWL2k Ra/072r0nhRsWZvd0xbd2jROArzvpEZk4vSMBQLkmju4PnMjRYVog1kG+T6SZagr4j w+Qk1Codi+TGkK50EEfta0H0jXRoWmoZkb58n64Gb4u0KfK1IjEZszaG/oGhSNkk56 S6vw/pq9iyo4+P8pGNUibJAEazvR1Gw2Ctdl0qt2GkKygXmQAJIblwqQmkA3QqFJi/ IyPehaJI3xo+oDo/EGAHPn3j41Sg0bo0yoOHi7Lqej/ZQJ8SwlY5RIVeqpoWPz9bGn e69pLTekd546A== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:12 -0500 Subject: [PATCH 16/20] filelock: reorganize locks_delete_block and __locks_insert_block Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-16-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5173; i=jlayton@kernel.org; h=from:subject:message-id; bh=kls0ou0CepUaWcmG52kQ6qFEQcCGT2zxwwb8Xgjj51M=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0i3yR4/c4kiH3TPF+F79Kq42wwoL7+Rx/zv amElbkvKFmJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIgAKCRAADmhBGVaC FbL8D/4k9g/iQZOsLtiBHHpIIf4BJI03BPbjvrz5xSL2ghQ1fayjQGKClMiDdt4ZoRmerAi5Q90 hR5cA9VjEL05KtCttnutdl4dQMNNCblGtObbwY1AgemJcan92LF/yWc2iNNE3C2t5tdaepWXlHg /4XEyNMU3qY1u7Q1VFiNS5Q8DlEsBqZeWe57990Nw2ipNwBu5+nO18hZIcajx4k1SSQ9y9QHhsC wyV+edmSVt4IJOOrw4bQKpKooW+73rDjyczKsp4HRSdZ8Pnp+7w33h3zh2OJUECdWFw49FTkdCf 7sSlBG8z2BRXBqKbeoPVGL85qQpI8ql0uhVGzr96hH15n85lUDrJro0ylwORtdlAbsi9i9DoFSm VR0iyPSBugjFwEpa331KPMlMJehUGcKjQMu2NvUiXNVwQH292cGtjOvq88Cd60ozv8mL6TpJP7p qr0u35L0POXs14HfHZ+GoVijX0RkSF5DYB4bVD1rOjTmWkwL3JzYMSC2dXAm/sqXUBcXy+KFljK CB5WPvn7lsnrwun4GdCzt8+cb+g67uraolCIgYAIUiGSQMH2YuLMs+IDgrnEL/xtQL0iRREc0VQ 0RsjSyelSIyfqfzpdGz+Swz14kBsazKmo4FBbt9fyVxYdfNajfDADuoGzBWn4dHKaDTERbDyHBC oZTcZ70VgjZH4cQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Rename the old __locks_delete_block to __locks_unlink_lock. Rename change old locks_delete_block function to __locks_delete_block and have it take a file_lock_core. Make locks_delete_block a simple wrapper around __locks_delete_block. Also, change __locks_insert_block to take struct file_lock_core, and fix up its callers. Signed-off-by: Jeff Layton --- fs/locks.c | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 3a028a8aafeb..27160dc65d63 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -682,7 +682,7 @@ static void locks_delete_global_blocked(struct file_lock_core *waiter) * * Must be called with blocked_lock_lock held. */ -static void __locks_delete_block(struct file_lock_core *waiter) +static void __locks_unlink_block(struct file_lock_core *waiter) { locks_delete_global_blocked(waiter); list_del_init(&waiter->fl_blocked_member); @@ -698,7 +698,7 @@ static void __locks_wake_up_blocks(struct file_lock_core *blocker) struct file_lock_core, fl_blocked_member); fl = file_lock(waiter); - __locks_delete_block(waiter); + __locks_unlink_block(waiter); if ((IS_POSIX(waiter) || IS_FLOCK(waiter)) && fl->fl_lmops && fl->fl_lmops->lm_notify) fl->fl_lmops->lm_notify(fl); @@ -714,16 +714,9 @@ static void __locks_wake_up_blocks(struct file_lock_core *blocker) } } -/** - * locks_delete_block - stop waiting for a file lock - * @waiter: the lock which was waiting - * - * lockd/nfsd need to disconnect the lock while working on it. - */ -int locks_delete_block(struct file_lock *waiter_fl) +static int __locks_delete_block(struct file_lock_core *waiter) { int status = -ENOENT; - struct file_lock_core *waiter = &waiter_fl->fl_core; /* * If fl_blocker is NULL, it won't be set again as this thread "owns" @@ -754,16 +747,27 @@ int locks_delete_block(struct file_lock *waiter_fl) if (waiter->fl_blocker) status = 0; __locks_wake_up_blocks(waiter); - __locks_delete_block(waiter); + __locks_unlink_block(waiter); /* * The setting of fl_blocker to NULL marks the "done" point in deleting * a block. Paired with acquire at the top of this function. */ - smp_store_release(waiter->fl_blocker, NULL); + smp_store_release(&waiter->fl_blocker, NULL); spin_unlock(&blocked_lock_lock); return status; } + +/** + * locks_delete_block - stop waiting for a file lock + * @waiter: the lock which was waiting + * + * lockd/nfsd need to disconnect the lock while working on it. + */ +int locks_delete_block(struct file_lock *waiter) +{ + return __locks_delete_block(&waiter->fl_core); +} EXPORT_SYMBOL(locks_delete_block); /* Insert waiter into blocker's block list. @@ -781,13 +785,11 @@ EXPORT_SYMBOL(locks_delete_block); * waiters, and add beneath any waiter that blocks the new waiter. * Thus wakeups don't happen until needed. */ -static void __locks_insert_block(struct file_lock *blocker_fl, - struct file_lock *waiter_fl, +static void __locks_insert_block(struct file_lock_core *blocker, + struct file_lock_core *waiter, bool conflict(struct file_lock_core *, struct file_lock_core *)) { - struct file_lock_core *blocker = &blocker_fl->fl_core; - struct file_lock_core *waiter = &waiter_fl->fl_core; struct file_lock_core *flc; BUG_ON(!list_empty(&waiter->fl_blocked_member)); @@ -812,8 +814,8 @@ static void __locks_insert_block(struct file_lock *blocker_fl, } /* Must be called with flc_lock held. */ -static void locks_insert_block(struct file_lock *blocker, - struct file_lock *waiter, +static void locks_insert_block(struct file_lock_core *blocker, + struct file_lock_core *waiter, bool conflict(struct file_lock_core *, struct file_lock_core *)) { @@ -1111,7 +1113,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) if (!(request->fl_core.fl_flags & FL_SLEEP)) goto out; error = FILE_LOCK_DEFERRED; - locks_insert_block(fl, request, flock_locks_conflict); + locks_insert_block(&fl->fl_core, &request->fl_core, flock_locks_conflict); goto out; } if (request->fl_core.fl_flags & FL_ACCESS) @@ -1205,7 +1207,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, __locks_wake_up_blocks(&request->fl_core); if (likely(!posix_locks_deadlock(request, fl))) { error = FILE_LOCK_DEFERRED; - __locks_insert_block(fl, request, + __locks_insert_block(&fl->fl_core, &request->fl_core, posix_locks_conflict); } spin_unlock(&blocked_lock_lock); @@ -1598,7 +1600,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) break_time -= jiffies; if (break_time == 0) break_time++; - locks_insert_block(fl, new_fl, leases_conflict); + locks_insert_block(&fl->fl_core, &new_fl->fl_core, leases_conflict); trace_break_lease_block(inode, new_fl); spin_unlock(&ctx->flc_lock); percpu_up_read(&file_rwsem); From patchwork Tue Jan 16 19:46:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521239 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 C7B5922327; Tue, 16 Jan 2024 19:47:53 +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=1705434474; cv=none; b=fbmUVWtOxNBXLNYZ47M2KQ1JiIXAAvH/gaq1HKA3zYQZm54Ccv7rWD0KDmusDjmGJwljKvJ2YQnqTJ2a00lh8d50aKHwujUBaWN/hkRwi5AZtvhXi/kKo28Il+VzmlolCeLx4SQua4MyAzlTem0oxo2Pg0MRVC1+Pt4kJqUzsek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434474; c=relaxed/simple; bh=FTw89+pku1zuIfZRGLXcRaoU9hVI0ZuADA0Yl4doYjQ=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=umRtQDb6wtdIcjNH79vOS05cXKuVxWMZKwa9y1r0nhXqP3QZD9hnCKyrXxPpozZgPhArFHoDtnjtq+nFcPeDjgo/itSVNukx2w3KyZ/G+UvhLFQIHNgQP6DKgEkSn4w7pneQq5y0P+D3LDOjH3EOeyS35FwjPmWyWJOlHiwKn/k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eq6bvn6m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eq6bvn6m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED925C43601; Tue, 16 Jan 2024 19:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434473; bh=FTw89+pku1zuIfZRGLXcRaoU9hVI0ZuADA0Yl4doYjQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eq6bvn6m5y/X2fER86pfthua2+nw74YlF5AZhYRF2tMunagWU3E77/71gxUymWI51 X7B9Ns2y7ytG7+ojucRsjxXSZXA2Jhl2BZ0CfApls+1648rEVgIU8z3cjapkaGS2/w Bb8cHtkCb6MfJUcHICyTqw1eEyvchT7tPUvHViuJIqpqAerR50dl8EYLJetQS7g0jS WRsoOBeIdYho8AFvY36xqzI3fm5AhJpwDrwnN0ZuwpykgxhxqZgoDxfHInB0jafJ9c 4XpKg2b6xAu1ZlkhVlTcL/5tyGIGw53RAdxcWbwhkiNAcLb23fjlnTrgqsSXty0y2G 6badSofqc4tNQ== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:13 -0500 Subject: [PATCH 17/20] filelock: make assign_type helper take a file_lock_core pointer Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-17-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1737; i=jlayton@kernel.org; h=from:subject:message-id; bh=FTw89+pku1zuIfZRGLXcRaoU9hVI0ZuADA0Yl4doYjQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0iremkDlRrQ+xc3ImeXplfQacBchpkS/H5Z 4ClsvaxqfaJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIgAKCRAADmhBGVaC FaqmD/9QMZUfmO+u/OFjkK9hUUWeg+zNsc0ZvrcUwhsTa3jV24S1CoQZ/YG7zth6GJgqBW5XQ10 MxwoKw1yrTOohD3h9mWVUiJ0QQbhr73HUsn226zjTv/DNU2LV2bp6PvF0ku5Tr3F37ZCwHs0K2X 81TwcvWX4kM7u7NMBeiPOjozUbWMY43jzZM55PTlAy9zgbScT83+3nZr9ROobKALKMWdvptjSDK X/QwUb87/llqyFUscBQmmJ4AdNsTu0CqurHCQOZ8JGxMofjyhmmrZ481Mq0lt+sNaV6GSz29MbB b7chk4kg5LO5pYbapu8sxb3R8VmJUiXBUH8UbGV4bm2qUV2X3agl+EB80DjXipZhoDT4PDqqFOa /UNM9RMvAD3oZMEgqugs+kPQ2qV29HcgCCV7sfo/PNlPClA6MiY80mqn0yZ+I2sBC3bAve8nx7J Sqbzm20Hq32Zi5VR23d0MxH9ZekvkgngM9U9Q/y3W9bmbpXDgkj2zl9N1LmRxRzVIptiqR7dfUK kUhSo3BABF26WycsO9+KBKx9IiG4tGfT4GUZEl20fFVsSfcfgyuUXyj2Yvt6TwqmsN/TDdS5KS6 a1TCeigv8R4L2KIeUFVQrnkP0Kn+ZzkZ07DY0mMruOu9pMl3kZfHDCGpbs6++ZFdzOHe/zbdyEW Wt4ZXifyIhxu3uQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Have assign_type take struct file_lock_core instead of file_lock. Signed-off-by: Jeff Layton --- fs/locks.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 27160dc65d63..4a1e9457c430 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -462,13 +462,13 @@ static void flock_make_lock(struct file *filp, struct file_lock *fl, int type) fl->fl_end = OFFSET_MAX; } -static int assign_type(struct file_lock *fl, int type) +static int assign_type(struct file_lock_core *flc, int type) { switch (type) { case F_RDLCK: case F_WRLCK: case F_UNLCK: - fl->fl_core.fl_type = type; + flc->fl_type = type; break; default: return -EINVAL; @@ -520,7 +520,7 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl, fl->fl_ops = NULL; fl->fl_lmops = NULL; - return assign_type(fl, l->l_type); + return assign_type(&fl->fl_core, l->l_type); } /* Verify a "struct flock" and copy it to a "struct file_lock" as a POSIX @@ -575,7 +575,7 @@ static const struct lock_manager_operations lease_manager_ops = { */ static int lease_init(struct file *filp, int type, struct file_lock *fl) { - if (assign_type(fl, type) != 0) + if (assign_type(&fl->fl_core, type) != 0) return -EINVAL; fl->fl_core.fl_owner = filp; @@ -1432,7 +1432,7 @@ static void lease_clear_pending(struct file_lock *fl, int arg) /* We already had a lease on this file; just change its type */ int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) { - int error = assign_type(fl, arg); + int error = assign_type(&fl->fl_core, arg); if (error) return error; From patchwork Tue Jan 16 19:46:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521240 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 B0E54823C7; Tue, 16 Jan 2024 19:47:57 +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=1705434477; cv=none; b=SYAfvFWViDwxVLJdlzyC0xtbPol55UaGB/iC3R73l1tXEp5zSS7zyJ/WYL6LxwUB/yx8Qktugnl4CETKe7R+kJCWKyVziHNtep6pNhsJIeu2LonCRyNtrLbkENCVhYaHoCVzEBC1iguAibFoAkpodVVcV17THjqJeQKczY0MU3w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434477; c=relaxed/simple; bh=cAmIIbMPxRZTJqkY9XtG7e1FF5ZQvaw1I6KUw0Tops8=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=hnMdH1XOIwMlc9PXz+L5gIst2eUUgkrDk3jqpLkjcWYiGflnPujVe2lucHF+Jk8iNd59oaIqh0vq5L6XjIj9JcliUna5GdMtBKf6+qe8hYbKTlgCav2PvS95GO4/H8gZyX6wQEsBGWsuNQZOPbuWlj60CdlovlH/7VZbmzz4RtY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CRFGk3F8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CRFGk3F8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7F3EC433B2; Tue, 16 Jan 2024 19:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434477; bh=cAmIIbMPxRZTJqkY9XtG7e1FF5ZQvaw1I6KUw0Tops8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CRFGk3F8SExbxOElcBSBKajj6soClSjjeedXHJ8MjMqo98s9dqZpn6TU+QEbb4IwP mQ2m3I8sbdnIKIJf081yXe2px46aPyWSxFzPXshqq71eJBNaIbWOyklczaVKNn2pX3 wehtXnMqsN8nxRvBZIbPKeAWgALOgX4CyfW6AZjcOSyu2A20+6ulb5SQfwQhHvOZ6m PwkyZQYR2+XpgnKbVLgLtqIBJFqsfelrd4Ohtezw5xFnXMhSSOehqZbwIa6BwNiSL+ 38qfSwkA+4kChPa+TrLwg561uqfaCVEGK0ub46qfNS3Q7xajSUh3zIjAf++Ef1GYv1 dx3PZZm8uM4Xw== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:14 -0500 Subject: [PATCH 18/20] filelock: convert locks_wake_up_blocks to take a file_lock_core pointer Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-18-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2246; i=jlayton@kernel.org; h=from:subject:message-id; bh=cAmIIbMPxRZTJqkY9XtG7e1FF5ZQvaw1I6KUw0Tops8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0iQy2Q/95WI9t43Bv7XN421VQLJ+2klLwZK nR6pvJi1PWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIgAKCRAADmhBGVaC FVRcD/4yTAkRFFLlCV//Lye7K/pHQlvdc0FyTNkTZ4pThskhFPpBbutOCB+hVuzj1WKVGWd4gVr 58c7ALPSStiS0wBkN5bpu0z6mYymzdmP34GNrebPcxb6GUm1dp0i3YieUr7dpp4wR91F+YgEOnz JIM+Vdz5sx6hP2yQcxd88ttqJXuRXIn2kkFVUu8pFbE9vKl9kt8fAhrwHzGFykv42RjA8T+j382 Yy9VfBYN7d442yEBepNbMHJR74Cjqay27P4wagefbfbnFSC/2m2CM/+YaNRADrn2x8JsXTRonUF ny61DccrUhajMycRsq+1xlB98zlW0aC50beGixktdDzbqU4jRJTUq46JHcjUM9FVMdUhgye5BOa /POc/VDgXJHe67TtZjhnPy3MdKrDDO34FkHDHbuIPyGQvgZwAn/NL9WzHUTRyzuj1vwsPfSAwx4 JOgD5fLKd2Lw/7FKOPcH/a4cE+UK0xkozI8+zSO9KQpbSS/apOuCJbcU5/DJvelU8Aj2gHBw1Ll NlY/iSj8XDRUo+Qq6YNBNOTaJWkHs5gqWob/kiGQN0UNSdbnwCsGXDvrTOmj9hlQchN7GY91uAg ZEJftHwe2r54pBoYAyTw7qqhHeFYz1q4IJTBL2lFxD/khLmOva63vfBGnYeOz8IuF4Q7tcOncY5 H9f83H00tXTG+sA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Have locks_wake_up_blocks take a file_lock_core pointer, and fix up the callers to pass one in. Signed-off-by: Jeff Layton --- fs/locks.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 4a1e9457c430..88c72eb4672e 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -829,7 +829,7 @@ static void locks_insert_block(struct file_lock_core *blocker, * * Must be called with the inode->flc_lock held! */ -static void locks_wake_up_blocks(struct file_lock *blocker) +static void locks_wake_up_blocks(struct file_lock_core *blocker) { /* * Avoid taking global lock if list is empty. This is safe since new @@ -838,11 +838,11 @@ static void locks_wake_up_blocks(struct file_lock *blocker) * fl_blocked_requests list does not require the flc_lock, so we must * recheck list_empty() after acquiring the blocked_lock_lock. */ - if (list_empty(&blocker->fl_core.fl_blocked_requests)) + if (list_empty(&blocker->fl_blocked_requests)) return; spin_lock(&blocked_lock_lock); - __locks_wake_up_blocks(&blocker->fl_core); + __locks_wake_up_blocks(blocker); spin_unlock(&blocked_lock_lock); } @@ -858,7 +858,7 @@ locks_unlink_lock_ctx(struct file_lock *fl) { locks_delete_global_locks(&fl->fl_core); list_del_init(&fl->fl_core.fl_list); - locks_wake_up_blocks(fl); + locks_wake_up_blocks(&fl->fl_core); } static void @@ -1351,11 +1351,11 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, locks_insert_lock_ctx(left, &fl->fl_core.fl_list); } right->fl_start = request->fl_end + 1; - locks_wake_up_blocks(right); + locks_wake_up_blocks(&right->fl_core); } if (left) { left->fl_end = request->fl_start - 1; - locks_wake_up_blocks(left); + locks_wake_up_blocks(&left->fl_core); } out: spin_unlock(&ctx->flc_lock); @@ -1437,7 +1437,7 @@ int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) if (error) return error; lease_clear_pending(fl, arg); - locks_wake_up_blocks(fl); + locks_wake_up_blocks(&fl->fl_core); if (arg == F_UNLCK) { struct file *filp = fl->fl_core.fl_file; From patchwork Tue Jan 16 19:46:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521241 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 F059682D66; Tue, 16 Jan 2024 19:48:01 +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=1705434482; cv=none; b=arPw67AywXCa4NkKQYb/SMnjO8R7uWRYkedX8OPCpKGYf3P8tKZgj5E46BDTFpHb1sw8dWVTUPi5D/nxsGbwkmyR7Rf1OiZwrLPHH5Z7sON/7/g8DG7fZI01Bbdg5wVB2+RaJQKAioAG1nY2FFNBqAvMESRKQ96CdmDPF+ft6wY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434482; c=relaxed/simple; bh=D+ddUFLduMUtoR3H6uRS8KrhCxNq0OONqJND5QMi4fg=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=tItFlqfY/twuJwJPDcwgyCF/1EiptCSUpmqolesJPCxVBq215beRvkifhFa2SWP/9YDJ+zTACuFhxgzu+6WGhiewrhVAnTLT7uSnmak7sjvfd6nVIsztCHtNv8mujSf28eTexIYkI4Ch/dzb/AV800e+Cp+KkqlJTRyDk/bbER0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sTC5ufjj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sTC5ufjj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3038C43330; Tue, 16 Jan 2024 19:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434481; bh=D+ddUFLduMUtoR3H6uRS8KrhCxNq0OONqJND5QMi4fg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sTC5ufjj0Mc666R2y5KyCLFPtD20KG9nYgjmgbKCBuDBPdpqauox9nHrJiifar+YI SxQVqXV1gVeLk3HrazU3qwp1uavYce0Kk49R/uwF4JAQg/Fhp0ba15DZmb0txz+RU3 4B/2Q+ZmMgT4T2ihOBeVeDWUCzG+Kkdl0YVVUAxoLg9udsSN13duYWIyl/4JcEbmRs GBx7lRJwj+g9uHUtkr6J0vLkFqcUhHBNVINeVCHaX2hj2ifQSFsEesuqnuyUYdOr4U 2X0bwToYcWJ5frEEQXwVNZLwAqprKDWrn2OTpDKgrwEGkXv5s3bBD2uBgCBNAA12T2 iekJuuLT/msHA== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:15 -0500 Subject: [PATCH 19/20] filelock: convert locks_insert_lock_ctx and locks_delete_lock_ctx Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-19-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5364; i=jlayton@kernel.org; h=from:subject:message-id; bh=D+ddUFLduMUtoR3H6uRS8KrhCxNq0OONqJND5QMi4fg=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0iAOTSqzyEvswjyEJ+QZM7pJ+eGv1g/Av5x XUh1X6QyeaJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIgAKCRAADmhBGVaC FYqQEADVZYP89CCK/zSJeNpFTmTeeF6KQbmYj4Vw1eRi0yq/ji5gBnAUbpXIWmap7bF5wzaNy54 ZbFhdN1MOWO8EjIg67wiBJSoinfW6xWDmtpbpZSs93FRzz4yS/yvVVv6MFheg4ygNVAaCzc/6tV vWcavcOB6TTQMVuG+NZYssu5GD+5i/gxSYhkfkLwpfeh9soB+RFMsB7gOcteloxd7/B1hg6mLIV 4bjPu+CnJUqZRSOG2skqaXvmDg9YGN+7ey6bIwBkEqKrsKKfZoqAjxF7ri9E1Ff9JBrbKWsAPII QkBQrh/J7U2X4qAiNxqX3DGKPR3o7UMnmiif4TshXb1EAmP7ylvRS6KwVE72YkxHitQxj2yG8L0 VNYNVEWWWKUSVAVSRFc3yMwR6Xu9BQmEh9kO0UTsuFWwBKPrRmMQmVp0PLo1mrLUMIY40vaUc+j iqx4yKyzhtT8AsSIvqn4OHQk1KDdVLmu8OEC1r2gAibK4edj0lKMgvIXBZjIwRCxmLfuYwFKSep q/MtuIlCSMN3B7Gc8g0o343qHmDQKZK7PEyr4q24pnPOgI1NLWykLDmXbBjdYYsXw9VyWU3lJau Bf+S1aLHAnrocxE6YEjzoWEBR5bk1WK+MBsE+hgmD4LDfYUR2T2ufSFDNK8X+SgXNzE3cSuZtU4 6OBW1sKhyVqwqKQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Have these functions take a file_lock_core pointer instead of a file_lock. Signed-off-by: Jeff Layton --- fs/locks.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 88c72eb4672e..6d24cf2525ec 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -847,28 +847,28 @@ static void locks_wake_up_blocks(struct file_lock_core *blocker) } static void -locks_insert_lock_ctx(struct file_lock *fl, struct list_head *before) +locks_insert_lock_ctx(struct file_lock_core *fl, struct list_head *before) { - list_add_tail(&fl->fl_core.fl_list, before); - locks_insert_global_locks(&fl->fl_core); + list_add_tail(&fl->fl_list, before); + locks_insert_global_locks(fl); } static void -locks_unlink_lock_ctx(struct file_lock *fl) +locks_unlink_lock_ctx(struct file_lock_core *fl) { - locks_delete_global_locks(&fl->fl_core); - list_del_init(&fl->fl_core.fl_list); - locks_wake_up_blocks(&fl->fl_core); + locks_delete_global_locks(fl); + list_del_init(&fl->fl_list); + locks_wake_up_blocks(fl); } static void -locks_delete_lock_ctx(struct file_lock *fl, struct list_head *dispose) +locks_delete_lock_ctx(struct file_lock_core *fl, struct list_head *dispose) { locks_unlink_lock_ctx(fl); if (dispose) - list_add(&fl->fl_core.fl_list, dispose); + list_add(&fl->fl_list, dispose); else - locks_free_lock(fl); + locks_free_lock(file_lock(fl)); } /* Determine if lock sys_fl blocks lock caller_fl. Common functionality @@ -1095,7 +1095,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) if (request->fl_core.fl_type == fl->fl_core.fl_type) goto out; found = true; - locks_delete_lock_ctx(fl, &dispose); + locks_delete_lock_ctx(&fl->fl_core, &dispose); break; } @@ -1120,7 +1120,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) goto out; locks_copy_lock(new_fl, request); locks_move_blocks(new_fl, request); - locks_insert_lock_ctx(new_fl, &ctx->flc_flock); + locks_insert_lock_ctx(&new_fl->fl_core, &ctx->flc_flock); new_fl = NULL; error = 0; @@ -1259,7 +1259,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, else request->fl_end = fl->fl_end; if (added) { - locks_delete_lock_ctx(fl, &dispose); + locks_delete_lock_ctx(&fl->fl_core, &dispose); continue; } request = fl; @@ -1288,7 +1288,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, * one (This may happen several times). */ if (added) { - locks_delete_lock_ctx(fl, &dispose); + locks_delete_lock_ctx(&fl->fl_core, &dispose); continue; } /* @@ -1305,9 +1305,9 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, locks_move_blocks(new_fl, request); request = new_fl; new_fl = NULL; - locks_insert_lock_ctx(request, + locks_insert_lock_ctx(&request->fl_core, &fl->fl_core.fl_list); - locks_delete_lock_ctx(fl, &dispose); + locks_delete_lock_ctx(&fl->fl_core, &dispose); added = true; } } @@ -1336,7 +1336,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, } locks_copy_lock(new_fl, request); locks_move_blocks(new_fl, request); - locks_insert_lock_ctx(new_fl, &fl->fl_core.fl_list); + locks_insert_lock_ctx(&new_fl->fl_core, &fl->fl_core.fl_list); fl = new_fl; new_fl = NULL; } @@ -1348,7 +1348,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, left = new_fl2; new_fl2 = NULL; locks_copy_lock(left, right); - locks_insert_lock_ctx(left, &fl->fl_core.fl_list); + locks_insert_lock_ctx(&left->fl_core, &fl->fl_core.fl_list); } right->fl_start = request->fl_end + 1; locks_wake_up_blocks(&right->fl_core); @@ -1448,7 +1448,7 @@ int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) printk(KERN_ERR "locks_delete_lock: fasync == %p\n", fl->fl_fasync); fl->fl_fasync = NULL; } - locks_delete_lock_ctx(fl, dispose); + locks_delete_lock_ctx(&fl->fl_core, dispose); } return 0; } @@ -1581,7 +1581,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) fl->fl_downgrade_time = break_time; } if (fl->fl_lmops->lm_break(fl)) - locks_delete_lock_ctx(fl, &dispose); + locks_delete_lock_ctx(&fl->fl_core, &dispose); } if (list_empty(&ctx->flc_lease)) @@ -1839,7 +1839,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri if (!leases_enable) goto out; - locks_insert_lock_ctx(lease, &ctx->flc_lease); + locks_insert_lock_ctx(&lease->fl_core, &ctx->flc_lease); /* * The check in break_lease() is lockless. It's possible for another * open to race in after we did the earlier check for a conflicting @@ -1852,7 +1852,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri smp_mb(); error = check_conflicting_open(filp, arg, lease->fl_core.fl_flags); if (error) { - locks_unlink_lock_ctx(lease); + locks_unlink_lock_ctx(&lease->fl_core); goto out; } From patchwork Tue Jan 16 19:46:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeffrey Layton X-Patchwork-Id: 13521242 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 9040C82D98; Tue, 16 Jan 2024 19:48:05 +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=1705434485; cv=none; b=eDkMvitPo098i+SoHZPF1hu6bSYOLfYm43IxlXKgMxNPEx2TTBQNYNiCJ49tXBFvekw7oEQMMq5bNfYvQYLqpqdynbE26yssr/d0C4NvjC3hVpZIOeT4+eUr6ITPXHR/CWLJfun9IxV9+CfveMyuIOSNgxzxbqM2VaAmAdDaJ7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705434485; c=relaxed/simple; bh=tUgny3IKWhbScVuSTLV7DUCLBlNMDIBoYB+H+8vByek=; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer:X-Developer-Signature:X-Developer-Key; b=Ijjr46swxTtkkyEmT5ZA7x5MrPRWyqH7eYitX4NWucYNJmwr8CXn239gQ4yJvYhqkbPakhELuKTQf2mNhP9N9zyn4KT21fTKvscClPLJTSZuSukjE3ui/BPjlrhHWtl7qUZ3gn02QV0XF7lvA1xwgOEuNb6R+HMSnn7D9S8BzNk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=esBeGGdE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="esBeGGdE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ADCAEC433F1; Tue, 16 Jan 2024 19:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705434485; bh=tUgny3IKWhbScVuSTLV7DUCLBlNMDIBoYB+H+8vByek=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=esBeGGdEninZHvph53qN//97ESmW2HYfWhrFu7zRRzGq66gsFHoCtvnDXQaUpwNpU v5MpOBDb3FK1gnycr/rm8PMcQSzkREvDuIfKg4QQM+n+eww23mHGBQ4sQE/E/a6w25 tLHS56E7ecolnIO4NqIBD9CaghHdnpCwc9b8wTpILaWJE4ElG5DS6LSeeWxFg0ybE7 tsuJEf5B4W9dqNX/ACQQ87/yY1/+a0Tnp2BCKnoXRabbXibmty1qcs0jA7WPJrVVDO erOIyLKM5L72csfZhgl81y2mFnSM6PnrKwJ63i7rhik6ZWJoisdP2IbD6g4fibMeoU OiAS2zJJVwWwA== From: Jeff Layton Date: Tue, 16 Jan 2024 14:46:16 -0500 Subject: [PATCH 20/20] filelock: split leases out of struct file_lock Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-flsplit-v1-20-c9d0f4370a5d@kernel.org> References: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> In-Reply-To: <20240116-flsplit-v1-0-c9d0f4370a5d@kernel.org> To: Christian Brauner , Alexander Viro , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Miklos Szeredi , Andreas Gruenbacher , Trond Myklebust , Anna Schumaker , Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Jan Kara , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-kernel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-trace-kernel@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=32025; i=jlayton@kernel.org; h=from:subject:message-id; bh=tUgny3IKWhbScVuSTLV7DUCLBlNMDIBoYB+H+8vByek=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlpt0i1dB3Oo3SpA6n32QmMmESoKqFsJEotRttN e3Un3ICfnyJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZabdIgAKCRAADmhBGVaC FSGEEACG4VI4KJIOEol/8Wvcq9bT8SZEY/46btJujElDZuyEB1QsZhwZYfaGpiWV5LUvSwM/OYV 7wyzrlEYShy6Sm6QOgyapNYDTCEV26q+puaJv6XKC1DN6Yd5KEvcyWcIOm4TnHsH2QZyj2e8J3z F8Qti36s55qijnFc1btze7OBMwR3MFKcs7JGlEzrdDY+uThnQ2agTPY5vpS1+G1Uv1ASNyicWip ik0HyeqU6Zr4o0EohAIBh4pPJop0ehnGpX65rZlnjblpE3sENAQ95p50Nol/WhdBee3A3oOLJZq WXk1+4z1tLT+IF5i6uiWDfMM1/gl70Hh092YmAQAoPLXEb7l5eD71yapern6FlLjUhzVHLR6vuU QCs8lQujMCUnvt7ByIGCQuSz5HlL100KEUhowjpHKIE2ILk4ziAOlfEMUDffVSYyjrzfOo+KZ3c sz7JJWcTr+kB9EMKlpUfX+aUkbppSPNodEwWBaw/at4+NUsWGapn9Vw2wsCYpw1WR1UjHYhkE4z fIksLsuXTHcza7oct6zMJn3e16k5GfYA2P/KYw52jC7DivZi9FW6b8p9BnOoMp4jhwbKw31DE7d ADxp4+Ivs0s8gzkT+1uCsE2lBYZll7u2Bi4glmSe/7tPWKcPyiuTSCtn3Zda3kibx1BqL8zzTJ8 n0lIX3KYCHdUBRg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Add a new struct file_lease and move the lease-specific fields from struct file_lock to it. Convert the appropriate API calls to take struct file_lease instead, and convert the callers to use them. Signed-off-by: Jeff Layton --- fs/libfs.c | 2 +- fs/locks.c | 130 ++++++++++++++++++++++++++-------------- fs/nfs/nfs4_fs.h | 2 +- fs/nfs/nfs4file.c | 2 +- fs/nfs/nfs4proc.c | 4 +- fs/nfsd/nfs4layouts.c | 17 +++--- fs/nfsd/nfs4state.c | 21 ++++--- fs/smb/client/cifsfs.c | 2 +- include/linux/filelock.h | 49 ++++++++++----- include/linux/fs.h | 5 +- include/trace/events/filelock.h | 18 +++--- 11 files changed, 154 insertions(+), 98 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index eec6031b0155..8b67cb4655d5 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1580,7 +1580,7 @@ EXPORT_SYMBOL(alloc_anon_inode); * All arguments are ignored and it just returns -EINVAL. */ int -simple_nosetlease(struct file *filp, int arg, struct file_lock **flp, +simple_nosetlease(struct file *filp, int arg, struct file_lease **flp, void **priv) { return -EINVAL; diff --git a/fs/locks.c b/fs/locks.c index 6d24cf2525ec..014cc984e295 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -92,17 +92,22 @@ static inline bool IS_LEASE(struct file_lock_core *flc) #define IS_REMOTELCK(fl) (fl->fl_core.fl_pid <= 0) -struct file_lock *file_lock(struct file_lock_core *flc) +static struct file_lock *file_lock(struct file_lock_core *flc) { return container_of(flc, struct file_lock, fl_core); } -static bool lease_breaking(struct file_lock *fl) +static struct file_lease *file_lease(struct file_lock_core *flc) +{ + return container_of(flc, struct file_lease, fl_core); +} + +static bool lease_breaking(struct file_lease *fl) { return fl->fl_core.fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); } -static int target_leasetype(struct file_lock *fl) +static int target_leasetype(struct file_lease *fl) { if (fl->fl_core.fl_flags & FL_UNLOCK_PENDING) return F_UNLCK; @@ -189,6 +194,7 @@ static DEFINE_SPINLOCK(blocked_lock_lock); static struct kmem_cache *flctx_cache __ro_after_init; static struct kmem_cache *filelock_cache __ro_after_init; +static struct kmem_cache *filelease_cache __ro_after_init; static struct file_lock_context * locks_get_lock_context(struct inode *inode, int type) @@ -298,6 +304,18 @@ struct file_lock *locks_alloc_lock(void) } EXPORT_SYMBOL_GPL(locks_alloc_lock); +/* Allocate an empty lock structure. */ +struct file_lease *locks_alloc_lease(void) +{ + struct file_lease *fl = kmem_cache_zalloc(filelease_cache, GFP_KERNEL); + + if (fl) + locks_init_lock_heads(&fl->fl_core); + + return fl; +} +EXPORT_SYMBOL_GPL(locks_alloc_lease); + void locks_release_private(struct file_lock *fl) { struct file_lock_core *flc = &fl->fl_core; @@ -359,15 +377,25 @@ void locks_free_lock(struct file_lock *fl) } EXPORT_SYMBOL(locks_free_lock); +/* Free a lease which is not in use. */ +void locks_free_lease(struct file_lease *fl) +{ + kmem_cache_free(filelease_cache, fl); +} +EXPORT_SYMBOL(locks_free_lease); + static void locks_dispose_list(struct list_head *dispose) { - struct file_lock *fl; + struct file_lock_core *flc; while (!list_empty(dispose)) { - fl = list_first_entry(dispose, struct file_lock, fl_core.fl_list); - list_del_init(&fl->fl_core.fl_list); - locks_free_lock(fl); + flc = list_first_entry(dispose, struct file_lock_core, fl_list); + list_del_init(&flc->fl_list); + if (IS_LEASE(flc)) + locks_free_lease(file_lease(flc)); + else + locks_free_lock(file_lock(flc)); } } @@ -378,6 +406,13 @@ void locks_init_lock(struct file_lock *fl) } EXPORT_SYMBOL(locks_init_lock); +void locks_init_lease(struct file_lease *fl) +{ + memset(fl, 0, sizeof(*fl)); + locks_init_lock_heads(&fl->fl_core); +} +EXPORT_SYMBOL(locks_init_lease); + /* * Initialize a new lock from an existing file_lock structure. */ @@ -541,14 +576,14 @@ static int flock_to_posix_lock(struct file *filp, struct file_lock *fl, /* default lease lock manager operations */ static bool -lease_break_callback(struct file_lock *fl) +lease_break_callback(struct file_lease *fl) { kill_fasync(&fl->fl_fasync, SIGIO, POLL_MSG); return false; } static void -lease_setup(struct file_lock *fl, void **priv) +lease_setup(struct file_lease *fl, void **priv) { struct file *filp = fl->fl_core.fl_file; struct fasync_struct *fa = *priv; @@ -564,7 +599,7 @@ lease_setup(struct file_lock *fl, void **priv) __f_setown(filp, task_pid(current), PIDTYPE_TGID, 0); } -static const struct lock_manager_operations lease_manager_ops = { +static const struct lease_manager_operations lease_manager_ops = { .lm_break = lease_break_callback, .lm_change = lease_modify, .lm_setup = lease_setup, @@ -573,7 +608,7 @@ static const struct lock_manager_operations lease_manager_ops = { /* * Initialize a lease, use the default lock manager operations */ -static int lease_init(struct file *filp, int type, struct file_lock *fl) +static int lease_init(struct file *filp, int type, struct file_lease *fl) { if (assign_type(&fl->fl_core, type) != 0) return -EINVAL; @@ -583,17 +618,14 @@ static int lease_init(struct file *filp, int type, struct file_lock *fl) fl->fl_core.fl_file = filp; fl->fl_core.fl_flags = FL_LEASE; - fl->fl_start = 0; - fl->fl_end = OFFSET_MAX; - fl->fl_ops = NULL; fl->fl_lmops = &lease_manager_ops; return 0; } /* Allocate a file_lock initialised to this type of lease */ -static struct file_lock *lease_alloc(struct file *filp, int type) +static struct file_lease *lease_alloc(struct file *filp, int type) { - struct file_lock *fl = locks_alloc_lock(); + struct file_lease *fl = locks_alloc_lease(); int error = -ENOMEM; if (fl == NULL) @@ -601,7 +633,7 @@ static struct file_lock *lease_alloc(struct file *filp, int type) error = lease_init(filp, type, fl); if (error) { - locks_free_lock(fl); + locks_free_lease(fl); return ERR_PTR(error); } return fl; @@ -1418,7 +1450,7 @@ static int posix_lock_inode_wait(struct inode *inode, struct file_lock *fl) return error; } -static void lease_clear_pending(struct file_lock *fl, int arg) +static void lease_clear_pending(struct file_lease *fl, int arg) { switch (arg) { case F_UNLCK: @@ -1430,7 +1462,7 @@ static void lease_clear_pending(struct file_lock *fl, int arg) } /* We already had a lease on this file; just change its type */ -int lease_modify(struct file_lock *fl, int arg, struct list_head *dispose) +int lease_modify(struct file_lease *fl, int arg, struct list_head *dispose) { int error = assign_type(&fl->fl_core, arg); @@ -1465,7 +1497,7 @@ static bool past_time(unsigned long then) static void time_out_leases(struct inode *inode, struct list_head *dispose) { struct file_lock_context *ctx = inode->i_flctx; - struct file_lock *fl, *tmp; + struct file_lease *fl, *tmp; lockdep_assert_held(&ctx->flc_lock); @@ -1481,8 +1513,8 @@ static void time_out_leases(struct inode *inode, struct list_head *dispose) static bool leases_conflict(struct file_lock_core *lc, struct file_lock_core *bc) { bool rc; - struct file_lock *lease = file_lock(lc); - struct file_lock *breaker = file_lock(bc); + struct file_lease *lease = file_lease(lc); + struct file_lease *breaker = file_lease(bc); if (lease->fl_lmops->lm_breaker_owns_lease && lease->fl_lmops->lm_breaker_owns_lease(lease)) @@ -1503,7 +1535,7 @@ static bool leases_conflict(struct file_lock_core *lc, struct file_lock_core *bc } static bool -any_leases_conflict(struct inode *inode, struct file_lock *breaker) +any_leases_conflict(struct inode *inode, struct file_lease *breaker) { struct file_lock_context *ctx = inode->i_flctx; struct file_lock_core *flc; @@ -1534,7 +1566,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) { int error = 0; struct file_lock_context *ctx; - struct file_lock *new_fl, *fl, *tmp; + struct file_lease *new_fl, *fl, *tmp; unsigned long break_time; int want_write = (mode & O_ACCMODE) != O_RDONLY; LIST_HEAD(dispose); @@ -1594,7 +1626,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) } restart: - fl = list_first_entry(&ctx->flc_lease, struct file_lock, fl_core.fl_list); + fl = list_first_entry(&ctx->flc_lease, struct file_lease, fl_core.fl_list); break_time = fl->fl_break_time; if (break_time != 0) break_time -= jiffies; @@ -1613,7 +1645,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) percpu_down_read(&file_rwsem); spin_lock(&ctx->flc_lock); trace_break_lease_unblock(inode, new_fl); - locks_delete_block(new_fl); + __locks_delete_block(&new_fl->fl_core); if (error >= 0) { /* * Wait for the next conflicting lease that has not been @@ -1630,7 +1662,7 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) percpu_up_read(&file_rwsem); locks_dispose_list(&dispose); free_lock: - locks_free_lock(new_fl); + locks_free_lease(new_fl); return error; } EXPORT_SYMBOL(__break_lease); @@ -1648,13 +1680,13 @@ void lease_get_mtime(struct inode *inode, struct timespec64 *time) { bool has_lease = false; struct file_lock_context *ctx; - struct file_lock *fl; + struct file_lease *fl; ctx = locks_inode_context(inode); if (ctx && !list_empty_careful(&ctx->flc_lease)) { spin_lock(&ctx->flc_lock); fl = list_first_entry_or_null(&ctx->flc_lease, - struct file_lock, fl_core.fl_list); + struct file_lease, fl_core.fl_list); if (fl && (fl->fl_core.fl_type == F_WRLCK)) has_lease = true; spin_unlock(&ctx->flc_lock); @@ -1690,7 +1722,7 @@ EXPORT_SYMBOL(lease_get_mtime); */ int fcntl_getlease(struct file *filp) { - struct file_lock *fl; + struct file_lease *fl; struct inode *inode = file_inode(filp); struct file_lock_context *ctx; int type = F_UNLCK; @@ -1762,9 +1794,9 @@ check_conflicting_open(struct file *filp, const int arg, int flags) } static int -generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **priv) +generic_add_lease(struct file *filp, int arg, struct file_lease **flp, void **priv) { - struct file_lock *fl, *my_fl = NULL, *lease; + struct file_lease *fl, *my_fl = NULL, *lease; struct inode *inode = file_inode(filp); struct file_lock_context *ctx; bool is_deleg = (*flp)->fl_core.fl_flags & FL_DELEG; @@ -1873,7 +1905,7 @@ generic_add_lease(struct file *filp, int arg, struct file_lock **flp, void **pri static int generic_delete_lease(struct file *filp, void *owner) { int error = -EAGAIN; - struct file_lock *fl, *victim = NULL; + struct file_lease *fl, *victim = NULL; struct inode *inode = file_inode(filp); struct file_lock_context *ctx; LIST_HEAD(dispose); @@ -1913,7 +1945,7 @@ static int generic_delete_lease(struct file *filp, void *owner) * The (input) flp->fl_lmops->lm_break function is required * by break_lease(). */ -int generic_setlease(struct file *filp, int arg, struct file_lock **flp, +int generic_setlease(struct file *filp, int arg, struct file_lease **flp, void **priv) { struct inode *inode = file_inode(filp); @@ -1960,7 +1992,7 @@ lease_notifier_chain_init(void) } static inline void -setlease_notifier(int arg, struct file_lock *lease) +setlease_notifier(int arg, struct file_lease *lease) { if (arg != F_UNLCK) srcu_notifier_call_chain(&lease_notifier_chain, arg, lease); @@ -1996,7 +2028,7 @@ EXPORT_SYMBOL_GPL(lease_unregister_notifier); * may be NULL if the lm_setup operation doesn't require it. */ int -vfs_setlease(struct file *filp, int arg, struct file_lock **lease, void **priv) +vfs_setlease(struct file *filp, int arg, struct file_lease **lease, void **priv) { if (lease) setlease_notifier(arg, *lease); @@ -2009,7 +2041,7 @@ EXPORT_SYMBOL_GPL(vfs_setlease); static int do_fcntl_add_lease(unsigned int fd, struct file *filp, int arg) { - struct file_lock *fl; + struct file_lease *fl; struct fasync_struct *new; int error; @@ -2019,14 +2051,14 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, int arg) new = fasync_alloc(); if (!new) { - locks_free_lock(fl); + locks_free_lease(fl); return -ENOMEM; } new->fa_fd = fd; error = vfs_setlease(filp, arg, &fl, (void **)&new); if (fl) - locks_free_lock(fl); + locks_free_lease(fl); if (new) fasync_free(new); return error; @@ -2646,7 +2678,7 @@ locks_remove_flock(struct file *filp, struct file_lock_context *flctx) static void locks_remove_lease(struct file *filp, struct file_lock_context *ctx) { - struct file_lock *fl, *tmp; + struct file_lease *fl, *tmp; LIST_HEAD(dispose); if (list_empty(&ctx->flc_lease)) @@ -2744,7 +2776,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, struct inode *inode = NULL; unsigned int fl_pid; struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)->i_sb); - int type; + int type = fl->fl_core.fl_type; fl_pid = locks_translate_pid(fl, proc_pidns); /* @@ -2761,6 +2793,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, if (repeat) seq_printf(f, "%*s", repeat - 1 + (int)strlen(pfx), pfx); + if (IS_POSIX(&fl->fl_core)) { if (fl->fl_core.fl_flags & FL_ACCESS) seq_puts(f, "ACCESS"); @@ -2774,21 +2807,25 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, } else if (IS_FLOCK(&fl->fl_core)) { seq_puts(f, "FLOCK ADVISORY "); } else if (IS_LEASE(&fl->fl_core)) { - if (fl->fl_core.fl_flags & FL_DELEG) + struct file_lease *lease = file_lease(&fl->fl_core); + + type = target_leasetype(lease); + + if (lease->fl_core.fl_flags & FL_DELEG) seq_puts(f, "DELEG "); else seq_puts(f, "LEASE "); - if (lease_breaking(fl)) + if (lease_breaking(lease)) seq_puts(f, "BREAKING "); - else if (fl->fl_core.fl_file) + else if (lease->fl_core.fl_file) seq_puts(f, "ACTIVE "); else seq_puts(f, "BREAKER "); } else { seq_puts(f, "UNKNOWN UNKNOWN "); } - type = IS_LEASE(&fl->fl_core) ? target_leasetype(fl) : fl->fl_core.fl_type; + seq_printf(f, "%s ", (type == F_WRLCK) ? "WRITE" : (type == F_RDLCK) ? "READ" : "UNLCK"); @@ -2964,6 +3001,9 @@ static int __init filelock_init(void) filelock_cache = kmem_cache_create("file_lock_cache", sizeof(struct file_lock), 0, SLAB_PANIC, NULL); + filelease_cache = kmem_cache_create("file_lock_cache", + sizeof(struct file_lease), 0, SLAB_PANIC, NULL); + for_each_possible_cpu(i) { struct file_lock_list_struct *fll = per_cpu_ptr(&file_lock_list, i); diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h index 581698f1b7b2..6ff41ceb9f1c 100644 --- a/fs/nfs/nfs4_fs.h +++ b/fs/nfs/nfs4_fs.h @@ -330,7 +330,7 @@ extern int update_open_stateid(struct nfs4_state *state, const nfs4_stateid *deleg_stateid, fmode_t fmode); extern int nfs4_proc_setlease(struct file *file, int arg, - struct file_lock **lease, void **priv); + struct file_lease **lease, void **priv); extern int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo); extern void nfs4_update_changeattr(struct inode *dir, diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index e238abc78a13..1cd9652f3c28 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -439,7 +439,7 @@ void nfs42_ssc_unregister_ops(void) } #endif /* CONFIG_NFS_V4_2 */ -static int nfs4_setlease(struct file *file, int arg, struct file_lock **lease, +static int nfs4_setlease(struct file *file, int arg, struct file_lease **lease, void **priv) { return nfs4_proc_setlease(file, arg, lease, priv); diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index a5596007b4d9..e2ef04e88603 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -7604,7 +7604,7 @@ static int nfs4_delete_lease(struct file *file, void **priv) return generic_setlease(file, F_UNLCK, NULL, priv); } -static int nfs4_add_lease(struct file *file, int arg, struct file_lock **lease, +static int nfs4_add_lease(struct file *file, int arg, struct file_lease **lease, void **priv) { struct inode *inode = file_inode(file); @@ -7622,7 +7622,7 @@ static int nfs4_add_lease(struct file *file, int arg, struct file_lock **lease, return -EAGAIN; } -int nfs4_proc_setlease(struct file *file, int arg, struct file_lock **lease, +int nfs4_proc_setlease(struct file *file, int arg, struct file_lease **lease, void **priv) { switch (arg) { diff --git a/fs/nfsd/nfs4layouts.c b/fs/nfsd/nfs4layouts.c index 4bef3349bd90..7726aca7ad52 100644 --- a/fs/nfsd/nfs4layouts.c +++ b/fs/nfsd/nfs4layouts.c @@ -25,7 +25,7 @@ static struct kmem_cache *nfs4_layout_cache; static struct kmem_cache *nfs4_layout_stateid_cache; static const struct nfsd4_callback_ops nfsd4_cb_layout_ops; -static const struct lock_manager_operations nfsd4_layouts_lm_ops; +static const struct lease_manager_operations nfsd4_layouts_lm_ops; const struct nfsd4_layout_ops *nfsd4_layout_ops[LAYOUT_TYPE_MAX] = { #ifdef CONFIG_NFSD_FLEXFILELAYOUT @@ -182,20 +182,19 @@ nfsd4_free_layout_stateid(struct nfs4_stid *stid) static int nfsd4_layout_setlease(struct nfs4_layout_stateid *ls) { - struct file_lock *fl; + struct file_lease *fl; int status; if (nfsd4_layout_ops[ls->ls_layout_type]->disable_recalls) return 0; - fl = locks_alloc_lock(); + fl = locks_alloc_lease(); if (!fl) return -ENOMEM; - locks_init_lock(fl); + locks_init_lease(fl); fl->fl_lmops = &nfsd4_layouts_lm_ops; fl->fl_core.fl_flags = FL_LAYOUT; fl->fl_core.fl_type = F_RDLCK; - fl->fl_end = OFFSET_MAX; fl->fl_core.fl_owner = ls; fl->fl_core.fl_pid = current->tgid; fl->fl_core.fl_file = ls->ls_file->nf_file; @@ -203,7 +202,7 @@ nfsd4_layout_setlease(struct nfs4_layout_stateid *ls) status = vfs_setlease(fl->fl_core.fl_file, fl->fl_core.fl_type, &fl, NULL); if (status) { - locks_free_lock(fl); + locks_free_lease(fl); return status; } BUG_ON(fl != NULL); @@ -724,7 +723,7 @@ static const struct nfsd4_callback_ops nfsd4_cb_layout_ops = { }; static bool -nfsd4_layout_lm_break(struct file_lock *fl) +nfsd4_layout_lm_break(struct file_lease *fl) { /* * We don't want the locks code to timeout the lease for us; @@ -737,14 +736,14 @@ nfsd4_layout_lm_break(struct file_lock *fl) } static int -nfsd4_layout_lm_change(struct file_lock *onlist, int arg, +nfsd4_layout_lm_change(struct file_lease *onlist, int arg, struct list_head *dispose) { BUG_ON(!(arg & F_UNLCK)); return lease_modify(onlist, arg, dispose); } -static const struct lock_manager_operations nfsd4_layouts_lm_ops = { +static const struct lease_manager_operations nfsd4_layouts_lm_ops = { .lm_break = nfsd4_layout_lm_break, .lm_change = nfsd4_layout_lm_change, }; diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index cf5d0b3a553f..8b394f8a14c5 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4922,7 +4922,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) /* Called from break_lease() with flc_lock held. */ static bool -nfsd_break_deleg_cb(struct file_lock *fl) +nfsd_break_deleg_cb(struct file_lease *fl) { struct nfs4_delegation *dp = (struct nfs4_delegation *) fl->fl_core.fl_owner; struct nfs4_file *fp = dp->dl_stid.sc_file; @@ -4960,7 +4960,7 @@ nfsd_break_deleg_cb(struct file_lock *fl) * %true: Lease conflict was resolved * %false: Lease conflict was not resolved. */ -static bool nfsd_breaker_owns_lease(struct file_lock *fl) +static bool nfsd_breaker_owns_lease(struct file_lease *fl) { struct nfs4_delegation *dl = fl->fl_core.fl_owner; struct svc_rqst *rqst; @@ -4977,7 +4977,7 @@ static bool nfsd_breaker_owns_lease(struct file_lock *fl) } static int -nfsd_change_deleg_cb(struct file_lock *onlist, int arg, +nfsd_change_deleg_cb(struct file_lease *onlist, int arg, struct list_head *dispose) { struct nfs4_delegation *dp = (struct nfs4_delegation *) onlist->fl_core.fl_owner; @@ -4991,7 +4991,7 @@ nfsd_change_deleg_cb(struct file_lock *onlist, int arg, return -EAGAIN; } -static const struct lock_manager_operations nfsd_lease_mng_ops = { +static const struct lease_manager_operations nfsd_lease_mng_ops = { .lm_breaker_owns_lease = nfsd_breaker_owns_lease, .lm_break = nfsd_break_deleg_cb, .lm_change = nfsd_change_deleg_cb, @@ -5331,18 +5331,17 @@ static bool nfsd4_cb_channel_good(struct nfs4_client *clp) return clp->cl_minorversion && clp->cl_cb_state == NFSD4_CB_UNKNOWN; } -static struct file_lock *nfs4_alloc_init_lease(struct nfs4_delegation *dp, +static struct file_lease *nfs4_alloc_init_lease(struct nfs4_delegation *dp, int flag) { - struct file_lock *fl; + struct file_lease *fl; - fl = locks_alloc_lock(); + fl = locks_alloc_lease(); if (!fl) return NULL; fl->fl_lmops = &nfsd_lease_mng_ops; fl->fl_core.fl_flags = FL_DELEG; fl->fl_core.fl_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK; - fl->fl_end = OFFSET_MAX; fl->fl_core.fl_owner = (fl_owner_t)dp; fl->fl_core.fl_pid = current->tgid; fl->fl_core.fl_file = dp->dl_stid.sc_file->fi_deleg_file->nf_file; @@ -5463,7 +5462,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, struct nfs4_clnt_odstate *odstate = stp->st_clnt_odstate; struct nfs4_delegation *dp; struct nfsd_file *nf = NULL; - struct file_lock *fl; + struct file_lease *fl; u32 dl_type; /* @@ -5536,7 +5535,7 @@ nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp, status = vfs_setlease(fp->fi_deleg_file->nf_file, fl->fl_core.fl_type, &fl, NULL); if (fl) - locks_free_lock(fl); + locks_free_lease(fl); if (status) goto out_clnt_odstate; @@ -8449,7 +8448,7 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct inode *inode) { __be32 status; struct file_lock_context *ctx; - struct file_lock *fl; + struct file_lease *fl; struct nfs4_delegation *dp; ctx = locks_inode_context(inode); diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c index 99b0ade833aa..d053c15d06b3 100644 --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -1084,7 +1084,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int whence) } static int -cifs_setlease(struct file *file, int arg, struct file_lock **lease, void **priv) +cifs_setlease(struct file *file, int arg, struct file_lease **lease, void **priv) { /* * Note that this is called by vfs setlease with i_lock held to diff --git a/include/linux/filelock.h b/include/linux/filelock.h index 9cf1ee3efeda..fcb3f7e86270 100644 --- a/include/linux/filelock.h +++ b/include/linux/filelock.h @@ -27,6 +27,7 @@ #define FILE_LOCK_DEFERRED 1 struct file_lock; +struct file_lease; struct file_lock_operations { void (*fl_copy_lock)(struct file_lock *, struct file_lock *); @@ -39,14 +40,17 @@ struct lock_manager_operations { void (*lm_put_owner)(fl_owner_t); void (*lm_notify)(struct file_lock *); /* unblock callback */ int (*lm_grant)(struct file_lock *, int); - bool (*lm_break)(struct file_lock *); - int (*lm_change)(struct file_lock *, int, struct list_head *); - void (*lm_setup)(struct file_lock *, void **); - bool (*lm_breaker_owns_lease)(struct file_lock *); bool (*lm_lock_expirable)(struct file_lock *cfl); void (*lm_expire_lock)(void); }; +struct lease_manager_operations { + bool (*lm_break)(struct file_lease *); + int (*lm_change)(struct file_lease *, int, struct list_head *); + void (*lm_setup)(struct file_lease *, void **); + bool (*lm_breaker_owns_lease)(struct file_lease *); +}; + struct lock_manager { struct list_head list; /* @@ -110,11 +114,6 @@ struct file_lock { loff_t fl_start; loff_t fl_end; - struct fasync_struct * fl_fasync; /* for lease break notifications */ - /* for lease breaks: */ - unsigned long fl_break_time; - unsigned long fl_downgrade_time; - const struct file_lock_operations *fl_ops; /* Callbacks for filesystems */ const struct lock_manager_operations *fl_lmops; /* Callbacks for lockmanagers */ union { @@ -131,6 +130,15 @@ struct file_lock { } fl_u; } __randomize_layout; +struct file_lease { + struct file_lock_core fl_core; + struct fasync_struct * fl_fasync; /* for lease break notifications */ + /* for lease breaks: */ + unsigned long fl_break_time; + unsigned long fl_downgrade_time; + const struct lease_manager_operations *fl_lmops; /* Callbacks for lockmanagers */ +} __randomize_layout; + struct file_lock_context { spinlock_t flc_lock; struct list_head flc_flock; @@ -156,7 +164,7 @@ int fcntl_getlease(struct file *filp); void locks_free_lock_context(struct inode *inode); void locks_free_lock(struct file_lock *fl); void locks_init_lock(struct file_lock *); -struct file_lock * locks_alloc_lock(void); +struct file_lock *locks_alloc_lock(void); void locks_copy_lock(struct file_lock *, struct file_lock *); void locks_copy_conflock(struct file_lock *, struct file_lock *); void locks_remove_posix(struct file *, fl_owner_t); @@ -170,11 +178,15 @@ int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_l int vfs_cancel_lock(struct file *filp, struct file_lock *fl); bool vfs_inode_has_locks(struct inode *inode); int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl); + +void locks_init_lease(struct file_lease *); +void locks_free_lease(struct file_lease *fl); +struct file_lease *locks_alloc_lease(void); int __break_lease(struct inode *inode, unsigned int flags, unsigned int type); void lease_get_mtime(struct inode *, struct timespec64 *time); -int generic_setlease(struct file *, int, struct file_lock **, void **priv); -int vfs_setlease(struct file *, int, struct file_lock **, void **); -int lease_modify(struct file_lock *, int, struct list_head *); +int generic_setlease(struct file *, int, struct file_lease **, void **priv); +int vfs_setlease(struct file *, int, struct file_lease **, void **); +int lease_modify(struct file_lease *, int, struct list_head *); struct notifier_block; int lease_register_notifier(struct notifier_block *); @@ -238,6 +250,11 @@ static inline void locks_init_lock(struct file_lock *fl) return; } +static inline void locks_init_lease(struct file_lease *fl) +{ + return; +} + static inline void locks_copy_conflock(struct file_lock *new, struct file_lock *fl) { return; @@ -312,18 +329,18 @@ static inline void lease_get_mtime(struct inode *inode, } static inline int generic_setlease(struct file *filp, int arg, - struct file_lock **flp, void **priv) + struct file_lease **flp, void **priv) { return -EINVAL; } static inline int vfs_setlease(struct file *filp, int arg, - struct file_lock **lease, void **priv) + struct file_lease **lease, void **priv) { return -EINVAL; } -static inline int lease_modify(struct file_lock *fl, int arg, +static inline int lease_modify(struct file_lease *fl, int arg, struct list_head *dispose) { return -EINVAL; diff --git a/include/linux/fs.h b/include/linux/fs.h index e6ba0cc6f2ee..07b73e5c8f55 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1064,6 +1064,7 @@ struct file *get_file_active(struct file **f); typedef void *fl_owner_t; struct file_lock; +struct file_lease; /* The following constant reflects the upper bound of the file/locking space */ #ifndef OFFSET_MAX @@ -2005,7 +2006,7 @@ struct file_operations { ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); void (*splice_eof)(struct file *file); - int (*setlease)(struct file *, int, struct file_lock **, void **); + int (*setlease)(struct file *, int, struct file_lease **, void **); long (*fallocate)(struct file *file, int mode, loff_t offset, loff_t len); void (*show_fdinfo)(struct seq_file *m, struct file *f); @@ -3238,7 +3239,7 @@ extern int simple_write_begin(struct file *file, struct address_space *mapping, extern const struct address_space_operations ram_aops; extern int always_delete_dentry(const struct dentry *); extern struct inode *alloc_anon_inode(struct super_block *); -extern int simple_nosetlease(struct file *, int, struct file_lock **, void **); +extern int simple_nosetlease(struct file *, int, struct file_lease **, void **); extern const struct dentry_operations simple_dentry_operations; extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); diff --git a/include/trace/events/filelock.h b/include/trace/events/filelock.h index 49263b69215e..344753e43aa4 100644 --- a/include/trace/events/filelock.h +++ b/include/trace/events/filelock.h @@ -117,12 +117,12 @@ DEFINE_EVENT(filelock_lock, flock_lock_inode, TP_ARGS(inode, fl, ret)); DECLARE_EVENT_CLASS(filelock_lease, - TP_PROTO(struct inode *inode, struct file_lock *fl), + TP_PROTO(struct inode *inode, struct file_lease *fl), TP_ARGS(inode, fl), TP_STRUCT__entry( - __field(struct file_lock *, fl) + __field(struct file_lease *, fl) __field(unsigned long, i_ino) __field(dev_t, s_dev) __field(struct file_lock_core *, fl_blocker) @@ -153,23 +153,23 @@ DECLARE_EVENT_CLASS(filelock_lease, __entry->fl_break_time, __entry->fl_downgrade_time) ); -DEFINE_EVENT(filelock_lease, break_lease_noblock, TP_PROTO(struct inode *inode, struct file_lock *fl), +DEFINE_EVENT(filelock_lease, break_lease_noblock, TP_PROTO(struct inode *inode, struct file_lease *fl), TP_ARGS(inode, fl)); -DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, struct file_lock *fl), +DEFINE_EVENT(filelock_lease, break_lease_block, TP_PROTO(struct inode *inode, struct file_lease *fl), TP_ARGS(inode, fl)); -DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lock *fl), +DEFINE_EVENT(filelock_lease, break_lease_unblock, TP_PROTO(struct inode *inode, struct file_lease *fl), TP_ARGS(inode, fl)); -DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lock *fl), +DEFINE_EVENT(filelock_lease, generic_delete_lease, TP_PROTO(struct inode *inode, struct file_lease *fl), TP_ARGS(inode, fl)); -DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lock *fl), +DEFINE_EVENT(filelock_lease, time_out_leases, TP_PROTO(struct inode *inode, struct file_lease *fl), TP_ARGS(inode, fl)); TRACE_EVENT(generic_add_lease, - TP_PROTO(struct inode *inode, struct file_lock *fl), + TP_PROTO(struct inode *inode, struct file_lease *fl), TP_ARGS(inode, fl), @@ -204,7 +204,7 @@ TRACE_EVENT(generic_add_lease, ); TRACE_EVENT(leases_conflict, - TP_PROTO(bool conflict, struct file_lock *lease, struct file_lock *breaker), + TP_PROTO(bool conflict, struct file_lease *lease, struct file_lease *breaker), TP_ARGS(conflict, lease, breaker),