From patchwork Wed Jan 31 23:02:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 1893717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=JnTGGgDo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-cifs+bounces-1064-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TQHxK1BJ8z23g7 for ; Thu, 1 Feb 2024 10:17:09 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 5D82C1C2048C for ; Wed, 31 Jan 2024 23:17:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D1512145B39; Wed, 31 Jan 2024 23:04:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JnTGGgDo" X-Original-To: linux-cifs@vger.kernel.org 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 9301B145B2C; Wed, 31 Jan 2024 23:04:23 +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=1706742263; cv=none; b=Q4QwSi2JdHRUHzsIu4PYws9HWHir3uyRghz5QA3G1totR1RyHy9iyJHskpncor77R0LBE55epWv/j4Ft8hf6ARQ3G631KacWS3f8rNRyMGuTLcCMuUS0sn7FHTZS9aFjckk9bCcpUqdlpzJr9zHUAt+4cXn3S/XPSXfh+0Up1Xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742263; c=relaxed/simple; bh=LrTuC12tZ/QtQEScYVhE54GLHT5AD/GwOclA9PHGmT8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dlq87BvzxUC+gb4+H4HulORYG9sVcyptxmNp/zvDTOxSIXDIcEj8HtiR77W63lIWBWcPKXuQADkJbd4PlAcptMBekH7/sVVAePOpM02rJkSrdziQ6I9ZYQVBrFGyNTvCuXOF3zGByzo4FYbE2lxJ+c2mv/infzuvJw5yve5Mvus= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JnTGGgDo; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id ABB1AC433F1; Wed, 31 Jan 2024 23:04:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742263; bh=LrTuC12tZ/QtQEScYVhE54GLHT5AD/GwOclA9PHGmT8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=JnTGGgDonD3liJE6IVRh/+68rvq3zAqBE5NugHrbPiNeqfTvmNv2WOFRKldxMCmUg dRySg7FJzd6rNhP5bpYfvY2HMCGM7Dsme9wh6CnWvWcEFnYOaCiKJjfNPjwGrCcRZO iNS6ys6mA7pIDyAZxc0qRXSIwJkN1yPCPt0AL8Fmk4xMVlPa2B+OXdogWWVvyHiy1L olccnqlZjpKwwYJ3TTEAHxY+HD8DZLzec0BYH3wZhhuNb2tY5QxRk1gqLqNeQkV6Y1 H7CgvifCwTa5f0HDvvgGvWX+Gl4qPAWGn1Cd35h3PuafYfbzyM7hm2d71iC7rsJ4HO M3cslZXqCvuMA== From: Jeff Layton Date: Wed, 31 Jan 2024 18:02:13 -0500 Subject: [PATCH v3 32/47] filelock: convert locks_translate_pid to take file_lock_core Precedence: bulk X-Mailing-List: linux-cifs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240131-flsplit-v3-32-c6129007ee8d@kernel.org> References: <20240131-flsplit-v3-0-c6129007ee8d@kernel.org> In-Reply-To: <20240131-flsplit-v3-0-c6129007ee8d@kernel.org> To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers , Chuck Lever , Alexander Viro , Christian Brauner , Jan Kara , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Howells , Marc Dionne , Xiubo Li , Ilya Dryomov , Alexander Aring , David Teigland , Andreas Gruenbacher , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Mark Fasheh , Joel Becker , Joseph Qi , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Namjae Jeon , Sergey Senozhatsky , Miklos Szeredi Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, gfs2@lists.linux.dev, linux-nfs@vger.kernel.org, ocfs2-devel@lists.linux.dev, linux-cifs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3170; i=jlayton@kernel.org; h=from:subject:message-id; bh=LrTuC12tZ/QtQEScYVhE54GLHT5AD/GwOclA9PHGmT8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFyjJ6e5wDFqFR/4d4Cd4muX6vg/Y08ASqVS 9l0rPUgHVGJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRcgAKCRAADmhBGVaC FUnJD/kBte7SHPfni6wANeCfXgKgNZdSACRHZ/YPayRBpDjCsGePqI5p9iO2j0UDC8WKmw3WbIt Fhuiwls6PztamS9oYT3Hvf3bwRdwv5MNF9TpJJJoKVIYA+TeZQlONgb9cmAA0MJdIdrq3wxIV0+ ox1suYoalWPCoTXWcB/FWLHlN1yzeDv93DMIxmUKKoZX56mHC05RYzsMHfQZPk2cQEC/Y41Jtbx 2fdgS6Od8Mr3Xm8y5xebKyuZ7lu2XI31qm5j9q5N2SILwPuuIuUrHcUyl1AExJHfNyn+tYMapio GjuQL+xWtzHpAfkUIMUb28IL53SRA25Kq83KUb8Q+fJKH5/XQc00+cWUIMvqj902HuXF/kI3pV6 PROH6H25wSYIn1kLiw2ya+ccMLWlPDrheu5QuKziXXV3eqXWnMdSvLT5jQgOfflGmwDWwED3D55 0p4UXkHlJrkwGfv8awZuZ7bWz5EI0N53ino15xM/WnENxjWibqmtckaXwrGjVGal2UI3FsyBJON 48xLe3o7znzTT0LFn6K3H6/SqxUEyfyhp3IHbjpAkFLBrooQoaQRDz3MhemR3E5z2ABL/GtgTUn JaZoaAmtR5WYJlwmKlQgoK6+pkOGgMn2WX9AQex9LNm6Eer7NQaPWayxnZVmYlBNn7j2n+JqnZi 4NIkVFNvo4VMbgg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 locks_translate_pid is used on both locks and leases, so have that take struct file_lock_core. Signed-off-by: Jeff Layton --- fs/locks.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 50d02a53ca75..97f6e9163130 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2169,17 +2169,17 @@ EXPORT_SYMBOL_GPL(vfs_test_lock); * * Used to translate a fl_pid into a namespace virtual pid number */ -static pid_t locks_translate_pid(struct file_lock *fl, struct pid_namespace *ns) +static pid_t locks_translate_pid(struct file_lock_core *fl, struct pid_namespace *ns) { pid_t vnr; struct pid *pid; - if (fl->c.flc_flags & FL_OFDLCK) + if (fl->flc_flags & FL_OFDLCK) return -1; /* Remote locks report a negative pid value */ - if (fl->c.flc_pid <= 0) - return fl->c.flc_pid; + if (fl->flc_pid <= 0) + return fl->flc_pid; /* * If the flock owner process is dead and its pid has been already @@ -2187,10 +2187,10 @@ static pid_t locks_translate_pid(struct file_lock *fl, struct pid_namespace *ns) * flock owner pid number in init pidns. */ if (ns == &init_pid_ns) - return (pid_t) fl->c.flc_pid; + return (pid_t) fl->flc_pid; rcu_read_lock(); - pid = find_pid_ns(fl->c.flc_pid, &init_pid_ns); + pid = find_pid_ns(fl->flc_pid, &init_pid_ns); vnr = pid_nr_ns(pid, ns); rcu_read_unlock(); return vnr; @@ -2198,7 +2198,7 @@ static pid_t locks_translate_pid(struct file_lock *fl, struct pid_namespace *ns) static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) { - flock->l_pid = locks_translate_pid(fl, task_active_pid_ns(current)); + flock->l_pid = locks_translate_pid(&fl->c, task_active_pid_ns(current)); #if BITS_PER_LONG == 32 /* * Make sure we can represent the posix lock via @@ -2220,7 +2220,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl) #if BITS_PER_LONG == 32 static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl) { - flock->l_pid = locks_translate_pid(fl, task_active_pid_ns(current)); + flock->l_pid = locks_translate_pid(&fl->c, task_active_pid_ns(current)); flock->l_start = fl->fl_start; flock->l_len = fl->fl_end == OFFSET_MAX ? 0 : fl->fl_end - fl->fl_start + 1; @@ -2726,7 +2726,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)->i_sb); int type = fl->c.flc_type; - pid = locks_translate_pid(fl, proc_pidns); + pid = locks_translate_pid(&fl->c, proc_pidns); /* * If lock owner is dead (and pid is freed) or not visible in current * pidns, zero is shown as a pid value. Check lock info from @@ -2819,7 +2819,7 @@ static int locks_show(struct seq_file *f, void *v) cur = hlist_entry(v, struct file_lock, c.flc_link); - if (locks_translate_pid(cur, proc_pidns) == 0) + if (locks_translate_pid(&cur->c, proc_pidns) == 0) return 0; /* View this crossed linked list as a binary tree, the first member of fl_blocked_requests