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: 195036 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp84776dyc; Wed, 31 Jan 2024 15:17:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXmKo0o+TMVQ+Ny+/5Ep4X7RdZaKi6qDof/LyPa4+sB2Qxy0cEBlyFElHfE81B51UvAdgA X-Received: by 2002:a05:620a:55a1:b0:783:e3be:9ad1 with SMTP id vr1-20020a05620a55a100b00783e3be9ad1mr625821qkn.17.1706743052921; Wed, 31 Jan 2024 15:17:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706743052; cv=pass; d=google.com; s=arc-20160816; b=KIU4EFBhFDciIsg3zwf0zg2MsZb212iLrDxEgltRYRkUeoNjGOsQyoSCKr3airdZvr JCoDZc6qlwpkc7VI0E5JDcnczSSU6Gy0Ohzk1pgAuC3GXvs32ZZ9ujmtNM4AViaFtltC ziENU/W82DVj8XuUb0ya4C2/VuORHGHko89dNNkO1PpqqOMX9OOgVMHw9swgNGJJ91GJ t8lSQnMTHvNhxLGMGhasW873ztcOtHCUeM6ui8r/AO6RGk8U404uRjPS+m25Q0WCQ1dg bU6k0x4kyXZOCh4N70ivdwR8XBnhV7u58/p3Qm0X09+7FqLraCewuFeQpU0rC/F6F8jX s2MA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=b8Y0PIQW4IRv3f7NHQZFvE055tyXxlx8wTzoGSBEqOI=; fh=ZfgIF1iZeppmV4oRhptPtPWn236SSTCrBUHY2ucT4Qg=; b=TqolG+Eds7DFsHveVuVF1HXAbXktIepHEzRqdqdoDlxflrGhmYJzUjT/U6uvUuBdnV h2oMkVgWB9zxBklpGzjTPpRtGxPqpN/1XzPQxly76+L9P5YlrkHaxZdYBgYSIJnjTmUY JdaVt8ecelTte0SF/vgvmtlzrqhXXQR/7ayxmPzYeiS31tUtrKgnyAqMT1IqS7EexLvS Nnw81ZDYsyiUetgmUfCI0mI6dU6m4FZYPdLd4I/6w8hg+PQ/8k47mJH9nd7xL4js454b NEUYmrjnKcpV7J2a/iiIDGVFiOvdyRJcASECzMwdIA8k33hp8xE58e8TaR3OeaF+rlL4 LuuQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JnTGGgDo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCV9B79SOhkjKJHhRRp1xszgl2rlplf6QretFhV+0cfbUAcyma7ebwDD1X05Ijt8N4XWYHJnVaC46/kcZ1YFsCoaVUO2dw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id bp43-20020a05620a45ab00b007839d816e60si14443789qkb.425.2024.01.31.15.17.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:17:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JnTGGgDo; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47319-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47319-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A71031C20B55 for ; Wed, 31 Jan 2024 23:17:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B650B1468EB; Wed, 31 Jan 2024 23:04:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JnTGGgDo" 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-kernel@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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789649803383032328 X-GMAIL-MSGID: 1789649803383032328 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