From mboxrd@z Thu Jan 1 00:00:00 1970 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 B89661F3FED; Tue, 27 Jan 2026 06:21:28 +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=1769494888; cv=none; b=kIaYMbKFeAutRHD0IWKyZFXsjlzhHpGWtl3F4yG6Lc9tKDKM/8WsGdl+y400IWafCwT+bWHj+z31XZGJqYWTK/VfdFt9sjlkH1nwg0FGW/N+sZjgZLAR8MDfrQK/S8pHXI0vreuDLuy3jXSH2SywPvcVr/qb4k5G6SeADlzw/PI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769494888; c=relaxed/simple; bh=kk2V4G3auJhPjVPWGb0eJbR78yju4WWua17kbmc6Gxc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=LxruRHFRI/4SH8QUNha46MGc3a9NErFCE0FKVyss18e+MWnKtfp1WCpgfGOVbtUQXbhVZaFDDxEEJGB7zKmx+yD0yxIlSpfAOcCoTylrg7gMD7XaKTH4nwLAZZubSWqu7/ZXN+Q9sezviKjHBqR/adH4Gf419sr5C1p06HUqPKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RTL4LvSM; 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="RTL4LvSM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8398C116C6; Tue, 27 Jan 2026 06:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769494888; bh=kk2V4G3auJhPjVPWGb0eJbR78yju4WWua17kbmc6Gxc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RTL4LvSMUGOTtLW9wXJkpR0u684upITx8xZl84Y31HC1RqoKXvCBezyDsiP3ySxUr E/B+8/BXI1rjjU3BkuZaAFz8J9hKYfFnYkRFHrf18UIwfmvBfV6YHk/uwHTp2HJQvS 6BKI68umDuXLIIj6tsO1PQXJlM4Jf7SQXPycRfvFXvAMNvpdSSTXwAvgN/7dcy0Df0 hr59kGK1M4AtByyuMO2mZWrc2ERwuVIuvR4fK3PqYyXBonryBdqnlvPZTfRfSBQmKj IiOBH48fB1ojGb3ercxDF4N9AjHTAaHezrLsbjyKZzMJBJBL2DGFWg0BoYDuI3m0NO 8zk5iJ28eeEOw== Date: Mon, 26 Jan 2026 22:20:55 -0800 From: Eric Biggers To: Christoph Hellwig Cc: "Darrick J. Wong" , Al Viro , Christian Brauner , Jan Kara , David Sterba , Theodore Ts'o , Jaegeuk Kim , Chao Yu , Andrey Albershteyn , Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, fsverity@lists.linux.dev Subject: Re: [PATCH 07/16] fsverity: don't issue readahead for non-ENOENT errors from __filemap_get_folio Message-ID: <20260127062055.GA90735@sol> References: <20260126045212.1381843-1-hch@lst.de> <20260126045212.1381843-8-hch@lst.de> <20260126191102.GO5910@frogsfrogsfrogs> <20260126205301.GD30838@quark> <20260127060039.GA25321@lst.de> Precedence: bulk X-Mailing-List: fsverity@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260127060039.GA25321@lst.de> On Tue, Jan 27, 2026 at 07:00:39AM +0100, Christoph Hellwig wrote: > > - if (PTR_ERR(folio) == -ENOENT || > > - !(IS_ERR(folio) && !folio_test_uptodate(folio))) { > > + if (folio == ERR_PTR(-ENOENT) || > > + (!IS_ERR(folio) && !folio_test_uptodate(folio))) { > > > > (Note that PTR_ERR() shouldn't be used before it's known that the > > pointer is an error pointer.) > > That's new to me, and I can't find anything in the documentation or > implementation suggesting that. Your example code above also does > this as does plenty of code in the kernel elsewhere. Not sure why this is controversial. The documentation for PTR_ERR() is clear that it's for error pointers: /** * PTR_ERR - Extract the error code from an error pointer. * @ptr: An error pointer. * Return: The error code within @ptr. */ static inline long __must_check PTR_ERR(__force const void *ptr) { return (long) ptr; } Yes, it's really just a cast, and 'PTR_ERR(folio) == -ENOENT' actually still works when folio isn't necessarily an error pointer. But normally it would be written as a pointer comparison as I suggested. - Eric From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA955D25944 for ; Tue, 27 Jan 2026 06:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type:Cc: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:In-Reply-To:MIME-Version:References: Message-ID:To:Date:Sender:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1dxgEJnUyLfCvtT371/mRTR9hT3lqUDF58JXpHkI2oQ=; b=luagh2zQhbz3pPq28eFm9cTlBC 4gFbN/3NKiQ9R5pdZk2rjsRnLepm1Cm9kOXHmQm652vCjNqRXn7CkR9UiGgKHKQB2OyvineZBt6oF ylvlxeK7XIyt0Dp2VlAZ82EPQ5dOlnM1VaJG2B15wtk8uaW60l6qknDH9tvvy0gmw5QA=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1vkcSL-0007L0-A5; Tue, 27 Jan 2026 06:21:41 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1vkcSJ-0007Ks-Ov for linux-f2fs-devel@lists.sourceforge.net; Tue, 27 Jan 2026 06:21:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=nGlEuJm8t8Nf819OqqlB1RN74loSnGuY3LiI4+ZKbnk=; b=gc39VF9Dk8meFvOwqTJ8Ll/Z9W cmYhvuF1DUvrC8FzW+DjIpnPMKt2DzMwBnZmNSzZ4PxrYhc3RVtdA2cqEH1CYhUbK8lztncGEJnFG rx5X7bAuoSbDTaqLyky0uGVfAC1bfclZFu+u6DR8nHP70YDGSHp15s+RwJIQIsZXgpXc=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=nGlEuJm8t8Nf819OqqlB1RN74loSnGuY3LiI4+ZKbnk=; b=ETnRF0+Bp3HV5UZO4QDHsT16xk fjDxCRGY71VNYnJDeAtIsoMWyN1cXjyrJl3h5BB9t0V3uGExL9dUHQcPLu/697oRwC7EmkTPPt8b6 VYLgnozAXgVcPqqa0PRHX+5SoRb3oqVsAPRlN4x/cY+X9l1OreVtUO1E7H0m51eB60QE=; Received: from tor.source.kernel.org ([172.105.4.254]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1vkcSJ-0001y5-Az for linux-f2fs-devel@lists.sourceforge.net; Tue, 27 Jan 2026 06:21:39 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id ACEB560051; Tue, 27 Jan 2026 06:21:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8398C116C6; Tue, 27 Jan 2026 06:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769494888; bh=kk2V4G3auJhPjVPWGb0eJbR78yju4WWua17kbmc6Gxc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RTL4LvSMUGOTtLW9wXJkpR0u684upITx8xZl84Y31HC1RqoKXvCBezyDsiP3ySxUr E/B+8/BXI1rjjU3BkuZaAFz8J9hKYfFnYkRFHrf18UIwfmvBfV6YHk/uwHTp2HJQvS 6BKI68umDuXLIIj6tsO1PQXJlM4Jf7SQXPycRfvFXvAMNvpdSSTXwAvgN/7dcy0Df0 hr59kGK1M4AtByyuMO2mZWrc2ERwuVIuvR4fK3PqYyXBonryBdqnlvPZTfRfSBQmKj IiOBH48fB1ojGb3ercxDF4N9AjHTAaHezrLsbjyKZzMJBJBL2DGFWg0BoYDuI3m0NO 8zk5iJ28eeEOw== Date: Mon, 26 Jan 2026 22:20:55 -0800 To: Christoph Hellwig Message-ID: <20260127062055.GA90735@sol> References: <20260126045212.1381843-1-hch@lst.de> <20260126045212.1381843-8-hch@lst.de> <20260126191102.GO5910@frogsfrogsfrogs> <20260126205301.GD30838@quark> <20260127060039.GA25321@lst.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20260127060039.GA25321@lst.de> X-Headers-End: 1vkcSJ-0001y5-Az Subject: Re: [f2fs-dev] [PATCH 07/16] fsverity: don't issue readahead for non-ENOENT errors from __filemap_get_folio X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Eric Biggers via Linux-f2fs-devel Reply-To: Eric Biggers Cc: fsverity@lists.linux.dev, Christian Brauner , Jan Kara , "Darrick J. Wong" , Andrey Albershteyn , Matthew Wilcox , linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, Al Viro , Jaegeuk Kim , David Sterba , Theodore Ts'o , linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Tue, Jan 27, 2026 at 07:00:39AM +0100, Christoph Hellwig wrote: > > - if (PTR_ERR(folio) == -ENOENT || > > - !(IS_ERR(folio) && !folio_test_uptodate(folio))) { > > + if (folio == ERR_PTR(-ENOENT) || > > + (!IS_ERR(folio) && !folio_test_uptodate(folio))) { > > > > (Note that PTR_ERR() shouldn't be used before it's known that the > > pointer is an error pointer.) > > That's new to me, and I can't find anything in the documentation or > implementation suggesting that. Your example code above also does > this as does plenty of code in the kernel elsewhere. Not sure why this is controversial. The documentation for PTR_ERR() is clear that it's for error pointers: /** * PTR_ERR - Extract the error code from an error pointer. * @ptr: An error pointer. * Return: The error code within @ptr. */ static inline long __must_check PTR_ERR(__force const void *ptr) { return (long) ptr; } Yes, it's really just a cast, and 'PTR_ERR(folio) == -ENOENT' actually still works when folio isn't necessarily an error pointer. But normally it would be written as a pointer comparison as I suggested. - Eric _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel