public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Zizhi Wo <wozizhi@huawei.com>
To: David Howells <dhowells@redhat.com>
Cc: <netfs@lists.linux.dev>, <jlayton@kernel.org>,
	<hsiangkao@linux.alibaba.com>, <jefflexu@linux.alibaba.com>,
	<zhujia.zj@bytedance.com>, <linux-erofs@lists.ozlabs.org>,
	<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<libaokun1@huawei.com>, <yangerkun@huawei.com>,
	<houtao1@huawei.com>, <yukuai3@huawei.com>
Subject: Re: [PATCH 1/8] cachefiles: Fix incorrect block calculations in __cachefiles_prepare_write()
Date: Thu, 10 Oct 2024 21:15:49 +0800	[thread overview]
Message-ID: <14905d87-9fc4-45c8-b845-d3f4badecf46@huawei.com> (raw)
In-Reply-To: <304311.1728560215@warthog.procyon.org.uk>



在 2024/10/10 19:36, David Howells 写道:
> Zizhi Wo <wozizhi@huawei.com> wrote:
> 
>> For scenarios such as nfs/cifs, the corresponding bsize is PAGE_SIZE aligned
> 
> cache->bsize is a property of the cache device, not the network filesystems
> that might be making use of it (and it might be shared between multiple
> volumes from multiple network filesystems, all of which could, in theory, have
> different 'block sizes', inasmuch as network filesystems have block sizes).
> 
> David
> 

Sorry, I might have a slightly different idea now. The EROFS process
based on fscache is similar to NFS and others, supporting only
PAGE_SIZE-granularity reads/writes, which is fine. The issue now lies in
the __cachefiles_prepare_write() function, specifically in the block
count calculation when calling cachefiles_has_space(). By default, the
block size used there is PAGE_SIZE.

If the block size of the underlying cache filesystem is not PAGE_SIZE
(for example, smaller than PAGE_SIZE), it leads to an incorrect
calculation of the required block count, which makes the system think
there is enough space when there might not be. This should be the same
problem for all network file systems that specify the back-end cache
file system mode.

For example, assume len=12k, pagesize=4k, and the underlying cache
filesystem block size is 1k. The currently available blocks are 4, with
4k of space remaining. However, cachefiles_has_space() calculates the
block count as 12k/4k=3, and since 4 > 3, it incorrectly returns that
there is enough space.

Therefore, I believe this could be a general issue. If
cachefiles_add_cache() is part of a common workflow, then using
cache->bsize here might be more appropriate? Looking forward to your
reply.

Thanks,
Zizhi Wo

> 

  parent reply	other threads:[~2024-10-10 13:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21  2:42 [PATCH 0/8] netfs/cachefiles: Some bugfixes Zizhi Wo
2024-08-21  2:42 ` [PATCH 1/8] cachefiles: Fix incorrect block calculations in __cachefiles_prepare_write() Zizhi Wo
2024-10-10 10:34   ` David Howells
2024-10-10 11:11     ` Zizhi Wo
2024-10-10 11:36       ` David Howells
2024-10-10 12:17         ` Zizhi Wo
2024-10-10 13:15         ` Zizhi Wo [this message]
2024-08-21  2:42 ` [PATCH 2/8] cachefiles: Fix incorrect length return value in cachefiles_ondemand_fd_write_iter() Zizhi Wo
2024-08-21  2:42 ` [PATCH 3/8] cachefiles: Fix missing pos updates " Zizhi Wo
2024-10-10 11:26   ` David Howells
2024-08-21  2:42 ` [PATCH 4/8] cachefiles: Clear invalid cache data in advance Zizhi Wo
2024-10-10 11:16   ` David Howells
2024-08-21  2:42 ` [PATCH 5/8] cachefiles: Clean up in cachefiles_commit_tmpfile() Zizhi Wo
2024-10-10 11:23   ` David Howells
2024-08-21  2:42 ` [PATCH 6/8] cachefiles: Modify inappropriate error return value in cachefiles_daemon_secctx() Zizhi Wo
2024-10-10 11:31   ` David Howells
2024-10-10 11:47     ` Zizhi Wo
2024-08-21  2:43 ` [PATCH 7/8] cachefiles: Fix NULL pointer dereference in object->file Zizhi Wo
2024-10-10 11:26   ` David Howells
2024-10-10 12:04     ` Zizhi Wo
2024-10-10 14:52       ` David Howells
2024-10-11  1:31         ` Zizhi Wo
2024-08-21  2:43 ` [PATCH 8/8] netfs/fscache: Add a memory barrier for FSCACHE_VOLUME_CREATING Zizhi Wo
2024-10-10 11:24   ` David Howells
2024-10-10  3:08 ` [PATCH 0/8] netfs/cachefiles: Some bugfixes Zizhi Wo
2024-10-10  3:31   ` Gao Xiang
2024-10-10  4:08     ` Zizhi Wo

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=14905d87-9fc4-45c8-b845-d3f4badecf46@huawei.com \
    --to=wozizhi@huawei.com \
    --cc=dhowells@redhat.com \
    --cc=houtao1@huawei.com \
    --cc=hsiangkao@linux.alibaba.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=jlayton@kernel.org \
    --cc=libaokun1@huawei.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netfs@lists.linux.dev \
    --cc=yangerkun@huawei.com \
    --cc=yukuai3@huawei.com \
    --cc=zhujia.zj@bytedance.com \
    /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