All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jaegeuk Kim via Linux-f2fs-devel <linux-f2fs-devel@lists.sourceforge.net>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Wenjie Qi <qwjhust@gmail.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, qiwenjie@xiaomi.com,
	stable@kernel.org
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: return symlink writeback errors
Date: Tue, 18 Aug 2026 20:04:01 +0000	[thread overview]
Message-ID: <aoS6sWz-hvdda1OJ@google.com> (raw)
In-Reply-To: <20260815051820.GA660827@ZenIV>

On 08/15, Al Viro wrote:
> On Mon, Aug 10, 2026 at 09:38:32PM +0800, Wenjie Qi wrote:
> > F2FS writes long symlink data with page_symlink() and then flushes the
> > symlink mapping to reduce the chance of exposing a broken symlink.
> > 
> > That flush result is currently ignored. If the writeback fails, symlink()
> > still returns success even though the symlink is not durable and the same
> > operation can already surface -EIO through syncfs().
> > 
> > Return the writeback error to userspace and skip the dirsync flush once the
> > symlink data flush has failed.
> 
> >  	if (!err) {
> > -		filemap_write_and_wait_range(inode->i_mapping, 0,
> > -							disk_link.len - 1);
> > +		err = filemap_write_and_wait_range(inode->i_mapping, 0,
> > +						   disk_link.len - 1);
> >  
> > -		if (IS_DIRSYNC(dir))
> > +		if (!err && IS_DIRSYNC(dir))
> >  			f2fs_sync_fs(sbi->sb, 1);
> > -	} else {
> > -		f2fs_unlink(dir, dentry);
> >  	}
> >  
> > +	if (err)
> > +		f2fs_unlink(dir, dentry);
> 
> That looks fishy.  At that point you already have dentry hashed and
> AFAICS f2fs_unlink() will leave it hashed and attached to the same
> inode; sure, memory pressure will eventually evict the sucker, but
> until that point any lookups will simply pick it from dcache.

Thanks, yeah..it seems we don't need to do f2fs_unlink() at this stage, since
IMHO, this code block is a nice-to-succeed as there'll be another chance to
flush dirty pages containing the symlink path.

IMO, we need to handle the error like this:

    1. f2fs_new_inode
    2. f2fs_add_link
    3. page_symlink
      -> if it fails, we should unlink and drop the inode

    4. flush dirty pages and or checkpoint
      -> leave as is and wait for writeback again

RFC: https://lore.kernel.org/linux-f2fs-devel/20260818200121.2684318-1-jaegeuk@kernel.org/T/#u

> 
> It's not introduced by this patch; the same issue, AFAICS, already exists
> in mainline.  Why do we even bother with d_instantiate_new() before we
> know that everything's fine, nevermind doing that when we already know
> the operation has failed?
> 
> Incidentally, is there any reason to add a directory entry before the
> inode is set up?  Usually that's the last step, and cleanup tends to
> be simpler that way; are there f2fs-specific reasons to do it in the
> unusual order?

I don't think there's a special reason in f2fs to do so. It seems ext4 does
it similarily like calling d_instantiate_new() in ext4_add_nondir() after
ext4_add_entry()?


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Wenjie Qi <qwjhust@gmail.com>,
	chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, stable@kernel.org,
	qiwenjie@xiaomi.com
Subject: Re: [PATCH v2] f2fs: return symlink writeback errors
Date: Tue, 18 Aug 2026 20:04:01 +0000	[thread overview]
Message-ID: <aoS6sWz-hvdda1OJ@google.com> (raw)
In-Reply-To: <20260815051820.GA660827@ZenIV>

On 08/15, Al Viro wrote:
> On Mon, Aug 10, 2026 at 09:38:32PM +0800, Wenjie Qi wrote:
> > F2FS writes long symlink data with page_symlink() and then flushes the
> > symlink mapping to reduce the chance of exposing a broken symlink.
> > 
> > That flush result is currently ignored. If the writeback fails, symlink()
> > still returns success even though the symlink is not durable and the same
> > operation can already surface -EIO through syncfs().
> > 
> > Return the writeback error to userspace and skip the dirsync flush once the
> > symlink data flush has failed.
> 
> >  	if (!err) {
> > -		filemap_write_and_wait_range(inode->i_mapping, 0,
> > -							disk_link.len - 1);
> > +		err = filemap_write_and_wait_range(inode->i_mapping, 0,
> > +						   disk_link.len - 1);
> >  
> > -		if (IS_DIRSYNC(dir))
> > +		if (!err && IS_DIRSYNC(dir))
> >  			f2fs_sync_fs(sbi->sb, 1);
> > -	} else {
> > -		f2fs_unlink(dir, dentry);
> >  	}
> >  
> > +	if (err)
> > +		f2fs_unlink(dir, dentry);
> 
> That looks fishy.  At that point you already have dentry hashed and
> AFAICS f2fs_unlink() will leave it hashed and attached to the same
> inode; sure, memory pressure will eventually evict the sucker, but
> until that point any lookups will simply pick it from dcache.

Thanks, yeah..it seems we don't need to do f2fs_unlink() at this stage, since
IMHO, this code block is a nice-to-succeed as there'll be another chance to
flush dirty pages containing the symlink path.

IMO, we need to handle the error like this:

    1. f2fs_new_inode
    2. f2fs_add_link
    3. page_symlink
      -> if it fails, we should unlink and drop the inode

    4. flush dirty pages and or checkpoint
      -> leave as is and wait for writeback again

RFC: https://lore.kernel.org/linux-f2fs-devel/20260818200121.2684318-1-jaegeuk@kernel.org/T/#u

> 
> It's not introduced by this patch; the same issue, AFAICS, already exists
> in mainline.  Why do we even bother with d_instantiate_new() before we
> know that everything's fine, nevermind doing that when we already know
> the operation has failed?
> 
> Incidentally, is there any reason to add a directory entry before the
> inode is set up?  Usually that's the last step, and cleanup tends to
> be simpler that way; are there f2fs-specific reasons to do it in the
> unusual order?

I don't think there's a special reason in f2fs to do so. It seems ext4 does
it similarily like calling d_instantiate_new() in ext4_add_nondir() after
ext4_add_entry()?

  reply	other threads:[~2026-08-18 20:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 13:38 [f2fs-dev] [PATCH v2] f2fs: return symlink writeback errors Wenjie Qi
2026-08-10 13:38 ` Wenjie Qi
2026-08-12  9:30 ` [f2fs-dev] " Chao Yu via Linux-f2fs-devel
2026-08-12  9:30   ` Chao Yu
2026-08-12 20:30 ` [f2fs-dev] " patchwork-bot+f2fs--- via Linux-f2fs-devel
2026-08-12 20:30   ` patchwork-bot+f2fs
2026-08-15  5:18 ` Al Viro
2026-08-15  5:18   ` [f2fs-dev] " Al Viro
2026-08-18 20:04   ` Jaegeuk Kim via Linux-f2fs-devel [this message]
2026-08-18 20:04     ` Jaegeuk Kim

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=aoS6sWz-hvdda1OJ@google.com \
    --to=linux-f2fs-devel@lists.sourceforge.net \
    --cc=jaegeuk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qiwenjie@xiaomi.com \
    --cc=qwjhust@gmail.com \
    --cc=stable@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.