From patchwork Wed Jan 31 23:01:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 195017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp79406dyc; Wed, 31 Jan 2024 15:06:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IFA5n1NUkihTNGpGQAldg9ZtqXsCG4dPmFzC/Tj/hpFiWs9krHFY4CDv8ZaBuuk3zuneWF0 X-Received: by 2002:a05:620a:1238:b0:784:b22:9811 with SMTP id v24-20020a05620a123800b007840b229811mr890549qkj.9.1706742369926; Wed, 31 Jan 2024 15:06:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706742369; cv=pass; d=google.com; s=arc-20160816; b=n3R5+i5J8iS07m8Tk2AqtJf3kMhOG6d0AXuTg4d3R8oGeuHcPmMpFO15GhbO7rTt2d FyNDg03l8s+KqFecJiNSWwdBSvbiYrFn6kzH/Dye2CXzjLVhNZ/mOJWXD+YQzcdwuS3X bVqLEvRkq05WE8GtZCxZwZW40/RijpIy0jpZnC2DSZs+XlB7E5R18VRpSePJlC2WjzGH a5yZ6YyXWe6IWgQXq2EikjXn0S80+hM1B1AaY5A4HwN3d9OXS/FCpNxX7TL7JCEMwwBZ dv5jfSMSN/DfrwcWfxdfIBe/+K0odWBJqXvBrt0rx1i6hvKIXgXOns7tnHLEAQwgbtGH nVwQ== 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=yFbH9tplOTIJdViLeadR4xvdpXW55pzJcskZB6yc7jc=; fh=yywawY2HtC2zwl+uEonvyUgZ6qc4yJIgw5WSnuPPdIg=; b=KnIu+PPRZeKHQNx9fSMD7z/172iX1inYR6eV64k00wdEXVFtbQzgQjLwA6xI+0QmU0 /K6W8fDEO264uIPx6EkH47B2fjmiGynnCx84NnPxM3/65s/9be8xL6HI68ilts2Yd2jb Iz4W6ctCSsStLOWIbQrSMwFpC5eyElPbwtVBWDE8YC9zRHcoge7gcweQUfSaaahuRY6I ZTUZWky7njPVvfcERDC1m3CKdp36cyI3ABAmmh1EzldE9NxcolET6aTQ38/1LJT39nmp NhUwQaGZYQ8/6nveO0XDWkWppwtgGjka2WvevWS7756DsAX5TSv6w+47E8QF4W4zDyfh raIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=feePs9zy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47293-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47293-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVFlbkye3hgrrwt4By/jpdH/nA70bBMKHWgigSqVeQdCIhjllyZbrwAmL9w1xSHTXKcuH6VpUagi3QbAC8HNlMuiOf6IA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id g21-20020ae9e115000000b00783daaec208si12020861qkm.17.2024.01.31.15.06.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:06:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47293-ouuuleilei=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=feePs9zy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-47293-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47293-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 A6BA21C22E57 for ; Wed, 31 Jan 2024 23:06:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6CB73B193; Wed, 31 Jan 2024 23:02:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="feePs9zy" 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 B079141215; Wed, 31 Jan 2024 23:02:44 +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=1706742164; cv=none; b=D5Qapzf/0YhencCfATmTjLusiLI2IdNf2nX4sgUNcb0RQ3ZbQUd2pputnPUjuus/LRLdhYucBVLjUGoSWOqG5bOLQX9JrnbfiTkP9PfUzGiAvaj2/hKO7riyJPaJoRhDfNFBai1VEl94gp5+rkR+uZQvEGeFek1KDZPUaqrOrUQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706742164; c=relaxed/simple; bh=jUsklV0M5ZShEslcSzKmuGytzj4BAvtswz7tp/C3yVQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=c6joR4OiAfn1kmw+fxhpSTa+jJxr3ttOwDIGb7TUbVCQ7e88HiM3C8LRgwquih4Rerir/pk0KRpReju91svKIrjFgf5/TXXO1qxB+TbhSoGhgNGHmlL84FnILqWG/on1fG8mx8sHFzVP6K7PLcVpfZLPl1DDqz6eCOtebuuX428= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=feePs9zy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 697F4C43601; Wed, 31 Jan 2024 23:02:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706742164; bh=jUsklV0M5ZShEslcSzKmuGytzj4BAvtswz7tp/C3yVQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=feePs9zyV01D+VTp+yo6a2mr1Bauz0ZluxMrEXDL3BexsjWjDecYRYOmckdjMgF2d f1sDa/frrrKne2X5XgPdKuOqmrPl5VSSK+1htXz6RECNCoqw2Eq4N7ArMV7QjhYicw X5x2b2UY3LkaCBDhCsT7jDH/RhOGiZ6q5rHG0HGcV5t1C0vJm2onG95W24X6y1UGEM WMt0XH2oAn3kXUyiU8a5ZviDAIhujR038AhCM2sNeDs7g9hZzf7vLQc0NNMTBvOOVk cYAKjrzVWKBy4NyMc8EWwQvPubM16NsOTT+j/geLuNIjMFIcK6Aovg42T3ZYh+3qF6 ohiwp7/rwcMlw== From: Jeff Layton Date: Wed, 31 Jan 2024 18:01:48 -0500 Subject: [PATCH v3 07/47] ceph: convert to using new filelock helpers 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-7-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=2941; i=jlayton@kernel.org; h=from:subject:message-id; bh=jUsklV0M5ZShEslcSzKmuGytzj4BAvtswz7tp/C3yVQ=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlutFvtGyTzSzaKQa548I+QZYrq4tsyYSSi27eN qH3OdZSsmeJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZbrRbwAKCRAADmhBGVaC FbLcEACBeyzNZcBkoXWWJ72IFHNoR6FdBBeTqxaKJFUsGzzgpP6tC5J5IUD030fKZEOyIbOKkJX 2rs0TUm7yZ8m2WN+s7lCJ0XILiLk+TC3/GuRNfMNSzhg8ACBnWFX1jmG5lMXwbZTgAXXHL6znSq LvkM691cYzJIune95niudSHKZ3KlnM2AimEqR7ayLyzylvrOa88zOSlz7VtrdNNx+/5prkw32oY wL4v9LXEkrUtTRqqd8vnPY68O2JfbB3WSUt9VlV7ZzOJqzSJoXBW54JNTuK11GjMxzxhWm1eoUp jLQUlMwnXbycwdegWCAEx6jfEm55FFuCawbjgmRhWI1JBLxY0R5M7N5aKtsSPj10QLJI2FzwKhx 0MnMtvI4akmLdbaugUx8LVDzekOcEz3q5VtAGbS7KY3VCfpYWyRATPm+rLm+iiXVeB7+SFENLlB cud2hrGHfIbY45UGj2GknCJa++Wzt7eUf+9oFmgFT+gqW9mHP7tuo+ZBBM44cU4NTzDf4LiEK2X aih79bdvX2tYM8rETaIrQJa5kmkMx9u5fCxbaceJzGfiU9dmegQCIPum/bVB1RKbBcFOvLFZ7kw nxEEifhq3YP9+ttF+0j7XXJ8RM2yKc3A3wxj6X6iSpslJMUb6XcgF5QJkl79Y/HPeu6APQs8EoN li0gL83Hwubq6oA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789649087639257189 X-GMAIL-MSGID: 1789649087639257189 Convert to using the new file locking helper functions. Signed-off-by: Jeff Layton --- fs/ceph/locks.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/fs/ceph/locks.c b/fs/ceph/locks.c index e07ad29ff8b9..80ebe1d6c67d 100644 --- a/fs/ceph/locks.c +++ b/fs/ceph/locks.c @@ -273,19 +273,19 @@ int ceph_lock(struct file *file, int cmd, struct file_lock *fl) } spin_unlock(&ci->i_ceph_lock); if (err < 0) { - if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_type) + if (op == CEPH_MDS_OP_SETFILELOCK && lock_is_unlock(fl)) posix_lock_file(file, fl, NULL); return err; } - if (F_RDLCK == fl->fl_type) + if (lock_is_read(fl)) lock_cmd = CEPH_LOCK_SHARED; - else if (F_WRLCK == fl->fl_type) + else if (lock_is_write(fl)) lock_cmd = CEPH_LOCK_EXCL; else lock_cmd = CEPH_LOCK_UNLOCK; - if (op == CEPH_MDS_OP_SETFILELOCK && F_UNLCK == fl->fl_type) { + if (op == CEPH_MDS_OP_SETFILELOCK && lock_is_unlock(fl)) { err = try_unlock_file(file, fl); if (err <= 0) return err; @@ -333,7 +333,7 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) } spin_unlock(&ci->i_ceph_lock); if (err < 0) { - if (F_UNLCK == fl->fl_type) + if (lock_is_unlock(fl)) locks_lock_file_wait(file, fl); return err; } @@ -341,14 +341,14 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl) if (IS_SETLKW(cmd)) wait = 1; - if (F_RDLCK == fl->fl_type) + if (lock_is_read(fl)) lock_cmd = CEPH_LOCK_SHARED; - else if (F_WRLCK == fl->fl_type) + else if (lock_is_write(fl)) lock_cmd = CEPH_LOCK_EXCL; else lock_cmd = CEPH_LOCK_UNLOCK; - if (F_UNLCK == fl->fl_type) { + if (lock_is_unlock(fl)) { err = try_unlock_file(file, fl); if (err <= 0) return err; @@ -385,9 +385,9 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count) ctx = locks_inode_context(inode); if (ctx) { spin_lock(&ctx->flc_lock); - list_for_each_entry(lock, &ctx->flc_posix, fl_list) + for_each_file_lock(lock, &ctx->flc_posix) ++(*fcntl_count); - list_for_each_entry(lock, &ctx->flc_flock, fl_list) + for_each_file_lock(lock, &ctx->flc_flock) ++(*flock_count); spin_unlock(&ctx->flc_lock); } @@ -453,7 +453,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, return 0; spin_lock(&ctx->flc_lock); - list_for_each_entry(lock, &ctx->flc_posix, fl_list) { + for_each_file_lock(lock, &ctx->flc_posix) { ++seen_fcntl; if (seen_fcntl > num_fcntl_locks) { err = -ENOSPC; @@ -464,7 +464,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode, goto fail; ++l; } - list_for_each_entry(lock, &ctx->flc_flock, fl_list) { + for_each_file_lock(lock, &ctx->flc_flock) { ++seen_flock; if (seen_flock > num_flock_locks) { err = -ENOSPC;