Skip to content

Commit cbcc268

Browse files
author
Matthew Wilcox (Oracle)
committed
fs: Move many prototypes to pagemap.h
These functions are page cache functionality and don't need to be declared in fs.h. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Miaohe Lin <[email protected]>
1 parent c56109d commit cbcc268

File tree

9 files changed

+121
-116
lines changed

9 files changed

+121
-116
lines changed

drivers/block/xen-blkback/xenbus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/module.h>
1212
#include <linux/kthread.h>
13+
#include <linux/pagemap.h>
1314
#include <xen/events.h>
1415
#include <xen/grant_table.h>
1516
#include "common.h"

drivers/usb/gadget/function/f_mass_storage.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
#include <linux/kthread.h>
180180
#include <linux/sched/signal.h>
181181
#include <linux/limits.h>
182+
#include <linux/pagemap.h>
182183
#include <linux/rwsem.h>
183184
#include <linux/slab.h>
184185
#include <linux/spinlock.h>

fs/coda/file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/time.h>
1515
#include <linux/file.h>
1616
#include <linux/fs.h>
17+
#include <linux/pagemap.h>
1718
#include <linux/stat.h>
1819
#include <linux/cred.h>
1920
#include <linux/errno.h>

fs/iomap/fiemap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/fs.h>
88
#include <linux/iomap.h>
99
#include <linux/fiemap.h>
10+
#include <linux/pagemap.h>
1011

1112
static int iomap_to_fiemap(struct fiemap_extent_info *fi,
1213
const struct iomap *iomap, u32 flags)

fs/nfsd/filecache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/hash.h>
88
#include <linux/slab.h>
99
#include <linux/file.h>
10+
#include <linux/pagemap.h>
1011
#include <linux/sched.h>
1112
#include <linux/list_lru.h>
1213
#include <linux/fsnotify_backend.h>

fs/nfsd/vfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/xattr.h>
2727
#include <linux/jhash.h>
2828
#include <linux/ima.h>
29+
#include <linux/pagemap.h>
2930
#include <linux/slab.h>
3031
#include <linux/uaccess.h>
3132
#include <linux/exportfs.h>

fs/vboxsf/utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/namei.h>
1010
#include <linux/nls.h>
1111
#include <linux/sizes.h>
12+
#include <linux/pagemap.h>
1213
#include <linux/vfs.h>
1314
#include "vfsmod.h"
1415

include/linux/fs.h

Lines changed: 0 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,50 +2746,6 @@ extern void init_special_inode(struct inode *, umode_t, dev_t);
27462746
extern void make_bad_inode(struct inode *);
27472747
extern bool is_bad_inode(struct inode *);
27482748

2749-
unsigned long invalidate_mapping_pages(struct address_space *mapping,
2750-
pgoff_t start, pgoff_t end);
2751-
2752-
static inline void invalidate_remote_inode(struct inode *inode)
2753-
{
2754-
if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
2755-
S_ISLNK(inode->i_mode))
2756-
invalidate_mapping_pages(inode->i_mapping, 0, -1);
2757-
}
2758-
extern int invalidate_inode_pages2(struct address_space *mapping);
2759-
extern int invalidate_inode_pages2_range(struct address_space *mapping,
2760-
pgoff_t start, pgoff_t end);
2761-
extern int write_inode_now(struct inode *, int);
2762-
extern int filemap_fdatawrite(struct address_space *);
2763-
extern int filemap_flush(struct address_space *);
2764-
extern int filemap_fdatawait_keep_errors(struct address_space *mapping);
2765-
extern int filemap_fdatawait_range(struct address_space *, loff_t lstart,
2766-
loff_t lend);
2767-
extern int filemap_fdatawait_range_keep_errors(struct address_space *mapping,
2768-
loff_t start_byte, loff_t end_byte);
2769-
2770-
static inline int filemap_fdatawait(struct address_space *mapping)
2771-
{
2772-
return filemap_fdatawait_range(mapping, 0, LLONG_MAX);
2773-
}
2774-
2775-
extern bool filemap_range_has_page(struct address_space *, loff_t lstart,
2776-
loff_t lend);
2777-
extern int filemap_write_and_wait_range(struct address_space *mapping,
2778-
loff_t lstart, loff_t lend);
2779-
extern int __filemap_fdatawrite_range(struct address_space *mapping,
2780-
loff_t start, loff_t end, int sync_mode);
2781-
extern int filemap_fdatawrite_range(struct address_space *mapping,
2782-
loff_t start, loff_t end);
2783-
extern int filemap_check_errors(struct address_space *mapping);
2784-
extern void __filemap_set_wb_err(struct address_space *mapping, int err);
2785-
int filemap_fdatawrite_wbc(struct address_space *mapping,
2786-
struct writeback_control *wbc);
2787-
2788-
static inline int filemap_write_and_wait(struct address_space *mapping)
2789-
{
2790-
return filemap_write_and_wait_range(mapping, 0, LLONG_MAX);
2791-
}
2792-
27932749
extern int __must_check file_fdatawait_range(struct file *file, loff_t lstart,
27942750
loff_t lend);
27952751
extern int __must_check file_check_and_advance_wb_err(struct file *file);
@@ -2801,67 +2757,6 @@ static inline int file_write_and_wait(struct file *file)
28012757
return file_write_and_wait_range(file, 0, LLONG_MAX);
28022758
}
28032759

