From patchwork Mon Jan 29 14:34: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: 13535765 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 35D7EC47DDB for ; Mon, 29 Jan 2024 14:35:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A3426B00A7; Mon, 29 Jan 2024 09:35:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7B4A46B00A8; Mon, 29 Jan 2024 09:35:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B84A6B00AA; Mon, 29 Jan 2024 09:35:35 -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 39D5A6B00A7 for ; Mon, 29 Jan 2024 09:35:35 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 1F9B140A48 for ; Mon, 29 Jan 2024 14:35:35 +0000 (UTC) X-FDA: 81732597030.08.4ED6CD6 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id 51D6916001F for ; Mon, 29 Jan 2024 14:35:33 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="NAc8SZQ/"; spf=none (imf08.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+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=1706538933; 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=5+G//0oCp4joBCMNmSMB9VbToHmHFLOf7sf0e46phAg=; b=3IPU3mdtxh0neT3CcKkICCWbXgloLa8P71wD5Vk2ujtQ0vaGYcIMAX5XIgDcvO2uko41MO 0gipjFiAW6agZDRiFTglGciNgcRlS2BBd8kit/8mTK//9HYKyGmx3uxQFIkv90Soq4qiod UxFPcRokBds1UJ7kfwDH3wuCaGIjrFY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706538933; a=rsa-sha256; cv=none; b=XEM5daIKV0EYl6b3FvxPgaTaTIbkmCHFTV8r1wwVz3EtHtaSIhsrkH3NxS0P5XPPRfy5D3 ia3gYeKwASo1n00FKRcdKKPNjwVRMH+UFc1HmGrYGt0PD/W7Q/uFFtA6Xj3QnTGZKuSD/q CWlDiltmg5OZfABHoPZw1EwvxheVMF0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b="NAc8SZQ/"; spf=none (imf08.hostedemail.com: domain of BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+95c35c30fd22f84c25d9+7463+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=5+G//0oCp4joBCMNmSMB9VbToHmHFLOf7sf0e46phAg=; b=NAc8SZQ/n7VJjolfOO3ePhisGj W70pOrthIiUlTiGlJCc2choYOwhhXwIshN0f7q4Z4noncpkTT00521IukXLRtVMT6myqdaAOTkG4d 10CzhEmZfzz6BSkWaZEoMpd7QtKZ4zNHLWiwHygIzzTj455ggTnkJVLHSyopIoiEzUYwm+ozPYih0 1Gy3I5e0OYzhajFy+sG7wgnZ48jemInmyzfozXbJYILhbxo3dQUz0gSwrqflOPt7ez6HoC/AhekC9 KHM8nm/Zs4nAGzT+dIAZumEbinj3Okbq0UKD2t2BWIxHhzQR4S/8ZfJsSREftO0p+Ou3ZVmdVwJse r9wxbILA==; Received: from [2001:4bb8:182:6550:c70:4a89:bc61:3] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUSjS-0000000D6D0-2Gci; Mon, 29 Jan 2024 14:35:31 +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/20] shmem: document how to "persist" data when using shmem_*file_setup Date: Mon, 29 Jan 2024 15:34:49 +0100 Message-Id: <20240129143502.189370-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240129143502.189370-1-hch@lst.de> References: <20240129143502.189370-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: 51D6916001F X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ksbywq9163gue1xukcp5osuktngqta75 X-HE-Tag: 1706538933-885704 X-HE-Meta: U2FsdGVkX19Y/NkaSGkJH851e3/WkMGU3vwoWUMblXRcdp7hmEKxokwBumNLD9vbya1/KRWVt/fOcR38TxCy2JRyONxYjhu3xWhwdcl2DPezgnOmyqXYsuv7an6twQ8ybRveAh2YeJ2C+9Nedf467nu9jc05NFe1jrT1LCW2t4IYNdso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NBuJRpO0OOXaJUvh7Oxe+p/Gv9FpnoqYvHdHt4Djm44hmuJ+3LthNf9m1HuCRRAJiGZUUQHfH7GHN3bdKg046CWXUF7VH5F+nmzYOvWAxE/BiK+vn7NUhgl31K6RcGXSni4TWqVUnNRQWvogcZK0wu7+rBiYbVStQN1f9L7wt/q+qen8ri1T+Ksmg8BrO/SAbP1HyFoqYuDdzR2121ir7XsEm40L3Rw8UjafPkLGwuOG+wc2sxoVyHZJq4Iz1mwxM= 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 Reviewed-by: Matthew Wilcox (Oracle) --- mm/shmem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index e89fb5eccb0c0a..f73dead491b11d 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2148,6 +2148,10 @@ static int shmem_get_folio_gfp(struct inode *inode, pgoff_t index, * * If this function returns a folio, it is returned with an increased refcount. * + * If the caller modifies data in the folio, it must call folio_mark_dirty() + * before unlocking the folio to ensure that the folio is not reclaimed. + * These is no need to reserve space before calling folio_mark_dirty(). + * * 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. */