Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7968709rwb; Mon, 12 Dec 2022 23:43:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf5V96NIY0/oUqQcbGIVnXpEvbZXsYRF4pqXnHXWYce0mNptf4sLNHws2BwNI1wdHmFer3We X-Received: by 2002:a17:90a:ea09:b0:219:8d8a:a608 with SMTP id w9-20020a17090aea0900b002198d8aa608mr19692465pjy.43.1670917383361; Mon, 12 Dec 2022 23:43:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670917383; cv=none; d=google.com; s=arc-20160816; b=d/t81GdqsOSqa6UE62dKgIPkbWW2UTmqLhntcDdTfWKB1x5hfhGaQMsjpihxHlu+Eb OEQuXWZYkZshEhEf/KRUGyHIk4XpCXnLTqpZsIGje6G5vlIc+cTgj4uujVHN1dfjmfZW zrcZLAIp2uwXsCGkl+DpRaTzfrixIbfaInjp/ulQPJ6p+vHJdzSwXdtUA9Zw7nNDHRLz Jzv35uKEu88XUn7SrU0y4gIcyHZpsbgqpdto7EC5KBRFKyBBgGL7jzjNQVZsYC5OdZ72 iiy+svgPLQdZ+pLR2lgDuwMTE0VrZhTZemkQiy9PhAxB8jVZ77H79jlqV5itF6/Jp9yC 6U7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=OtUnH8puMoigAwnSYIolqkRd6u4feH/uNXVMZiHt9uQ=; b=yXX4ozZ101DAw5igdsHOjom1Gdd5jmo+WqRjID7D3nYa5r3EOW6uYVyWNrHZ/gmisB Mp6S0485MS1UtoMcnph7qLMsMMia7sCfQvBruWqyBN8Mu3zdPL+XzcIjrXosb8G7OlXJ ItLxpTLcuoRA5SkLhZv/l0Yz0KAGgoONn4xFX3Lsy4dunKX5qKf3xn5MlqGazSLlu3eP 2RW/BAaYjIA7VygfvO2nmhCYx4s2XnjaVqYPVYifsRjBMpj7k3eoUY8LKCMYF4IC8loc IW66e2ZqcNw2rTzgAb/zXwWTady0BjP+wkEt5p+ytcshXBfEUHh7L1yK3D62dffPygnv O+FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=XoiqYhnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v23-20020a17090a899700b00209a3e49f63si11990557pjn.94.2022.12.12.23.42.46; Mon, 12 Dec 2022 23:43:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=XoiqYhnc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234143AbiLMHLJ (ORCPT + 74 others); Tue, 13 Dec 2022 02:11:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233843AbiLMHLG (ORCPT ); Tue, 13 Dec 2022 02:11:06 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D673129 for ; Mon, 12 Dec 2022 23:11:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=OtUnH8puMoigAwnSYIolqkRd6u4feH/uNXVMZiHt9uQ=; b=XoiqYhncV4I3m31iL7plQmDCx3 HRJuT65Chgb7HFFH1dpfnRiUeV67PHNZ8VKF1GqSk3/OqsZTQet1c2A/GWfopxm4yxteoeOMnzSG6 cP25trUIAwmQ7fUAF0zvErgXIlLVyVGD79uBy1Oy8TVQMUBhFIwh80ryB0suLlN2iPULbiM1HMqw5 MHp5MAq1GBMjFYN4oLWACBmE1gUcBzhPL67SytL11p3kXFJ5RetE6rbPH4/+xNhmpxxrypx3uAUlg DnhftcZykZVB5XrQPg3zxra4dbs3GB9HPiUTCkykDT1ZXaKPuW/88lnaQx0T49UtvfcOnD0IbGT6r awBXhMDw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1p4zRK-00BYAu-2L; Tue, 13 Dec 2022 07:10:58 +0000 Date: Tue, 13 Dec 2022 07:10:58 +0000 From: Al Viro To: "Fabio M. De Francesco" Cc: Evgeniy Dushistov , Ira Weiny , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] fs/ufs: Change the signature of ufs_get_page() Message-ID: References: <20221212231906.19424-1-fmdefrancesco@gmail.com> <20221212231906.19424-3-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221212231906.19424-3-fmdefrancesco@gmail.com> Sender: Al Viro X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 13, 2022 at 12:19:05AM +0100, Fabio M. De Francesco wrote: > +static void *ufs_get_page(struct inode *dir, unsigned long n, struct page **page) > { > struct address_space *mapping = dir->i_mapping; > - struct page *page = read_mapping_page(mapping, n, NULL); > - if (!IS_ERR(page)) { > - kmap(page); > - if (unlikely(!PageChecked(page))) { > - if (!ufs_check_page(page)) > + *page = read_mapping_page(mapping, n, NULL); > + if (!IS_ERR(*page)) { > + kmap(*page); > + if (unlikely(!PageChecked(*page))) { > + if (!ufs_check_page(*page)) > goto fail; > } > } > - return page; > + return page_address(*page); Er... You really don't want to do that when you've got ERR_PTR() from read_mapping_page(). > > fail: > - ufs_put_page(page); > + ufs_put_page(*page); > return ERR_PTR(-EIO); > } IDGI... static void *ufs_get_page(struct inode *dir, unsigned long n, struct page **p) { struct address_space *mapping = dir->i_mapping; struct page *page = read_mapping_page(mapping, n, NULL); if (!IS_ERR(page)) { kmap(page); if (unlikely(!PageChecked(page))) { if (!ufs_check_page(page)) goto fail; } *p = page; return page_address(page); } return ERR_CAST(page); fail: ufs_put_page(page); return ERR_PTR(-EIO); } all there is to it... The only things you need to change are 1) type of function 2) make sure to store the page into that pointer to pointer to page on success 3) return page_address(page) instead of page on success 4) use ERR_CAST() to convert ERR_PTR() that is struct page * into equal ERR_PTR() that is void * (the last one is optional, just makes the intent more clear).