* [PATCH 0/2] fscache/cachefiles: some work for on-demand mode
@ 2023-02-21 10:33 Jingbo Xu
2023-02-21 10:33 ` [PATCH 1/2] cachefiles: don't align the write IO in ondemand mode Jingbo Xu
2023-02-21 10:33 ` [PATCH 2/2] fscache: introduce fscache_begin_wait_operation() helper Jingbo Xu
0 siblings, 2 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-02-21 10:33 UTC (permalink / raw)
To: dhowells, linux-cachefs; +Cc: linux-kernel
Hi there's some work to make users of fscache on-demand mode support
PAGE_SIZE larger than 4KB (e.g. 16/64KB in aarch64) [1]. I think they
may be also useful for other users of fscache/cachefiles.
Strictly speacking, patch 1 is a bug fix though the issue doesn't cause
serious harm when erofs doesn't support large PAGE_SIZE (other than
4KB).
__cachefiles_prepare_write() will align the requested file range to
PAGE_SIZE boundary. This is reasonable for libnetfs as libnetfs will
construct an iter with the aligned file range from the ground.
While for fscache on-demand mode, cachefiles_ondemand_fd_write_iter() is
called by the user daemon, and thus it is unexpected to align the file
range to PAGE_SIZE boundary, as the iov_iter/kiocb is given by the user
daemon. If the given file range is not aligned with the block size of
the backing filesystem, let's fail the write directly.
Patch 2 adds a new helper, by which users of fscache on-demand mode
could wait for the wrangling of the cache object and then derive the
object size (set in cachefiles_ondemand_copen()).
fscache_begin_read_operation() is not feasible for this purpose as
in this case @want_state is FSCACHE_WANT_PARAMS and it will not wait
there for object wrangling when cookie is in
FSCACHE_COOKIE_STATE_CREATING state. An example use case of this helper
is illustrated in [2].
Any comment is welcomed.
[1] https://lore.kernel.org/all/20230221091719.126127-1-jefflexu@linux.alibaba.com/
[2] https://lore.kernel.org/all/20230221091719.126127-2-jefflexu@linux.alibaba.com/
Jingbo Xu (2):
cachefiles: don't align the write IO in ondemand mode
fscache: introduce fscache_begin_wait_operation() helper
fs/cachefiles/ondemand.c | 3 ++-
fs/fscache/io.c | 9 +++++++++
include/linux/fscache.h | 22 ++++++++++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
--
2.19.1.6.gb485710b
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] cachefiles: don't align the write IO in ondemand mode
2023-02-21 10:33 [PATCH 0/2] fscache/cachefiles: some work for on-demand mode Jingbo Xu
@ 2023-02-21 10:33 ` Jingbo Xu
2023-02-21 10:33 ` [PATCH 2/2] fscache: introduce fscache_begin_wait_operation() helper Jingbo Xu
1 sibling, 0 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-02-21 10:33 UTC (permalink / raw)
To: dhowells, linux-cachefs; +Cc: linux-kernel
If the write IO requested by the user daemon is not aligned with the
block size of the backing filesystem, it's expected to fail directly
rather than submit the aligned write IO (with expanded file range
unmatching with the given iov_iter).
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/cachefiles/ondemand.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c
index 0254ed39f68c..c017aca2a8a2 100644
--- a/fs/cachefiles/ondemand.c
+++ b/fs/cachefiles/ondemand.c
@@ -52,7 +52,8 @@ static ssize_t cachefiles_ondemand_fd_write_iter(struct kiocb *kiocb,
return -ENOBUFS;
cachefiles_begin_secure(cache, &saved_cred);
- ret = __cachefiles_prepare_write(object, file, &pos, &len, true);
+ ret = cachefiles_has_space(cache, 0, len >> cache->bshift,
+ cachefiles_has_space_for_write);
cachefiles_end_secure(cache, saved_cred);
if (ret < 0)
return ret;
--
2.19.1.6.gb485710b
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] fscache: introduce fscache_begin_wait_operation() helper
2023-02-21 10:33 [PATCH 0/2] fscache/cachefiles: some work for on-demand mode Jingbo Xu
2023-02-21 10:33 ` [PATCH 1/2] cachefiles: don't align the write IO in ondemand mode Jingbo Xu
@ 2023-02-21 10:33 ` Jingbo Xu
1 sibling, 0 replies; 3+ messages in thread
From: Jingbo Xu @ 2023-02-21 10:33 UTC (permalink / raw)
To: dhowells, linux-cachefs; +Cc: linux-kernel
This is a variant of fscache_wait_for_operation() except that it's
exported for users of FsCache, and thus cookie->lock is held when
checking cookie's state.
Exporting fscache_begin_operation() directly is not acceptable as it
would introduce dependency of <trace/events/fscache.h> for users of
FsCache.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/fscache/io.c | 9 +++++++++
include/linux/fscache.h | 22 ++++++++++++++++++++++
2 files changed, 31 insertions(+)
diff --git a/fs/fscache/io.c b/fs/fscache/io.c
index 0d2b8dec8f82..6ccc5aadf151 100644
--- a/fs/fscache/io.c
+++ b/fs/fscache/io.c
@@ -158,6 +158,15 @@ int __fscache_begin_write_operation(struct netfs_cache_resources *cres,
}
EXPORT_SYMBOL(__fscache_begin_write_operation);
+int __fscache_begin_wait_operation(struct netfs_cache_resources *cres,
+ struct fscache_cookie *cookie,
+ enum fscache_want_state want_state)
+{
+ return fscache_begin_operation(cres, cookie, want_state,
+ fscache_access_io_wait);
+}
+EXPORT_SYMBOL(__fscache_begin_wait_operation);
+
/**
* fscache_dirty_folio - Mark folio dirty and pin a cache object for writeback
* @mapping: The mapping the folio belongs to.
diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index 8e312c8323a8..708cf8db7f46 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -171,6 +171,8 @@ extern void __fscache_resize_cookie(struct fscache_cookie *, loff_t);
extern void __fscache_invalidate(struct fscache_cookie *, const void *, loff_t, unsigned int);
extern int __fscache_begin_read_operation(struct netfs_cache_resources *, struct fscache_cookie *);
extern int __fscache_begin_write_operation(struct netfs_cache_resources *, struct fscache_cookie *);
+extern int __fscache_begin_wait_operation(struct netfs_cache_resources *, struct fscache_cookie *,
+ enum fscache_want_state want_state);
extern void __fscache_write_to_cache(struct fscache_cookie *, struct address_space *,
loff_t, size_t, loff_t, netfs_io_terminated_t, void *,
@@ -543,6 +545,26 @@ int fscache_begin_write_operation(struct netfs_cache_resources *cres,
return -ENOBUFS;
}
+/**
+ * fscache_begin_wait_operation - Wait for an object become accessible
+ * @cres: The cache resources for the operation being performed
+ * @cookie: The cookie representing the cache object
+ *
+ * Returns:
+ * * 0 - Success
+ * * -ENOBUFS - No caching available
+ * * Other error code from the cache, such as -ENOMEM.
+ */
+static inline
+int fscache_begin_wait_operation(struct netfs_cache_resources *cres,
+ struct fscache_cookie *cookie,
+ enum fscache_want_state want_state)
+{
+ if (fscache_cookie_enabled(cookie))
+ return __fscache_begin_wait_operation(cres, cookie, want_state);
+ return -ENOBUFS;
+}
+
/**
* fscache_write - Start a write to the cache.
* @cres: The cache resources to use
--
2.19.1.6.gb485710b
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-21 10:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 10:33 [PATCH 0/2] fscache/cachefiles: some work for on-demand mode Jingbo Xu
2023-02-21 10:33 ` [PATCH 1/2] cachefiles: don't align the write IO in ondemand mode Jingbo Xu
2023-02-21 10:33 ` [PATCH 2/2] fscache: introduce fscache_begin_wait_operation() helper Jingbo Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®