Skip to content

Commit 26aaeff

Browse files
committed
fscache, cachefiles: Add alternate API to use kiocb for read/write to cache
Add an alternate API by which the cache can be accessed through a kiocb, doing async DIO, rather than using the current API that tells the cache where all the pages are. The new API is intended to be used in conjunction with the netfs helper library. A filesystem must pick one or the other and not mix them. Filesystems wanting to use the new API must #define FSCACHE_USE_NEW_IO_API before #including the header. This prevents them from continuing to use the old API at the same time as there are incompatibilities in how the PG_fscache page bit is used. Changes: v6: - Provide a routine to shape a write so that the start and length can be aligned for DIO[3]. v4: - Use the vfs_iocb_iter_read/write() helpers[1] - Move initial definition of fscache_begin_read_operation() here. - Remove a commented-out line[2] - Combine ki->term_func calls in cachefiles_read_complete()[2]. - Remove explicit NULL initialiser[2]. - Remove extern on func decl[2]. - Put in param names on func decl[2]. - Remove redundant else[2]. - Fill out the kdoc comment for fscache_begin_read_operation(). - Rename fs/fscache/page2.c to io.c to match later patches. Signed-off-by: David Howells <[email protected]> Reviewed-and-tested-by: Jeff Layton <[email protected]> Tested-by: Dave Wysochanski <[email protected]> Tested-By: Marc Dionne <[email protected]> cc: Christoph Hellwig <[email protected]> cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] cc: [email protected] Link: https://lore.kernel.org/r/[email protected]/ [1] Link: https://lore.kernel.org/r/[email protected]/ [2] Link: https://lore.kernel.org/r/161781047695.463527.7463536103593997492.stgit@warthog.procyon.org.uk/ [3] Link: https://lore.kernel.org/r/161118142558.1232039.17993829899588971439.stgit@warthog.procyon.org.uk/ # rfc Link: https://lore.kernel.org/r/161161037850.2537118.8819808229350326503.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/161340402057.1303470.8038373593844486698.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/161539545919.286939.14573472672781434757.stgit@warthog.procyon.org.uk/ # v4 Link: https://lore.kernel.org/r/161653801477.2770958.10543270629064934227.stgit@warthog.procyon.org.uk/ # v5 Link: https://lore.kernel.org/r/161789084517.6155.12799689829859169640.stgit@warthog.procyon.org.uk/ # v6
1 parent 0246f3e commit 26aaeff

File tree

12 files changed

+600
-3
lines changed

12 files changed

+600
-3
lines changed

fs/cachefiles/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ cachefiles-y := \
77
bind.o \
88
daemon.o \
99
interface.o \
10+
io.o \
1011
key.o \
1112
main.o \
1213
namei.o \

fs/cachefiles/interface.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,8 @@ static void cachefiles_drop_object(struct fscache_object *_object)
319319
/*
320320
* dispose of a reference to an object
321321
*/
322-
static void cachefiles_put_object(struct fscache_object *_object,
323-
enum fscache_obj_ref_trace why)
322+
void cachefiles_put_object(struct fscache_object *_object,
323+
enum fscache_obj_ref_trace why)
324324
{
325325
struct cachefiles_object *object;
326326
struct fscache_cache *cache;
@@ -568,4 +568,5 @@ const struct fscache_cache_ops cachefiles_cache_ops = {
568568
.uncache_page = cachefiles_uncache_page,
569569
.dissociate_pages = cachefiles_dissociate_pages,
570570
.check_consistency = cachefiles_check_consistency,
571+
.begin_read_operation = cachefiles_begin_read_operation,
571572
};

fs/cachefiles/internal.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ extern int cachefiles_has_space(struct cachefiles_cache *cache,
150150
*/
151151
extern const struct fscache_cache_ops cachefiles_cache_ops;
152152

153+
void cachefiles_put_object(struct fscache_object *_object,
154+
enum fscache_obj_ref_trace why);
155+
153156
/*
154157
* key.c
155158
*/
@@ -217,6 +220,12 @@ extern int cachefiles_allocate_pages(struct fscache_retrieval *,
217220
extern int cachefiles_write_page(struct fscache_storage *, struct page *);
218221
extern void cachefiles_uncache_page(struct fscache_object *, struct page *);
219222

223+
/*
224+
* rdwr2.c
225+
*/
226+
extern int cachefiles_begin_read_operation(struct netfs_read_request *,
227+
struct fscache_retrieval *);
228+
220229
/*
221230
* security.c
222231
*/

0 commit comments

Comments
 (0)