linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-fsdevel@vger.kernel.org
Subject: truncate for block size > page size
Date: Sun, 17 May 2020 14:54:07 -0700	[thread overview]
Message-ID: <20200517215407.GS16070@bombadil.infradead.org> (raw)

I'm currently looking at the truncate path for large pages and I suspect
you have thought about the situation with block size > page size more
than I have.

Let's say you have a fs with 8kB blocks and a CPU with 4kB PAGE_SIZE.
If you have a 32kB file with all its pages in the cache, and the user
truncates it down to 10kB, should we leave three pages in the page cache
or four?

Three pages means (if the last page of the file is dirty) we'd need to
add in either a freshly allocated zero page or the generic zero page to
the bio when writing back the last page.

Four pages mean we'll need to teach the truncate code to use the larger
of page size and block size when deciding the boundary to truncate the
page cache to, and zero the last page(s) of the file if needed.

Depending on your answer, I may have some follow-up questions about how
we handle reading a 10kB file with an 8kB block size on a 4kB PAGE SIZE
machine (whether we allocate 3 or 4 pages, and what we do about the
extra known-to-be-zero bytes that will come from the device).

             reply	other threads:[~2020-05-17 21:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-17 21:54 Matthew Wilcox [this message]
2020-05-22  0:03 ` truncate for block size > page size Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200517215407.GS16070@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=david@fromorbit.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).