From: Matthew Wilcox <willy@infradead.org>
To: "陈涛涛 Taotao Chen" <chentaotao@didiglobal.com>
Cc: "tytso@mit.edu" <tytso@mit.edu>,
"hch@infradead.org" <hch@infradead.org>,
"adilger.kernel@dilger.ca" <adilger.kernel@dilger.ca>,
"brauner@kernel.org" <brauner@kernel.org>,
"jani.nikula@linux.intel.com" <jani.nikula@linux.intel.com>,
"rodrigo.vivi@intel.com" <rodrigo.vivi@intel.com>,
"tursulin@ursulin.net" <tursulin@ursulin.net>,
"airlied@gmail.com" <airlied@gmail.com>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>,
"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
"intel-gfx@lists.freedesktop.org"
<intel-gfx@lists.freedesktop.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"chentao325@qq.com" <chentao325@qq.com>,
"frank.li@vivo.com" <frank.li@vivo.com>
Subject: Re: [PATCH v3 3/4] fs: change write_begin/write_end interface to take struct kiocb *
Date: Fri, 27 Jun 2025 16:45:52 +0100 [thread overview]
Message-ID: <aF68sKzx24P1q54h@casper.infradead.org> (raw)
In-Reply-To: <20250627110257.1870826-4-chentaotao@didiglobal.com>
On Fri, Jun 27, 2025 at 11:03:11AM +0000, 陈涛涛 Taotao Chen wrote:
> diff --git a/fs/exfat/file.c b/fs/exfat/file.c
> index 841a5b18e3df..fdc2fa1e5c41 100644
> --- a/fs/exfat/file.c
> +++ b/fs/exfat/file.c
> @@ -532,10 +532,12 @@ int exfat_file_fsync(struct file *filp, loff_t start, loff_t end, int datasync)
> return blkdev_issue_flush(inode->i_sb->s_bdev);
> }
>
> -static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size)
> +static int exfat_extend_valid_size(const struct kiocb *iocb,
> + loff_t new_valid_size)
> {
> int err;
> loff_t pos;
> + struct file *file = iocb->ki_filp;
> struct inode *inode = file_inode(file);
> struct exfat_inode_info *ei = EXFAT_I(inode);
> struct address_space *mapping = inode->i_mapping;
> @@ -551,14 +553,14 @@ static int exfat_extend_valid_size(struct file *file, loff_t new_valid_size)
> if (pos + len > new_valid_size)
> len = new_valid_size - pos;
>
> - err = ops->write_begin(file, mapping, pos, len, &folio, NULL);
> + err = ops->write_begin(iocb, mapping, pos, len, &folio, NULL);
> if (err)
> goto out;
>
> off = offset_in_folio(folio, pos);
> folio_zero_new_buffers(folio, off, off + len);
>
> - err = ops->write_end(file, mapping, pos, len, len, folio, NULL);
> + err = ops->write_end(iocb, mapping, pos, len, len, folio, NULL);
> if (err < 0)
> goto out;
> pos += len;
> @@ -604,7 +606,7 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
> }
>
> if (pos > valid_size) {
> - ret = exfat_extend_valid_size(file, pos);
> + ret = exfat_extend_valid_size(iocb, pos);
> if (ret < 0 && ret != -ENOSPC) {
> exfat_err(inode->i_sb,
> "write: fail to zero from %llu to %llu(%zd)",
> @@ -655,8 +657,11 @@ static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)
> struct file *file = vma->vm_file;
> struct inode *inode = file_inode(file);
> struct exfat_inode_info *ei = EXFAT_I(inode);
> + struct kiocb iocb;
> loff_t start, end;
>
> + init_sync_kiocb(&iocb, file);
> +
> if (!inode_trylock(inode))
> return VM_FAULT_RETRY;
>
> @@ -665,7 +670,7 @@ static vm_fault_t exfat_page_mkwrite(struct vm_fault *vmf)
> start + vma->vm_end - vma->vm_start);
>
> if (ei->valid_size < end) {
> - err = exfat_extend_valid_size(file, end);
> + err = exfat_extend_valid_size(&iocb, end);
> if (err < 0) {
> inode_unlock(inode);
> return vmf_fs_error(err);
This is unnecessary work. The only ->write_begin/write_end that we'll
see here is exfat_write_begin() / exfat_write_end() which don't actually
need iocb (or file). Traditionally we pass NULL in these situations,
but the exfat people probably weren't aware of this convention.
exfat_extend_valid_size() only uses the file it's passed to get the
inode, and both callers already have the inode. So I'd change
exfat_extend_valid_size() to take an inode instead of a file as its
first argument, then you can skip the creation of an iocb in
exfat_page_mkwrite().
next prev parent reply other threads:[~2025-06-27 15:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-27 11:02 [PATCH v3 0/4] fs: refactor write_begin/write_end and add ext4 IOCB_DONTCACHE support 陈涛涛 Taotao Chen
2025-06-27 11:03 ` [PATCH v3 1/4] drm/i915: Use kernel_write() in shmem object create 陈涛涛 Taotao Chen
2025-06-27 11:03 ` [PATCH v3 2/4] drm/i915: Refactor shmem_pwrite() to use kiocb and write_iter 陈涛涛 Taotao Chen
2025-06-27 11:03 ` [PATCH v3 3/4] fs: change write_begin/write_end interface to take struct kiocb * 陈涛涛 Taotao Chen
2025-06-27 15:45 ` Matthew Wilcox [this message]
2025-07-02 14:12 ` Taotao Chen
2025-06-27 15:52 ` Matthew Wilcox
2025-07-02 14:51 ` Taotao Chen
2025-06-27 11:03 ` [PATCH v3 4/4] ext4: support uncached buffered I/O 陈涛涛 Taotao Chen
2025-06-27 17:03 ` Matthew Wilcox
2025-06-30 6:41 ` hch
2025-07-03 11:45 ` Matthew Wilcox
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=aF68sKzx24P1q54h@casper.infradead.org \
--to=willy@infradead.org \
--cc=adilger.kernel@dilger.ca \
--cc=airlied@gmail.com \
--cc=brauner@kernel.org \
--cc=chentao325@qq.com \
--cc=chentaotao@didiglobal.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=frank.li@vivo.com \
--cc=hch@infradead.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=rodrigo.vivi@intel.com \
--cc=tursulin@ursulin.net \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).