Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1966985rdb; Wed, 31 Jan 2024 15:09:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdd8pATy5MDOqkv5sawIKcDD4K6oIWWQfUUCJAHJrAXukuFEzecLPE5B/T4HOvNcMvlho4 X-Received: by 2002:a05:6214:ca9:b0:68c:444e:2bea with SMTP id s9-20020a0562140ca900b0068c444e2beamr7416361qvs.6.1706742593663; Wed, 31 Jan 2024 15:09:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742593; cv=pass; d=google.com; s=arc-20160816; b=F/sD8qqmoutCf4bGLMbCZ6JGgb8qnfeWPkuupTTwRFScQr+BHQuUn2H8kv0b6ps6Y7 ppoTKrGRY2imwWiymXlM7902lUKNziyqWdP92RoU59sRk3VvdagSKj6CRujFY7J6Z5xD aT+d5iu1NHRGBTVYbWxMFx9ZUmvrsjJ8HiU19cqbdYXQvgnkDDeboWLVa4yVcpk/UZo/ WyLxxU77IYanUXxl3vIpxyIEprpVCia3Gr/HReTAok0r/AgBoeuUCLqNUkdte1Ej0Y4+ cLzKYY5D7gh88B6qx5FFl4WZbmSE+3TEJfC4NTyAspMT+VlXwNR9XojC7Y4YgacV55G5 gDEw== 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=ordhsCujwxywn4AWSqyhr7x3yzg3ozOpIKWAL4XjKgY=; fh=tBqtRSHRxTqyltQVZxLhkiwKrEepF1smTq/oSO57XQA=; b=GlyBbx8gaQXgsrE8XwMeQgO8i92O7xdjEoKPI+jt79OAYV3TIJggHo6CJa6riV9xYS j17fL9qdlgRi5PIedDk2785fXVdmEEQk3X24b7h/DxgG1cWC4eAsRtEQKsUs7IoR084f DI2O3rB/IboOO+ZirJkgNDVmPHybvzIlrayd908eO3EOHYmrJe2xkgSsub6nuokwXmiA GasbNoKgW885z66FegRiZVuv3HQ8OFf8SkuXXSbjfzLwrF3cJbIyM/fC359CBhZFfew/ D6JRDG8n2wLtFd4Evm6dHaWeCQNINIou7E4peaEJzSMJOLZPev4erNq0q+7xRHL50Vv+ Ef+A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tkDZvqSH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47302-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCXdmN4v8mmA8ZPuzcDwa+KXvxgZelc+PB9/yuRD20Xy8sAMXJUwXRQfs1ZphPTIzlE8SbJFxcb04wWivedhO1R9eDDH773MzFexKl28xA== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h16-20020a05620a13f000b007840a695ae6si4852041qkl.359.2024.01.31.15.09.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:09:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tkDZvqSH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47302-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47302-linux.lists.archive=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 5E8811C25E88 for ; Wed, 31 Jan 2024 23:09:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 857D069D11; Wed, 31 Jan 2024 23:03:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tkDZvqSH" 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 45B9A5677B; Wed, 31 Jan 2024 23:03:20 +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=1706742200; cv=none; b=UCrARcBwUzJotppUrmpcc4FhJH6hNcu9xg36j3LkoDRxTm+otsUJ/Df2Ep9WsDDX8L5wtkbNy/nZQAnDSW9ZuUC+B6xH/dIUq5MpJBjNl8+elnmrpolHkmHEjVv1oYXyfFBkF5ZxPRQksl662ORqDJe5Uu9UkiqYyJQqIb5jvck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742200; c=relaxed/simple; bh=5swEox7V4hK8YGA2X7E7k10sEDLgEh0qA057+uwiAbI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TO5Pvv83UCCVR+x76noNiGQWPK/2kE+NByp5Ea8BMLK/QwLyY31uv6qXKeTqV19x30BvoioSsqKUS3FC4D43wm1jYEtOF6cACvhoBHx8z9C4RdudZWlBbo3+Ea+SeD6sLKxmSG1QbrZ/zJdm0QJ2lkL24gqCbi3/d0qpCVu3i/w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tkDZvqSH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 25D33C433B2; Wed, 31 Jan 2024 23:03:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742199; bh=5swEox7V4hK8YGA2X7E7k10sEDLgEh0qA057+uwiAbI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tkDZvqSHCUpfwZClKkxlyG6uTkY15Ou0cqbbpV7PlnGagszHGxcMa1jnZkXR98oU3 qIb9Idx3nVnPug8413GPmfHCo/H/7Q92ZoXrr1iP+78l8dC1FYzATD8AMAXXenNL80 4552kNJRSCnWCEz/aFwCbjchbX6hcm4QljunWVjLO2GMwcZcqoaneHBqsBApnk44Ks ULhp3+G6wNKDcoq1fIQZTWpFG4BnyYcAYl9wdfatGBg1FHMiFGq3SHhdCxSqw3maRm WlCnxcsiqCqTARY3dlwF3ez00KHz59q1OM+CZ12ywYQAXxxWqwy7PhHyaKdR8NhWRe zhxkrJIugubBA== From: Jeff Layton Date: Wed, 31 Jan 2024 18:01:57 -0500 Subject: [PATCH v3 16/47] filelock: drop the IS_* macros Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240131-flsplit-v3-16-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=3882; i=jlayton@kernel.org; h=from:subject:message-id; bh=5swEox7V4hK8YGA2X7E7k10sEDLgEh0qA057+uwiAbI=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFw1gNZXaBpHdfIiv1gOKh+XtMS35AGJtNDY f87s9/sgGCJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRcAAKCRAADmhBGVaC FaCTEADWGpwDJy9k978zXhQu7rq2iKRa7A+5cqrfAodW8VK1sF01UKKoyv8z4/vrF3jei4ernAI 6s7OCbt7o0zEbpJfP0A8EK4gLNnHhA0U/MonNdZoOe05S2JpCf7Igako+cx0Ije8/iJc9ZxGU/2 ND6365olXE5xeTzezicUTLepgNWL1KJPpJ4B2DrzD3c0yhF6o96ttkix5fak7jOpyVT85h9l3ph idPJDRigG8UMdJ9dEewZuT1o13FqtYX7fyOqPpvgcKf/sgid6Qf3SQ597xTyw9RaBxIHCH5R451 Z8GVBR1T+ZyyeTvbl2alGLQpYI2UNmhTSflE8OjU6OkfkYgyjRHMVQ+KogeptjCoJw4HUyCBW9L zi2XCAg1y94Aj3cyqVHrHQyH4gi4QD1wcpHUzPvU4k7z5W4WHHXZzGBjM2pTUJsBd6nISAl9EA8 hEip8991FDmgY2xomZItbya283R5gbVonbeLBKyZxN/sWaufQeVprpb3v4Ubsw0al7IQJeb/BcK q9gcEMiaVxJbNqBPXDChfBn2p18av2NA02Vn03YITVoWHAV9nCJ7vwkzwFTZzk/vvSUrN+c/Nqu GkgCUaVBT1FIR8AO0OYJyL4Q7miSgfddhcLWndjkuG2XCdt56y+LUKSWCAYR3fAZFKs4RRejNkf F2mrJg3I4Q0mLXg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 These don't add a lot of value over just open-coding the flag check. Suggested-by: NeilBrown Signed-off-by: Jeff Layton --- fs/locks.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 149070fd3b66..d685c3fdbea5 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -70,12 +70,6 @@ #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) - static bool lease_breaking(struct file_lock *fl) { return fl->fl_flags & (FL_UNLOCK_PENDING | FL_DOWNGRADE_PENDING); @@ -767,7 +761,7 @@ static void __locks_insert_block(struct file_lock *blocker, } waiter->fl_blocker = blocker; list_add_tail(&waiter->fl_blocked_member, &blocker->fl_blocked_requests); - if (IS_POSIX(blocker) && !IS_OFDLCK(blocker)) + if ((blocker->fl_flags & (FL_POSIX|FL_OFDLCK)) == FL_POSIX) locks_insert_global_blocked(waiter); /* The requests in waiter->fl_blocked are known to conflict with @@ -999,7 +993,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 (caller_fl->fl_flags & FL_OFDLCK) return 0; while ((block_fl = what_owner_is_waiting_for(block_fl))) { @@ -2150,10 +2144,13 @@ 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 (fl->fl_flags & FL_OFDLCK) return -1; - if (IS_REMOTELCK(fl)) + + /* Remote locks report a negative pid value */ + if (fl->fl_pid <= 0) return fl->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 @@ -2697,7 +2694,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, struct inode *inode = NULL; unsigned int pid; struct pid_namespace *proc_pidns = proc_pid_ns(file_inode(f->file)->i_sb); - int type; + int type = fl->fl_type; pid = locks_translate_pid(fl, proc_pidns); /* @@ -2714,19 +2711,21 @@ 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 (fl->fl_flags & FL_POSIX) { if (fl->fl_flags & FL_ACCESS) seq_puts(f, "ACCESS"); - else if (IS_OFDLCK(fl)) + else if (fl->fl_flags & FL_OFDLCK) seq_puts(f, "OFDLCK"); else seq_puts(f, "POSIX "); seq_printf(f, " %s ", (inode == NULL) ? "*NOINODE*" : "ADVISORY "); - } else if (IS_FLOCK(fl)) { + } else if (fl->fl_flags & FL_FLOCK) { seq_puts(f, "FLOCK ADVISORY "); - } else if (IS_LEASE(fl)) { + } else if (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT)) { + type = target_leasetype(fl); + if (fl->fl_flags & FL_DELEG) seq_puts(f, "DELEG "); else @@ -2741,7 +2740,6 @@ 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_type; seq_printf(f, "%s ", (type == F_WRLCK) ? "WRITE" : (type == F_RDLCK) ? "READ" : "UNLCK"); @@ -2753,7 +2751,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, } else { seq_printf(f, "%d :0 ", pid); } - if (IS_POSIX(fl)) { + if (fl->fl_flags & FL_POSIX) { if (fl->fl_end == OFFSET_MAX) seq_printf(f, "%Ld EOF\n", fl->fl_start); else -- 2.43.0