mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 12:28:41 +08:00
93345c3ba5
Rename netfs_rreq_unlock() to netfs_rreq_unlock_folios() to make it sound less like it's dropping a lock on an netfs_io_request struct. Remove the 'static' marker on netfs_rreq_unlock_folios() and declaring it in internal.h preparatory to splitting the file. Changes ======= ver #2) - Slide this patch to after the one adding netfs_begin_read(). - As a consequence, don't need to unstatic so many functions. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: linux-cachefs@redhat.com Link: https://lore.kernel.org/r/164623002861.3564931.17340149482236413375.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/164678215208.1200972.9761906209395002182.stgit@warthog.procyon.org.uk/ # v2 Link: https://lore.kernel.org/r/164692912709.2099075.4349905992838317797.stgit@warthog.procyon.org.uk/ # v3
143 lines
3.7 KiB
C
143 lines
3.7 KiB
C
/* 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/netfs.h>
|
|
#include <linux/fscache.h>
|
|
#include <trace/events/netfs.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);
|
|
|
|
/*
|
|
* 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);
|
|
}
|
|
|
|
/*
|
|
* read_helper.c
|
|
*/
|
|
extern unsigned int netfs_debug;
|
|
|
|
int netfs_begin_read(struct netfs_io_request *rreq, bool sync);
|
|
|
|
/*
|
|
* stats.c
|
|
*/
|
|
#ifdef CONFIG_NETFS_STATS
|
|
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;
|
|
|
|
|
|
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_i_context *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
|
|
}
|
|
|
|
/*****************************************************************************/
|
|
/*
|
|
* 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
|