Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp539819pxb; Fri, 13 Aug 2021 00:14:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ3VaVd7mEnEIwNCbytk68KpNUp6t5RFBcaz2uIXmPjNPyI2VKOIq06OAuzSYOtWqR5gP+ X-Received: by 2002:a02:7348:: with SMTP id a8mr962577jae.116.1628838884068; Fri, 13 Aug 2021 00:14:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628838884; cv=none; d=google.com; s=arc-20160816; b=sZjzmnzYAP+OuhL7ccHwzcPbVAs3sl1Gbmy3RJAelLIjRGnrRI05SjczUgQwxBIAMA 84L5YCK6SNJ8g6hRo9Zrc09YPz3je1ohBPVZGHY4zvba26l359qoDy+5RbITb4LtPU6h j29qxZLwgSJujxJ5ZDIwTKbyhN3tjMCh7Aloe+w1ARZdrNYHk0DBb9nZZmUYPijEIbbO EQMnSmMAMRmM2DLrm4SdFV8B2UxxewqjdA7Gw1C4kE93hGTWookG9bx14j8sNLV7Rof8 ECYqxN0q9d5FTJUYMDgrCylpHpgBFPnQ2twj6N8WivdSsL4dFqqPze4mkkfR8CVTWOKg lmKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=//1zgN/OgY4vtZD6jUN9NxLaQYxGq2d0RsslIBJtImg=; b=LlAUw4TTRdgclX1fdAlQZNcaWxT1ZiZSmasba1qNItSSPbrxphrVOptq16cnemFpEB FX4ww2ycKg6PIYQw0BQ0spc9FjHxNwBgXgarPvmgqMLLkIQzZmCsd7362d/Uqh19OPFp gXVDfpXtb2TClBrOLtXrElfru/6fuKyu8pJS7v9wSQ9Ek6tLrDOsgOvgwc1TkixpQtB0 0xiesX5ViBuRkfKJPf7+ugm+QJEQCzLD9GgpKRrCdBzHFixKAsG6x/r8tYN3vAemhPBJ MiAaPGbSScLYvIab9aKQFDdP3SDN6kkAbpYk8JojE61tYqVC35tiNYEDcfyYQab02X9B 2hvA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 q7si806344iow.71.2021.08.13.00.14.27; Fri, 13 Aug 2021 00:14:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239340AbhHMHNV (ORCPT + 99 others); Fri, 13 Aug 2021 03:13:21 -0400 Received: from verein.lst.de ([213.95.11.211]:46616 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239319AbhHMHNQ (ORCPT ); Fri, 13 Aug 2021 03:13:16 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id EA67C67373; Fri, 13 Aug 2021 09:12:45 +0200 (CEST) Date: Fri, 13 Aug 2021 09:12:45 +0200 From: Christoph Hellwig To: David Howells Cc: willy@infradead.org, trond.myklebust@primarydata.com, darrick.wong@oracle.com, hch@lst.de, viro@zeniv.linux.org.uk, jlayton@kernel.org, sfrench@samba.org, torvalds@linux-foundation.org, linux-nfs@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH v2 3/5] mm: Make swap_readpage() for SWP_FS_OPS use ->direct_IO() not ->readpage() Message-ID: <20210813071245.GC26339@lst.de> References: <162879971699.3306668.8977537647318498651.stgit@warthog.procyon.org.uk> <162879974434.3306668.4798886633463058599.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <162879974434.3306668.4798886633463058599.stgit@warthog.procyon.org.uk> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org > +/* > + * Keep track of the kiocb we're using to do async DIO. We have to > + * refcount it until various things stop looking at the kiocb *after* > + * calling ->ki_complete(). > + */ > +struct swapfile_kiocb { > + struct kiocb iocb; > + refcount_t ki_refcnt; > +}; The ki_ prefix is a little strange here. > + > +static void swapfile_put_kiocb(struct swapfile_kiocb *ki) > +{ > + if (refcount_dec_and_test(&ki->ki_refcnt)) { > + fput(ki->iocb.ki_filp); What do we need the file reference for here? The swap code has to have higher level prevention for closing the file vs active I/O, at least the block path seems to rely on that. > +static void swapfile_read_complete(struct kiocb *iocb, long ret, long ret2) > +{ > + struct swapfile_kiocb *ki = container_of(iocb, struct swapfile_kiocb, iocb); Overly long line. > + /* Should set IOCB_HIPRI too, but the box becomes unresponsive whilst > + * putting out occasional messages about the NFS sunrpc scheduling > + * tasks being hung. > + */ IOCB_HIPRI has a very specific meaning, so I'm not sure we should use it never mind leave such a comment here. Also this is not the proper standard kernel comment style. > + > + iov_iter_bvec(&to, READ, &bv, 1, thp_size(page)); > + ret = swap_file->f_mapping->a_ops->direct_IO(&kiocb, &to); > + > + __swapfile_read_complete(&kiocb, ret, 0); > + return (ret > 0) ? 0 : ret; No need for the braces. > + return (ret > 0) ? 0 : ret; Same here.