2804-
/**
2805-
* filemap_set_wb_err - set a writeback error on an address_space
2806-
* @mapping: mapping in which to set writeback error
2807-
* @err: error to be set in mapping
2808-
*
2809-
* When writeback fails in some way, we must record that error so that
2810-
* userspace can be informed when fsync and the like are called. We endeavor
2811-
* to report errors on any file that was open at the time of the error. Some
2812-
* internal callers also need to know when writeback errors have occurred.
2813-
*
2814-
* When a writeback error occurs, most filesystems will want to call
2815-
* filemap_set_wb_err to record the error in the mapping so that it will be
2816-
* automatically reported whenever fsync is called on the file.
2817-
*/
2818-
static inline void filemap_set_wb_err(struct address_space *mapping, int err)
2819-
{
2820-
/* Fastpath for common case of no error */
2821-
if (unlikely(err))
2822-
__filemap_set_wb_err(mapping, err);
2823-
}
2824-
2825-
/**
2826-
* filemap_check_wb_err - has an error occurred since the mark was sampled?
2827-
* @mapping: mapping to check for writeback errors
2828-
* @since: previously-sampled errseq_t
2829-
*
2830-
* Grab the errseq_t value from the mapping, and see if it has changed "since"
2831-
* the given value was sampled.
2832-
*
2833-
* If it has then report the latest error set, otherwise return 0.
2834-
*/
2835-
static inline int filemap_check_wb_err(struct address_space *mapping,
2836-
errseq_t since)
2837-
{
2838-
return errseq_check(&mapping->wb_err, since);
2839-
}
2840-
2841-
/**
2842-
* filemap_sample_wb_err - sample the current errseq_t to test for later errors
2843-
* @mapping: mapping to be sampled
2844-
*
2845-
* Writeback errors are always reported relative to a particular sample point
2846-
* in the past. This function provides those sample points.
2847-
*/
2848-
static inline errseq_t filemap_sample_wb_err(struct address_space *mapping)
2849-
{
2850-
return errseq_sample(&mapping->wb_err);
2851-
}
2852-
2853-
/**
2854-
* file_sample_sb_err - sample the current errseq_t to test for later errors
2855-
* @file: file pointer to be sampled
2856-
*
2857-
* Grab the most current superblock-level errseq_t value for the given
2858-
* struct file.
2859-
*/
2860-
static inline errseq_t file_sample_sb_err(struct file *file)
2861-
{
2862-
return errseq_sample(&file->f_path.dentry->d_sb->s_wb_err);
2863-
}
2864-
28652760
extern int vfs_fsync_range(struct file *file, loff_t start, loff_t end,
28662761
int datasync);
28672762
extern int vfs_fsync(struct file *file, int datasync);
@@ -3604,15 +3499,4 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len,
36043499
extern int generic_fadvise(struct file *file, loff_t offset, loff_t len,
36053500
int advice);
36063501

3607-
/*
3608-
* Flush file data before changing attributes. Caller must hold any locks
3609-
* required to prevent further writes to this file until we're done setting
3610-
* flags.
3611-
*/
3612-
static inline int inode_drain_writes(struct inode *inode)
3613-
{
3614-
inode_dio_wait(inode);
3615-
return filemap_write_and_wait(inode->i_mapping);
3616-
}
3617-
36183502
#endif /* _LINUX_FS_H */

include/linux/pagemap.h

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,120 @@
1818

1919
struct folio_batch;
2020

