[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250514035125.GB178093@mit.edu>
Date: Tue, 13 May 2025 23:51:25 -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 1/3] mm/filemap: initialize fsdata with iocb->ki_flags
On Mon, Apr 21, 2025 at 10:50:30AM +0000, 陈涛涛 Taotao Chen wrote:
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 7b90cbeb4a1a..9174b6310f0b 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -4087,7 +4087,11 @@ ssize_t generic_perform_write(struct kiocb *iocb, struct iov_iter *i)
> size_t offset; /* Offset into folio */
> size_t bytes; /* Bytes to write to folio */
> size_t copied; /* Bytes copied from user */
> - void *fsdata = NULL;
> + /*
> + * Initialize fsdata with iocb flags pointer so that filesystems
> + * can check ki_flags (like IOCB_DONTCACHE) in write operations.
> + */
> + void *fsdata = &iocb->ki_flags;
Unfortunately, this is't safe. There may very well be code
paths which depend on fsdata being initialized to NULL before
calling write_begin().
In fact in the patch 2/3 in this series, ext4_write_end() will get
confused in the non-delayed allocation case, since ext4_write_begin()
doesn't force fsdata to be not be &iocb->ki_flags, and this will cause
ext4_write_end() to potentially get confused and do the wrong thing.
I understand that it would be a lot more inconvenient change the
function signature of write_begin() to pass through iocb->ki_fags via
a new parameter. But I think that probably is the best way to go.
Cheers,
- Ted
Powered by blists - more mailing lists