From patchwork Wed Jan 31 23:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 195055 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp91556dyc; Wed, 31 Jan 2024 15:33:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCaWJD0GvGCbWJuVXYUy/2y2/MX+c8S4AxIVaZT1cI6unxs+MJo6hulgU87HqYiHY1pF87 X-Received: by 2002:a17:90b:f8d:b0:295:bf53:2a with SMTP id ft13-20020a17090b0f8d00b00295bf53002amr3389161pjb.46.1706744021344; Wed, 31 Jan 2024 15:33:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706744021; cv=pass; d=google.com; s=arc-20160816; b=RAzawirMAEruVqNkQYl/ANjk3ZRp4Qlpi8XTTbNfDDGAc3901F78Pegem+s1ndl4hs k+Ut/IY1unLliuilfMr3JPGZE9A7LlcZ+3aqJEr2jV8hoBhhRWzE+89sMz8q/7RNiO6O FQHKdjTAxqBpdq8bIvqn7cRMt7gXNPQTHuE9dcTfGuL1GN0g/O56nICUOIT5dLU8zPWy RW2aXaN3vDEE7mDQ0b47al+ZiO6FdZ3jBA0Yku22loNe9Q0LDh7z4BIGep1wAY13XNj8 lxr7qDdT7JNDs1X6/6VVUNsAWwTQLTKuCmfwFUTzzAvlith2IlMnwLS60N5DHH9c5VOi 8gaQ== 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=lFIvWe1q4qKtW1eXXQq6Z3dkda1raboH8Hmi7zgloVo=; fh=ieHS5ZToMByhvyjk0hCwya+BziveukJQdP1B+oki1GE=; b=OIQn7DrUO9EvlZr3XXiTAXEJXLFoN94fONB6CDTGZTOmBWzRXkUcgWuojpZ3qk0OWj HeLY3S9f42gBqKPrWnQys1jowy5c1wQnVJaZGbFL7M0q7/cpFJvf5j6WCIM93AI/O3wc XWtn7/yj6PI49UsQcR32m7IXStstNCDPILRxUZpphl5+e0Y0ZN8/h1AwodQ6yeN2YaCn qpaxiD+8/JEPssPR9a1qkcIprbQPiNUgPBLsVQFzcFdTnkZxvsRTvTSsUqAoNKUWozFl OmkX//+HuHxDDT7bf8oUYOq5ExokxnIShbfbrNQf7kwQuRwuASKIzZwgz01q47KNGSHH AcUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HX9GxtHj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47315-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47315-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCWb5zAg/XWG75MnVm2kO4eIcdwEhfrKhJnBD1KfnOCJEPvplgwvS2+W8ayAwLwrV8OBXFDS6xPx/NKYd/1y8oDeb7rL2g== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g9-20020a17090a128900b00295bc158e90si2281616pja.147.2024.01.31.15.33.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:33:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47315-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HX9GxtHj; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47315-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47315-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 8DBE62934A3 for ; Wed, 31 Jan 2024 23:15:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF4A71420DE; Wed, 31 Jan 2024 23:04:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HX9GxtHj" 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 126CA1420A0; Wed, 31 Jan 2024 23:04:07 +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=1706742248; cv=none; b=f7Xnv6DHmlId0Mz/blW67MzX3A/t+pfvqMiTFEkmt/FfBocQHovfZEt/rKeyctVZ9+m06JTqgtJFVVfQWy0JtxZVzQFSkp0uV4vpFL209j80T33MBUV7T3k37lGR2bBViICV1API7WXkDYI8l0DNeUVe3LU+4xr02LJ46toUVBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742248; c=relaxed/simple; bh=oXsh7Z3Zj8YwVWNqhAyX9dCLEvRylLbk3GgRqMltkDI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IxKUKtuKn/gV+wNlNUddWnDj35dwQzAyPpcIwqoiVPaB0HWcKOP7e08QfIOFGsllTvfNtCPEwpu4iV7hcd0+YWN2RMmSxKY46ljBErslGgJPkND9Wd/NwhLmFkG/mFoYWNhItO2YIQTlFbMSor8/wvB5JCoCqcrJ8rdSHiW+4NE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HX9GxtHj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAFC5C433B1; Wed, 31 Jan 2024 23:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742247; bh=oXsh7Z3Zj8YwVWNqhAyX9dCLEvRylLbk3GgRqMltkDI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=HX9GxtHji864xbCpDr8dxOatkhLnwmHD0kzn3uJRfOEEC8HMzkSQFFqiWpcbIe3II 8p97Hc3SuHpM6Gx9Gp5KIVavPWCQdNdOmdbGlav4n+VNubaw53U/nNlh4VUXSe6Tag +K+KHbMb0HRmHeEdutcN9e6mWqsgOJCSrR/tI5eDCKq7+k+S7Cxfd4wRsNxA6vwOGB de0Z0sMVLDjlMlaUKMgDvaYPhOkk/4WeAw/VEbMRbkZ9hbUxRU2XQwh4Dda41PL/c4 E2bXVexu35OP7niUGHSjDIICZ+oLBrXa/jPyCof119NB79ydojsS765KLBhLa1nXUY YR6xc72bd3emA== From: Jeff Layton Date: Wed, 31 Jan 2024 18:02:09 -0500 Subject: [PATCH v3 28/47] filelock: reorganize locks_delete_block and __locks_insert_block 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-28-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=5008; i=jlayton@kernel.org; h=from:subject:message-id; bh=oXsh7Z3Zj8YwVWNqhAyX9dCLEvRylLbk3GgRqMltkDI=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFxzre30atP5W7Sf7TY3lvrDobazNYOrGTQw 1ZIjFXzhniJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRcQAKCRAADmhBGVaC FUqXD/93uE7hJ0eDVn4U040TdajOsoJFEqE1JMzX+yb36gB+XiyHGvC/8ulONCZCBeKaFB4uZ2v aV0ZxfzvOUN+PUbUt+vgA+K4V4x3CsJT/Y3XzKtyCusvA5Wd+TJ1mYIAmp2n2oyD2wzn/vTopV2 to5rboxgaRQ57Qofqun64NDS/ZbvIVGgD36Y9Lsix9ZWqKTGwFJ08BLk1rimPLzbJHIg9lI/mFk VgJkncKS7d3skJ//+XzGLwAk4sZwtaPBk2HBu4H5VES9qVbC2NqwJu7zUKVao4j5AZHXaW2f0wB dAHFnfDDVA7ReLiv42YsbZeT8+2UikrtbQoqqRyEkDVGm5HpN3fU47lzP/7iaZ1qc6et80DnRKq tXbGmic0tpS7TdODZBv0CdatkBY04US4dYS52Kz4zmyYYXfuiilIigYeuYfoqQ081KE9uOunPsJ VTyeCUdfEdaaBpHpN8210I55Yg4QU8R6cjSPB+WAdQYoNdIISmIivpjMWNpNvahI6R20apzB2hg i8dIqBXN4/rr+BaEiYLFdezT3ENS36+E2QMrhRJrgp67NjPgv6/M5hkiMHr3IMLcbNLOLyA2I71 qvak+Vhs5kLhHFmdsWNKsG0WJL4LfI8LeuXFNZJYvFN0cZvi2Sg2Av9qKBFpRAOxX6TNug8QQFu x1WBiRjN1IzKhfA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789650818796523360 X-GMAIL-MSGID: 1789650818796523360 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 | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index a2be1e0b5a94..c8fd2964dd98 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -659,7 +659,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->flc_blocked_member); @@ -675,7 +675,7 @@ static void __locks_wake_up_blocks(struct file_lock_core *blocker) struct file_lock_core, flc_blocked_member); fl = file_lock(waiter); - __locks_delete_block(waiter); + __locks_unlink_block(waiter); if ((waiter->flc_flags & (FL_POSIX | FL_FLOCK)) && fl->fl_lmops && fl->fl_lmops->lm_notify) fl->fl_lmops->lm_notify(fl); @@ -691,16 +691,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->c; /* * If fl_blocker is NULL, it won't be set again as this thread "owns" @@ -731,7 +724,7 @@ int locks_delete_block(struct file_lock *waiter_fl) if (waiter->flc_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 @@ -741,6 +734,17 @@ int locks_delete_block(struct file_lock *waiter_fl) 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->c); +} EXPORT_SYMBOL(locks_delete_block); /* Insert waiter into blocker's block list. @@ -758,13 +762,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->c; - struct file_lock_core *waiter = &waiter_fl->c; struct file_lock_core *flc; BUG_ON(!list_empty(&waiter->flc_blocked_member)); @@ -789,8 +791,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 *)) { @@ -1088,7 +1090,7 @@ static int flock_lock_inode(struct inode *inode, struct file_lock *request) if (!(request->c.flc_flags & FL_SLEEP)) goto out; error = FILE_LOCK_DEFERRED; - locks_insert_block(fl, request, flock_locks_conflict); + locks_insert_block(&fl->c, &request->c, flock_locks_conflict); goto out; } if (request->c.flc_flags & FL_ACCESS) @@ -1182,7 +1184,7 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, __locks_wake_up_blocks(&request->c); if (likely(!posix_locks_deadlock(request, fl))) { error = FILE_LOCK_DEFERRED; - __locks_insert_block(fl, request, + __locks_insert_block(&fl->c, &request->c, posix_locks_conflict); } spin_unlock(&blocked_lock_lock); @@ -1575,7 +1577,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->c, &new_fl->c, leases_conflict); trace_break_lease_block(inode, new_fl); spin_unlock(&ctx->flc_lock); percpu_up_read(&file_rwsem);