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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 7B956C4338F for ; Thu, 12 Aug 2021 13:02:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EFBC760C40 for ; Thu, 12 Aug 2021 13:02:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EFBC760C40 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 5132D8D0001; Thu, 12 Aug 2021 09:02:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4B8C58D0003; Thu, 12 Aug 2021 09:02:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 400FD8D0001; Thu, 12 Aug 2021 09:02:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0125.hostedemail.com [216.40.44.125]) by kanga.kvack.org (Postfix) with ESMTP id 2040C8D0001 for ; Thu, 12 Aug 2021 09:02:33 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id B9BAD256E4 for ; Thu, 12 Aug 2021 13:02:32 +0000 (UTC) X-FDA: 78466442544.35.9D9C1B0 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf26.hostedemail.com (Postfix) with ESMTP id D50472016560 for ; Thu, 12 Aug 2021 13:02:31 +0000 (UTC) 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=KapCwCgb5M/iDHR5WR0+lkw3WeXDUWMNBxTJHFQJfdk=; b=mUxh/OAAFJWkKC9+tghFkWl6hg SZiBaIayBiLszQP6Y6dHB8UvkrxEK3sQ9wab2rBSWRK2bhYHSwZa129SIRI2avRPZfWPJeGzG060b T3zCuCccJk3aevzfE5d6a/3Hb7gnv/gNqQweiqHELVODBTwRc4Rwr1y2FVZswU170C5YfHboMqiXS 5dR3EmfcarVaOGLY+8q5RBjYsga667g5MwbuNeieBs98bD8acNKTJhoW8UyYEG5U92f4IWX+uNy3u X9Psw1hLChFTCFrgqcNzV0/rKUbyOKhVzTYsko3pZGzje14uic6S4HZdHO29oLJxYBi0xWoIrfK1t fUfKRYvw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mEAJi-00EaEh-DM; Thu, 12 Aug 2021 13:00:28 +0000 Date: Thu, 12 Aug 2021 14:00:14 +0100 From: Matthew Wilcox To: David Howells Cc: trond.myklebust@primarydata.com, darrick.wong@oracle.com, hch@lst.de, 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: [PATCH 2/2] mm: Make swap_readpage() for SWP_FS_OPS use ->direct_IO() not ->readpage() Message-ID: References: <162876946134.3068428.15475611190876694695.stgit@warthog.procyon.org.uk> <162876947840.3068428.12591293664586646085.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <162876947840.3068428.12591293664586646085.stgit@warthog.procyon.org.uk> X-Rspamd-Queue-Id: D50472016560 Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="mUxh/OAA"; dmarc=none; spf=none (imf26.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Rspamd-Server: rspam04 X-Stat-Signature: ywcmdfo7ns1kpp6u8o4xhdumkbnhemf9 X-HE-Tag: 1628773351-671832 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: On Thu, Aug 12, 2021 at 12:57:58PM +0100, David Howells wrote: I'm not quite sure why we need the refcount. > + refcount_set(&ki->ki_refcnt, 2); > + init_sync_kiocb(&ki->iocb, swap_file); > + ki->page = page; > + ki->iocb.ki_flags = IOCB_DIRECT | IOCB_SWAP; > + ki->iocb.ki_pos = page_file_offset(page); > + ki->iocb.ki_filp = get_file(swap_file); > + if (!synchronous) > + ki->iocb.ki_complete = swapfile_read_complete; > + > + iov_iter_bvec(&to, READ, &bv, 1, PAGE_SIZE); > + ret = swap_file->f_mapping->a_ops->direct_IO(&ki->iocb, &to); After submitting the IO here ... > + if (ret != -EIOCBQUEUED) > + swapfile_read_complete(&ki->iocb, ret, 0); We only touch the 'ki' here ... if the caller didn't call read_complete > + swapfile_put_kiocb(ki); Except for here, which is only touched in order to put the refcount. So why can't swapfile_read_complete() do the work of freeing the ki?