From patchwork Wed Jan 3 08:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13509720 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A074FC3DA6E for ; Wed, 3 Jan 2024 08:41:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E61D6B029A; Wed, 3 Jan 2024 03:41:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 21F1F6B029C; Wed, 3 Jan 2024 03:41:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A2A36B0293; Wed, 3 Jan 2024 03:41:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EB9416B028F for ; Wed, 3 Jan 2024 03:41:52 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id C7E361C08CF for ; Wed, 3 Jan 2024 08:41:52 +0000 (UTC) X-FDA: 81637356864.23.7B24F53 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf16.hostedemail.com (Postfix) with ESMTP id 3A61518001C for ; Wed, 3 Jan 2024 08:41:51 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lwuKokl9; spf=none (imf16.hostedemail.com: domain of BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704271311; a=rsa-sha256; cv=none; b=y/fJjY2BGhuD+N4EegNETvkvvPHKYzT8n4izNGF1I9QR3NPR92GqDvBHcIqP57hJEJahHy gi3udYi4dT5BHoUbbTxw2QuJnlEcRLQAmaXi3iDgTJemzMN+3JQz7QbN8w9Djpcq1EACZU s/5+UFaAM3HrQ0PH4S/MK0oPyWT9BDI= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=lwuKokl9; spf=none (imf16.hostedemail.com: domain of BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+f852f126c6d693376302+7437+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704271311; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lo04JMqhsFGkQ8TlRgHQOmhRNZvE2v0cppmArCUs8rY=; b=mJbZ8xzdPg2BjoOi9097ixXd8LBCbWMrLzUKN/VVDjGAwSY0m9/aOENxBjqAjgcZ6hj1QD H2ubn9MLpr/A+bqafN/lEWTxvHeljdu5HDLv3ExUPRx2/IJUMBeJ+Kt0M/atJ/69jpZUzX CIsEeZPC5ya/sL4K4gwa6ZFCOUZFvkw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=lo04JMqhsFGkQ8TlRgHQOmhRNZvE2v0cppmArCUs8rY=; b=lwuKokl9u6QXkYesoWSmuTt3UM 28rIQJEb0WRqGFlb4Uvq1J6D6VRwtf7PQ0nPrU3NIuIp277ZHrHJ1PMbR0r/rU1GgTzu+NOeSFjzl fFdobPKyYC7J6D82wluQHy9jQcPXz9GG77j49J8FiiKSTtzLknJhoLprAerz59Y7zb+eJV52dGWvs G09csf6c7y1coPI9VcSuLeofiCD+iu8I9Zb2xlGSx/MfWcccYiTw7t0Cny0uaVK7wySSMEcVpMfXE Bp1Svfq81sdy0WIl5WUrUr0asyTG/+SZY/jGo8mKwa2NPojfx9cKBlYyC8pvz/y1x1XoyMFEYrdud Ja8t42fA==; Received: from [89.144.222.185] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rKwoq-00A6ZS-33; Wed, 03 Jan 2024 08:41:45 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" , Hugh Dickins , Andrew Morton Cc: linux-xfs@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 03/15] shmem: document how to "persist" data when using shmem_*file_setup Date: Wed, 3 Jan 2024 08:41:14 +0000 Message-Id: <20240103084126.513354-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240103084126.513354-1-hch@lst.de> References: <20240103084126.513354-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3A61518001C X-Stat-Signature: sm41pqebo87eppgbwcoujhx5tzcxg13g X-Rspam-User: X-HE-Tag: 1704271311-947593 X-HE-Meta: U2FsdGVkX18Lc6U1n6JQDGe65OHbsshpDTfAnRl/eQOcvgk0rrq27jhnX/bafk91Qld/CYJrLqgVrY9xFWBLju1dX+G2wve2UgFnasLjpEXEgPlst+IRsnTrzIBVPsnJdYU+Ic4W6/vNIqQpXLaegn9i6QEMUuk6LfUIZOKHuEdNujpSRhNEAm6O6DwynKD/9NwZ1Q66gN6Rb7aF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1OX5sh1y9+gVLc303zeXLZJt92VfX8IBHjpEeMjwWpUn2srEIKQLHk+UQldgIAkX4ovyJ7iAqYkCwcLeBClvtPIH1WLRtq52Pxt1i7MsNTFfwGEO75l14BbAq6G4rFoMwXQS8ykCpdABsGQ== 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: List-Subscribe: List-Unsubscribe: Add a blurb that simply dirtying the folio will persist data for in-kernel shmem files. This is what most of the callers already do. Signed-off-by: Christoph Hellwig --- mm/shmem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 328eb3dbea9f1c..235fac6dc53a0b 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2129,6 +2129,11 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * * Return: The found folio, %NULL if SGP_READ or SGP_NOALLOC was passed in @sgp * and no folio was found at @index, or an ERR_PTR() otherwise. + * + * If the caller modifies data in the returned folio, it must call + * folio_mark_dirty() on the locked folio before dropping the reference to + * ensure the folio is not reclaimed. Unlike for normal file systems there is + * no need to reserve space for users of shmem_*file_setup(). */ int shmem_get_folio(struct inode *inode, pgoff_t index, struct folio **foliop, enum sgp_type sgp)