From patchwork Fri Jan 26 13:28:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13532570 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 B9C61C47422 for ; Fri, 26 Jan 2024 13:29:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 538806B0087; Fri, 26 Jan 2024 08:29:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E8F76B0088; Fri, 26 Jan 2024 08:29:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D8466B0089; Fri, 26 Jan 2024 08:29:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2F8C06B0087 for ; Fri, 26 Jan 2024 08:29:36 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EF2B1160F35 for ; Fri, 26 Jan 2024 13:29:35 +0000 (UTC) X-FDA: 81721544310.25.9429656 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id 3EECC16001F for ; Fri, 26 Jan 2024 13:29:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=hBXzXlpS; spf=none (imf08.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+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=1706275774; 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=1ZlI1ZeOEvNmLW1NU66Umna2PQgDHzmJWRjfo1IHrxA=; b=EgctxG2trBydsmRoS6fdUScK5dYDHfG+aYifo15N/BDg19gUndjD/sQYmEXVc2Q8vcZrQp QYOL1JYyegq099IBCmUNd6jWJsZUn+lE1mwUNfba9VkBkjj+tXTGQ9DtQuxqQs0nF/no1d wigReGq3vs6ITp9ZG/Ag54GVRSzATA0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=hBXzXlpS; spf=none (imf08.hostedemail.com: domain of BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+8230b42af99c397292d7+7460+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706275774; a=rsa-sha256; cv=none; b=osfsC1qtiaD3yaPtCa9UsmJPAZKtAF8TOpO+Ns6AaZUfAwQD0A+muLX9/9CGjDHs1U7W8A 5V24R6+x6s9BS3sQr3GyLeoktCxVeCh8BsGY2G0rE5sLxusBrAIKG8FIy6c8ExzWQrRCK+ OHNgJ954ftljLkFFOMKExUyntF41f3s= 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=1ZlI1ZeOEvNmLW1NU66Umna2PQgDHzmJWRjfo1IHrxA=; b=hBXzXlpSNVfwODPh0iAWHy5XE2 Hfntstaa47+3zsTC9HXLiMvZQcVj6O03twOhOK6sB6yQ7L8H+JIabfU+ALOLsBbqYrQInmBVtRjOZ 0gVY/MvRjLVuwMcxSmb/QApth1Ze7qjV6wJ3ZU1ocbv5cwpC8Evwz1nU+3qN9oA6LHrW/pwrfJK3v Fnhb8fbzAT60tCdce84FedQ5jOY1+4PaTrQMI7jP1eNgExBD6hAMRNcy7ICC2YoWmoN0HudxwXuG+ P0eBnPJT2yNlX3nu9wwNPpscRVLswTIpaKDPw6x0ZZM/DpKawySlvRxz+oP5AsEts6ZY0fM9dYgB1 zParwbug==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rTMGx-00000004Chj-2hTj; Fri, 26 Jan 2024 13:29:32 +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 07/21] shmem: document how to "persist" data when using shmem_*file_setup Date: Fri, 26 Jan 2024 14:28:49 +0100 Message-Id: <20240126132903.2700077-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240126132903.2700077-1-hch@lst.de> References: <20240126132903.2700077-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-Queue-Id: 3EECC16001F X-Rspam-User: X-Stat-Signature: q9rmrh1uo6fngnyqng4yyu7bkf9pke8e X-Rspamd-Server: rspam01 X-HE-Tag: 1706275773-96682 X-HE-Meta: U2FsdGVkX19FTEDvdvA6NlMNX18xg0GbQQ7YPRUFDoK93gzKI2QnWuyHlGbp0/l3cwYGRV8ebaWX2AqZpm3geUwhsleeMv9hKHapNQX6ijWLFjhexL5xwjhQ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kFlH8P0YkqrB2GRV76siJ2CPM8M/eq0D5oOjzwyib/ypUseipoTfncIvLqy8mbrh2XTh6xi0MarpR0O4wAztGaIXjwTV8b/c8KZ5QALKh/oIybVdRaKBY9/f/Qdnq44EBVsIyWKfkQQs8RdV/go986KtSzxX9fL5bNW1meHjPeS27x2SAp+z2q8HYJCa4I/4h25njcAN8rHr7MjRbt3+xx+BodCioLD3uCoN14tPg2Us2LDefqZcghlCgAxQz2INBra8C6M+oujU3KybGR0dlHvhuX5q2VjoNmWFt2M= 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 Reviewed-by: Darrick J. Wong --- mm/shmem.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index e89fb5eccb0c0a..f7d6848fb294d6 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2150,6 +2150,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)