Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp875625pxf; Wed, 7 Apr 2021 13:54:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxm9hCo3aR2bS3Sgdc8w2FBp7a87niufaCrqM4xFoFsvRPhmgeCoFaaig5RwEXuZf7874ad X-Received: by 2002:aa7:c7da:: with SMTP id o26mr6878784eds.244.1617828872046; Wed, 07 Apr 2021 13:54:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617828872; cv=none; d=google.com; s=arc-20160816; b=zaK2fSlmnBKs34Kv405s487rLasnM/CMCI9bgLp9TmwddKXkME2s65osoLeVJMGZxd DkB9biNnvSIrybgmtQBk4M9EjXVJxgSVjTC098W+swOiXPAC5phZnBgsQcY4v8uBiikE UEZB/RKdH844AjOvL7Y6ILoWDtjnzo1F5IIcYScxkaaS24Q+ZsLifDu6aRs+1RDnTvFn gnR50LvlPoKLYFZnPO+I5i+xng87KJMxo7yx8nbt1Z97FOrGbyrNMBLlNWTIBlsFds7O PgQAStMycpVE0Fc9NNRWDmztY6nabs5hFEiw5SIFEv3kK+oEALHYFwNa+C9TrwoUOt74 +33g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gXTPe6Z3xf8fN6/+SVbn3oskaMk/+fmn0nXa9QgNoq4=; b=gYYPxxJKzGMkiA+6lcHzOE0qO2cStLn3WNmNNUNZuM9I5UaDSw3IHd/MuKH4Nj0WNh rjA9pRft2QV7WiUGdb6XpuIco2SIZt/fsEs2dJmeIWdN+Z7bERx9xdgm8SU/a4PI9MlF UVW+MgtPxcQcxj0y2X7qdCkWRFPjIca53YGjSDtBv3mEoiM7vQTQ8c+LIG4nryqP7s80 EIIUtddd3xsLvGBSN/1eIdl9vIMBwq0n4NtvbKfvjmCokcYfGgoKx7zlW09h4Ev0FvhS 8rf9pH95HJ+JEPZhtbfoiJLp3rLXyg5r+Be6Q60/Bp8h2ptOpp+QtvYk6a1G9FFavdF1 T5Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=adTni07H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d15si18840778edu.375.2021.04.07.13.54.09; Wed, 07 Apr 2021 13:54:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=adTni07H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351764AbhDGLOm (ORCPT + 99 others); Wed, 7 Apr 2021 07:14:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232429AbhDGLOh (ORCPT ); Wed, 7 Apr 2021 07:14:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 529E9C061756; Wed, 7 Apr 2021 04:14:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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; bh=gXTPe6Z3xf8fN6/+SVbn3oskaMk/+fmn0nXa9QgNoq4=; b=adTni07HAeWwLS2YFlGyWwnHef /sZm3ojRZKo+Ygx1EnVM5PliOVz1wtKizmuCGBSAmi0UJIsH7P6kMBF+ti7Mrf2S1tKMDzlyDFpO0 BozxGSdjTVRNpdjd7IRtXJhaaLurr6AHi9d4x+v6JKg99TLPnvcs+ApVba0ZvMRXqgVrLC7CBfWPX hC5TVO5JLQaL446fVish6SQMaP0pZkmtI39bSBclvNEoVk1UvjJlJz/3FPOdGKF/0nxtnnV0a1i7a BeCe93JNy2rJKClRUwuIe5/6KPKkgRyghnTNtdRBO89EYmGqKOehHaE4aBEeR0hLoWj3OqAyOqtyr xRUHT6cQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lU68B-00EN6A-FD; Wed, 07 Apr 2021 11:14:06 +0000 Date: Wed, 7 Apr 2021 12:13:55 +0100 From: Matthew Wilcox To: Shiyang Ruan Cc: linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org, darrick.wong@oracle.com, dan.j.williams@intel.com, jack@suse.cz, viro@zeniv.linux.org.uk, linux-btrfs@vger.kernel.org, david@fromorbit.com, hch@lst.de, rgoldwyn@suse.de, Ritesh Harjani Subject: Re: [PATCH 1/3] fsdax: Factor helpers to simplify dax fault code Message-ID: <20210407111355.GD2531743@casper.infradead.org> References: <20210407063207.676753-1-ruansy.fnst@fujitsu.com> <20210407063207.676753-2-ruansy.fnst@fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210407063207.676753-2-ruansy.fnst@fujitsu.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 07, 2021 at 02:32:05PM +0800, Shiyang Ruan wrote: > +static int dax_fault_cow_page(struct vm_fault *vmf, struct iomap *iomap, > + loff_t pos, vm_fault_t *ret) > +{ > + int error = 0; > + unsigned long vaddr = vmf->address; > + sector_t sector = dax_iomap_sector(iomap, pos); > + > + switch (iomap->type) { > + case IOMAP_HOLE: > + case IOMAP_UNWRITTEN: > + clear_user_highpage(vmf->cow_page, vaddr); > + break; > + case IOMAP_MAPPED: > + error = copy_cow_page_dax(iomap->bdev, iomap->dax_dev, > + sector, vmf->cow_page, vaddr); > + break; > + default: > + WARN_ON_ONCE(1); > + error = -EIO; > + break; > + } > + > + if (error) > + return error; > + > + __SetPageUptodate(vmf->cow_page); > + *ret = finish_fault(vmf); > + if (!*ret) > + *ret = VM_FAULT_DONE_COW; > + return 0; > +} ... > + error = dax_fault_cow_page(vmf, &iomap, pos, &ret); > if (error) > + ret = dax_fault_return(error); > goto finish_iomap; This seems unnecessarily complex. Why not return the vm_fault_t instead of returning the errno and then converting it?