From: "Theodore Ts'o" <tytso@mit.edu>
To: "陈涛涛 Taotao Chen" <chentaotao@didiglobal.com>
Cc: "adilger.kernel@dilger.ca" <adilger.kernel@dilger.ca>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"willy@infradead.org" <willy@infradead.org>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: Re: [PATCH 2/3] ext4: implement IOCB_DONTCACHE handling in write operations
Date: Wed, 14 May 2025 07:52:11 -0400 [thread overview]
Message-ID: <20250514115211.GC9943@mit.edu> (raw)
In-Reply-To: <20250421105026.19577-3-chentaotao@didiglobal.com>
On Mon, Apr 21, 2025 at 10:50:30AM +0000, 陈涛涛 Taotao Chen wrote:
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 94c7d2d828a6..787dd152a47e 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -1147,16 +1147,22 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
> {
> struct inode *inode = mapping->host;
> int ret, needed_blocks;
> + int iocb_flag;
> handle_t *handle;
> int retries = 0;
> struct folio *folio;
> pgoff_t index;
> + fgf_t fgp = FGP_WRITEBEGIN;
> unsigned from, to;
>
> ret = ext4_emergency_state(inode->i_sb);
> if (unlikely(ret))
> return ret;
>
> + iocb_flag = (int)(uintptr_t)(*fsdata);
> + if (iocb_flag & IOCB_DONTCACHE)
> + fgp |= FGP_DONTCACHE;
> +
See my comment against the first patch in this series. It *should* be
possible to solve the problem just for ext4 by adding this line here:
*fsdata = (void *)0;
The problem is that it's super-fragile, since how *fsdata gets used
changes at different points in time, so it makes code review and
maintenance more difficult. (As evidenced by the fact that you missed
this; this is not a criticism on your programming ability, but rather
for the design choise of overloading the use of *fsdata. This is a
trap that someone else might fall into when doing future code
changes.)
And of course, the question is whether PATCH 1/3 could potentially
break other file systems. We would need audit all of the other
*_write_begin() functions, and then document this for the sake of
future file system developers that might want to change their
write_begin() function.
This is why my preference would be to add an extra flags paramter to
write_begin(), but that is going to be a lot more work.
Cheers,
- Ted
next prev parent reply other threads:[~2025-05-14 11:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-21 10:50 [PATCH 0/3] ext4: Implement IOCB_DONTCACHE handling 陈涛涛 Taotao Chen
2025-04-21 10:50 ` [PATCH 1/3] mm/filemap: initialize fsdata with iocb->ki_flags 陈涛涛 Taotao Chen
2025-05-14 3:51 ` Theodore Ts'o
2025-05-14 13:38 ` Matthew Wilcox
2025-05-14 14:23 ` Theodore Ts'o
2025-05-14 15:06 ` Christoph Hellwig
2025-05-18 14:01 ` Taotao Chen
2025-04-21 10:50 ` [PATCH 2/3] ext4: implement IOCB_DONTCACHE handling in write operations 陈涛涛 Taotao Chen
2025-05-14 11:52 ` Theodore Ts'o [this message]
2025-04-21 10:50 ` [PATCH 3/3] ext4: support FOP_DONTCACHE flag 陈涛涛 Taotao Chen
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=20250514115211.GC9943@mit.edu \
--to=tytso@mit.edu \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=chentaotao@didiglobal.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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