21+
unsigned long invalidate_mapping_pages(struct address_space *mapping,
22+
pgoff_t start, pgoff_t end);
23+
24+
static inline void invalidate_remote_inode(struct inode *inode)
25+
{
26+
if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
27+
S_ISLNK(inode->i_mode))
28+
invalidate_mapping_pages(inode->i_mapping, 0, -1);
29+
}
30+
int invalidate_inode_pages2(struct address_space *mapping);
31+
int invalidate_inode_pages2_range(struct address_space *mapping,
32+
pgoff_t start, pgoff_t end);
33+
int write_inode_now(struct inode *, int sync);
34+
int filemap_fdatawrite(struct address_space *);
35+
int filemap_flush(struct address_space *);
36+
int filemap_fdatawait_keep_errors(struct address_space *mapping);
37+
int filemap_fdatawait_range(struct address_space *, loff_t lstart, loff_t lend);
38+
int filemap_fdatawait_range_keep_errors(struct address_space *mapping,
39+
loff_t start_byte, loff_t end_byte);
40+
41+
static inline int filemap_fdatawait(struct address_space *mapping)
42+
{
43+
return filemap_fdatawait_range(mapping, 0, LLONG_MAX);
44+
}
45+
46+
bool filemap_range_has_page(struct address_space *, loff_t lstart, loff_t lend);
47+
int filemap_write_and_wait_range(struct address_space *mapping,
48+
loff_t lstart, loff_t lend);
49+
int __filemap_fdatawrite_range(struct address_space *mapping,
50+
loff_t start, loff_t end, int sync_mode);
51+
int filemap_fdatawrite_range(struct address_space *mapping,
52+
loff_t start, loff_t end);
53+
int filemap_check_errors(struct address_space *mapping);
54+
void __filemap_set_wb_err(struct address_space *mapping, int err);
55+
int filemap_fdatawrite_wbc(struct address_space *mapping,
56+
struct writeback_control *wbc);
57+
58+
static inline int filemap_write_and_wait(struct address_space *mapping)
59+
{
60+
return filemap_write_and_wait_range(mapping, 0, LLONG_MAX);
61+
}
62+
63+
/**
64+
* filemap_set_wb_err - set a writeback error on an address_space
65+
* @mapping: mapping in which to set writeback error
66+
* @err: error to be set in mapping
67+
*
68+
* When writeback fails in some way, we must record that error so that
69+
* userspace can be informed when fsync and the like are called. We endeavor
70+
* to report errors on any file that was open at the time of the error. Some
71+
* internal callers also need to know when writeback errors have occurred.
72+
*
73+
* When a writeback error occurs, most filesystems will want to call
74+
* filemap_set_wb_err to record the error in the mapping so that it will be
75+
* automatically reported whenever fsync is called on the file.
76+
*/
77+
static inline void filemap_set_wb_err(struct address_space *mapping, int err)
78+
{
79+
/* Fastpath for common case of no error */
80+
if (unlikely(err))
81+
__filemap_set_wb_err(mapping, err);
82+
}
83+
84+
/**
85+
* filemap_check_wb_err - has an error occurred since the mark was sampled?
86+
* @mapping: mapping to check for writeback errors
87+
* @since: previously-sampled errseq_t
88+
*
89+
* Grab the errseq_t value from the mapping, and see if it has changed "since"
90+
* the given value was sampled.
91+
*
92+
* If it has then report the latest error set, otherwise return 0.
93+
*/
94+
static inline int filemap_check_wb_err(struct address_space *mapping,
95+
errseq_t since)
96+
{
97+
return errseq_check(&mapping->wb_err, since);
98+
}
99+
100+
/**
101+
* filemap_sample_wb_err - sample the current errseq_t to test for later errors
102+
* @mapping: mapping to be sampled
103+
*
104+
* Writeback errors are always reported relative to a particular sample point
105+
* in the past. This function provides those sample points.
106+
*/
107+
static inline errseq_t filemap_sample_wb_err(struct address_space *mapping)
108+
{
109+
return errseq_sample(&mapping->wb_err);
110+
}
111+
112+
/**
113+
* file_sample_sb_err - sample the current errseq_t to test for later errors
114+
* @file: file pointer to be sampled
115+
*
116+
* Grab the most current superblock-level errseq_t value for the given
117+
* struct file.
118+
*/
119+
static inline errseq_t file_sample_sb_err(struct file *file)
120+
{
121+
return errseq_sample(&file->f_path.dentry->d_sb->s_wb_err);
122+
}
123+
124+
/*
125+
* Flush file data before changing attributes. Caller must hold any locks
126+
* required to prevent further writes to this file until we're done setting
127+
* flags.
128+
*/
129+
static inline int inode_drain_writes(struct inode *inode)
130+
{
131+
inode_dio_wait(inode);
132+
return filemap_write_and_wait(inode->i_mapping);
133+
}
134+
21135
static inline bool mapping_empty(struct address_space *mapping)
22136
{
23137
return xa_empty(&mapping->i_pages);

0 commit comments

Comments
 (0)