diff options
author | David Howells <dhowells@redhat.com> | 2023-09-29 17:28:25 +0100 |
---|---|---|
committer | David Howells <dhowells@redhat.com> | 2023-12-28 09:45:21 +0000 |
commit | 9ebff83e648148b9ece97d4e4890dd84ca54d6ce (patch) | |
tree | 78f35f132024a833131795708f043d660ebca098 /fs/netfs/internal.h | |
parent | 4fcccc38ebbdcff74494701c50a8e2fe4689837e (diff) | |
download | linux-9ebff83e648148b9ece97d4e4890dd84ca54d6ce.tar.gz linux-9ebff83e648148b9ece97d4e4890dd84ca54d6ce.tar.bz2 linux-9ebff83e648148b9ece97d4e4890dd84ca54d6ce.zip |
netfs: Prep to use folio->private for write grouping and streaming write
Prepare to use folio->private to hold information write grouping and
streaming write. These are implemented in the same commit as they both
make use of folio->private and will be both checked at the same time in
several places.
"Write grouping" involves ordering the writeback of groups of writes, such
as is needed for ceph snaps. A group is represented by a
filesystem-supplied object which must contain a netfs_group struct. This
contains just a refcount and a pointer to a destructor.
"Streaming write" is the storage of data in folios that are marked dirty,
but not uptodate, to avoid unnecessary reads of data. This is represented
by a netfs_folio struct. This contains the offset and length of the
modified region plus the otherwise displaced write grouping pointer.
The way folio->private is multiplexed is:
(1) If private is NULL then neither is in operation on a dirty folio.
(2) If private is set, with bit 0 clear, then this points to a group.
(3) If private is set, with bit 0 set, then this points to a netfs_folio
struct (with bit 0 AND'ed out).
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
Diffstat (limited to 'fs/netfs/internal.h')
-rw-r--r-- | fs/netfs/internal.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/fs/netfs/internal.h b/fs/netfs/internal.h index 2bf2e82b2ad7..d72292e40f9b 100644 --- a/fs/netfs/internal.h +++ b/fs/netfs/internal.h @@ -150,6 +150,34 @@ static inline bool netfs_is_cache_enabled(struct netfs_inode *ctx) } /* + * Get a ref on a netfs group attached to a dirty page (e.g. a ceph snap). + */ +static inline struct netfs_group *netfs_get_group(struct netfs_group *netfs_group) +{ + if (netfs_group) + refcount_inc(&netfs_group->ref); + return netfs_group; +} + +/* + * Dispose of a netfs group attached to a dirty page (e.g. a ceph snap). + */ +static inline void netfs_put_group(struct netfs_group *netfs_group) +{ + if (netfs_group && refcount_dec_and_test(&netfs_group->ref)) + netfs_group->free(netfs_group); +} + +/* + * Dispose of a netfs group attached to a dirty page (e.g. a ceph snap). + */ +static inline void netfs_put_group_many(struct netfs_group *netfs_group, int nr) +{ + if (netfs_group && refcount_sub_and_test(nr, &netfs_group->ref)) + netfs_group->free(netfs_group); +} + +/* * fscache-cache.c */ #ifdef CONFIG_PROC_FS |