From mboxrd@z Thu Jan 1 00:00:00 1970 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 91174C3DA4A for ; Mon, 19 Aug 2024 16:39:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E95606B007B; Mon, 19 Aug 2024 12:39:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E44BA6B0082; Mon, 19 Aug 2024 12:39:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D0BC46B0088; Mon, 19 Aug 2024 12:39:53 -0400 (EDT) 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 B479C6B007B for ; Mon, 19 Aug 2024 12:39:53 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id EBEDD121491 for ; Mon, 19 Aug 2024 16:39:52 +0000 (UTC) X-FDA: 82469556624.19.E775362 Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) by imf26.hostedemail.com (Postfix) with ESMTP id 8DC1A140024 for ; Mon, 19 Aug 2024 16:39:50 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=he7M3R6G; spf=pass (imf26.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724085514; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zHZf6l7SvG4/hCJDbBwd8yZbMsE33hc0REoLdH7Jm04=; b=e0Pnyb1z5g5TcTclzL0LzBq3z6Kr2DI8IPVsRsVhzDf7jEN3OOpiRY0e2q4/cpoYWsjpCL 5KvmUF2kbE+Ujd41giLQcD0t+lNWULwj9OaE+/JouV+89wFkU1SRza4cASDdgwOLjsdb2t d/asdUTU8oCephMGue7O451UxiYM544= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724085514; a=rsa-sha256; cv=none; b=RfyETWMaD6t0Xvm9N8Kg3I7PIvO0NUwCCuLdY7WFeZlsagwpJ9Mkk15jQjQKcn3dWDdK3B A1AecpXS4BOCI/VMxFJLPBVP0Ai+gtznNRRuMl4F5QhxUN+/dkSz04i+lyE5P+XteUteZf AU5ckcEmCJZxzSME182FjGgzs9q7RDY= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=he7M3R6G; spf=pass (imf26.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.161 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4Wndc12bHsz9sjQ; Mon, 19 Aug 2024 18:39:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1724085585; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=zHZf6l7SvG4/hCJDbBwd8yZbMsE33hc0REoLdH7Jm04=; b=he7M3R6GWXkRiOlZobuMtaxrzuauIaRakC1efjnTxmG7tLGplbnh/x+KKh1VeGhIHLQqpe SyypPhTNXZ1QdIPnxrQTOWfLI3BKLYHdQGvmhcIIIMcKmLefNdrlDGFU22PfT5ZqEHDfJO u58h65RHaIDkizoqDgi0RTKgB2de5uACJQUj4wo0ocWpe7WHZuuETB1d16AebMCpwLJgCO B3bhlfrFe2d+BVImcm8m5eefM2dshMT2FZx61L3s8zxOxcEV7tD9cGoGgjE2sPnic4+jei he4Us/5cFvayLVzHw1BSCoprOTIhamRvxac1cQMqqfhB7H6N2x2l11U6qvfQ9w== Date: Mon, 19 Aug 2024 16:39:38 +0000 From: "Pankaj Raghav (Samsung)" To: David Howells Cc: brauner@kernel.org, akpm@linux-foundation.org, chandan.babu@oracle.com, linux-fsdevel@vger.kernel.org, djwong@kernel.org, hare@suse.de, gost.dev@samsung.com, linux-xfs@vger.kernel.org, hch@lst.de, david@fromorbit.com, Zi Yan , yang@os.amperecomputing.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, willy@infradead.org, john.g.garry@oracle.com, cl@os.amperecomputing.com, p.raghav@samsung.com, mcgrof@kernel.org, ryan.roberts@arm.com Subject: Re: [PATCH v12 00/10] enable bs > ps in XFS Message-ID: <20240819163938.qtsloyko67cqrmb6@quentin> References: <20240818165124.7jrop5sgtv5pjd3g@quentin> <20240815090849.972355-1-kernel@pankajraghav.com> <2924797.1723836663@warthog.procyon.org.uk> <3402933.1724068015@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3402933.1724068015@warthog.procyon.org.uk> X-Rspamd-Queue-Id: 8DC1A140024 X-Stat-Signature: 3e7zz31184p5f5riwbmyuborhk4h5rjc X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724085590-257833 X-HE-Meta: U2FsdGVkX181q9TUPLL4/ex9tBCWCjvsxzrY/EZDWbpuKa9dyakAA4PgZ1jrYC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j5I/jZqAmlU1C0kwvNajs1oAqJ43g65trFiEXAPlO4JcC5QDPDeKsKSfSxh79OgiF4231AaVWH3zVgkNJzUrE2yk 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: > --- > /* Distillation of the generic/393 xfstest */ > #include > #include > #include > #include > > #define ERR(x, y) do { if ((long)(x) == -1) { perror(y); exit(1); } } while(0) > > static const char xxx[40] = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; > static const char yyy[40] = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"; > static const char dropfile[] = "/proc/sys/vm/drop_caches"; > static const char droptype[] = "3"; > static const char file[] = "/xfstest.test/wubble"; > > int main(int argc, char *argv[]) > { > int fd, drop; > > /* Fill in the second 8K block of the file... */ > fd = open(file, O_CREAT|O_TRUNC|O_WRONLY, 0666); > ERR(fd, "open"); > ERR(ftruncate(fd, 0), "pre-trunc $file"); > ERR(pwrite(fd, yyy, sizeof(yyy), 0x2000), "write-2000"); > ERR(close(fd), "close"); > > /* ... and drop the pagecache so that we get a streaming > * write, attaching some private data to the folio. > */ > drop = open(dropfile, O_WRONLY); > ERR(drop, dropfile); > ERR(write(drop, droptype, sizeof(droptype) - 1), "write-drop"); > ERR(close(drop), "close-drop"); > > fd = open(file, O_WRONLY, 0666); > ERR(fd, "reopen"); > /* Make a streaming write on the first 8K block (needs O_WRONLY). */ > ERR(pwrite(fd, xxx, sizeof(xxx), 0), "write-0"); > /* Now use truncate to shrink and reexpand. */ > ERR(ftruncate(fd, 4), "trunc-4"); > ERR(ftruncate(fd, 4096), "trunc-4096"); > ERR(close(fd), "close-2"); > exit(0); > } I tried this code on XFS, and it is working as expected (I am getting xxxx). [nix-shell:~/xfstests]# hexdump -C /media/test/wubble 00000000 78 78 78 78 00 00 00 00 00 00 00 00 00 00 00 00 |xxxx............| 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * 00001000 I did some tracing as well and here are the results. $ trace-cmd record -e xfs_file_fsync -e xfs_file_buffered_write -e xfs_setattr -e xfs_zero_eof -F -c ./a.out [nix-shell:~/xfstests]# trace-cmd report cpus=4 a.out-3872 [003] 84120.161472: xfs_setattr: dev 259:0 ino 0x103 iflags 0x0 a.out-3872 [003] 84120.172109: xfs_setattr: dev 259:0 ino 0x103 iflags 0x20 a.out-3872 [003] 84120.172151: xfs_zero_eof: dev 259:0 ino 0x103 isize 0x0 disize 0x0 pos 0x0 bytecount 0x2000 // First truncate a.out-3872 [003] 84120.172156: xfs_file_buffered_write: dev 259:0 ino 0x103 disize 0x0 pos 0x2000 bytecount 0x28 a.out-3872 [003] 84120.185423: xfs_file_buffered_write: dev 259:0 ino 0x103 disize 0x2028 pos 0x0 bytecount 0x28 a.out-3872 [003] 84120.185477: xfs_setattr: dev 259:0 ino 0x103 iflags 0x0 a.out-3872 [003] 84120.186493: xfs_setattr: dev 259:0 ino 0x103 iflags 0x20 a.out-3872 [003] 84120.186495: xfs_zero_eof: dev 259:0 ino 0x103 isize 0x4 disize 0x4 pos 0x4 bytecount 0xffc // Third truncate First and third truncate result in calling xfs_zero_eof as we are increasing the size of the file. When we do the second ftruncate(fd, 4), we call into iomap_truncate_page() with offset 0: int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero, const struct iomap_ops *ops) { unsigned int blocksize = i_blocksize(inode); unsigned int off = pos & (blocksize - 1); /* Block boundary? Nothing to do */ if (!off) return 0; return iomap_zero_range(inode, pos, blocksize - off, did_zero, ops); } As you can see, we take into account the blocksize (which is set as minorder during inode init) and make sure the sub-block zeroing is done correctly. Also if you see iomap_invalidate_folio(), we don't remove the folio private data until the whole folio is invalidated. I doubt we are doing anything wrong from the page cache layer with these patches. All we do with minorder support is to make sure we always allocate folios in the page cache that are at least min order in size and aligned to the min order (PATCH 2 and 3) and we maintain this even we do a split (PATCH 4). I hope this helps! -- Pankaj