mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <slava@dubeyko.com>
To: hengyul@cs.unc.edu
Cc: glaubitz@physik.fu-berlin.de, frank.li@vivo.com,
	 linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] hfs: report errors when extending files with setattr
Date: Mon, 19 Oct 2026 15:45:59 -0700	[thread overview]
Message-ID: <209bd8166668e2ca3edce092c0480ec7f56a1fd8.camel@dubeyko.com> (raw)
In-Reply-To: <20261017160612.3740256-1-hengyul@cs.unc.edu>

On Sat, 2026-10-17 at 12:06 -0400, hengyul@cs.unc.edu wrote:
> From: Hengyu Liang <hengyul@cs.unc.edu>
> 
> hfs_inode_setattr() sets i_size and calls hfs_file_truncate() to
> change
> the allocation. If expansion fails, hfs_file_truncate() restores
> i_size
> to the allocated size, but its void return type leaves setattr
> reporting
> success.
> 
> On a freshly formatted 64 MiB HFS volume, ftruncate() to 128 MiB
> returns
> zero while the file remains empty. When the requested size fits
> within
> the volume but exceeds the free space, it also returns zero, leaving
> the file only partially extended.
> 
> Call generic_cont_expand_simple() before truncate_setsize() when
> growing
> a file, and propagate its error. This makes failed extensions report
> EFBIG or ENOSPC.
> 
> Signed-off-by: Hengyu Liang <hengyul@cs.unc.edu>

Mostly, patch looks good and it mimics the HFS+ logic but I have
several comments.

> ---
> Compared unpatched and patched v7.3-rc7 in KVM with GCC 10.5 and
> identical KASAN configurations:
> - 36 growth/shrink/error cases per kernel on 32/64/128 MiB HFS
> volumes;
>   content, zeroing and read-only remount checks passed.
> - fsx (10,000 operations) and generic/736 (10 runs) passed on both
>   kernels; post-test fsck.hfs -fn was clean.

I don't see any relation of this fix to generic/736. So, this comment
is not very useful. It will be much better to run the whole set of
xfstests and to check that this fix decrease, increase or keep the same
the number of failures. This run results could be really good to have.

> - fsck.hfs -fn was also clean for ordinary and recovery cases.
> 
> No kernel BUG, WARN or KASAN report was observed.
> 
>  fs/hfs/inode.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index 2aef3c36a150..44b1735a54c2 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -684,6 +684,12 @@ int hfs_inode_setattr(struct mnt_idmap *idmap,
> struct dentry *dentry,
>  		if (error)
>  			return error;
>  
> +		if (attr->ia_size > inode->i_size) {
> +			error = generic_cont_expand_simple(inode,
> attr->ia_size);
> +			if (error)
> +				return error;
> +		}
> +
>  		truncate_setsize(inode, attr->ia_size);
>  		hfs_file_truncate(inode);

Probably, we don't need to call the hfs_file_truncate() for the case of
attr->ia_size > inode->i_size. We have the same code in HFS+ logic. Do
you think this improvement makes sense?

Thanks,
Slava.

>  		inode_set_mtime_to_ts(inode,
> inode_set_ctime_current(inode));

      reply	other threads:[~2026-10-19 22:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-17 16:06 hengyul
2026-10-19 22:45 ` Viacheslav Dubeyko [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=209bd8166668e2ca3edce092c0480ec7f56a1fd8.camel@dubeyko.com \
    --to=slava@dubeyko.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=hengyul@cs.unc.edu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®