add patch fix-wrong-return-value-in-ext4_read_inode_bitmap
[ext4-patch-queue.git] / old-patches / move-read-page-functions-to-new-file
blob6a477f1d8152322fd115abf9632cfbc5ef70d77c
1 ext4: move ext4_readpage() and ext4_readpages() to their own file
3 In preparation for weaning ext4 completely off of fs/mpage.c, move the
4 readpage[s] function to their own file.  Eventually we'll probably end
5 up moving the writepage[s] function here and renaming this to
6 something like read_write_page.c, or some such, but for now, let's
7 keep things simple.
9 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
10 ---
11  fs/ext4/Makefile   |  2 +-
12  fs/ext4/ext4.h     |  5 +++++
13  fs/ext4/inode.c    | 29 -----------------------------
14  fs/ext4/readpage.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15  4 files changed, 66 insertions(+), 30 deletions(-)
17 diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile
18 index 0310fec..cd6f50f 100644
19 --- a/fs/ext4/Makefile
20 +++ b/fs/ext4/Makefile
21 @@ -8,7 +8,7 @@ ext4-y  := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \
22                 ioctl.o namei.o super.o symlink.o hash.o resize.o extents.o \
23                 ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o \
24                 mmp.o indirect.o extents_status.o xattr.o xattr_user.o \
25 -               xattr_trusted.o inline.o
26 +               xattr_trusted.o inline.o readpage.o
28  ext4-$(CONFIG_EXT4_FS_POSIX_ACL)       += acl.o
29  ext4-$(CONFIG_EXT4_FS_SECURITY)                += xattr_security.o
30 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
31 index f70c3fc..5c115ea 100644
32 --- a/fs/ext4/ext4.h
33 +++ b/fs/ext4/ext4.h
34 @@ -2775,6 +2775,11 @@ extern int ext4_bio_write_page(struct ext4_io_submit *io,
35                                struct writeback_control *wbc,
36                                bool keep_towrite);
38 +/* readpage.c */
39 +extern int ext4_readpage(struct file *file, struct page *page);
40 +extern int ext4_readpages(struct file *file, struct address_space *mapping,
41 +                         struct list_head *pages, unsigned nr_pages);
43  /* mmp.c */
44  extern int ext4_multi_mount_protect(struct super_block *, ext4_fsblk_t);
46 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
47 index d5dd7d4..b3c7b92 100644
48 --- a/fs/ext4/inode.c
49 +++ b/fs/ext4/inode.c
50 @@ -2798,35 +2798,6 @@ static sector_t ext4_bmap(struct address_space *mapping, sector_t block)
51         return generic_block_bmap(mapping, block, ext4_get_block);
52  }
54 -static int ext4_readpage(struct file *file, struct page *page)
56 -       int ret = -EAGAIN;
57 -       struct inode *inode = page->mapping->host;
59 -       trace_ext4_readpage(page);
61 -       if (ext4_has_inline_data(inode))
62 -               ret = ext4_readpage_inline(inode, page);
64 -       if (ret == -EAGAIN)
65 -               return mpage_readpage(page, ext4_get_block);
67 -       return ret;
70 -static int
71 -ext4_readpages(struct file *file, struct address_space *mapping,
72 -               struct list_head *pages, unsigned nr_pages)
74 -       struct inode *inode = mapping->host;
76 -       /* If the file has inline data, no need to do readpages. */
77 -       if (ext4_has_inline_data(inode))
78 -               return 0;
80 -       return mpage_readpages(mapping, pages, nr_pages, ext4_get_block);
83  static void ext4_invalidatepage(struct page *page, unsigned int offset,
84                                 unsigned int length)
85  {
86 diff --git a/fs/ext4/readpage.c b/fs/ext4/readpage.c
87 new file mode 100644
88 index 0000000..b5249db
89 --- /dev/null
90 +++ b/fs/ext4/readpage.c
91 @@ -0,0 +1,60 @@
92 +/*
93 + *  linux/fs/ext4/readpage.c
94 + */
96 +#include <linux/fs.h>
97 +#include <linux/time.h>
98 +#include <linux/jbd2.h>
99 +#include <linux/highuid.h>
100 +#include <linux/pagemap.h>
101 +#include <linux/quotaops.h>
102 +#include <linux/string.h>
103 +#include <linux/buffer_head.h>
104 +#include <linux/writeback.h>
105 +#include <linux/pagevec.h>
106 +#include <linux/mpage.h>
107 +#include <linux/namei.h>
108 +#include <linux/uio.h>
109 +#include <linux/bio.h>
110 +#include <linux/workqueue.h>
111 +#include <linux/kernel.h>
112 +#include <linux/printk.h>
113 +#include <linux/slab.h>
114 +#include <linux/ratelimit.h>
115 +#include <linux/aio.h>
116 +#include <linux/bitops.h>
118 +#include "ext4_jbd2.h"
119 +#include "xattr.h"
120 +#include "acl.h"
122 +#include <trace/events/ext4.h>
124 +int ext4_readpage(struct file *file, struct page *page)
126 +       int ret = -EAGAIN;
127 +       struct inode *inode = page->mapping->host;
129 +       trace_ext4_readpage(page);
131 +       if (ext4_has_inline_data(inode))
132 +               ret = ext4_readpage_inline(inode, page);
134 +       if (ret == -EAGAIN)
135 +               return mpage_readpage(page, ext4_get_block);
137 +       return ret;
140 +int ext4_readpages(struct file *file, struct address_space *mapping,
141 +                  struct list_head *pages, unsigned nr_pages)
143 +       struct inode *inode = mapping->host;
145 +       /* If the file has inline data, no need to do readpages. */
146 +       if (ext4_has_inline_data(inode))
147 +               return 0;
149 +       return mpage_readpages(mapping, pages, nr_pages, ext4_get_block);