Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
41d8e76
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
9p
adfs
affs
afs
autofs
bcachefs
befs
bfs
btrfs
cachefiles
ceph
coda
configfs
cramfs
crypto
debugfs
devpts
dlm
ecryptfs
efivarfs
efs
erofs
exfat
exportfs
ext2
ext4
f2fs
fat
freevxfs
fuse
gfs2
hfs
hfsplus
hostfs
hpfs
hugetlbfs
iomap
isofs
jbd2
jffs2
jfs
kernfs
lockd
minix
netfs
Kconfig
Makefile
buffered_read.c
buffered_write.c
direct_read.c
direct_write.c
fscache_cache.c
fscache_cookie.c
fscache_internal.h
fscache_io.c
fscache_main.c
fscache_proc.c
fscache_stats.c
fscache_volume.c
internal.h
io.c
iterator.c
locking.c
main.c
misc.c
objects.c
output.c
stats.c
nfs
nfs_common
nfsd
nilfs2
nls
notify
ntfs
ntfs3
ocfs2
omfs
openpromfs
orangefs
overlayfs
proc
pstore
qnx4
qnx6
quota
ramfs
reiserfs
romfs
smb
squashfs
sysfs
sysv
tracefs
ubifs
udf
ufs
unicode
vboxsf
verity
xfs
zonefs
Kconfig
Kconfig.binfmt
Makefile
aio.c
anon_inodes.c
attr.c
bad_inode.c
binfmt_elf.c
binfmt_elf_fdpic.c
binfmt_elf_test.c
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
buffer.c
char_dev.c
compat_binfmt_elf.c
coredump.c
d_path.c
dax.c
dcache.c
direct-io.c
drop_caches.c
eventfd.c
eventpoll.c
exec.c
fcntl.c
fhandle.c
file.c
file_table.c
filesystems.c
fs-writeback.c
fs_context.c
fs_parser.c
fs_pin.c
fs_struct.c
fs_types.c
fsopen.c
init.c
inode.c
internal.h
ioctl.c
kernel_read_file.c
libfs.c
locks.c
mbcache.c
mnt_idmapping.c
mount.h
mpage.c
namei.c
namespace.c
nsfs.c
open.c
pipe.c
pnode.c
pnode.h
posix_acl.c
proc_namespace.c
read_write.c
readdir.c
remap_range.c
select.c
seq_file.c
signalfd.c
splice.c
stack.c
stat.c
statfs.c
super.c
sync.c
sysctls.c
timerfd.c
userfaultfd.c
utimes.c
xattr.c
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
Breadcrumbs
linux
/
fs
/
netfs
/
internal.h
Blame
Blame
Latest commit
History
History
433 lines (372 loc) · 11.6 KB
Breadcrumbs
linux
/
fs
/
netfs
/
internal.h
Top
File metadata and controls
Code
Blame
433 lines (372 loc) · 11.6 KB
Raw
/* SPDX-License-Identifier: GPL-2.0-or-later */ /* Internal definitions for network filesystem support * * Copyright (C) 2021 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) */ #include <linux/slab.h> #include <linux/seq_file.h> #include <linux/netfs.h> #include <linux/fscache.h> #include <linux/fscache-cache.h> #include <trace/events/netfs.h> #include <trace/events/fscache.h> #ifdef pr_fmt #undef pr_fmt #endif #define pr_fmt(fmt) "netfs: " fmt /* * buffered_read.c */ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq); int netfs_prefetch_for_write(struct file *file, struct folio *folio, size_t offset, size_t len); /* * direct_write.c */ ssize_t netfs_unbuffered_write_iter_locked(struct kiocb *iocb, struct iov_iter *iter, struct netfs_group *netfs_group); /* * io.c */ int netfs_begin_read(struct netfs_io_request *rreq, bool sync); /* * main.c */ extern unsigned int netfs_debug; extern struct list_head netfs_io_requests; extern spinlock_t netfs_proc_lock; #ifdef CONFIG_PROC_FS static inline void netfs_proc_add_rreq(struct netfs_io_request *rreq) { spin_lock(&netfs_proc_lock); list_add_tail_rcu(&rreq->proc_link, &netfs_io_requests); spin_unlock(&netfs_proc_lock); } static inline void netfs_proc_del_rreq(struct netfs_io_request *rreq) { if (!list_empty(&rreq->proc_link)) { spin_lock(&netfs_proc_lock); list_del_rcu(&rreq->proc_link); spin_unlock(&netfs_proc_lock); } } #else static inline void netfs_proc_add_rreq(struct netfs_io_request *rreq) {} static inline void netfs_proc_del_rreq(struct netfs_io_request *rreq) {} #endif /* * misc.c */ #define NETFS_FLAG_PUT_MARK BIT(0) #define NETFS_FLAG_PAGECACHE_MARK BIT(1) int netfs_xa_store_and_mark(struct xarray *xa, unsigned long index, struct folio *folio, unsigned int flags, gfp_t gfp_mask); int netfs_add_folios_to_buffer(struct xarray *buffer, struct address_space *mapping, pgoff_t index, pgoff_t to, gfp_t gfp_mask); void netfs_clear_buffer(struct xarray *buffer); /* * objects.c */ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping, struct file *file, loff_t start, size_t len, enum netfs_io_origin origin); void netfs_get_request(struct netfs_io_request *rreq, enum netfs_rreq_ref_trace what); void netfs_clear_subrequests(struct netfs_io_request *rreq, bool was_async); void netfs_put_request(struct netfs_io_request *rreq, bool was_async, enum netfs_rreq_ref_trace what); struct netfs_io_subrequest *netfs_alloc_subrequest(struct netfs_io_request *rreq); static inline void netfs_see_request(struct netfs_io_request *rreq, enum netfs_rreq_ref_trace what) { trace_netfs_rreq_ref(rreq->debug_id, refcount_read(&rreq->ref), what); } /* * output.c */ int netfs_begin_write(struct netfs_io_request *wreq, bool may_wait, enum netfs_write_trace what); struct netfs_io_request *netfs_begin_writethrough(struct kiocb *iocb, size_t len); int netfs_advance_writethrough(struct netfs_io_request *wreq, size_t copied, bool to_page_end); int netfs_end_writethrough(struct netfs_io_request *wreq, struct kiocb *iocb); /* * stats.c */ #ifdef CONFIG_NETFS_STATS extern atomic_t netfs_n_rh_dio_read; extern atomic_t netfs_n_rh_readahead; extern atomic_t netfs_n_rh_readpage; extern atomic_t netfs_n_rh_rreq; extern atomic_t netfs_n_rh_sreq; extern atomic_t netfs_n_rh_download; extern atomic_t netfs_n_rh_download_done; extern atomic_t netfs_n_rh_download_failed; extern atomic_t netfs_n_rh_download_instead; extern atomic_t netfs_n_rh_read; extern atomic_t netfs_n_rh_read_done; extern atomic_t netfs_n_rh_read_failed; extern atomic_t netfs_n_rh_zero; extern atomic_t netfs_n_rh_short_read; extern atomic_t netfs_n_rh_write; extern atomic_t netfs_n_rh_write_begin; extern atomic_t netfs_n_rh_write_done; extern atomic_t netfs_n_rh_write_failed; extern atomic_t netfs_n_rh_write_zskip; extern atomic_t netfs_n_wh_upload; extern atomic_t netfs_n_wh_upload_done; extern atomic_t netfs_n_wh_upload_failed; extern atomic_t netfs_n_wh_write; extern atomic_t netfs_n_wh_write_done; extern atomic_t netfs_n_wh_write_failed; int netfs_stats_show(struct seq_file *m, void *v); static inline void netfs_stat(atomic_t *stat) { atomic_inc(stat); } static inline void netfs_stat_d(atomic_t *stat) { atomic_dec(stat); } #else #define netfs_stat(x) do {} while(0) #define netfs_stat_d(x) do {} while(0) #endif /* * Miscellaneous functions. */ static inline bool netfs_is_cache_enabled(struct netfs_inode *ctx) { #if IS_ENABLED(CONFIG_FSCACHE) struct fscache_cookie *cookie = ctx->cache; return fscache_cookie_valid(cookie) && cookie->cache_priv && fscache_cookie_enabled(cookie); #else return false; #endif } /* * 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 extern const struct seq_operations fscache_caches_seq_ops; #endif bool fscache_begin_cache_access(struct fscache_cache *cache, enum fscache_access_trace why); void fscache_end_cache_access(struct fscache_cache *cache, enum fscache_access_trace why); struct fscache_cache *fscache_lookup_cache(const char *name, bool is_cache); void fscache_put_cache(struct fscache_cache *cache, enum fscache_cache_trace where); static inline enum fscache_cache_state fscache_cache_state(const struct fscache_cache *cache) { return smp_load_acquire(&cache->state); } static inline bool fscache_cache_is_live(const struct fscache_cache *cache) { return fscache_cache_state(cache) == FSCACHE_CACHE_IS_ACTIVE; } static inline void fscache_set_cache_state(struct fscache_cache *cache, enum fscache_cache_state new_state) { smp_store_release(&cache->state, new_state); } static inline bool fscache_set_cache_state_maybe(struct fscache_cache *cache, enum fscache_cache_state old_state, enum fscache_cache_state new_state) { return try_cmpxchg_release(&cache->state, &old_state, new_state); } /* * fscache-cookie.c */ extern struct kmem_cache *fscache_cookie_jar; #ifdef CONFIG_PROC_FS extern const struct seq_operations fscache_cookies_seq_ops; #endif extern struct timer_list fscache_cookie_lru_timer; extern void fscache_print_cookie(struct fscache_cookie *cookie, char prefix); extern bool fscache_begin_cookie_access(struct fscache_cookie *cookie, enum fscache_access_trace why); static inline void fscache_see_cookie(struct fscache_cookie *cookie, enum fscache_cookie_trace where) { trace_fscache_cookie(cookie->debug_id, refcount_read(&cookie->ref), where); } /* * fscache-main.c */ extern unsigned int fscache_hash(unsigned int salt, const void *data, size_t len); #ifdef CONFIG_FSCACHE int __init fscache_init(void); void __exit fscache_exit(void); #else static inline int fscache_init(void) { return 0; } static inline void fscache_exit(void) {} #endif /* * fscache-proc.c */ #ifdef CONFIG_PROC_FS extern int __init fscache_proc_init(void); extern void fscache_proc_cleanup(void); #else #define fscache_proc_init() (0) #define fscache_proc_cleanup() do {} while (0) #endif /* * fscache-stats.c */ #ifdef CONFIG_FSCACHE_STATS extern atomic_t fscache_n_volumes; extern atomic_t fscache_n_volumes_collision; extern atomic_t fscache_n_volumes_nomem; extern atomic_t fscache_n_cookies; extern atomic_t fscache_n_cookies_lru; extern atomic_t fscache_n_cookies_lru_expired; extern atomic_t fscache_n_cookies_lru_removed; extern atomic_t fscache_n_cookies_lru_dropped; extern atomic_t fscache_n_acquires; extern atomic_t fscache_n_acquires_ok; extern atomic_t fscache_n_acquires_oom; extern atomic_t fscache_n_invalidates; extern atomic_t fscache_n_relinquishes; extern atomic_t fscache_n_relinquishes_retire; extern atomic_t fscache_n_relinquishes_dropped; extern atomic_t fscache_n_resizes; extern atomic_t fscache_n_resizes_null; static inline void fscache_stat(atomic_t *stat) { atomic_inc(stat); } static inline void fscache_stat_d(atomic_t *stat) { atomic_dec(stat); } #define __fscache_stat(stat) (stat) int fscache_stats_show(struct seq_file *m); #else #define __fscache_stat(stat) (NULL) #define fscache_stat(stat) do {} while (0) #define fscache_stat_d(stat) do {} while (0) static inline int fscache_stats_show(struct seq_file *m) { return 0; } #endif /* * fscache-volume.c */ #ifdef CONFIG_PROC_FS extern const struct seq_operations fscache_volumes_seq_ops; #endif struct fscache_volume *fscache_get_volume(struct fscache_volume *volume, enum fscache_volume_trace where); void fscache_put_volume(struct fscache_volume *volume, enum fscache_volume_trace where); bool fscache_begin_volume_access(struct fscache_volume *volume, struct fscache_cookie *cookie, enum fscache_access_trace why); void fscache_create_volume(struct fscache_volume *volume, bool wait); /*****************************************************************************/ /* * debug tracing */ #define dbgprintk(FMT, ...) \ printk("[%-6.6s] "FMT"\n", current->comm, ##__VA_ARGS__) #define kenter(FMT, ...) dbgprintk("==> %s("FMT")", __func__, ##__VA_ARGS__) #define kleave(FMT, ...) dbgprintk("<== %s()"FMT"", __func__, ##__VA_ARGS__) #define kdebug(FMT, ...) dbgprintk(FMT, ##__VA_ARGS__) #ifdef __KDEBUG #define _enter(FMT, ...) kenter(FMT, ##__VA_ARGS__) #define _leave(FMT, ...) kleave(FMT, ##__VA_ARGS__) #define _debug(FMT, ...) kdebug(FMT, ##__VA_ARGS__) #elif defined(CONFIG_NETFS_DEBUG) #define _enter(FMT, ...) \ do { \ if (netfs_debug) \ kenter(FMT, ##__VA_ARGS__); \ } while (0) #define _leave(FMT, ...) \ do { \ if (netfs_debug) \ kleave(FMT, ##__VA_ARGS__); \ } while (0) #define _debug(FMT, ...) \ do { \ if (netfs_debug) \ kdebug(FMT, ##__VA_ARGS__); \ } while (0) #else #define _enter(FMT, ...) no_printk("==> %s("FMT")", __func__, ##__VA_ARGS__) #define _leave(FMT, ...) no_printk("<== %s()"FMT"", __func__, ##__VA_ARGS__) #define _debug(FMT, ...) no_printk(FMT, ##__VA_ARGS__) #endif /* * assertions */ #if 1 /* defined(__KDEBUGALL) */ #define ASSERT(X) \ do { \ if (unlikely(!(X))) { \ pr_err("\n"); \ pr_err("Assertion failed\n"); \ BUG(); \ } \ } while (0) #define ASSERTCMP(X, OP, Y) \ do { \ if (unlikely(!((X) OP (Y)))) { \ pr_err("\n"); \ pr_err("Assertion failed\n"); \ pr_err("%lx " #OP " %lx is false\n", \ (unsigned long)(X), (unsigned long)(Y)); \ BUG(); \ } \ } while (0) #define ASSERTIF(C, X) \ do { \ if (unlikely((C) && !(X))) { \ pr_err("\n"); \ pr_err("Assertion failed\n"); \ BUG(); \ } \ } while (0) #define ASSERTIFCMP(C, X, OP, Y) \ do { \ if (unlikely((C) && !((X) OP (Y)))) { \ pr_err("\n"); \ pr_err("Assertion failed\n"); \ pr_err("%lx " #OP " %lx is false\n", \ (unsigned long)(X), (unsigned long)(Y)); \ BUG(); \ } \ } while (0) #else #define ASSERT(X) do {} while (0) #define ASSERTCMP(X, OP, Y) do {} while (0) #define ASSERTIF(C, X) do {} while (0) #define ASSERTIFCMP(C, X, OP, Y) do {} while (0) #endif /* assert or not */
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
You can’t perform that action at this time.