Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp3110838lqo; Tue, 14 May 2024 22:59:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVwg6kY86+Vxpst3ZCC3ycTLNZHPtr5/TkRvCWbqGYDhcK5P26EsOptK9l8h95V4um/7ONYaxDXNORyWfntXrXuc+zsX9FaLwWHfzIdAg== X-Google-Smtp-Source: AGHT+IGbsrA5hIpHfZsrIBCo2eE6LVUOJZO94f2rKYuQ1eexyyrxcLdDiAzpKMnqg12PfP90PGUn X-Received: by 2002:a05:620a:4623:b0:792:e88e:f7b1 with SMTP id af79cd13be357-792e88ef8b4mr660850685a.51.1715752762612; Tue, 14 May 2024 22:59:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715752762; cv=pass; d=google.com; s=arc-20160816; b=CZWmWfbFLXqnk+AiQL1jG0zazsOUaSiJG8LnLdll9ydCPSSWdZCWYG4FpH56T2XEHb hae8G3f1lmVAn8fDol3VWAMvebOYtezL3D7dWHYAN4MBhtzwg+SYNvN5GSLLSOCc4wMk K61zyBHyuVXtfnxeOsEcMBfjjWwxISCwLdyIMRAbfE7z88jAsYLA/UeNajdi/XIYsli5 KqQ5GtNL/mC3zmbgAjTHFmzu0ijy7TJOGOp2nE1tutwi/svalPuwEMOSsTWtkJpVteqG anYOjJwrHkCeJ5bdGMsiDXizfyGD7KEjG6ubNfmnfqU/ta63RT1OAS/g/ogNcnJwFnpP MQYQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:cms-type:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:content-transfer-encoding:content-language :accept-language:in-reply-to:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature:dkim-filter; bh=Yzf34yJLjjOZ5L6S/TOvcg7MvQWva+m/QvkKTJ1hVb4=; fh=boE2T1tfXWhPiAXKUEd+pJodvJpwHMz3xvNd2cVdM48=; b=sHKmEdfMAfh73gy8NqIpW6CNaO81RjwkZJEN8NNBWEJTKQVnamjBfbAGCL+PsjZ1/6 aKgtWvgUqNJo98SgTH9EBBBlJcLHjXdb5U7LF/QruOc5pneSM7X70qdUCA7vkcPAyPfH hXI/EzWOxUXybdKCUXVDqiWMfU9RjZT7YEqpx6xA/J+1iI8iEFZ/PR2H6m8bS1+VtzK3 YbQkYBrxhqgf71GlRmmGOQ1fePj2uEcIpJXfWcq2yAds6YNonhA9RQLUAUDSmkSnkW98 txXImRz4fdaE9Lziapl2DSZCkomRPb8wIv2mmDvItUbgSOwylx4oaSYOKPAKU4SwhhCU Be4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="kKiv/K/0"; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-179490-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179490-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792d0f9e325si864587785a.230.2024.05.14.22.59.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 22:59:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179490-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b="kKiv/K/0"; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-179490-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179490-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 3A5E81C21DE3 for ; Wed, 15 May 2024 05:59:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA25A4AECA; Wed, 15 May 2024 05:57:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="kKiv/K/0" Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF8F43D57D for ; Wed, 15 May 2024 05:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.118.77.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752657; cv=none; b=RuRW+W+TLlGKsmM1esW4VSGH0aprM0BGTNWqtxc6bemJFBzyBtXQIvn6ofVg/x5KFXGWz6RxkNEafEuTozQAGqEjisLi+xlPJEWKWFfG30Hp92LU8WiGHAHi3ckZFZxA/6qWtyC/IN4ipYOffKi2tUwqnzLZoH0zCBtprml0xCw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715752657; c=relaxed/simple; bh=ctPb7XxM+TWxPhd3Fu6+Fa+0hskhZ7PD8nkromhva34=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=LuFdUXFO2z/eyQcGVo6oAXNZtTEQUi78rnzlbz64kqsjU4bG3c/67nQNsSxO3C9LjMmzI6oyL9nbHbI/EJ3Rj1EHAln2oVuXmSmzPxGRLRQAIFsGkzhjr0+Uv9l6Ta3aSvSmL/KEBkoFGYu1nr9p7i1qTt47AL8gSyWjukgD1AE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=kKiv/K/0; arc=none smtp.client-ip=210.118.77.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20240515055734euoutp013044dcfeb0aa942b804ec9aa2a47741f~Pk-LLGPIe1531815318euoutp01G for ; Wed, 15 May 2024 05:57:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240515055734euoutp013044dcfeb0aa942b804ec9aa2a47741f~Pk-LLGPIe1531815318euoutp01G DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1715752654; bh=Yzf34yJLjjOZ5L6S/TOvcg7MvQWva+m/QvkKTJ1hVb4=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=kKiv/K/0A8lf09vqiaIlDRS+gML5VtHlI2Q7RrAPMGRgI+49KSIhBA+ip3dV2J9Fz zsXZ9z/AXfGOPn/puBP6qb4iY8y+Z7Kir1jke0oh1ezzjLcJqzMhbN4drL/MHLvsUl MxraXULuMzNCaydYXN/bliQ0l4wfGqBZmBlUbQZ8= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20240515055733eucas1p2a521a9e0623f0531a8272ecfb655f5b7~Pk-K2bw-B0810008100eucas1p2S; Wed, 15 May 2024 05:57:33 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id FC.BC.09624.DCE44466; Wed, 15 May 2024 06:57:33 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240515055733eucas1p2804d2fb5f5bf7d6adb460054f6e9f4d8~Pk-KcM6iH1245212452eucas1p2C; Wed, 15 May 2024 05:57:33 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240515055733eusmtrp129539bea3fb8883a5d82c38a09701dcf~Pk-Kbl7An0411404114eusmtrp1B; Wed, 15 May 2024 05:57:33 +0000 (GMT) X-AuditID: cbfec7f2-bfbff70000002598-5c-66444ecd6288 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id FB.F1.09010.DCE44466; Wed, 15 May 2024 06:57:33 +0100 (BST) Received: from CAMSVWEXC01.scsc.local (unknown [106.1.227.71]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240515055733eusmtip1aa61160f14684c57a464d66ecebdd55b~Pk-KOVfKq0235902359eusmtip1T; Wed, 15 May 2024 05:57:33 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC01.scsc.local (2002:6a01:e347::6a01:e347) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 15 May 2024 06:57:32 +0100 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Wed, 15 May 2024 06:57:32 +0100 From: Daniel Gomez To: "hughd@google.com" , "akpm@linux-foundation.org" , "willy@infradead.org" , "jack@suse.cz" , "mcgrof@kernel.org" CC: "linux-mm@kvack.org" , "linux-xfs@vger.kernel.org" , "djwong@kernel.org" , "Pankaj Raghav" , "dagmcr@gmail.com" , "yosryahmed@google.com" , "baolin.wang@linux.alibaba.com" , "ritesh.list@gmail.com" , "lsf-pc@lists.linux-foundation.org" , "david@redhat.com" , "chandan.babu@oracle.com" , "linux-kernel@vger.kernel.org" , "brauner@kernel.org" , Daniel Gomez Subject: [PATCH 08/12] shmem: clear uptodate blocks after PUNCH_HOLE Thread-Topic: [PATCH 08/12] shmem: clear uptodate blocks after PUNCH_HOLE Thread-Index: AQHapozGSURBX17ZzUyZscS7mtN1hQ== Date: Wed, 15 May 2024 05:57:32 +0000 Message-ID: <20240515055719.32577-9-da.gomez@samsung.com> In-Reply-To: <20240515055719.32577-1-da.gomez@samsung.com> Accept-Language: en-US, en-GB Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEKsWRmVeSWpSXmKPExsWy7djPc7pn/VzSDH6/UbaYs34Nm8X/vccY LV4f/sRocemonMXZvt9sFl/X/2K2uPyEz+Lppz4Wi9nTm5ksLu+aw2Zxb81/Votdf3awW+x7 vZfZ4saEp4wWB091sFv8/gGU3b4r0kHQY+esu+weCzaVemxeoeWxaVUnm8emT5PYPU7M+M3i sfOhpcfkG8sZPT4+vcXi8X7fVTaPMwuOsHt83iQXwBPFZZOSmpNZllqkb5fAldHeuJG14Kh6 xb+jrYwNjB/kuxg5OSQETCRebWtj6WLk4hASWMEoMelDOztIQkjgC6PEtGWGEPZnRomZW7Jg Ghp/zmGCaFjOKLF4YgMjhANU9O36HTYI5wyjxIMzJ1khnJWMEjOOv2AB6WcT0JTYd3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6e9f4d8 X-Msg-Generator: CA X-RootMTR: 20240515055733eucas1p2804d2fb5f5bf7d6adb460054f6e9f4d8 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240515055733eucas1p2804d2fb5f5bf7d6adb460054f6e9f4d8 References: <20240515055719.32577-1-da.gomez@samsung.com> In the fallocate path with PUNCH_HOLE mode flag enabled, clear the uptodate flag for those blocks covered by the punch. Skip all partial blocks as they may still contain data. Signed-off-by: Daniel Gomez --- mm/shmem.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 6 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index e06cb6438ef8..d5e6c8eba983 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -209,6 +209,28 @@ static void sfs_set_range_uptodate(struct folio *folio= , spin_unlock_irqrestore(&sfs->state_lock, flags); } =20 +static void sfs_clear_range_uptodate(struct folio *folio, + struct shmem_folio_state *sfs, size_t off, + size_t len) +{ + struct inode *inode =3D folio->mapping->host; + unsigned int first_blk, last_blk; + unsigned long flags; + + first_blk =3D DIV_ROUND_UP_ULL(off, 1 << inode->i_blkbits); + last_blk =3D DIV_ROUND_DOWN_ULL(off + len, 1 << inode->i_blkbits) - 1; + if (last_blk =3D=3D UINT_MAX) + return; + + if (first_blk > last_blk) + return; + + spin_lock_irqsave(&sfs->state_lock, flags); + bitmap_clear(sfs->state, first_blk, last_blk - first_blk + 1); + folio_clear_uptodate(folio); + spin_unlock_irqrestore(&sfs->state_lock, flags); +} + static struct shmem_folio_state *sfs_alloc(struct inode *inode, struct folio *folio) { @@ -276,6 +298,19 @@ static void shmem_set_range_uptodate(struct folio *fol= io, size_t off, else folio_mark_uptodate(folio); } + +static void shmem_clear_range_uptodate(struct folio *folio, size_t off, + size_t len) +{ + struct shmem_folio_state *sfs =3D folio->private; + + if (sfs) + sfs_clear_range_uptodate(folio, sfs, off, len); + else + folio_clear_uptodate(folio); + +} + #ifdef CONFIG_TMPFS static unsigned long shmem_default_max_blocks(void) { @@ -1103,12 +1138,33 @@ static struct folio *shmem_get_partial_folio(struct= inode *inode, pgoff_t index) return folio; } =20 +static void shmem_clear(struct folio *folio, loff_t start, loff_t end, int= mode) +{ + loff_t pos =3D folio_pos(folio); + unsigned int offset, length; + + if (!(mode & FALLOC_FL_PUNCH_HOLE) || !(folio_test_large(folio))) + return; + + if (pos < start) + offset =3D start - pos; + else + offset =3D 0; + length =3D folio_size(folio); + if (pos + length <=3D (u64)end) + length =3D length - offset; + else + length =3D end + 1 - pos - offset; + + shmem_clear_range_uptodate(folio, offset, length); +} + /* * Remove range of pages and swap entries from page cache, and free them. * If !unfalloc, truncate or punch hole; if unfalloc, undo failed fallocat= e. */ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t le= nd, - bool unfalloc) + bool unfalloc, int mode) { struct address_space *mapping =3D inode->i_mapping; struct shmem_inode_info *info =3D SHMEM_I(inode); @@ -1166,6 +1222,7 @@ static void shmem_undo_range(struct inode *inode, lof= f_t lstart, loff_t lend, if (folio) { same_folio =3D lend < folio_pos(folio) + folio_size(folio); folio_mark_dirty(folio); + shmem_clear(folio, lstart, lend, mode); if (!truncate_inode_partial_folio(folio, lstart, lend)) { start =3D folio_next_index(folio); if (same_folio) @@ -1255,9 +1312,17 @@ static void shmem_undo_range(struct inode *inode, lo= ff_t lstart, loff_t lend, shmem_recalc_inode(inode, 0, -nr_swaps_freed); } =20 +static void shmem_truncate_range_mode(struct inode *inode, loff_t lstart, + loff_t lend, int mode) +{ + shmem_undo_range(inode, lstart, lend, false, mode); + inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); + inode_inc_iversion(inode); +} + void shmem_truncate_range(struct inode *inode, loff_t lstart, loff_t lend) { - shmem_undo_range(inode, lstart, lend, false); + shmem_undo_range(inode, lstart, lend, false, 0); inode_set_mtime_to_ts(inode, inode_set_ctime_current(inode)); inode_inc_iversion(inode); } @@ -3342,7 +3407,7 @@ static long shmem_fallocate(struct file *file, int mo= de, loff_t offset, if ((u64)unmap_end > (u64)unmap_start) unmap_mapping_range(mapping, unmap_start, 1 + unmap_end - unmap_start, 0); - shmem_truncate_range(inode, offset, offset + len - 1); + shmem_truncate_range_mode(inode, offset, offset + len - 1, mode); /* No need to unmap again: hole-punching leaves COWed pages */ =20 spin_lock(&inode->i_lock); @@ -3408,9 +3473,10 @@ static long shmem_fallocate(struct file *file, int m= ode, loff_t offset, info->fallocend =3D undo_fallocend; /* Remove the !uptodate folios we added */ if (index > start) { - shmem_undo_range(inode, - (loff_t)start << PAGE_SHIFT, - ((loff_t)index << PAGE_SHIFT) - 1, true); + shmem_undo_range( + inode, (loff_t)start << PAGE_SHIFT, + ((loff_t)index << PAGE_SHIFT) - 1, true, + 0); } goto undone; } --=20 2.43.0