[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250514115211.GC9943@mit.edu>
Date: Wed, 14 May 2025 07:52:11 -0400
From: "Theodore Ts'o" <tytso@....edu>
To: 陈涛涛 Taotao Chen <chentaotao@...iglobal.com>
Cc: "adilger.kernel@...ger.ca" <adilger.kernel@...ger.ca>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"willy@...radead.org" <willy@...radead.org>,
"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [PATCH 2/3] ext4: implement IOCB_DONTCACHE handling in write
operations
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
Powered by blists - more mailing lists