From patchwork Fri Feb 9 14:29:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Gomez X-Patchwork-Id: 198931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp900260dyd; Fri, 9 Feb 2024 06:44:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXd0ytFH3bTSssk+5ITi5ltlfYV+sj3TR3ETCPe9jUw6XuVIZHXLaKW4VYu0iINZ8T29wfAB46XlfgLX0NadlkouRunag== X-Google-Smtp-Source: AGHT+IEaRSRd6tTk8dQiiWMf146aD0HEsTRTkwb2WFKBhfeWM814Yd0SBt6Alf7nrEY+5LUzXmKl X-Received: by 2002:a05:6e02:ee9:b0:363:d8dc:2a31 with SMTP id j9-20020a056e020ee900b00363d8dc2a31mr1986006ilk.14.1707489887813; Fri, 09 Feb 2024 06:44:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707489887; cv=pass; d=google.com; s=arc-20160816; b=wipCNej4cf7V8a2ykTJ24ctLnrQqVngIlT7zik2fT6jpEgwLCy9WxZGuhwJeG0H4c1 T2zgi9jsVmgCSwZur1sJUFT3HGoJuIMgEyV/AH31q1xmw6q9rhNYjrZP4Unt/yAOITlx mab6lTVr6Zx6HX5wQsUpsEKj9J1ElRQikYgmNA06RqEpslx58zP+S4H9GgeazsEA8nc3 md/74vefeVow69MmxMZ4kATARCX38/AYdUA1W9JbnONEpAgJSpXXeopeo4RRU+jtA4/n 2OSuaZeRlOcIhryfnsQFz+n5eHcTh2xA8mJxaR9bjUiLjBDA3338kIAiQy0i8oR+YlY2 lJ+g== 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=a88W1Bbg0jxB2ngLMkFDtFwflxkCFGav4/gOzgelMLM=; fh=YlqtYRcpf0j5NKNqzScupTwQ089wdLR6XPfkrPKdbvI=; b=G/FLieQ8bq7fGcWZE72ZK45oJwo+IPo0hF4DCOceM7vfmJhkl/L7aEuxmaqGcn3AU7 RTwWHI4b/jbcWjXMt0y6zrtGip34t5oUvlgoCHNTgXBUWP6fUuec9xzF/Ulzxm81LdUM x9xzwhDQmjTqmreOArfp68ljVs8gyLLsgV+T/JZdCwQv8PQxTDBhJIow+qLqnndrdsMF dSrdkkAKu/I+42oW8h3zwhQ+LITf5yXlTXCdsK3+XNAhdRAu5bVb1EnE8WiqdIWKtrvY b3amrxxc3XUdPge+xbvSDmtKEvvj00oqx1/9TqitMp5b2Mzn3ukPyn7LL4y5kgf/PGIh xQ3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tjFYJKAe; 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-59459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59459-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com X-Forwarded-Encrypted: i=2; AJvYcCVKyXKmzBk3VPnpyTvXFmlyBWZIgSyUOjpl3HdI/cyjHLdNTwxpCWGzb8xCXH6QsYYHLYB+YTN4R4zj94dMAvJ/eNH0Yg== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cb18-20020a056a02071200b005c5e24d4364si1923150pgb.428.2024.02.09.06.44.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 06:44:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tjFYJKAe; 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-59459-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59459-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 1968BB27457 for ; Fri, 9 Feb 2024 14:32:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A46E762DC; Fri, 9 Feb 2024 14:29:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="tjFYJKAe" 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 8C0BB69DFF for ; Fri, 9 Feb 2024 14:29:11 +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=1707488953; cv=none; b=Ssd2KTZoa3UHA/jg8ORIXL7z1Z5G3eMxY9MYWCkMygromumSliZqw/nihQB7q2Rl1RfERuaf+GAz1okE/cQ6vkY/JsogDGAh32bBoFYG3q4/d8VfsFITjZ/p3DeGZEFmzFOTesnu6sELFectAY/e9dRBtYIb2N92RmN2L41+Z6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707488953; c=relaxed/simple; bh=8CpVZl2bJx8NP6Riuz2Y+yedCiDF5mfz2vl6gbJDV5I=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:Content-Type: MIME-Version:References; b=EBe7BGpfHX13qAhW2CiWd4vqco8dKA2m0c0kYoEVFyB+2n7rWBNWGq2VWpxvgSUfUMGpzExMbk2wZRjs7R+buovM6Mg9O1XaxzzQNgdAAHEwSk9JyJbvtqPqp9K7BBSuAxQY+XeBK+OP/IY8F+BW1G6H/0VN7CsY60w4jPkdqp4= 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=tjFYJKAe; 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 20240209142908euoutp017d8614aa37188ed7b24f3fafa37562f2~yOCbnh6ME2778527785euoutp01j for ; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20240209142908euoutp017d8614aa37188ed7b24f3fafa37562f2~yOCbnh6ME2778527785euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1707488948; bh=a88W1Bbg0jxB2ngLMkFDtFwflxkCFGav4/gOzgelMLM=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=tjFYJKAebkiJIwpM50vhlXOLbPn0zREBKWRH/LD5cD5jan0ZiYFAg0HXrgf2WLmT+ 4J0RCX0UfX9sCyYkie2JirnYLxF74XihbO/qQ6de9Qxb5XZ4yxE+zw+c0hn6j4HAxs ASETTTjD5AfGyHF8E0CxWzVIEW020EKZorD5gM1E= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20240209142908eucas1p16a6b31632e8d9865f952e959c973c8e5~yOCbPMlkz0281802818eucas1p1s; Fri, 9 Feb 2024 14:29:08 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id B6.0E.09539.3B636C56; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2~yOCatdJaJ2253522535eucas1p2p; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20240209142907eusmtrp11d733555d1468f5959c30cb5a5a11e05~yOCasoSCp0528405284eusmtrp1H; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) X-AuditID: cbfec7f2-52bff70000002543-1c-65c636b3da7b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F5.B3.10702.3B636C56; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (unknown [106.1.227.72]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20240209142907eusmtip1170d8fecd9e85f89a441b27f26df0489~yOCaisoha0140701407eusmtip1F; Fri, 9 Feb 2024 14:29:07 +0000 (GMT) Received: from CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) by CAMSVWEXC02.scsc.local (2002:6a01:e348::6a01:e348) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 9 Feb 2024 14:29:06 +0000 Received: from CAMSVWEXC02.scsc.local ([::1]) by CAMSVWEXC02.scsc.local ([fe80::3c08:6c51:fa0a:6384%13]) with mapi id 15.00.1497.012; Fri, 9 Feb 2024 14:29:06 +0000 From: Daniel Gomez To: "viro@zeniv.linux.org.uk" , "brauner@kernel.org" , "jack@suse.cz" , "hughd@google.com" , "akpm@linux-foundation.org" CC: "dagmcr@gmail.com" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , "willy@infradead.org" , "hch@infradead.org" , "mcgrof@kernel.org" , Pankaj Raghav , "gost.dev@samsung.com" , Daniel Gomez Subject: [RFC PATCH 8/9] shmem: clear uptodate blocks after PUNCH_HOLE Thread-Topic: [RFC PATCH 8/9] shmem: clear uptodate blocks after PUNCH_HOLE Thread-Index: AQHaW2RVqhumUoqlFUi8PRO0fiHHFQ== Date: Fri, 9 Feb 2024 14:29:04 +0000 Message-ID: <20240209142901.126894-9-da.gomez@samsung.com> In-Reply-To: <20240209142901.126894-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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJKsWRmVeSWpSXmKPExsWy7djPc7qbzY6lGnhYzFm/hs3i9eFPjBZn +36zWZyesIjJ4umnPhaL2dObmSz27D3JYnF51xw2i3tr/rNa3JjwlNHi/N/jrBa/f8xhc+Dx 2DnrLrvHgk2lHptXaHlsWtXJ5rHp0yR2jxMzfrN4nFlwhN3j8yY5j01P3jIFcEZx2aSk5mSW pRbp2yVwZZz/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q0Cq02mSuejtbv6tLf++laUosxRmJhlrMRcWJABo8BnvZAwAA X-CMS-MailID: 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2 X-Msg-Generator: CA X-RootMTR: 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20240209142907eucas1p2c61ae37b2a1ca2caeccc48b2169226f2 References: <20240209142901.126894-1-da.gomez@samsung.com> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790432916810500375 X-GMAIL-MSGID: 1790432916810500375 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 2d2eeb40f19b..2157a87b2e4b 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); } +static void sfs_clear_range_uptodate(struct folio *folio, + struct shmem_folio_state *sfs, size_t off, + size_t len) +{ + struct inode *inode = folio->mapping->host; + unsigned int first_blk, last_blk; + unsigned long flags; + + first_blk = DIV_ROUND_UP_ULL(off, 1 << inode->i_blkbits); + last_blk = DIV_ROUND_DOWN_ULL(off + len, 1 << inode->i_blkbits) - 1; + if (last_blk == 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 *folio, 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 = 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; } +static void shmem_clear(struct folio *folio, loff_t start, loff_t end, int mode) +{ + loff_t pos = folio_pos(folio); + unsigned int offset, length; + + if (!(mode & FALLOC_FL_PUNCH_HOLE) || !(folio_test_large(folio))) + return; + + if (pos < start) + offset = start - pos; + else + offset = 0; + length = folio_size(folio); + if (pos + length <= (u64)end) + length = length - offset; + else + length = 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 fallocate. */ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, - bool unfalloc) + bool unfalloc, int mode) { struct address_space *mapping = inode->i_mapping; struct shmem_inode_info *info = SHMEM_I(inode); @@ -1166,6 +1222,7 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, if (folio) { same_folio = 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 = folio_next_index(folio); if (same_folio) @@ -1255,9 +1312,17 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, shmem_recalc_inode(inode, 0, -nr_swaps_freed); } +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); } @@ -3315,7 +3380,7 @@ static long shmem_fallocate(struct file *file, int mode, 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 */ spin_lock(&inode->i_lock); @@ -3381,9 +3446,10 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, info->fallocend = 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; }