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 X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 277A7C4338F for ; Fri, 13 Aug 2021 07:12:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C79BC6103A for ; Fri, 13 Aug 2021 07:12:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C79BC6103A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 658596B006C; Fri, 13 Aug 2021 03:12:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E0A96B0071; Fri, 13 Aug 2021 03:12:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A8418D0001; Fri, 13 Aug 2021 03:12:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0096.hostedemail.com [216.40.44.96]) by kanga.kvack.org (Postfix) with ESMTP id 2BE0A6B006C for ; Fri, 13 Aug 2021 03:12:49 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id D622C180ACEFB for ; Fri, 13 Aug 2021 07:12:48 +0000 (UTC) X-FDA: 78469190016.25.10312DC Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf16.hostedemail.com (Postfix) with ESMTP id 76D83F007D23 for ; Fri, 13 Aug 2021 07:12:48 +0000 (UTC) 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) X-Rspamd-Queue-Id: 76D83F007D23 Authentication-Results: imf16.hostedemail.com; dkim=none; spf=none (imf16.hostedemail.com: domain of hch@lst.de has no SPF policy when checking 213.95.11.211) smtp.mailfrom=hch@lst.de; dmarc=none X-Rspamd-Server: rspam01 X-Stat-Signature: w4jti83u8yqxq5hx7b3oq6xrqeytqk6f X-HE-Tag: 1628838768-556141 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: > +/* > + * 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.