From patchwork Fri Aug 30 13:04:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785065 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 2AF421A4B9C for ; Fri, 30 Aug 2024 13:05:39 +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=1725023139; cv=none; b=SwBIDgxvbgmLZcaDMVT/PQuN8NiAx9nT6tg1xRje7Hq2ZaZ8FUeiqxtawIuSflt2Nz6yWBRkQrrR0bTxc+eCIE+1CDkRfVNqSXAKUsUFnVQLojaKTR6Xp7/Zix8PvMz7K+3APlo/34yLQ2/NoRRSVsnTsfMpvlesPtRJe9cUagY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023139; c=relaxed/simple; bh=6+/BQjTYLKgRaWf4QkVYNhAQgcALSUgSaI+CKTgvLJg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YeJ8OLfr1LdAxOI5THJzWTBqXipaRWQVAkXcSqizSTBITFbfxaiwLUv/ueNCnbq0cBFiemFQQOawF9sUpTnKn2x4iQWxKpQZ99bQJsx36IkgBg48HB/7XzyNAvRVhtzs/lyOthv0AZuuXFoALYIoboKXxNIgEmT17YW1PCFFpyM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bhMZbavw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bhMZbavw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8250C4CEC2; Fri, 30 Aug 2024 13:05:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023138; bh=6+/BQjTYLKgRaWf4QkVYNhAQgcALSUgSaI+CKTgvLJg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bhMZbavwdkC60DHJbSsTs5KU3aTNwYfnSYQnyQQ9/gs5BbnFrRxb6P2oDlEwT/0Y8 cR/wj/ZqxREQBvIVnLu9oOvRf9KitIO0i1BXHyKab+sfFSw2ccJeLkvQzxLJ6B5qxQ OOF+ilS8KEbCPX2yMX5tS5piUdRZRQteYIRFrwtKwrLyLQd62oBmBNsj8TtCOvaz3Z sMXL7+bpU5QyFhN426Bgq2yngYIpFh9LNOI4lVjvdtLT6vEF3MYFnHBWL6ONvaax6m dOgwgPBZ4JyI1Nr4E6/Wk2wU/6IJh+SHixjEKsPYVskIjll83zM9TnWWXjjnsT0uU/ KwUBfZKF7uYyA== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:42 +0200 Subject: [PATCH RFC 01/20] file: remove pointless comment Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-1-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=599; i=brauner@kernel.org; h=from:subject:message-id; bh=6+/BQjTYLKgRaWf4QkVYNhAQgcALSUgSaI+CKTgvLJg=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDz7cqJl0oYJto83fRQTezg5ec42/9ULTc7c1b8a/ +GmrkpIfkcpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBE/l1mZPi+SUCvuvlhwIPN X/LF//7JF26YpjnpJU+SS2HMfdvoPQ8YGVZZcP+5p+q06pFrn/NtwdaVW7/tCf1kvebjkW+eVge DPvICAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 There's really no need to mention f_version. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/file_table.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/file_table.c b/fs/file_table.c index 3ef558f27a1c..bf1cbe47c93d 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -159,7 +159,6 @@ static int init_file(struct file *f, int flags, const struct cred *cred) mutex_init(&f->f_pos_lock); f->f_flags = flags; f->f_mode = OPEN_FMODE(flags); - /* f->f_version: 0 */ /* * We're SLAB_TYPESAFE_BY_RCU so initialize f_count last. While From patchwork Fri Aug 30 13:04:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785066 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 E68C2199952 for ; Fri, 30 Aug 2024 13:05:41 +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=1725023142; cv=none; b=TafNj/aB0kvr+MQ/KipN2zLmLNP0nj7fJ+XQOXWPMoOZqOK0Kl/1z5uXMr3DMRE5spcwtnZ8XCj3dOLeHosbgu11WvunWIueE9H0RK7kXNWS6mtz0iM4jpE+01Bhd4Cl1RVQvNcSxPAtH0ioBMEDm/O7YCxpwig+Mx8Yp9viy2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023142; c=relaxed/simple; bh=m0MK5x14xYeWUlpHuGJRO2AE5ttSGHy3ztVlwwlYFLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mshIzNeiWVlcFOeUy6UpBzudtZWNeNhFuoESrMns/2bT4UTGmAByh6FJHPdDXIDJCGhUS1d6sO0x5XHcg7wtvuHTUwLFjGN9DPq5HrM7OSO6V5lS8nr1uuzEqJMo33fsFyjjKGKbsVL5ReMbIlgCe30xD9/l4vJy2WvrYZtf2SU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nnE5ip4/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nnE5ip4/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75530C4CEC7; Fri, 30 Aug 2024 13:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023141; bh=m0MK5x14xYeWUlpHuGJRO2AE5ttSGHy3ztVlwwlYFLU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nnE5ip4/tOYUufqD+D8B27ljwwqUnk2gQkuuqsRQTcOcb34ogB4FxYoUvQrh2Pz/u /p+fpzCnob31DjZequ2dCPcw3cLTjpAo0KzROrOS9EyYlzMJAfujq2YxYOOZX+UVLQ qG9PDvu4frtOvh0+uCsHspOC6XTh+EKRHHUsPU3b9qZQlbCFwAFaNkmxLFgYg8u1O5 2doI0g/LHrERfELyK1LYPbWZL591+c/LNcwT27mM0+M8E4e9fTQrLlDxhAxokVEtWo uglADzqinqz0Mr5H0J+IoO69HkyNCCMKlBmRzikqhtD1LemG9gksmt0GMkdl/+ILwz dR3lTdY7eOYKQ== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:43 +0200 Subject: [PATCH RFC 02/20] adi: remove unused f_version Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-2-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=544; i=brauner@kernel.org; h=from:subject:message-id; bh=m0MK5x14xYeWUlpHuGJRO2AE5ttSGHy3ztVlwwlYFLU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDxbdEP+xNZpSYslyl2WeM9dorryzErXEKb1yjPuV bP3sVVt7ShlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjI1e0M/1OfX2nSnmWywehZ Vt67R78l9gY7HnEsuBsgEKXJwJzmvobhvwufn1PFmoPm/zZqSCut7K3LaW5euWNN298djD0RO99 ksQIA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 It's not used for adi so don't bother with it at all. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- drivers/char/adi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/char/adi.c b/drivers/char/adi.c index 751d7cc0da1b..c091a0282ad0 100644 --- a/drivers/char/adi.c +++ b/drivers/char/adi.c @@ -196,7 +196,6 @@ static loff_t adi_llseek(struct file *file, loff_t offset, int whence) if (offset != file->f_pos) { file->f_pos = offset; - file->f_version = 0; ret = offset; } From patchwork Fri Aug 30 13:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785067 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 A70E71A4AAF for ; Fri, 30 Aug 2024 13:05: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=1725023144; cv=none; b=sRtC7YJ7uXBRLF9pWLYtUBTRRxI4oWQTTAxWQLGd0PUCQTg8wk3C862ibaLeAbfbDGLGIwRKxTDZCxSlyLgrRME4yaP34RfYN52189Aktm/oSUFm2A2X02BI9Mw2zsiWhhZf1xMw5xI4HYuM9y0E/EOBF4rdisfMV56fLq48bqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023144; c=relaxed/simple; bh=B+0ZLA0i60D7ZBtX17/wNvaeIn0U40DUrbuGI8hezxI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fCwG+xXA52nt7FURH0ZWezEeSbNzrQXfULdYnlxIzWptnfzLqJXu6e16cO+TTYzM3ZM99664a9KGcTsfluZ0RhRhyVSR8rifUEvRqVP3wN0qitRCdpaYpCnzI7j4nKFdNKS1Yv/cKM5KxGmenhYC/JFcVtdgdcZh0G4QYihZ7Nw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KnfLm4+I; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KnfLm4+I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B3E8C4CEC5; Fri, 30 Aug 2024 13:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023144; bh=B+0ZLA0i60D7ZBtX17/wNvaeIn0U40DUrbuGI8hezxI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=KnfLm4+IOS83tNnm04CSmbpxOqtpjd7BFaSVtg0JgeMMuK996fq6V3DeDeaEzf9l7 cfB11HseEI+DPIJuMvH8h3c6nuZZSKkcGPPrTQzDlm/20eFFytlchfwIhJ/RFMEK86 GWKmgFxTfAjGCWDoQjM5H5/m21OworgmNcHNGeq/ysFcZchxwldQVHtCNbw950Ghsu nbhitPyFSMvBQFcVz3Rfvz3rpxymODDCqzYViIB9xz4wVJS8ifZwpO+R8wBW6UBexN 2+UaCQMuFSDmlsPOT0/SgQo6LUoQhbFoYtF5lIWaZS+0bKmb548Zd8y6scCK1tWEen tqj0Qtz4er7Pw== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:44 +0200 Subject: [PATCH RFC 03/20] ceph: remove unused f_version Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-3-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=573; i=brauner@kernel.org; h=from:subject:message-id; bh=B+0ZLA0i60D7ZBtX17/wNvaeIn0U40DUrbuGI8hezxI=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDzbsubZvNc5Vz6ILysKWC1QuNfzJldZaP/0XZEd2 +V25SgLdJSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEzkOh/DX3Fr0QPOJp3piwrr XD9sYuyWse3YefqQTKRBd43OzN51Fgx/5etjnSf9k1yrLD/p8IY8vuCvdg8/nX7GKRg5RaCP61Q oJwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 It's not used for ceph so don't bother with it at all. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/ceph/dir.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 18c72b305858..ddec8c9244ee 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -707,7 +707,6 @@ static loff_t ceph_dir_llseek(struct file *file, loff_t offset, int whence) if (offset != file->f_pos) { file->f_pos = offset; - file->f_version = 0; dfi->file_info.flags &= ~CEPH_F_ATEND; } retval = offset; From patchwork Fri Aug 30 13:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785068 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 3B0D91A7AC6 for ; Fri, 30 Aug 2024 13:05:47 +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=1725023147; cv=none; b=Lcge3JEO70587t/tt4aMqli6PSuzQ3Nulqpk7ykkh8DBV0F+A5CUj/CG9s/Q7jq7cho6EdClkf5BRZOfZnZYT2JAaXT1PUqB04ztrOF892xygNbnEsh24JtBuG7TD6G20tG/iIii0iGW/0GsAJI/kHid91JJvYk3J+V7ErxDcdc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023147; c=relaxed/simple; bh=GCB9+S862ME+HCXFAL4isX9ZuNjSsK5z1qW2TPkA7g0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VXfS3ePNSLovwt3Lbps/vyrjDY8WDnjaF/KyXnQPZJOurUthg/ZCUhE113KPFjM5S9mR4ijfA7Kkji5efCeL2QbhR+y/W5kcwHJIJJHCRwErnywdrtjDR4YAgQHunG5G+zrGX2vgckn5PV3vYxRQT1I2HKpfX3zDCPm28fx6Ugo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nvLkQt0C; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nvLkQt0C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1F93C4CEC5; Fri, 30 Aug 2024 13:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023147; bh=GCB9+S862ME+HCXFAL4isX9ZuNjSsK5z1qW2TPkA7g0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nvLkQt0CvSU13CzkMO2uh86xTBtgAFTzGYingKua0eAi9b1rZX5XecAUyjRLQzqrB JYDZvh5KgNOKJDKujvfdP7ZBI5+KzYk+AoK5rskm/+DCvmaFRXF/q9prs1mI9g9FP9 ICivmqsOEX12a7ZZ9+uHnRpJWrr8va33THPPxdbd6fV6psmSYA0G+v/VjWIodJd4Ri 7mkxkoNo/88AqrVqqOGV4Yn4w9/egdckZ/rQ7VKjkrZaGRIHDL74+IDr97SZOfZOW+ SrgWgO+yBJ3wjpX5BXTa2ELQfUI40UkMebodPWwvyxM2+CQuw5ihVlQebYF9FZJfZl AAyUj6PvVczVA== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:45 +0200 Subject: [PATCH RFC 04/20] s390: remove unused f_version Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-4-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=614; i=brauner@kernel.org; h=from:subject:message-id; bh=GCB9+S862ME+HCXFAL4isX9ZuNjSsK5z1qW2TPkA7g0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDz7n3C33jytnbfs7LYIt53e+pJB3K977d/ks1Zi0 54u2Bkh3VHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRjCaG/1V/7Z/luhw+lGNa xyKWFLH6cLJJ8PLORaar3b4u4L7F2s3w30lhb1V1atjdY89nSoXcCOyqeaSeozu98a/dylvHdfS V2AA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 It's not used so don't bother with it at all. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- drivers/s390/char/hmcdrv_dev.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/s390/char/hmcdrv_dev.c b/drivers/s390/char/hmcdrv_dev.c index 8d50c894711f..e069dd685899 100644 --- a/drivers/s390/char/hmcdrv_dev.c +++ b/drivers/s390/char/hmcdrv_dev.c @@ -186,9 +186,6 @@ static loff_t hmcdrv_dev_seek(struct file *fp, loff_t pos, int whence) if (pos < 0) return -EINVAL; - if (fp->f_pos != pos) - ++fp->f_version; - fp->f_pos = pos; return pos; } From patchwork Fri Aug 30 13:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785069 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 00BE21AF4D5 for ; Fri, 30 Aug 2024 13:05:49 +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=1725023150; cv=none; b=a5IMYICfzGbSwAOhMNFHt9krFidpRzcW4iF7LRAvdr7q1avIHUUCSCOAzKzr0gF1Y87o5vOU2TOYSGKCkb9nzLvaJC05AzpT8HQIWZ3HdcriYi3wPj/iyLA1sScaERBt3drviakjd7zThLtMMtZtdmHwVeNVCwITdr9v6aEU0Tk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023150; c=relaxed/simple; bh=pZf6+t/viyHgiwzusJ9PMI1aFRzOx2txikjpQentD+A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=T50gQfRvRQjHhxVqmPqUPSh14WGFHgzMslGS2p2afPCoDTYFlQYsQRDE9xlen4Jl3a4YDMMO+4hbZ5YOh8/w/tIKYbygGfb6ylaxSwnesfj8BpNKmhetJqTAfRT2ZniJTlGU/6C2xAJ+AzphaFnNzlGzfN1dIF9w4NxYDAAAzCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ezuQJQxu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ezuQJQxu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C174C4CEC8; Fri, 30 Aug 2024 13:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023149; bh=pZf6+t/viyHgiwzusJ9PMI1aFRzOx2txikjpQentD+A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ezuQJQxuY7H0u4OlCwMqi0dheDdx8O1RbcMqUFNb+saCl9CaZNlmi1FMFH5LWIpWx hDlQpPteGlL3BWg/8Id+ErxWXoeqKXQFh0YM8Gsv6zxt6JXuGeI0d0fih1PX1dKgfK sfLlVVDlqf/nL12VQhegsHEjBrqShG3lCB+O4mMnQihqDQQDbzHdqXdGiWvgolRF8o TXMw8pOc17VLujFXY2T0g9xth/1JAoxv067gg0wzuXI7uBfBsDPR+27yTZ4niVysMx Iq/3JSHv7NtQnTTcROa30sNXLRECMTf4qWtA2M6SaOvhQ5LtIwfhe0iB8hZ91snnqT iFGB1HMFtx/rQ== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:46 +0200 Subject: [PATCH RFC 05/20] fs: add vfs_setpos_cookie() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-5-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2359; i=brauner@kernel.org; h=from:subject:message-id; bh=pZf6+t/viyHgiwzusJ9PMI1aFRzOx2txikjpQentD+A=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDyHs8lp5e6m4m2KFjYqxcv3b+96mGN8O0LyINPFd tVoxs+OHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABNp2cLwTzH2SaKI7P+vX3ii XMOPHUgI2uRnxhc9yUxOoIQxM+qQO8M/+7Tghs18XnVTj7z28dCSnnP7lAnH5j89Ex8665Z9XTC XFQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Add a new helper and make vfs_setpos() call it. We will use it in follow-up patches. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/read_write.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 90e283b31ca1..66ff52860496 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -40,18 +40,20 @@ static inline bool unsigned_offsets(struct file *file) } /** - * vfs_setpos - update the file offset for lseek + * vfs_setpos_cookie - update the file offset for lseek and reset cookie * @file: file structure in question * @offset: file offset to seek to * @maxsize: maximum file size + * @cookie: cookie to reset * - * This is a low-level filesystem helper for updating the file offset to - * the value specified by @offset if the given offset is valid and it is - * not equal to the current file offset. + * Update the file offset to the value specified by @offset if the given + * offset is valid and it is not equal to the current file offset and + * reset the specified cookie to indicate that a seek happened. * * Return the specified offset on success and -EINVAL on invalid offset. */ -loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize) +static loff_t vfs_setpos_cookie(struct file *file, loff_t offset, + loff_t maxsize, u64 *cookie) { if (offset < 0 && !unsigned_offsets(file)) return -EINVAL; @@ -60,10 +62,27 @@ loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize) if (offset != file->f_pos) { file->f_pos = offset; - file->f_version = 0; + *cookie = 0; } return offset; } + +/** + * vfs_setpos - update the file offset for lseek + * @file: file structure in question + * @offset: file offset to seek to + * @maxsize: maximum file size + * + * This is a low-level filesystem helper for updating the file offset to + * the value specified by @offset if the given offset is valid and it is + * not equal to the current file offset. + * + * Return the specified offset on success and -EINVAL on invalid offset. + */ +loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize) +{ + return vfs_setpos_cookie(file, offset, maxsize, &file->f_version); +} EXPORT_SYMBOL(vfs_setpos); /** From patchwork Fri Aug 30 13:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785070 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 BDF5C1B1D4D for ; Fri, 30 Aug 2024 13:05:52 +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=1725023152; cv=none; b=C6MN4fQ+aRs2SscgSRX4bSuSYNg4OASv8ZDZkut9V0AzdYjqrpLxI9abGUPMLNIiVDIsY6gMgtUrNadAyabO0x3nEhp/hDVxv9ygOVJ44mS00xTO5U0GZGtWCzQCsWR1QgApI6AZMV+Lh5Gkj++VHrgDmgJJ16Wair0mPJId67Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023152; c=relaxed/simple; bh=6DHhCREChoI64snZkWIgdThng4Uj2MiT59kqnddj2VQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W/SRvEm34bro78DA3wcUJPF0Mg2aryn4blOmYsB3cEoohv9tCCtsCCtjaJVlJ08+gGKKpPEUY9gCk7gMkcNAJpoCjC9IyfDNuS2zjK+gvv/Hp4/vuQ0QHZR+1oHN7dXugGe7pi15rknKgrcbBAVMQjaUNtW4q9+OeD2ft9u+R9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=if0H5LE5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="if0H5LE5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81F01C4CEC5; Fri, 30 Aug 2024 13:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023152; bh=6DHhCREChoI64snZkWIgdThng4Uj2MiT59kqnddj2VQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=if0H5LE5j2mDVJWxZe5D3XESzSQftSoxto8KVfPnzenOhGuwdg79Zazp+VyV7hWpR h3JDkNr9xBDOhGv54cmLOWYLHtPnzBYJpWiZoZ4WPZQa6OSWizr4V/PcggNhl2JXjf 5dS1pBisZ9E2ihUElmresN6MzteCOFyOibDUumqJR+Ar+d0KMwQXrTSuC3H+Eu6PBp 0BaoKo3t3lBIdL1CAJ5Tf+TVZ/CTezgfq3Ve/MrJlj/TAT6/jEB5LZ2YhbKy0jLprC HzKZoAw+KRqY2Wh459xmyBzMOq9zng5jdtIjZCyUZuOmDu1F2WbLk1Ef0fpjDEXFu8 Wb6J64/LNgXgw== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:47 +0200 Subject: [PATCH RFC 06/20] fs: add must_set_pos() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-6-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2160; i=brauner@kernel.org; h=from:subject:message-id; bh=6DHhCREChoI64snZkWIgdThng4Uj2MiT59kqnddj2VQ=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDznpond2ra/D6bFb/9sFmi443+4uMPCCfsyJxx8q Jd28eyaHR2lLAxiXAyyYoosDu0m4XLLeSo2G2VqwMxhZQIZwsDFKQATkZzCyLCvOZptY/Sk2E3h c8V1l15d/ury65NvP5zgbbrmet0jWfgjI0NTnPjCJxWLoznOS35f/7Y7g7EiK+j0WoZT3RHeqbe 2TeUAAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Add a new must_set_pos() helper. We will use it in follow-up patches. Temporarily mark it as unused. This is only done to keep the diff small and reviewable. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/read_write.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 66ff52860496..acee26989d95 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -85,6 +85,58 @@ loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize) } EXPORT_SYMBOL(vfs_setpos); +/** + * must_set_pos - check whether f_pos has to be updated + * @offset: offset to use + * @whence: type of seek operation + * @eof: end of file + * + * Check whether f_pos needs to be updated and update @offset according + * to @whence. + * + * Return: 0 if f_pos doesn't need to be updated, 1 if f_pos has to be + * updated, and negative error code on failure. + */ +static __maybe_unused int must_set_pos(struct file *file, loff_t *offset, int whence, loff_t eof) +{ + switch (whence) { + case SEEK_END: + *offset += eof; + break; + case SEEK_CUR: + /* + * Here we special-case the lseek(fd, 0, SEEK_CUR) + * position-querying operation. Avoid rewriting the "same" + * f_pos value back to the file because a concurrent read(), + * write() or lseek() might have altered it + */ + if (*offset == 0) { + *offset = file->f_pos; + return 0; + } + break; + case SEEK_DATA: + /* + * In the generic case the entire file is data, so as long as + * offset isn't at the end of the file then the offset is data. + */ + if ((unsigned long long)*offset >= eof) + return -ENXIO; + break; + case SEEK_HOLE: + /* + * There is a virtual hole at the end of the file, so as long as + * offset isn't i_size or larger, return i_size. + */ + if ((unsigned long long)*offset >= eof) + return -ENXIO; + *offset = eof; + break; + } + + return 1; +} + /** * generic_file_llseek_size - generic llseek implementation for regular files * @file: file structure to seek on From patchwork Fri Aug 30 13:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785071 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 B7E5C1B1D73 for ; Fri, 30 Aug 2024 13:05:55 +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=1725023155; cv=none; b=eNxA4letRU+FbxkMBKwIGJJU3DPScOcsaJ1ANwBBISo1zwXMhJczotTrB+yWkNbPPrHv8vqAWMwfFx00ldKwvU6hE2ygkTWSPdnqnXhIkaj4iNJlIFOcSvNFGDiHxbcioGoL6UwkFdPzIpEcbCE92xI5KaTTYwyQl5zD3W6/cbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023155; c=relaxed/simple; bh=gsSA09+HfFYPf4pBq8Y5a4O4tybJu+VWXORMDBTPkXw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AZEenu3tk/BQWIu2Fer8ESuqKw30z8wgGxjY3gw3NIGgn5byNpqRrcPY65t22ZYTcE8XTfgi5XKKH5JaG+JrMFSRhCluR4ftYxjSh+Ih0Gytv5GFKiUmfdHYuIDJTtjT892DJC/fjReXumeYsdAeb1Vgbzh2sSWfrHlgr4wFiRU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ovh6/W+q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ovh6/W+q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17D61C4CECA; Fri, 30 Aug 2024 13:05:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023155; bh=gsSA09+HfFYPf4pBq8Y5a4O4tybJu+VWXORMDBTPkXw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Ovh6/W+qfXZF2Ki23cVCBZkhxPkhruizsWyA0oBCRlnYyiT4T7fwp5Nq71lJUeCxZ xKhqKnd/i3mDHmKmybIykW3By/TshNspv0mDZO6Ifu4Ag3L+ZWshoEY9ykafOUoDOc aN9DIu8WYM163C24IxZsVa6MWrRALyNwDDtMTrm3XQ/LE7Ux7DAMVohxZKXrtg7iMp ann+BdntojVNa4NqaZHTj4C/ExnTmt1KVn1ACXAFcU4flVZiYfIO6vnhLATq3ic9vf 2TvPpt9cqwCtDiJiX4YK090JckeQO7FRCAbXjeuHKYS46Q706FruwU6T5Qf8ZTWgGL VdExTQ0qtE13A== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:48 +0200 Subject: [PATCH RFC 07/20] fs: use must_set_pos() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-7-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2677; i=brauner@kernel.org; h=from:subject:message-id; bh=gsSA09+HfFYPf4pBq8Y5a4O4tybJu+VWXORMDBTPkXw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDxH6FXZ7MNXUuInaHxZ+9iS6+zx80lB/wr4WwJ/a dcqeW141VHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjAR692MDPu3bdi2IeZ7wM/D 6nuenW//WXyvuTi20ZxZ+5jaB565HKyMDLtuhT/yzSzeN7Hg2917G03KDI5GlU4qjdeLkLgeGrb lDBMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Make generic_file_llseek_size() use must_set_pos(). We'll use must_set_pos() in another helper in a minutes. Remove __maybe_unused from must_set_pos() now that it's used. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/read_write.c | 51 ++++++++++++++------------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index acee26989d95..ad93b72cc378 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -97,7 +97,7 @@ EXPORT_SYMBOL(vfs_setpos); * Return: 0 if f_pos doesn't need to be updated, 1 if f_pos has to be * updated, and negative error code on failure. */ -static __maybe_unused int must_set_pos(struct file *file, loff_t *offset, int whence, loff_t eof) +static int must_set_pos(struct file *file, loff_t *offset, int whence, loff_t eof) { switch (whence) { case SEEK_END: @@ -157,45 +157,22 @@ loff_t generic_file_llseek_size(struct file *file, loff_t offset, int whence, loff_t maxsize, loff_t eof) { - switch (whence) { - case SEEK_END: - offset += eof; - break; - case SEEK_CUR: - /* - * Here we special-case the lseek(fd, 0, SEEK_CUR) - * position-querying operation. Avoid rewriting the "same" - * f_pos value back to the file because a concurrent read(), - * write() or lseek() might have altered it - */ - if (offset == 0) - return file->f_pos; - /* - * f_lock protects against read/modify/write race with other - * SEEK_CURs. Note that parallel writes and reads behave - * like SEEK_SET. - */ - spin_lock(&file->f_lock); - offset = vfs_setpos(file, file->f_pos + offset, maxsize); - spin_unlock(&file->f_lock); + int ret; + + ret = must_set_pos(file, &offset, whence, eof); + if (ret < 0) + return ret; + if (ret == 0) return offset; - case SEEK_DATA: - /* - * In the generic case the entire file is data, so as long as - * offset isn't at the end of the file then the offset is data. - */ - if ((unsigned long long)offset >= eof) - return -ENXIO; - break; - case SEEK_HOLE: + + if (whence == SEEK_CUR) { /* - * There is a virtual hole at the end of the file, so as long as - * offset isn't i_size or larger, return i_size. + * f_lock protects against read/modify/write race with + * other SEEK_CURs. Note that parallel writes and reads + * behave like SEEK_SET. */ - if ((unsigned long long)offset >= eof) - return -ENXIO; - offset = eof; - break; + guard(spinlock)(&file->f_lock); + return vfs_setpos(file, file->f_pos + offset, maxsize); } return vfs_setpos(file, offset, maxsize); From patchwork Fri Aug 30 13:04:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785072 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 7B8DE1AF4F7 for ; Fri, 30 Aug 2024 13:05:58 +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=1725023158; cv=none; b=TX90yMnEvXPgO4mWBttHbxKz9Go6eW6GSx5fT4HWFLBbzXnr61xjF+InbEhrbGo4uFPYHlOiGTcycsU+vmni6TWbwcUFXrKp7hVpwrCQzY/FiiSMGKhbAF/FsHZQBpw+5yU5T2vmLcIwUUpGBWz7js7MtHEABJBmLo5GoISiUwU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023158; c=relaxed/simple; bh=ke7sJon/SOR0neb++AsgdfoyyC78KHWq+1liodzQ8S0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nOY5huVGbw6x7MRas0FXUR3sVtLB7SE1mCuqDB+EOtnfTk2/2/E66NYByW9vUst4KqwnDNIe4jNe9eN9FxvFJ8vPPWlZQBrrr/du2w3APce6aw6CztgzfU+mSKHNH1feZZ94VS6E0KYy1h5W8Gx3h8/z0k0bUDtSHXgtsd+aVCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CiAYgUqQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CiAYgUqQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC127C4CEC5; Fri, 30 Aug 2024 13:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023158; bh=ke7sJon/SOR0neb++AsgdfoyyC78KHWq+1liodzQ8S0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CiAYgUqQFpJ4E2yqp6reYh+4BW3SaHJ98IL3JI590/pXYfNmPi52Fk2ca7GoD6vTU /EpLiFlIse/rCkJKKlufB6ZwuVgXQNhT8XsDTc10BD/vQCnirCJRRYZ6PAJWaEVkZI qxZt92HTYJOgU41CLigN65XSd36EUOn2oJLdpSIE9ajqyVHQ/wPCFDGuIkjx5m91BA BDa/Heqjo+avfZpWV/rnk44puJRusgxvVXAsFbDZP/QaEvG5yhERJpzHMUAm5Ultzy 9keaEL/zzBVMiQHngrkMKybs0OiCop0ch84drkVlXldhAFK+U4bND3CGHYa6dDG5ME eEd1C/BCeqFrg== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:49 +0200 Subject: [PATCH RFC 08/20] fs: add generic_llseek_cookie() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-8-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2829; i=brauner@kernel.org; h=from:subject:message-id; bh=ke7sJon/SOR0neb++AsgdfoyyC78KHWq+1liodzQ8S0=; b=kA0DAAoWkcYbwGV43KIByyZiAGbRw5ygp4r8gNC+RskQAjT62Y22pe+LxrHZOshx3s8trdxH2 Ih1BAAWCgAdFiEEQIc0Vx6nDHizMmkokcYbwGV43KIFAmbRw5wACgkQkcYbwGV43KLZMgEAyNP1 kdjmDTMiB4hKioALskXm+Kvrw4+gNOkVLZfdFs0BAMbgbikvsWo6GAp0QQo3FHIYi4S5B5oYL8Q WAApoocgM X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 This is similar to generic_file_llseek() but allows the caller to specify a cookie that will be updated to indicate that a seek happened. Caller's requiring that information in their readdir implementations can use that. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/read_write.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 2 ++ 2 files changed, 46 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index ad93b72cc378..47f7b4e32a53 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -179,6 +179,50 @@ generic_file_llseek_size(struct file *file, loff_t offset, int whence, } EXPORT_SYMBOL(generic_file_llseek_size); +/** + * generic_llseek_cookie - versioned llseek implementation + * @file: file structure to seek on + * @offset: file offset to seek to + * @whence: type of seek + * @cookie: cookie to update + * + * See generic_file_llseek for a general description and locking assumptions. + * + * In contrast to generic_file_llseek, this function also resets a + * specified cookie to indicate a seek took place. + */ +loff_t generic_llseek_cookie(struct file *file, loff_t offset, int whence, + u64 *cookie) +{ + struct inode *inode = file->f_mapping->host; + loff_t maxsize = inode->i_sb->s_maxbytes; + loff_t eof = i_size_read(inode); + int ret; + + if (WARN_ON_ONCE(!cookie)) + return -EINVAL; + + ret = must_set_pos(file, &offset, whence, eof); + if (ret < 0) + return ret; + if (ret == 0) + return offset; + + if (whence == SEEK_CUR) { + /* + * f_lock protects against read/modify/write race with + * other SEEK_CURs. Note that parallel writes and reads + * behave like SEEK_SET. + */ + guard(spinlock)(&file->f_lock); + return vfs_setpos_cookie(file, file->f_pos + offset, maxsize, + cookie); + } + + return vfs_setpos_cookie(file, offset, maxsize, cookie); +} +EXPORT_SYMBOL(generic_llseek_cookie); + /** * generic_file_llseek - generic llseek implementation for regular files * @file: file structure to seek on diff --git a/include/linux/fs.h b/include/linux/fs.h index 58c91a52cad1..3e6b3c1afb31 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3202,6 +3202,8 @@ extern loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize); extern loff_t generic_file_llseek(struct file *file, loff_t offset, int whence); extern loff_t generic_file_llseek_size(struct file *file, loff_t offset, int whence, loff_t maxsize, loff_t eof); +loff_t generic_llseek_cookie(struct file *file, loff_t offset, int whence, + u64 *cookie); extern loff_t fixed_size_llseek(struct file *file, loff_t offset, int whence, loff_t size); extern loff_t no_seek_end_llseek_size(struct file *, loff_t, int, loff_t); From patchwork Fri Aug 30 13:04:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785073 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 E3D0B1B252D for ; Fri, 30 Aug 2024 13:06:00 +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=1725023161; cv=none; b=XYrqfq4uKcIYXZO1JzHjRMgevxRzmdMv7/gSI25z3/B7Uy/c25zOu/n6KwTeDwHh/1GW1nrkjCZTAgB7Uyp6eCzdXuTSg/bxI8023+UgHATH7qEXfcX2/vPKF6nHLra16lMqYlngMc0yjn55ojRezTb57avWCUGuJU0rJ3wQP/8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023161; c=relaxed/simple; bh=UfPRvxuAGZjmkL5geC8XQuk8Sjo6h7iIyziW4E0fCug=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mtb8dpB0XE7EKomDQHT5tI09ErbGQGCCTz0FU3Fl0/HrqNRtJGaTZzr0aTdj4fjsRiyFztZ0FJpRjN8sqit39Yq/kq1VSzLUGkkKCUHdq18rmjJOw9PihgDKFdPCWGKmyDIMrE6h2RGBSjJBKSTkeFhj2kBrjuAzlde/fEBbDpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eeGf1sej; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eeGf1sej" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAACCC4CEC7; Fri, 30 Aug 2024 13:05:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023160; bh=UfPRvxuAGZjmkL5geC8XQuk8Sjo6h7iIyziW4E0fCug=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eeGf1sejl0MMt8zH/Bsjx3QpuAOHIGUVF6Y+1M0QsN/Qz2bBWJ1pCWyhWZfa6etL9 5uEOguOWBZumvB1gQQjPPJo5gsgCMRbFchnZfZfDNGdKEa4aVJBU2z09RrTMFd8snN pRjmaXMKdzXiMMfUUgYM3jcZM2+18lcnwjVE1VpEXQ6SULIYdDi630S3YPIjEpFwwP by0DDjUarAuqc3bRe3TvpbhiqPkglm50OgFEfvT8NLcp8EMYdLM7In0sgyEahQGWzW nFGfbPQVruSx0VtqRXptiO/49iYjFs6h2ZiFKaQuXd0mTLLldRmbOclbfYCkDHTHXr rzCTZ5YhjqryA== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:50 +0200 Subject: [PATCH RFC 09/20] affs: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-9-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2848; i=brauner@kernel.org; h=from:subject:message-id; bh=UfPRvxuAGZjmkL5geC8XQuk8Sjo6h7iIyziW4E0fCug=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDzHxq9azm8KH/vnTbxcOxK5fG+v3MAZ0+7VdcDJN nb97g3MHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABM5c5uR4cGx+QXR1bsS98sx ntrsvqljzZ1r/Up/Ay6Z9skF2N5/E87IsGH35ANcq/8vjZQVOpLVpx5Q7t/kcfb1ryveMds9/Sb q8AIA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/affs/dir.c | 44 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/fs/affs/dir.c b/fs/affs/dir.c index b2bf7016e1b3..bd40d5f08810 100644 --- a/fs/affs/dir.c +++ b/fs/affs/dir.c @@ -17,13 +17,44 @@ #include #include "affs.h" +struct affs_dir_data { + unsigned long ino; + u64 cookie; +}; + static int affs_readdir(struct file *, struct dir_context *); +static loff_t affs_dir_llseek(struct file *file, loff_t offset, int whence) +{ + struct affs_dir_data *data = file->private_data; + + return generic_llseek_cookie(file, offset, whence, &data->cookie); +} + +static int affs_dir_open(struct inode *inode, struct file *file) +{ + struct affs_dir_data *data; + + data = kzalloc(sizeof(struct affs_dir_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + file->private_data = data; + return 0; +} + +static int affs_dir_release(struct inode *inode, struct file *file) +{ + kfree(file->private_data); + return 0; +} + const struct file_operations affs_dir_operations = { + .open = affs_dir_open, .read = generic_read_dir, - .llseek = generic_file_llseek, + .llseek = affs_dir_llseek, .iterate_shared = affs_readdir, .fsync = affs_file_fsync, + .release = affs_dir_release, }; /* @@ -45,6 +76,7 @@ static int affs_readdir(struct file *file, struct dir_context *ctx) { struct inode *inode = file_inode(file); + struct affs_dir_data *data = file->private_data; struct super_block *sb = inode->i_sb; struct buffer_head *dir_bh = NULL; struct buffer_head *fh_bh = NULL; @@ -59,7 +91,7 @@ affs_readdir(struct file *file, struct dir_context *ctx) pr_debug("%s(ino=%lu,f_pos=%llx)\n", __func__, inode->i_ino, ctx->pos); if (ctx->pos < 2) { - file->private_data = (void *)0; + data->ino = 0; if (!dir_emit_dots(file, ctx)) return 0; } @@ -80,8 +112,8 @@ affs_readdir(struct file *file, struct dir_context *ctx) /* If the directory hasn't changed since the last call to readdir(), * we can jump directly to where we left off. */ - ino = (u32)(long)file->private_data; - if (ino && inode_eq_iversion(inode, file->f_version)) { + ino = data->ino; + if (ino && inode_eq_iversion(inode, data->cookie)) { pr_debug("readdir() left off=%d\n", ino); goto inside; } @@ -131,8 +163,8 @@ affs_readdir(struct file *file, struct dir_context *ctx) } while (ino); } done: - file->f_version = inode_query_iversion(inode); - file->private_data = (void *)(long)ino; + data->cookie = inode_query_iversion(inode); + data->ino = ino; affs_brelse(fh_bh); out_brelse_dir: From patchwork Fri Aug 30 13:04:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785074 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 2E01D1B252D for ; Fri, 30 Aug 2024 13:06:03 +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=1725023164; cv=none; b=vGV3djyKE5vlCO3SbPJ6Ov0sNu6CwEdFOQZhRhTyLGAX7QGTvgrD+4BihG8FmlWKe0tlbLdG1EMO8clMa/MSR5N3n+LOgE+9Jg3BNUZpplIBQr85YRtpcamjPYVJlYCrNLqIFHpnLO1XLRA0aaPNKm6pxrUXh+k3Ocp3AfMahMs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023164; c=relaxed/simple; bh=5TFStna3v+h2JmpsNdxCOVxrFroUUfHd5AjYd1lMZUM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qcGVPAdCnGfCNRFCLicElBQL/E9TlNAaZ9RQ5zLccSdYnrCtjlTuBa+81ilDUYL/y+x5asY7np474Kx5iJxs4WYviLOcPGf4LoDlD/hvlNS0BwtF6F6wH/7Mu4dUrDIV79NaKy+Ogzi1gzNf0bMXdDGvbaexxr7gTKAeY8PqmgM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Todo69nV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Todo69nV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5721FC4CEC9; Fri, 30 Aug 2024 13:06:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023163; bh=5TFStna3v+h2JmpsNdxCOVxrFroUUfHd5AjYd1lMZUM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Todo69nV/8Fjxx78J79JW57tj3R84PGYCiLC7H4lOpogF/l6DCSSWRsIbAOp2F4US CgErVN6dbcv7v4EAqskbtzgGdU2kVniX0xSk6ZjquEhxCaIeLRKcoz4HlZuhaBV1Cy zBW6YuywNMIhnHhSUtC0p8RmREZrAywdFyv/VzEFW+J3nqz8fZFufsLKZV1Ds3TyGu aWk8yU9XoSxTqjeU2YnHw4zdvFAshxtHQ1lgdiNeh2pG7r2olZTzkCinaEU7merIAC 3KMG9nW6Y+afZQv/9YJuBgjxTYgqxqJoU3g3aYISpW6Y74Th8tIYGwKs1yb2wOtxZC LAP7I+8KpTWVA== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:51 +0200 Subject: [PATCH RFC 10/20] ext2: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-10-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2078; i=brauner@kernel.org; h=from:subject:message-id; bh=5TFStna3v+h2JmpsNdxCOVxrFroUUfHd5AjYd1lMZUM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDznQngH65+2xNndIvapZr7Bt5z/XM1f4pZ7YEOce 8cbywnxHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABPR38Lwv3pLipw61529opzn HixjKtMPFE9ryTsydfVO/h3ProQtecLIcN13Sptk8bPc2POCTNwv312KUQx9OqPh/v/bitVSvV3 1PAA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/ext2/dir.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c index 087457061c6e..6622c582f550 100644 --- a/fs/ext2/dir.c +++ b/fs/ext2/dir.c @@ -263,7 +263,7 @@ ext2_readdir(struct file *file, struct dir_context *ctx) unsigned long n = pos >> PAGE_SHIFT; unsigned long npages = dir_pages(inode); unsigned chunk_mask = ~(ext2_chunk_size(inode)-1); - bool need_revalidate = !inode_eq_iversion(inode, file->f_version); + bool need_revalidate = !inode_eq_iversion(inode, *(u64 *)file->private_data); bool has_filetype; if (pos > inode->i_size - EXT2_DIR_REC_LEN(1)) @@ -290,7 +290,7 @@ ext2_readdir(struct file *file, struct dir_context *ctx) offset = ext2_validate_entry(kaddr, offset, chunk_mask); ctx->pos = (n<f_version = inode_query_iversion(inode); + *(u64 *)file->private_data = inode_query_iversion(inode); need_revalidate = false; } de = (ext2_dirent *)(kaddr+offset); @@ -703,8 +703,30 @@ int ext2_empty_dir(struct inode *inode) return 0; } +static int ext2_dir_open(struct inode *inode, struct file *file) +{ + file->private_data = kzalloc(sizeof(u64), GFP_KERNEL); + if (!file->private_data) + return -ENOMEM; + return 0; +} + +static int ext2_dir_release(struct inode *inode, struct file *file) +{ + kfree(file->private_data); + return 0; +} + +static loff_t ext2_dir_llseek(struct file *file, loff_t offset, int whence) +{ + return generic_llseek_cookie(file, offset, whence, + (u64 *)file->private_data); +} + const struct file_operations ext2_dir_operations = { - .llseek = generic_file_llseek, + .open = ext2_dir_open, + .release = ext2_dir_release, + .llseek = ext2_dir_llseek, .read = generic_read_dir, .iterate_shared = ext2_readdir, .unlocked_ioctl = ext2_ioctl, From patchwork Fri Aug 30 13:04:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785075 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 D6C321B2EC7 for ; Fri, 30 Aug 2024 13:06:06 +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=1725023166; cv=none; b=Vm+TYNnfTrN5WoZIDX84GGVED5LSPoLZhz43yBkmYQOgyDHVPWOqWFgY+wcJwVsO3RW7OpkKnlgsbGLdAY7M+mGhKlZNoMhscclMVo+kVXNUfPhmFWqg1Laa5ivMaf+0kl87CX591yVgWszxK4aD/TKT3DT2fuA9+ASXjscfuUc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023166; c=relaxed/simple; bh=XwzYRfekCC2N/I6St2Xy5oSr+ska1W6v2XklXWJHBb0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=N64agHLM14SSmfJgzxWZ46NxmZuBXGvmLHbezz44KSu/jDpqBykGZP6kR4g1jcLjjVHnIrl5e0LmB7xBbux+IR8cZ7SN5IpCfvbLJWxDGT1ZoUgZEz6oDrTYwOuZSk1Js9RaRI50IeoKKN85/trjLEcWu+Pg4HFcPzTqVgRx+bw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=poEiIK4n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="poEiIK4n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40311C4CEC5; Fri, 30 Aug 2024 13:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023166; bh=XwzYRfekCC2N/I6St2Xy5oSr+ska1W6v2XklXWJHBb0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=poEiIK4noC3bfw1uigkkucduH4mRPxhqJd3IH4UosWkQcZ3cFOlQ1rks8JbqlLXnK 8NjlcxA7zVYcH/kLjAKfe0yhowrAxps8fBi2op2SOi3CYAoYCY7hp1ja87FleF8tUC XMVzOi6oLbTZs99tkpU9Xd8DfgYBMHRqzIkTMHUxxbj3TsSr0DaECT1trn+gUYtxal Sb1Okr/CK5MRzNwg+0cB3heBgGjFLU5HlrKATM2AzTftEtrTDqDXdRMXUqoVGLtaOk UicqK9BHQ6C4af90aqDeeMoLAc6aB3sCqkTGhHkDK0elEhx/F/iMrZAoJtsWzp2/yA q7bBjQB9XZllw== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:52 +0200 Subject: [PATCH RFC 11/20] ext4: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-11-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=6123; i=brauner@kernel.org; h=from:subject:message-id; bh=XwzYRfekCC2N/I6St2Xy5oSr+ska1W6v2XklXWJHBb0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDxngzSn0il550v31+dJqVZKsS26/3wqa0bBseISO 92Qz6saOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACayIo+R4e2rPrf6VftMqloU +8N97+5dUB59fNXL0CnVyW+d5zEm8zIy3NUsnHcstfNvuO8fwY8Gr5l/Jn//y2ax7e30DR9TtnJ H8QEA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner Acked-by: Theodore Ts'o Reviewed-by: Jan Kara --- fs/ext4/dir.c | 50 ++++++++++++++++++++++++++++---------------------- fs/ext4/ext4.h | 2 ++ fs/ext4/inline.c | 7 ++++--- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c index ff4514e4626b..13196afe55ce 100644 --- a/fs/ext4/dir.c +++ b/fs/ext4/dir.c @@ -133,6 +133,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx) struct super_block *sb = inode->i_sb; struct buffer_head *bh = NULL; struct fscrypt_str fstr = FSTR_INIT(NULL, 0); + struct dir_private_info *info = file->private_data; err = fscrypt_prepare_readdir(inode); if (err) @@ -229,7 +230,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx) * readdir(2), then we might be pointing to an invalid * dirent right now. Scan from the start of the block * to make sure. */ - if (!inode_eq_iversion(inode, file->f_version)) { + if (!inode_eq_iversion(inode, info->cookie)) { for (i = 0; i < sb->s_blocksize && i < offset; ) { de = (struct ext4_dir_entry_2 *) (bh->b_data + i); @@ -249,7 +250,7 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx) offset = i; ctx->pos = (ctx->pos & ~(sb->s_blocksize - 1)) | offset; - file->f_version = inode_query_iversion(inode); + info->cookie = inode_query_iversion(inode); } while (ctx->pos < inode->i_size @@ -384,6 +385,7 @@ static inline loff_t ext4_get_htree_eof(struct file *filp) static loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence) { struct inode *inode = file->f_mapping->host; + struct dir_private_info *info = file->private_data; int dx_dir = is_dx_dir(inode); loff_t ret, htree_max = ext4_get_htree_eof(file); @@ -392,7 +394,7 @@ static loff_t ext4_dir_llseek(struct file *file, loff_t offset, int whence) htree_max, htree_max); else ret = ext4_llseek(file, offset, whence); - file->f_version = inode_peek_iversion(inode) - 1; + info->cookie = inode_peek_iversion(inode) - 1; return ret; } @@ -429,18 +431,15 @@ static void free_rb_tree_fname(struct rb_root *root) *root = RB_ROOT; } - -static struct dir_private_info *ext4_htree_create_dir_info(struct file *filp, - loff_t pos) +static void ext4_htree_init_dir_info(struct file *filp, loff_t pos) { - struct dir_private_info *p; - - p = kzalloc(sizeof(*p), GFP_KERNEL); - if (!p) - return NULL; - p->curr_hash = pos2maj_hash(filp, pos); - p->curr_minor_hash = pos2min_hash(filp, pos); - return p; + struct dir_private_info *p = filp->private_data; + + if (is_dx_dir(file_inode(filp)) && !p->initialized) { + p->curr_hash = pos2maj_hash(filp, pos); + p->curr_minor_hash = pos2min_hash(filp, pos); + p->initialized = true; + } } void ext4_htree_free_dir_info(struct dir_private_info *p) @@ -552,12 +551,7 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx) struct fname *fname; int ret = 0; - if (!info) { - info = ext4_htree_create_dir_info(file, ctx->pos); - if (!info) - return -ENOMEM; - file->private_data = info; - } + ext4_htree_init_dir_info(file, ctx->pos); if (ctx->pos == ext4_get_htree_eof(file)) return 0; /* EOF */ @@ -590,10 +584,10 @@ static int ext4_dx_readdir(struct file *file, struct dir_context *ctx) * cached entries. */ if ((!info->curr_node) || - !inode_eq_iversion(inode, file->f_version)) { + !inode_eq_iversion(inode, info->cookie)) { info->curr_node = NULL; free_rb_tree_fname(&info->root); - file->f_version = inode_query_iversion(inode); + info->cookie = inode_query_iversion(inode); ret = ext4_htree_fill_tree(file, info->curr_hash, info->curr_minor_hash, &info->next_hash); @@ -664,7 +658,19 @@ int ext4_check_all_de(struct inode *dir, struct buffer_head *bh, void *buf, return 0; } +static int ext4_dir_open(struct inode *inode, struct file *file) +{ + struct dir_private_info *info; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + file->private_data = info; + return 0; +} + const struct file_operations ext4_dir_operations = { + .open = ext4_dir_open, .llseek = ext4_dir_llseek, .read = generic_read_dir, .iterate_shared = ext4_readdir, diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 08acd152261e..d62a4b9b26ce 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2553,6 +2553,8 @@ struct dir_private_info { __u32 curr_hash; __u32 curr_minor_hash; __u32 next_hash; + u64 cookie; + bool initialized; }; /* calculate the first block number of the group */ diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c index e7a09a99837b..4282e12dc405 100644 --- a/fs/ext4/inline.c +++ b/fs/ext4/inline.c @@ -1460,6 +1460,7 @@ int ext4_read_inline_dir(struct file *file, struct ext4_iloc iloc; void *dir_buf = NULL; int dotdot_offset, dotdot_size, extra_offset, extra_size; + struct dir_private_info *info = file->private_data; ret = ext4_get_inode_loc(inode, &iloc); if (ret) @@ -1503,12 +1504,12 @@ int ext4_read_inline_dir(struct file *file, extra_size = extra_offset + inline_size; /* - * If the version has changed since the last call to + * If the cookie has changed since the last call to * readdir(2), then we might be pointing to an invalid * dirent right now. Scan from the start of the inline * dir to make sure. */ - if (!inode_eq_iversion(inode, file->f_version)) { + if (!inode_eq_iversion(inode, info->cookie)) { for (i = 0; i < extra_size && i < offset;) { /* * "." is with offset 0 and @@ -1540,7 +1541,7 @@ int ext4_read_inline_dir(struct file *file, } offset = i; ctx->pos = offset; - file->f_version = inode_query_iversion(inode); + info->cookie = inode_query_iversion(inode); } while (ctx->pos < extra_size) { From patchwork Fri Aug 30 13:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785076 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 926711B2EEE for ; Fri, 30 Aug 2024 13:06:09 +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=1725023170; cv=none; b=F0l02rmEbiok3JcukxqDhTyOCYlGg3j0N7Wr1S9Q7ZV31dUmbFh2TyY8jKHV9e6UyUs1L5WLggJ13uxxs+L2UTMhBFZrEbE/F6l3eWAJUvROVi4j7zfemzAI9t348oHSuu8iykJsDSFVhSQP0iZYFcsFKLk6wX8zUZfxcQGF5hI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023170; c=relaxed/simple; bh=/p1il7Thqi0OGbn6Xz4Ra6ZuS26mNe4kBd4gJc1HSzU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VuC405jUE1Q9GdiFA+XJDRqBlYr6hMYzuMduy+XkZdH/sM7tQAkfKC+4l5k9Fg7Kg/oMvkY725KvyRdfmlpp5XLr+heHgFGv4BBuBXWDVfO68Dj6Oezh0ffZwxSpdTNT1rjs9gb08u4nquSXffcDr+b1az90NkNwDhsPyXtQH3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rNIp3QTx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rNIp3QTx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1FC4DC4CEC7; Fri, 30 Aug 2024 13:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023169; bh=/p1il7Thqi0OGbn6Xz4Ra6ZuS26mNe4kBd4gJc1HSzU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rNIp3QTxSOqzFr1oGnH9h5bRmQ89sf4WfAS07mpxvEeCAyRYcZDk6l0yiTtxMP9/z 9JxGR9i8iYoDTrB89M5CKhx1acU+MamuWG68gAHZVLDpWooHkwTcHvaUnegZ7SFA+Y WRojAehFy6rMYAD4V2pcqqIk8hNVtHVVKFheofJkvIktyTz72EWRWy+kL34kQScuy7 G54ngNlFMBFqZEf6OZIlwbvk7q/osP8eIvnICEQTcPpOM+94bTCw7UhE31FvKGwqYR IlDJU5b51uDErOES9xDOCIHgi0sS5TrvxpeKNIQVvYTo3L/jrN92Br9ityOAZes8bH lGehb2S299HdA== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:53 +0200 Subject: [PATCH RFC 12/20] input: remove f_version abuse Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-12-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1272; i=brauner@kernel.org; h=from:subject:message-id; bh=/p1il7Thqi0OGbn6Xz4Ra6ZuS26mNe4kBd4gJc1HSzU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDynTuanHe/ZGxkfOf2FxZX2TE4L73nqf6Z6++z36 w6JpF517ShlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjI4naG/2FfU0WFEkIXt7pP Vu15l31UodlxS5NJ8cLwdZfL/18L0WX4X1hwMtqdd0WOivNZ8Z/lMmdfzj+iaqjw2u36W6PjYo5 T2QE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Remove the f_version abuse from input. Use seq_private_open() to stash the information for poll. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- drivers/input/input.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/input/input.c b/drivers/input/input.c index 54c57b267b25..b03ae43707d8 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c @@ -1081,9 +1081,11 @@ static inline void input_wakeup_procfs_readers(void) static __poll_t input_proc_devices_poll(struct file *file, poll_table *wait) { + struct seq_file *m = file->private_data; + poll_wait(file, &input_devices_poll_wait, wait); - if (file->f_version != input_devices_state) { - file->f_version = input_devices_state; + if (*(u64 *)m->private != input_devices_state) { + *(u64 *)m->private = input_devices_state; return EPOLLIN | EPOLLRDNORM; } @@ -1210,7 +1212,7 @@ static const struct seq_operations input_devices_seq_ops = { static int input_proc_devices_open(struct inode *inode, struct file *file) { - return seq_open(file, &input_devices_seq_ops); + return seq_open_private(file, &input_devices_seq_ops, sizeof(u64)); } static const struct proc_ops input_devices_proc_ops = { From patchwork Fri Aug 30 13:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785077 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 AB2C71AF4F9 for ; Fri, 30 Aug 2024 13:06:12 +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=1725023172; cv=none; b=fuu5uVXXpc0Cqyv4iGA9sjSaIrpdYGAEWtyuoqjZJNpOHYr5zk96JgVJib6EsIqETe4SKxqBqzPH38z5OCnbJLtmVWujHatyPMtcTXbSPimyhuuG3BbP8RsLSMgf0VzMTDbNM5tgiYXtK4DWdJ41ijsOnydor9eAF7L/ZwBxanw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023172; c=relaxed/simple; bh=Xtr4hSA6zi572+OZOYqTqxLNXXtD13Ffk+HiNZKb6Bw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=b0IWF0vA6JprQuDiRRTEpLvHbqvvnHP8fwOZXQbOtFnv6mY+G8GN3C+7SuOB9bNRbO4U0grGEAIbOHDvUiPxo6iJf2rCNgp8dwphW2bGhX+xo9471Cem4pvrq4LmmQsn3yME98gn8RZ/FhxI0yqE6LX06jzwWfSWCfWnXDIkHG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IwCFV0rZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IwCFV0rZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0368C4CEC2; Fri, 30 Aug 2024 13:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023172; bh=Xtr4hSA6zi572+OZOYqTqxLNXXtD13Ffk+HiNZKb6Bw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IwCFV0rZmR4yk9Ak2Ck80eQ3VWJFp7umwpsfHjlVM+lQEGWsYieAsEH+9MmmAseSK uXU3/UvkR7gH3bPEsP5qSvbLuqwglF04LOOTk1vWfys77FORY3UW637Tim+PZkuGjy AJE6NAXOFTxi1BUMaYQh88dpJL8L72DV196CVnHPE62KQUyD7uakMVehxzZOvu2cM6 /r6zBEFdiPPHQrpArTC5IVloCOQDy6icdppbKF6S9caNi01cD7BChs2A3yRz7bC73V wFMXvyQhrev0hFwVibaWfWRDRaMyDKNnQ/QkGxGsbttYO2ioKgszkB8ISsjum2YAN4 yrR4Rth7s/eWw== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:54 +0200 Subject: [PATCH RFC 13/20] ocfs2: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-13-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2640; i=brauner@kernel.org; h=from:subject:message-id; bh=Xtr4hSA6zi572+OZOYqTqxLNXXtD13Ffk+HiNZKb6Bw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDyn4k9/5qtgs/Wf/jGdCF7JYL71vcSFa/Hfyx1vz +RLPeth3VHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRldcZGWbvv79K4+u1CUcX ciU2zXr27NGEC/H3FDwdxTRvyb9Krz/JyHBt1ty/QdPYl5ULr7TWqz6ynrXs4roMIabUp4subt+ lvZYBAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/ocfs2/dir.c | 3 ++- fs/ocfs2/file.c | 11 +++++++++-- fs/ocfs2/file.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/ocfs2/dir.c b/fs/ocfs2/dir.c index f0beb173dbba..ccef3f42b333 100644 --- a/fs/ocfs2/dir.c +++ b/fs/ocfs2/dir.c @@ -1932,6 +1932,7 @@ int ocfs2_readdir(struct file *file, struct dir_context *ctx) { int error = 0; struct inode *inode = file_inode(file); + struct ocfs2_file_private *fp = file->private_data; int lock_level = 0; trace_ocfs2_readdir((unsigned long long)OCFS2_I(inode)->ip_blkno); @@ -1952,7 +1953,7 @@ int ocfs2_readdir(struct file *file, struct dir_context *ctx) goto bail_nolock; } - error = ocfs2_dir_foreach_blk(inode, &file->f_version, ctx, false); + error = ocfs2_dir_foreach_blk(inode, &fp->cookie, ctx, false); ocfs2_inode_unlock(inode, lock_level); if (error) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index ccc57038a977..115ab2172820 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2750,6 +2750,13 @@ static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, return remapped > 0 ? remapped : ret; } +static loff_t ocfs2_dir_llseek(struct file *file, loff_t offset, int whence) +{ + struct ocfs2_file_private *fp = file->private_data; + + return generic_llseek_cookie(file, offset, whence, &fp->cookie); +} + const struct inode_operations ocfs2_file_iops = { .setattr = ocfs2_setattr, .getattr = ocfs2_getattr, @@ -2797,7 +2804,7 @@ const struct file_operations ocfs2_fops = { WRAP_DIR_ITER(ocfs2_readdir) // FIXME! const struct file_operations ocfs2_dops = { - .llseek = generic_file_llseek, + .llseek = ocfs2_dir_llseek, .read = generic_read_dir, .iterate_shared = shared_ocfs2_readdir, .fsync = ocfs2_sync_file, @@ -2843,7 +2850,7 @@ const struct file_operations ocfs2_fops_no_plocks = { }; const struct file_operations ocfs2_dops_no_plocks = { - .llseek = generic_file_llseek, + .llseek = ocfs2_dir_llseek, .read = generic_read_dir, .iterate_shared = shared_ocfs2_readdir, .fsync = ocfs2_sync_file, diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h index 8e53e4ac1120..41e65e45a9f3 100644 --- a/fs/ocfs2/file.h +++ b/fs/ocfs2/file.h @@ -20,6 +20,7 @@ struct ocfs2_alloc_context; enum ocfs2_alloc_restarted; struct ocfs2_file_private { + u64 cookie; struct file *fp_file; struct mutex fp_mutex; struct ocfs2_lock_res fp_flock; From patchwork Fri Aug 30 13:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785078 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 D270E1AD5D8 for ; Fri, 30 Aug 2024 13:06:14 +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=1725023174; cv=none; b=hmeM/6gjRGK4GB/PELCcXWhzv+dOpV8QOXyVQmwIWmzoHM7MLh4ImEcXWj4oSXH7C09IFKa6F+rOPcQ1F9yihtQtc1v3ryz0SyjyGS7lrstbFIURlSzZ2V+NLAjMqvEkBDjCoSm5nesZjERfOsRXiS+5W/ooi9UEa0rHGlwlSwo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023174; c=relaxed/simple; bh=Ki7eZdDe+8S6Dp8c8eAe5SK+vFGc0TNMjq2+D+aXI/s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ehXTbie56AgcT1mpsyu4HIiwzAOJopsn5o0ScTPP7gfoA9OFfVz8DeBZJwoaLShTQQbR+oV1EjLiqs6hR96yDqRNBGt0wJpH4JQzfames0ZYK/sRkxAWrk+Ng3lzv/3Zijvv0WKTx0XVJ/O7Lvua0qSsC44Zqa+GgTSxRnZEECM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aPJJPHeq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aPJJPHeq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7647C4CEC7; Fri, 30 Aug 2024 13:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023174; bh=Ki7eZdDe+8S6Dp8c8eAe5SK+vFGc0TNMjq2+D+aXI/s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aPJJPHeqOCkBhFxcy58uOqhhxEC6zkqeKMRdftifN+TitUICTHc7L2nkcEwAZe814 uHFdKOWbgqPIX9cRgSwZdjPVpMFbvgJ8LnTWIGAXmwAUKM0n53aXhEqduzlMC4VCuJ Wi4fWKr3h55ZnQPCr0SxFAByMMgWG1VTCN012YigUicHq7N4Z4PduIKtUyZ8sBVLSv XulCU4D8g07EQy/6szzy5lPCUxBVQauRqtrEx4KHwW2RcSQAB7qPjnx0A1wH+6pwm6 K2K4O1GOGlzsfzLvCa/kV2Doa//WAFbVadG9vgRuwsw49tOEaA9MLzajmzJBpYVH67 8SQtGdeKK9cGA== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:55 +0200 Subject: [PATCH RFC 14/20] proc: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-14-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2207; i=brauner@kernel.org; h=from:subject:message-id; bh=Ki7eZdDe+8S6Dp8c8eAe5SK+vFGc0TNMjq2+D+aXI/s=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDz3n9KH9YvkD3LNWzX9fZzmS9m518Q9ljzdyryGK dplmfPdko5SFgYxLgZZMUUWh3aTcLnlPBWbjTI1YOawMoEMYeDiFICJRN1n+F+YMbdHl33zZOPj 7TW2Gxq/8zu+E0o4N+1Grdy+Ou8nC7MYGeYIT7NbZK3rskxcdens+M7CN8e3L4nJftGbtefodM5 n/lwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner --- fs/proc/base.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index 72a1acd03675..8a8aab6b9801 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -3870,12 +3870,12 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx) if (!dir_emit_dots(file, ctx)) return 0; - /* f_version caches the tgid value that the last readdir call couldn't - * return. lseek aka telldir automagically resets f_version to 0. + /* We cache the tgid value that the last readdir call couldn't + * return and lseek resets it to 0. */ ns = proc_pid_ns(inode->i_sb); - tid = (int)file->f_version; - file->f_version = 0; + tid = (int)(intptr_t)file->private_data; + file->private_data = NULL; for (task = first_tid(proc_pid(inode), tid, ctx->pos - 2, ns); task; task = next_tid(task), ctx->pos++) { @@ -3890,7 +3890,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx) proc_task_instantiate, task, NULL)) { /* returning this tgid failed, save it as the first * pid for the next readir call */ - file->f_version = (u64)tid; + file->private_data = (void *)(intptr_t)tid; put_task_struct(task); break; } @@ -3915,6 +3915,12 @@ static int proc_task_getattr(struct mnt_idmap *idmap, return 0; } +static loff_t proc_dir_llseek(struct file *file, loff_t offset, int whence) +{ + return generic_llseek_cookie(file, offset, whence, + (u64 *)(uintptr_t)&file->private_data); +} + static const struct inode_operations proc_task_inode_operations = { .lookup = proc_task_lookup, .getattr = proc_task_getattr, @@ -3925,7 +3931,7 @@ static const struct inode_operations proc_task_inode_operations = { static const struct file_operations proc_task_operations = { .read = generic_read_dir, .iterate_shared = proc_task_readdir, - .llseek = generic_file_llseek, + .llseek = proc_dir_llseek, }; void __init set_proc_pid_nlink(void) From patchwork Fri Aug 30 13:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785079 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 712D51AF4F9 for ; Fri, 30 Aug 2024 13:06:17 +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=1725023177; cv=none; b=fuDdksKaR/OiPA7XCMcM3hJ1nHHQCOWu0Z8LPxpthT5ML3kmTOHoY/Sv2nrqYXKwmLqTHN6zPJnEOR+PLK3mZd/kI2BLT36EgAdp4JPxS2jHelvB5/MSykqnnY4pnCBBWLocD+pn9bc3utd+HifCzwrW7oT4ftaPMZM6f6PICiM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023177; c=relaxed/simple; bh=KNRyxwtoBb565wjzV065TxRfaksQi1n5rMvPeXlpGmA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dOI+xQ3o+IDZEUz6lNCoHyF/my2lvSGOENn/VAihuz01opz6vkFtlEB3f1+N/uQyhYPw7KdIZu+tZNlc38JAplLY8u0ZpUg5tjb+jSHyVFbckriKJ0Hd6H+UJWZ+umER126crMzY2Ea/8Q6msTXiUNqe/lynZrQ1m8/Hf8nETbA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Mslo6IBu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Mslo6IBu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35519C4CEC2; Fri, 30 Aug 2024 13:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023177; bh=KNRyxwtoBb565wjzV065TxRfaksQi1n5rMvPeXlpGmA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Mslo6IBuqw1mzzifXJt2ZTUkWkC3MuX6GKPuDmj09JPMxtq0Nqaywx5lAq5LIRhk1 Wdyho34a2GwVraYbKulhMfLoW10iu/uGDpq/2ftExzl8z+rKyKwrDF0Nyk8vKIrMwM tYokzTRK/s36HiwPH37ftA6fIyh3gvHYZ3wceMH8EU+8HOu7ZIjI9jB1t5alJs0KJw 3wHqY2o9eQrH8ogvhMnj7IOUxU0F5ZauOUdn5Y8vVR9fsJ5jZRGI5Vr70Ug6q215gI rZvB1e4bRPiBjKjFgzNIuGMUmeea8t66Szb0fhaUPVpD2lF90+iZ0ZUI+8zb4a+TRZ G2rHNMMi2p4Fg== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:56 +0200 Subject: [PATCH RFC 15/20] udf: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-15-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1884; i=brauner@kernel.org; h=from:subject:message-id; bh=KNRyxwtoBb565wjzV065TxRfaksQi1n5rMvPeXlpGmA=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDx3xu3jnXp83OuFn7DmJh+wZYgI7/JleDnpioHHP LUmOTHOjlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgIms3svIcP78d76ksznX533v ndo2a9srzo+LngiyzNMymHPk6fdgBgFGhrU/nzLzxRWlpN+atVl1Sgv3P9ZLxXNL4g78Yp1yUEH Fmh8A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/udf/dir.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/fs/udf/dir.c b/fs/udf/dir.c index f94f45fe2c91..5023dfe191e8 100644 --- a/fs/udf/dir.c +++ b/fs/udf/dir.c @@ -60,7 +60,7 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) * identifying beginning of dir entry (names are under user control), * we need to scan the directory from the beginning. */ - if (!inode_eq_iversion(dir, file->f_version)) { + if (!inode_eq_iversion(dir, *(u64 *)file->private_data)) { emit_pos = nf_pos; nf_pos = 0; } else { @@ -122,15 +122,37 @@ static int udf_readdir(struct file *file, struct dir_context *ctx) udf_fiiter_release(&iter); out: if (pos_valid) - file->f_version = inode_query_iversion(dir); + *(u64 *)file->private_data = inode_query_iversion(dir); kfree(fname); return ret; } +static int udf_dir_open(struct inode *inode, struct file *file) +{ + file->private_data = kzalloc(sizeof(u64), GFP_KERNEL); + if (!file->private_data) + return -ENOMEM; + return 0; +} + +static int udf_dir_release(struct inode *inode, struct file *file) +{ + kfree(file->private_data); + return 0; +} + +static loff_t udf_dir_llseek(struct file *file, loff_t offset, int whence) +{ + return generic_llseek_cookie(file, offset, whence, + (u64 *)file->private_data); +} + /* readdir and lookup functions */ const struct file_operations udf_dir_operations = { - .llseek = generic_file_llseek, + .open = udf_dir_open, + .release = udf_dir_release, + .llseek = udf_dir_llseek, .read = generic_read_dir, .iterate_shared = udf_readdir, .unlocked_ioctl = udf_ioctl, From patchwork Fri Aug 30 13:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785080 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 998391AF4F9 for ; Fri, 30 Aug 2024 13:06:19 +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=1725023179; cv=none; b=S3BVXQwMXxMYyLkd8XDv5xKTyGuyQI0F8iYOSk1d+vl67UEcjl3oh67fr3PmGuKRmr2mIl7m4XktcgoZHsp9grj+LHFSyj6G2GhgLjnlZquz7VV0j7xyOmX3c8P+/y0dRye9WJ8WkYqAVfJSCLvU49knKKZWecHAfSb4PI8ALPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023179; c=relaxed/simple; bh=7XWXiqTJI/Pb166wlRFa5S7205u4Kt0D94PluQkdy00=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YUcukxYdhrMOqiybo37U80o3gyLQob8ZpF2TZZlZCC9ockmvGi5IhfRr6+oiH7TDwTz6EE246pWcVwt9bxtRlCZsu4QpCCciYoTQFOC8uv5rLAWC9vBqlYlUwvJWpAxhMlU+Ci6JFgTEbJ7MMb6SttEmrQ9KRphcAg7Dpg+96aA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TQbzrUyg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TQbzrUyg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 72B12C4CEC9; Fri, 30 Aug 2024 13:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023179; bh=7XWXiqTJI/Pb166wlRFa5S7205u4Kt0D94PluQkdy00=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TQbzrUygvfJwyANPWQawPmIE/nPVYNZEP2oZzyt15Uuze1PWlVMT80oVq4hi+xChR BheEgcxDVGFS7pt2BwnpQ/t6GhnAQo9zT78m4Uo8MRDe8GrLuES+Cc9ST7zSDf5hdv k+A/qZR0SbIDFjHcXKkcB9f+Wkz+3G1srmm3nBGPwqtcI0e+kAEG6m6r5H9jxKyFI8 pHNcNfQuW1phh+MWc3c3sp2EwCdd5I8LYjh5pc2WcTt+zaISxFuKlKumRREp4cWMK8 pmwG/Aleb1E5BInYvN2SGdPiUe+YwA3wUB86h0ik12xf6UtHtAeN1Lr2xgPcX2I1TX 4exPsntr1Fuqw== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:57 +0200 Subject: [PATCH RFC 16/20] ufs: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-16-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2081; i=brauner@kernel.org; h=from:subject:message-id; bh=7XWXiqTJI/Pb166wlRFa5S7205u4Kt0D94PluQkdy00=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDx3jZVu4GePr4VX5wtXPAxUlz0lJGwT5l145Fpbw A+nrVUvOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACZyg5eR4aGCSYLNruuLygO1 ljP8ff0m+vwX5kdq7laZ5g62kr96VjH84VDZ4j/32QOTt3u/rXzZ/mu2jcjNf3Fr2ORab8/K4c+ fyQkA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/ufs/dir.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 61f25d3cf3f7..335f0ae529b4 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -435,7 +435,7 @@ ufs_readdir(struct file *file, struct dir_context *ctx) unsigned long n = pos >> PAGE_SHIFT; unsigned long npages = dir_pages(inode); unsigned chunk_mask = ~(UFS_SB(sb)->s_uspi->s_dirblksize - 1); - bool need_revalidate = !inode_eq_iversion(inode, file->f_version); + bool need_revalidate = !inode_eq_iversion(inode, *(u64 *)file->private_data); unsigned flags = UFS_SB(sb)->s_flags; UFSD("BEGIN\n"); @@ -462,7 +462,7 @@ ufs_readdir(struct file *file, struct dir_context *ctx) offset = ufs_validate_entry(sb, kaddr, offset, chunk_mask); ctx->pos = (n<f_version = inode_query_iversion(inode); + *(u64 *)file->private_data = inode_query_iversion(inode); need_revalidate = false; } de = (struct ufs_dir_entry *)(kaddr+offset); @@ -646,9 +646,31 @@ int ufs_empty_dir(struct inode * inode) return 0; } +static int ufs_dir_open(struct inode *inode, struct file *file) +{ + file->private_data = kzalloc(sizeof(u64), GFP_KERNEL); + if (!file->private_data) + return -ENOMEM; + return 0; +} + +static int ufs_dir_release(struct inode *inode, struct file *file) +{ + kfree(file->private_data); + return 0; +} + +static loff_t ufs_dir_llseek(struct file *file, loff_t offset, int whence) +{ + return generic_llseek_cookie(file, offset, whence, + (u64 *)file->private_data); +} + const struct file_operations ufs_dir_operations = { + .open = ufs_dir_open, + .release = ufs_dir_release, .read = generic_read_dir, .iterate_shared = ufs_readdir, .fsync = generic_file_fsync, - .llseek = generic_file_llseek, + .llseek = ufs_dir_llseek, }; From patchwork Fri Aug 30 13:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785081 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 EC1551AF4F9 for ; Fri, 30 Aug 2024 13:06:22 +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=1725023183; cv=none; b=aXlrervd+7QfgIoPFuYJ+0eAQ3PO7OA0CpvJvmaotjjn6BIrzGc4ne73YGW6K8BSll0PMGEYjkAzms/va8ZVI95zQ/RcK1myGvaHW3cVw5af7E7joZnVAI+Y7BR1StihgPljvLDWigmH0GycPOc/7dz9S9P2kAF37cGedHSVwfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023183; c=relaxed/simple; bh=l65jWK5+JGZmVWppDzjyXx1NF8+EjedCBbQVuso34UE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ctVbOpcoPirx0trj4RhhD8IHaiP6PJtU1NcPeeguFAaolSXdUpgxEGsPl9DxLTnAdgHaVK75vWpRBYf0/kbi+5CmDuXWN60fh47OTp8usZFSvhWEhAakK/SHTNTVvU2Cs5ZLsoxrUS5Rp0JbgPb3sK0JW1ojdiX3V90iFqzlvJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F0tpD4eM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F0tpD4eM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7AD9C4AF0C; Fri, 30 Aug 2024 13:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023182; bh=l65jWK5+JGZmVWppDzjyXx1NF8+EjedCBbQVuso34UE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=F0tpD4eM/sr+WII47YEtwqHAa0Oaky9Ukd+g/OFZhZpINI0+9zFNvE/id1Tm5QWmb z/t5KFTlQNj2G91sV0RKE35VMGQxwGsuksEpa7Dsh8r5XZyI+5+0i3IM6KrpuXd5pB 2AIOmL85c39Ka9OZ2Fk9IhwdQQybK8c84crKfCFZlsgziHJWBvsL1Lf4Zj5exbRWFH qjy1/UICe3Dl60qjaUmY4BMaROq0Jq69UuExnVpfpbfRUvPPd6KWR5nvwwVG2tHVXn 0E4DLo1I2oC8k2c520t7Nd2f4CMFzQZrRf0WxDTGC/4uJ6Ego/DCKEJojK1sASiYyF CjWEYfpBhr3Rw== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:58 +0200 Subject: [PATCH RFC 17/20] ubifs: store cookie in private data Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-17-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=4912; i=brauner@kernel.org; h=from:subject:message-id; bh=l65jWK5+JGZmVWppDzjyXx1NF8+EjedCBbQVuso34UE=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDzX/956b5XOd0rvStY9MVg0ObzzpEO1cO/MBMEy0 x06lmGPO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACYyxYPhn07PVy5Fi/OXjhuc 1t+VNqf5aOQf8/CTT782Lsh/ZZNi9pKRYZvMVokotgM/Yx2cZsxplk/Z/3TWs4m3eHISJ7Kc7N/ BxgwA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Store the cookie to detect concurrent seeks on directories in file->private_data. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/ubifs/dir.c | 65 ++++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index c77ea57fe696..76bcafa92200 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -555,6 +555,11 @@ static unsigned int vfs_dent_type(uint8_t type) return 0; } +struct ubifs_dir_data { + struct ubifs_dent_node *dent; + u64 cookie; +}; + /* * The classical Unix view for directory is that it is a linear array of * (name, inode number) entries. Linux/VFS assumes this model as well. @@ -582,6 +587,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) struct inode *dir = file_inode(file); struct ubifs_info *c = dir->i_sb->s_fs_info; bool encrypted = IS_ENCRYPTED(dir); + struct ubifs_dir_data *data = file->private_data; dbg_gen("dir ino %lu, f_pos %#llx", dir->i_ino, ctx->pos); @@ -604,27 +610,27 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) fstr_real_len = fstr.len; } - if (file->f_version == 0) { + if (data->cookie == 0) { /* - * The file was seek'ed, which means that @file->private_data + * The file was seek'ed, which means that @data->dent * is now invalid. This may also be just the first * 'ubifs_readdir()' invocation, in which case - * @file->private_data is NULL, and the below code is + * @data->dent is NULL, and the below code is * basically a no-op. */ - kfree(file->private_data); - file->private_data = NULL; + kfree(data->dent); + data->dent = NULL; } /* - * 'generic_file_llseek()' unconditionally sets @file->f_version to - * zero, and we use this for detecting whether the file was seek'ed. + * 'ubifs_dir_llseek()' sets @data->cookie to zero, and we use this + * for detecting whether the file was seek'ed. */ - file->f_version = 1; + data->cookie = 1; /* File positions 0 and 1 correspond to "." and ".." */ if (ctx->pos < 2) { - ubifs_assert(c, !file->private_data); + ubifs_assert(c, !data->dent); if (!dir_emit_dots(file, ctx)) { if (encrypted) fscrypt_fname_free_buffer(&fstr); @@ -641,10 +647,10 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) } ctx->pos = key_hash_flash(c, &dent->key); - file->private_data = dent; + data->dent = dent; } - dent = file->private_data; + dent = data->dent; if (!dent) { /* * The directory was seek'ed to and is now readdir'ed. @@ -658,7 +664,7 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) goto out; } ctx->pos = key_hash_flash(c, &dent->key); - file->private_data = dent; + data->dent = dent; } while (1) { @@ -701,15 +707,15 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) goto out; } - kfree(file->private_data); + kfree(data->dent); ctx->pos = key_hash_flash(c, &dent->key); - file->private_data = dent; + data->dent = dent; cond_resched(); } out: - kfree(file->private_data); - file->private_data = NULL; + kfree(data->dent); + data->dent = NULL; if (encrypted) fscrypt_fname_free_buffer(&fstr); @@ -733,7 +739,10 @@ static int ubifs_readdir(struct file *file, struct dir_context *ctx) /* Free saved readdir() state when the directory is closed */ static int ubifs_dir_release(struct inode *dir, struct file *file) { - kfree(file->private_data); + struct ubifs_dir_data *data = file->private_data; + + kfree(data->dent); + kfree(data); file->private_data = NULL; return 0; } @@ -1712,6 +1721,24 @@ int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path, return 0; } +static int ubifs_dir_open(struct inode *inode, struct file *file) +{ + struct ubifs_dir_data *data; + + data = kzalloc(sizeof(struct ubifs_dir_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + file->private_data = data; + return 0; +} + +static loff_t ubifs_dir_llseek(struct file *file, loff_t offset, int whence) +{ + struct ubifs_dir_data *data = file->private_data; + + return generic_llseek_cookie(file, offset, whence, &data->cookie); +} + const struct inode_operations ubifs_dir_inode_operations = { .lookup = ubifs_lookup, .create = ubifs_create, @@ -1732,7 +1759,9 @@ const struct inode_operations ubifs_dir_inode_operations = { }; const struct file_operations ubifs_dir_operations = { - .llseek = generic_file_llseek, + .open = ubifs_dir_open, + .release = ubifs_dir_release, + .llseek = ubifs_dir_llseek, .release = ubifs_dir_release, .read = generic_read_dir, .iterate_shared = ubifs_readdir, From patchwork Fri Aug 30 13:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785082 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 01C971B4C33 for ; Fri, 30 Aug 2024 13:06:24 +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=1725023185; cv=none; b=Qk89Z0sCdIX89T3hKMV0OBvuyNRMMeue+YUKUORoXNhqWRJnu3E1y/uoFWXsqJp3g7Abl8tA0mO/q1xhjvLOx4Jq19C7DZLlvYIP9omNg2yhtLqpFmzqDqqL982rfgImAiIG4ka3qdfPmishPgJRqcp+s7yIWS3RzSOMmG9Dzmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023185; c=relaxed/simple; bh=hC6hPuH2LomzSUd3WOSO5wPh2FCfHtQOP1NTqJrdxEM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bVIVkUXap8h5Y6Sy/Ze5p9YXOKpdf3ziOjinIhqLlJEHWz9DhN3gUq/I/zrBHyZ1qtWqCl2pAzwzACTATnB94zWEl8sS9jsim+itQrCKPM05qmWuIvaCCzidhb0J9sxWThv4284Z1Eyq2NkQtFbXo4K/TmgTuyXlMbCVxoT963Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LtsDommX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LtsDommX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12D79C4CEC7; Fri, 30 Aug 2024 13:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023184; bh=hC6hPuH2LomzSUd3WOSO5wPh2FCfHtQOP1NTqJrdxEM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LtsDommX4Ehprldy4yFJQ4huifBysNwG+d2ZsJ/Uix2D3qghGSTfKeedjxplzj7QM c5w2xYzEq7eM8NpZAiULB+mmjmH8Lcng9sVcYjsuY/hw3JjzQ0dORlDyMR2smLYTgW CauCRoj9RNsqAbOwbhinZCSpnZW34gr+GpZv9gYX40Sbsf9Kxc5fNFnB0ZDHk3i5Uj 0Yl++HuS+Hb8JdbKFkpIdxRvvGlbI0dcity1is8YI1bsIFN+qLVg0rmSOgxbLGMjuq SbhZ3tTFA6yfgOes2x7vw4NqaEEExqQkm7bnnFPMFocq7yzTqDGen6+zuHUdgSrzqT hdNQkESHAyeUg== From: Christian Brauner Date: Fri, 30 Aug 2024 15:04:59 +0200 Subject: [PATCH RFC 18/20] fs: add f_pipe Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-18-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1293; i=brauner@kernel.org; h=from:subject:message-id; bh=hC6hPuH2LomzSUd3WOSO5wPh2FCfHtQOP1NTqJrdxEM=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDyXscWsyToqINvZ5+lEf+PFm5Sma67f63bx+GZtL eNTUdstO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACaybBHDH47E0tc/vbWPJ3iV Xrr657BBT6D7p12zeJuW8nWKvrzs/46R4QLjY+kvK3ZYL97G/7iurSNwQkDSl/evevkmVtVJnPo myAQA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Only regular files with FMODE_ATOMIC_POS and directories need f_pos_lock. Place a new f_pipe member in a union with f_pos_lock that they can use and make them stop abusing f_version in follow-up patches. Signed-off-by: Christian Brauner --- include/linux/fs.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3e6b3c1afb31..ca4925008244 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1001,6 +1001,7 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index) * @f_cred: stashed credentials of creator/opener * @f_path: path of the file * @f_pos_lock: lock protecting file position + * @f_pipe: specific to pipes * @f_pos: file position * @f_version: file version * @f_security: LSM security context of this file @@ -1026,7 +1027,12 @@ struct file { const struct cred *f_cred; /* --- cacheline 1 boundary (64 bytes) --- */ struct path f_path; - struct mutex f_pos_lock; + union { + /* regular files (with FMODE_ATOMIC_POS) and directories */ + struct mutex f_pos_lock; + /* pipes */ + u64 f_pipe; + }; loff_t f_pos; u64 f_version; /* --- cacheline 2 boundary (128 bytes) --- */ From patchwork Fri Aug 30 13:05:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785083 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 2C2BD1AE056 for ; Fri, 30 Aug 2024 13:06:27 +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=1725023187; cv=none; b=b5d8xQN/PLvDsuq0CDD/GrxYg55A7nt2nO+M3moKX3QEJVYTApg2dRz01zzvbQgjy0KK3dBHYauUF7SASIUY8F0yR6WU4u90E3Fpcdm/I75BW2rOg8USzmgwoqQ2mg/wguFQkh44ZrtuIWCwr5X5Ij/apsy7ydSUkfD/kGDm3xU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023187; c=relaxed/simple; bh=RwsfX6+8EZo3gpTxiLhlAX6rMlnrpQk6hJ4HFOwb8o4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aXr6V4b3bovb33kVk3J/hO4iUowFW04oePEquIPXWacP1y1IZB+n7U7B4JRnOYu/ZrLk18nnvGiw8VaI1OlWFoqlyvGaSCXQa3ZzgCdlgOQ4hoiwPZGc2M1ZN/YDatXZkb/E6c8jr8WT4vc1nVQ5n6Vq1Rku5rLY7uS8PaGLrFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gKBkV3l+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gKBkV3l+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45D87C4CEC8; Fri, 30 Aug 2024 13:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023187; bh=RwsfX6+8EZo3gpTxiLhlAX6rMlnrpQk6hJ4HFOwb8o4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gKBkV3l+E/6riwoHIci4bltkrd8kcIcx2wVhI94Mcqe+3eH2yosbCmdx7PeZ79G3x d/nMzerenLgif87FlQMAt3L2lYi9veq/2kmlZ/s8tuZ1OredJ4FtpuZKlKAfgpIQDg m5htEOZflhdpiv/0SGMFCUm3x7CBGJXr1lawHWMaF/b+ZgTpB8tcoem8sBlJRwydXn kVr23OWs4kBYRdedHZLiBH9jLOecDN67a1O8fOE0VqM6uMc3H9H7j5ovYC8E/guU0N bPh1Zkw51k8r4J824KcxDhmgRje7Ds5GUvvmQWsIzJQ4b8g1DMeh4j3nLsKVw0ZIEC nD49nOq7rNGjw== From: Christian Brauner Date: Fri, 30 Aug 2024 15:05:00 +0200 Subject: [PATCH RFC 19/20] pipe: use f_pipe Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-19-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=1775; i=brauner@kernel.org; h=from:subject:message-id; bh=RwsfX6+8EZo3gpTxiLhlAX6rMlnrpQk6hJ4HFOwb8o4=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDy39+UKFYZ77cI3QrPm55Z2m++aPfN9/8oHKYkzX jf2h39u6ihlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZhI01OG/76vhI/dc+sWam07 LJgy8VvrskuS/kFlu2dEN+VdWOVuvZbhn3LxD3VhJktmC97bbq+U5jw3uOVlXRW8+f1ptWLpaye iuAE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Pipes use f_version to defer poll notifications until a write has been observed. Since multiple file's refer to the same struct pipe_inode_info in their ->private_data moving it into their isn't feasible since we would need to introduce an additional pointer indirection. However, since pipes don't require f_pos_lock we placed a new f_pipe member into a union with f_pos_lock that pipes can use. This is similar to what we already do for struct inode where we have additional fields per file type. This will allow us to fully remove f_version in the next step. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/pipe.c b/fs/pipe.c index 7dff2aa50a6d..b8f1943c57b9 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -686,7 +686,7 @@ pipe_poll(struct file *filp, poll_table *wait) if (filp->f_mode & FMODE_READ) { if (!pipe_empty(head, tail)) mask |= EPOLLIN | EPOLLRDNORM; - if (!pipe->writers && filp->f_version != pipe->w_counter) + if (!pipe->writers && filp->f_pipe != pipe->w_counter) mask |= EPOLLHUP; } @@ -1108,7 +1108,7 @@ static int fifo_open(struct inode *inode, struct file *filp) bool is_pipe = inode->i_sb->s_magic == PIPEFS_MAGIC; int ret; - filp->f_version = 0; + filp->f_pipe = 0; spin_lock(&inode->i_lock); if (inode->i_pipe) { @@ -1155,7 +1155,7 @@ static int fifo_open(struct inode *inode, struct file *filp) if ((filp->f_flags & O_NONBLOCK)) { /* suppress EPOLLHUP until we have * seen a writer */ - filp->f_version = pipe->w_counter; + filp->f_pipe = pipe->w_counter; } else { if (wait_for_partner(pipe, &pipe->w_counter)) goto err_rd; From patchwork Fri Aug 30 13:05:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13785084 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 626F31AE056 for ; Fri, 30 Aug 2024 13:06:29 +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=1725023189; cv=none; b=j+NAr7eppqHvrmo6Tvm+9zrUjdejJV4/dwTL/njv7MUwZ/XWVvBM0ZgYRbb3yCtAcw7B1Q67IvYuAi036zl5sk1EGgA0datKNh0msCmfz4qgo3dX8WC/7CoBV9HfsHRbNxlc/VtUP+nCadi8lV2YV1A2EG5TqzuzwYc2jWJ9NKk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725023189; c=relaxed/simple; bh=3woYN5gWU2ZxDLzsw5HkcAJ38mFoKEtN6YbTejqApNY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oG104G5Ngvk6yonEo2R6bXSdllP1yB88bqOx8O4sjRChCobGMIyVqNddjnqE8LvrkYQNznfMEFEfGYgSI8xJQqrX/Cd+FJRw7Ux5MntKXk5kHSeYeHOxNZeSJXrnuHW8Jw0gySWT/W5rzsb2HRCjZiw7BiPZX7nCdrgdJ17TBLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nQJb2tQS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nQJb2tQS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F794C4CEC2; Fri, 30 Aug 2024 13:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725023189; bh=3woYN5gWU2ZxDLzsw5HkcAJ38mFoKEtN6YbTejqApNY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nQJb2tQSevZ38AR9LiZroCs39xOoE5faSvjTZ4aOcokUnSHmH3om9i058KPyw+qnR l/g4MPjV/NsYFDZY00gHPyJx4LMFjETr4xTUSHlnwPKVAXm26oCFW1gVJvjUnrLJqx rouvFP/md1KQgW3tus43QojV2h5Pbal02ZTTYRgehEfXYffFeTVRzXBKbA/CMpHCVB 9KUeXomfx2NylzxzH7WSHbyMJ6v+81/l3xmn49BUn5WaQV/Irpg3nJQ51E98+V8MW0 ex2+hjDWHg6BSYkHwK6r4nQbsxNB1K8LxxZoVUyxABqr3ErcGTX3hEW6MnuRZX21Ed Y8wAGuEvH2AMA== From: Christian Brauner Date: Fri, 30 Aug 2024 15:05:01 +0200 Subject: [PATCH RFC 20/20] fs: remove f_version Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240830-vfs-file-f_version-v1-20-6d3e4816aa7b@kernel.org> References: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> In-Reply-To: <20240830-vfs-file-f_version-v1-0-6d3e4816aa7b@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Jan Kara , Al Viro , Jeff Layton , Josef Bacik , Jens Axboe , Christoph Hellwig , Christian Brauner X-Mailer: b4 0.15-dev-37811 X-Developer-Signature: v=1; a=openpgp-sha256; l=2184; i=brauner@kernel.org; h=from:subject:message-id; bh=3woYN5gWU2ZxDLzsw5HkcAJ38mFoKEtN6YbTejqApNY=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaRdPDx3fdhqu2knbJnnmIc+WsTdeH9SZL/K9jcFrw4Gz yy7d8BhX0cpC4MYF4OsmCKLQ7tJuNxynorNRpkaMHNYmUCGMHBxCsBEBJ8z/OH93VJRsJuru22y juXCdPbNsg8eGLmrOPwTdi44JOsh1sDwz5pP+XFn652M5TOW/2Nfavx+7pEL8WrlzouV3lTN5+V dzwoA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Now that detecting concurrent seeks is done by the filesystems that require it we can remove f_version and free up 8 bytes for future extensions. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- fs/read_write.c | 9 ++++----- include/linux/fs.h | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 47f7b4e32a53..981146f50568 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -62,7 +62,8 @@ static loff_t vfs_setpos_cookie(struct file *file, loff_t offset, if (offset != file->f_pos) { file->f_pos = offset; - *cookie = 0; + if (cookie) + *cookie = 0; } return offset; } @@ -81,7 +82,7 @@ static loff_t vfs_setpos_cookie(struct file *file, loff_t offset, */ loff_t vfs_setpos(struct file *file, loff_t offset, loff_t maxsize) { - return vfs_setpos_cookie(file, offset, maxsize, &file->f_version); + return vfs_setpos_cookie(file, offset, maxsize, NULL); } EXPORT_SYMBOL(vfs_setpos); @@ -362,10 +363,8 @@ loff_t default_llseek(struct file *file, loff_t offset, int whence) } retval = -EINVAL; if (offset >= 0 || unsigned_offsets(file)) { - if (offset != file->f_pos) { + if (offset != file->f_pos) file->f_pos = offset; - file->f_version = 0; - } retval = offset; } out: diff --git a/include/linux/fs.h b/include/linux/fs.h index ca4925008244..7e11ce172140 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1003,7 +1003,6 @@ static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index) * @f_pos_lock: lock protecting file position * @f_pipe: specific to pipes * @f_pos: file position - * @f_version: file version * @f_security: LSM security context of this file * @f_owner: file owner * @f_wb_err: writeback error @@ -1034,11 +1033,10 @@ struct file { u64 f_pipe; }; loff_t f_pos; - u64 f_version; - /* --- cacheline 2 boundary (128 bytes) --- */ #ifdef CONFIG_SECURITY void *f_security; #endif + /* --- cacheline 2 boundary (128 bytes) --- */ struct fown_struct *f_owner; errseq_t f_wb_err; errseq_t f_sb_err;