From: Baolin Wang <baolin.wang@linux.alibaba.com>
To: Hungyu Lin <dennylin0707@gmail.com>, hughd@google.com
Cc: david@kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] shmem: skip empty unmap ranges when punching holes
Date: Thu, 5 Nov 2026 17:32:46 +0800 [thread overview]
Message-ID: <d07c04cb-3ee2-48fc-b289-7167a8589f38@linux.alibaba.com> (raw)
In-Reply-To: <20261105055619.58289-1-dennylin0707@gmail.com>
On 11/5/26 1:56 PM, Hungyu Lin wrote:
> When a hole ends before the first page boundary, shmem_fallocate()
> calculates unmap_end as -1. Casting it to u64 makes the range check
> succeed even though the hole contains no complete pages.
>
> For example, punching one byte at offset zero calls unmap_mapping_range()
> with a zero length, which means unmap to the end of the file. The file
> contents are preserved outside the hole, but unrelated mappings are
> removed and must fault back in. This can be reproduced with fallocate -p
> -o 0 -l 1 on a mapped tmpfs file.
>
> Keep unmap_end as the exclusive rounded end instead of subtracting one,
> and adjust shmem_falloc.next and the unmap length accordingly. A hole
> ending before the first page boundary then has an end of zero, so the
> unsigned range check skips the empty range. Retain the unsigned
> comparison so rounding the start near the maximum file offset continues
> to be handled correctly.
>
> Fixes: 83e4fa9c16e4 ("tmpfs: support fallocate FALLOC_FL_PUNCH_HOLE")
> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
> ---
> Changes in v2:
> - Use an exclusive unmap_end throughout, following David's suggestion.
> - Add Baolin's Reviewed-by.
Thanks. This still looks good to me.
prev parent reply other threads:[~2026-11-05 9:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 5:56 Hungyu Lin
2026-11-05 9:32 ` Baolin Wang [this message]
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=d07c04cb-3ee2-48fc-b289-7167a8589f38@linux.alibaba.com \
--to=baolin.wang@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=dennylin0707@gmail.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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
all inboxes | Powered by JetHome®