From patchwork Wed Jan 31 23:01:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 195081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp97300dyc; Wed, 31 Jan 2024 15:48:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IEbvnTitlp8ogGd5LU5JM+SRks7kvPQ8ICdxalbFiUCYqN+re7sA+x6XeybDxl9M5uVdtRS X-Received: by 2002:a17:903:2306:b0:1d9:4e4c:23b1 with SMTP id d6-20020a170903230600b001d94e4c23b1mr356207plh.2.1706744898824; Wed, 31 Jan 2024 15:48:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706744898; cv=pass; d=google.com; s=arc-20160816; b=WeKG1ghzICMN7ixPZLtMfO/D+xD4RwTkwuOXWZ3ydVMz6gOBHyJVNTEEXeQl21PCoD VFsuJ/yZzvYgLUQ9utcqxQdT1bErZBorAaMN4YjcgBIX1eUPJqYdHB3KJakl+IpMBW1x 4GZHTLXG5IG4KARQ5CGaIEIC2urnHnGJq+tMbmxtCpAsIcfu2ISChA1AHOOMrZFqFSxi MA0Vvl1JtwYq1B5IVd8efQXWoVNNA0RU9v4co+yg5Rgop63Ru1es1vUzDXQrNDYXT48s Zz+Z6ygtkUA8LNxYyUmQiK8twbUtAT2umjvEX8b6ATyA/MFOBxeCUvy2qjmiqR4NLLgG 3PWw== 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=lxuuQvgfvMMp+mzFjJONYRet0a8eHNmQGQioSCUsukw=; b=mIkxU+1vWIafSW177TzoFEr+KscgHHPsn0Y/aB6skSVHlW7hWoqO9lNwM9NchsBhDE vWNzJ4QhPQCyfHUl2Cz1mZYs8iczIdtON5+oViv5/ryg/QNLfbFvddcwha4g9tRxAWqu fgM+/b2L+5U8fkUvjxYP5evnRGeH1J6+twgx/1iJMTO0pMS2bCh14HKJiRrTuRkbyvvR I3hvHZm0GTzJGiqkpB23Hx1+BSsksVBPtM62LkHb9eDwA1ugnzOC1ZFLjBvXjaf/Gl62 wCJQ7jG8QzDnf7fsNY8uwXO4etWvroBkeonvKRJqXmiE/EvLUZxz7xdaz5Wnv1B46EfN b/sg==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47302-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCU2yQHWY2+P/s3pbRKBByLcbCBT1Wouzk57w2pmIqmWQJAAJIzaMjT5/7/I/oW3/nJnbwDSvSK9/LQHsuAGwXxYnm0yxw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id bn7-20020a056a02030700b005d6047fb09asi10920556pgb.770.2024.01.31.15.48.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:48:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47302-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47302-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5FA7FB2F992 for ; Wed, 31 Jan 2024 23:10:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A8F2B7866F; Wed, 31 Jan 2024 23:03:23 +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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789651738917176214 X-GMAIL-MSGID: 1789651738917176214 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