Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2645277pxp; Tue, 22 Mar 2022 03:07:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaGelp0tb+oVTqv/1keqxFFE0kR87FQ2XqysaImPHJyTj6yhK/+e2THNR0gRzvKioLsDRh X-Received: by 2002:a05:6402:4402:b0:418:ff4c:f102 with SMTP id y2-20020a056402440200b00418ff4cf102mr25293655eda.365.1647943652351; Tue, 22 Mar 2022 03:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647943652; cv=none; d=google.com; s=arc-20160816; b=RgY00kfTwAat1+98H/OZ3z9rpBYLoLeXjX224tTyPxVRNrR6FoFBiZBptEiA18ixE5 xlOeG/lMNHftzmAWJuV4pxOoA461BSsa3a+xAauzAoeJfsxTPJCMpnYuccyqhzvbsNLk q7Kd/q4VIo2UyPp0fOfIcHTJUXvdElcln1pbXZbJ5TdyWiOnbRrapc0LUc8BAFNYxRFf yOHLlexXIjRfBPR+ZgFtefpsIEvGjD9jQS0BG+65MFIzqdS3K/KkexJdHx/EJOGEqIz8 YxbrBFQtCsLOjCljS1LfjXTuxmnEi3Bsw5QxkKpWocb24YNB/kEEM3lcj0v2J658OL9v 73/g== 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=uJdzlcEvij5Ft5CrLtuSMWt2NhA+02RXJxJray9JMj4=; b=ep7mMI1vCS2eWzo7GMikXM7AXa1Jo0fiLCZsk46M/J7epvIo75JOygsVW5KcIjT/WN kaIYumTZIO/d94Cv+JJiy8hkINpyrR4zv/YxO8hOcKGX+jgPXn3t6btM/FHmyFjrIg8Z DH5NOsNArrbm9ZMiZOttrqQsBuvkrCH42Tsp7aiDQc6DiFTBJxvMlsmVo2Tp2+U3mWJa dZlz6YufMs+uDHm2jJlXPbo5qhGNkdzYwNr7vxoJg9DftINwkqNdV/MiudKoYLSYsrD4 NjC9ouor++FsJ8/dys4piam29obITBZH9rM+Gtusm5Gam3kUEj4ydVXicdeDpNNLjeqU PDAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=M9YAGf4D; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j13-20020a170906410d00b006dfed3fa17esi6051681ejk.693.2022.03.22.03.06.48; Tue, 22 Mar 2022 03:07:32 -0700 (PDT) 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=@infradead.org header.s=bombadil.20210309 header.b=M9YAGf4D; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231271AbiCVIyo (ORCPT + 99 others); Tue, 22 Mar 2022 04:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbiCVIyi (ORCPT ); Tue, 22 Mar 2022 04:54:38 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 792F0CC7; Tue, 22 Mar 2022 01:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; 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=uJdzlcEvij5Ft5CrLtuSMWt2NhA+02RXJxJray9JMj4=; b=M9YAGf4DfLFxhrF5jVExSCvkEh F5kzgwhWOl5Rhw1rx8z0Q1Tk614exWnNSewldl9jMIQzc5LkF+IK4YWl5o1M8da8g6a3+uEReKaod r5/OvpYjZUkLj6pqAIS8MdtWHq813xsfM01oCqrQ8Lkh4hInX2nfBYj87F9y1bQ/Zbe+Og8lYPy2Z ticSqIplcnJBoCCPg7jSYPfZ2qc9u0dQe5qoOxTYE9ugxK8ywSK6Uzrp7EzxHPM9d9cr0wR9Q5BBL R0/JmZJihfa3SxFUqAIfCSdBIoXY7cR0rP8Ds0Q9z0xu/nq6HUZDFVO5qbbMwetDdyls+5ZhfyYPU /y5sUiig==; Received: from hch by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nWaGF-00AVAX-ND; Tue, 22 Mar 2022 08:53:03 +0000 Date: Tue, 22 Mar 2022 01:53:03 -0700 From: Christoph Hellwig To: Jane Chu Cc: david@fromorbit.com, djwong@kernel.org, dan.j.williams@intel.com, hch@infradead.org, vishal.l.verma@intel.com, dave.jiang@intel.com, agk@redhat.com, snitzer@redhat.com, dm-devel@redhat.com, ira.weiny@intel.com, willy@infradead.org, vgoyal@redhat.com, linux-fsdevel@vger.kernel.org, nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org Subject: Re: [PATCH v6 5/6] pmem: refactor pmem_clear_poison() Message-ID: References: <20220319062833.3136528-1-jane.chu@oracle.com> <20220319062833.3136528-6-jane.chu@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220319062833.3136528-6-jane.chu@oracle.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE 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 > -static void hwpoison_clear(struct pmem_device *pmem, > - phys_addr_t phys, unsigned int len) > +static phys_addr_t to_phys(struct pmem_device *pmem, phys_addr_t offset) > { > + return pmem->phys_addr + offset; > +} > + > +static sector_t to_sect(struct pmem_device *pmem, phys_addr_t offset) > +{ > + return (offset - pmem->data_offset) / 512; > +} > + > +static phys_addr_t to_offset(struct pmem_device *pmem, sector_t sector) > +{ > + return sector * 512 + pmem->data_offset; > +} The multiplicate / divison using 512 could use shifts using SECTOR_SHIFT. > + > +static void clear_hwpoison(struct pmem_device *pmem, phys_addr_t offset, > + unsigned int len) > +static void clear_bb(struct pmem_device *pmem, sector_t sector, long blks) All these functions lack a pmem_ prefix. > +static blk_status_t __pmem_clear_poison(struct pmem_device *pmem, > + phys_addr_t offset, unsigned int len, > + unsigned int *blks) > +{ > + phys_addr_t phys = to_phys(pmem, offset); > long cleared; > + blk_status_t rc; > > + cleared = nvdimm_clear_poison(to_dev(pmem), phys, len); > + *blks = cleared / 512; > + rc = (cleared < len) ? BLK_STS_IOERR : BLK_STS_OK; > + if (cleared <= 0 || *blks == 0) > + return rc; This look odd. I think just returing the cleared byte value would make much more sense: static long __pmem_clear_poison(struct pmem_device *pmem, phys_addr_t offset, unsigned int len) { long cleared = nvdimm_clear_poison(to_dev(pmem), phys, len); if (cleared > 0) { clear_hwpoison(pmem, offset, cleared); arch_invalidate_pmem(pmem->virt_addr + offset, len); } return cleared; }