diff options
Diffstat (limited to 'fs/gfs2/page.c')
-rw-r--r-- | fs/gfs2/page.c | 64 |
1 files changed, 26 insertions, 38 deletions
diff --git a/fs/gfs2/page.c b/fs/gfs2/page.c index cd93644c7d70..a8165a693b56 100644 --- a/fs/gfs2/page.c +++ b/fs/gfs2/page.c | |||
@@ -38,20 +38,17 @@ void gfs2_pte_inval(struct gfs2_glock *gl) | |||
38 | struct inode *inode; | 38 | struct inode *inode; |
39 | 39 | ||
40 | ip = gl->gl_object; | 40 | ip = gl->gl_object; |
41 | inode = &ip->i_inode; | ||
41 | if (!ip || !S_ISREG(ip->i_di.di_mode)) | 42 | if (!ip || !S_ISREG(ip->i_di.di_mode)) |
42 | return; | 43 | return; |
43 | 44 | ||
44 | if (!test_bit(GIF_PAGED, &ip->i_flags)) | 45 | if (!test_bit(GIF_PAGED, &ip->i_flags)) |
45 | return; | 46 | return; |
46 | 47 | ||
47 | inode = gfs2_ip2v_lookup(ip); | 48 | unmap_shared_mapping_range(inode->i_mapping, 0, 0); |
48 | if (inode) { | ||
49 | unmap_shared_mapping_range(inode->i_mapping, 0, 0); | ||
50 | iput(inode); | ||
51 | 49 | ||
52 | if (test_bit(GIF_SW_PAGED, &ip->i_flags)) | 50 | if (test_bit(GIF_SW_PAGED, &ip->i_flags)) |
53 | set_bit(GLF_DIRTY, &gl->gl_flags); | 51 | set_bit(GLF_DIRTY, &gl->gl_flags); |
54 | } | ||
55 | 52 | ||
56 | clear_bit(GIF_SW_PAGED, &ip->i_flags); | 53 | clear_bit(GIF_SW_PAGED, &ip->i_flags); |
57 | } | 54 | } |
@@ -68,19 +65,12 @@ void gfs2_page_inval(struct gfs2_glock *gl) | |||
68 | struct inode *inode; | 65 | struct inode *inode; |
69 | 66 | ||
70 | ip = gl->gl_object; | 67 | ip = gl->gl_object; |
68 | inode = &ip->i_inode; | ||
71 | if (!ip || !S_ISREG(ip->i_di.di_mode)) | 69 | if (!ip || !S_ISREG(ip->i_di.di_mode)) |
72 | return; | 70 | return; |
73 | 71 | ||
74 | inode = gfs2_ip2v_lookup(ip); | 72 | truncate_inode_pages(inode->i_mapping, 0); |
75 | if (inode) { | 73 | gfs2_assert_withdraw(GFS2_SB(&ip->i_inode), !inode->i_mapping->nrpages); |
76 | struct address_space *mapping = inode->i_mapping; | ||
77 | |||
78 | truncate_inode_pages(mapping, 0); | ||
79 | gfs2_assert_withdraw(ip->i_sbd, !mapping->nrpages); | ||
80 | |||
81 | iput(inode); | ||
82 | } | ||
83 | |||
84 | clear_bit(GIF_PAGED, &ip->i_flags); | 74 | clear_bit(GIF_PAGED, &ip->i_flags); |
85 | } | 75 | } |
86 | 76 | ||
@@ -97,32 +87,30 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags) | |||
97 | { | 87 | { |
98 | struct gfs2_inode *ip; | 88 | struct gfs2_inode *ip; |
99 | struct inode *inode; | 89 | struct inode *inode; |
90 | struct address_space *mapping; | ||
91 | int error = 0; | ||
100 | 92 | ||
101 | ip = gl->gl_object; | 93 | ip = gl->gl_object; |
94 | inode = &ip->i_inode; | ||
102 | if (!ip || !S_ISREG(ip->i_di.di_mode)) | 95 | if (!ip || !S_ISREG(ip->i_di.di_mode)) |
103 | return; | 96 | return; |
104 | 97 | ||
105 | inode = gfs2_ip2v_lookup(ip); | 98 | mapping = inode->i_mapping; |
106 | if (inode) { | ||
107 | struct address_space *mapping = inode->i_mapping; | ||
108 | int error = 0; | ||
109 | 99 | ||
110 | if (flags & DIO_START) | 100 | if (flags & DIO_START) |
111 | filemap_fdatawrite(mapping); | 101 | filemap_fdatawrite(mapping); |
112 | if (!error && (flags & DIO_WAIT)) | 102 | if (!error && (flags & DIO_WAIT)) |
113 | error = filemap_fdatawait(mapping); | 103 | error = filemap_fdatawait(mapping); |
114 | 104 | ||
115 | /* Put back any errors cleared by filemap_fdatawait() | 105 | /* Put back any errors cleared by filemap_fdatawait() |
116 | so they can be caught by someone who can pass them | 106 | so they can be caught by someone who can pass them |
117 | up to user space. */ | 107 | up to user space. */ |
118 | 108 | ||
119 | if (error == -ENOSPC) | 109 | if (error == -ENOSPC) |
120 | set_bit(AS_ENOSPC, &mapping->flags); | 110 | set_bit(AS_ENOSPC, &mapping->flags); |
121 | else if (error) | 111 | else if (error) |
122 | set_bit(AS_EIO, &mapping->flags); | 112 | set_bit(AS_EIO, &mapping->flags); |
123 | 113 | ||
124 | iput(inode); | ||
125 | } | ||
126 | } | 114 | } |
127 | 115 | ||
128 | /** | 116 | /** |
@@ -138,8 +126,8 @@ void gfs2_page_sync(struct gfs2_glock *gl, int flags) | |||
138 | int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, | 126 | int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, |
139 | uint64_t block, void *private) | 127 | uint64_t block, void *private) |
140 | { | 128 | { |
141 | struct gfs2_sbd *sdp = ip->i_sbd; | 129 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
142 | struct inode *inode = ip->i_vnode; | 130 | struct inode *inode = &ip->i_inode; |
143 | struct page *page = (struct page *)private; | 131 | struct page *page = (struct page *)private; |
144 | struct buffer_head *bh; | 132 | struct buffer_head *bh; |
145 | int release = 0; | 133 | int release = 0; |
@@ -193,8 +181,8 @@ int gfs2_unstuffer_page(struct gfs2_inode *ip, struct buffer_head *dibh, | |||
193 | int gfs2_block_truncate_page(struct address_space *mapping) | 181 | int gfs2_block_truncate_page(struct address_space *mapping) |
194 | { | 182 | { |
195 | struct inode *inode = mapping->host; | 183 | struct inode *inode = mapping->host; |
196 | struct gfs2_inode *ip = inode->u.generic_ip; | 184 | struct gfs2_inode *ip = GFS2_I(inode); |
197 | struct gfs2_sbd *sdp = ip->i_sbd; | 185 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
198 | loff_t from = inode->i_size; | 186 | loff_t from = inode->i_size; |
199 | unsigned long index = from >> PAGE_CACHE_SHIFT; | 187 | unsigned long index = from >> PAGE_CACHE_SHIFT; |
200 | unsigned offset = from & (PAGE_CACHE_SIZE-1); | 188 | unsigned offset = from & (PAGE_CACHE_SIZE-1); |