filemap.c (6d75f366b9242f9b17ed7d0b0604d7460f818f21) filemap.c (14b468791fa955d442f962fdf5207dfd39a131c8)
1/*
2 * linux/mm/filemap.c
3 *
4 * Copyright (C) 1994-1999 Linus Torvalds
5 */
6
7/*
8 * This file handles the generic file mmap semantics used by

--- 118 unchanged lines hidden (view full) ---

127 p = radix_tree_deref_slot_protected(slot, &mapping->tree_lock);
128 if (!radix_tree_exceptional_entry(p))
129 return -EEXIST;
130
131 mapping->nrexceptional--;
132 if (!dax_mapping(mapping)) {
133 if (shadowp)
134 *shadowp = p;
1/*
2 * linux/mm/filemap.c
3 *
4 * Copyright (C) 1994-1999 Linus Torvalds
5 */
6
7/*
8 * This file handles the generic file mmap semantics used by

--- 118 unchanged lines hidden (view full) ---

127 p = radix_tree_deref_slot_protected(slot, &mapping->tree_lock);
128 if (!radix_tree_exceptional_entry(p))
129 return -EEXIST;
130
131 mapping->nrexceptional--;
132 if (!dax_mapping(mapping)) {
133 if (shadowp)
134 *shadowp = p;
135 if (node)
136 workingset_node_shadows_dec(node);
137 } else {
138 /* DAX can replace empty locked entry with a hole */
139 WARN_ON_ONCE(p !=
140 (void *)(RADIX_TREE_EXCEPTIONAL_ENTRY |
141 RADIX_DAX_ENTRY_LOCK));
135 } else {
136 /* DAX can replace empty locked entry with a hole */
137 WARN_ON_ONCE(p !=
138 (void *)(RADIX_TREE_EXCEPTIONAL_ENTRY |
139 RADIX_DAX_ENTRY_LOCK));
142 /* DAX accounts exceptional entries as normal pages */
143 if (node)
144 workingset_node_pages_dec(node);
145 /* Wakeup waiters for exceptional entry lock */
146 dax_wake_mapping_entry_waiter(mapping, page->index,
147 false);
148 }
149 }
140 /* Wakeup waiters for exceptional entry lock */
141 dax_wake_mapping_entry_waiter(mapping, page->index,
142 false);
143 }
144 }
150 radix_tree_replace_slot(&mapping->page_tree, slot, page);
145 __radix_tree_replace(&mapping->page_tree, node, slot, page,
146 workingset_update_node, mapping);
151 mapping->nrpages++;
147 mapping->nrpages++;
152 if (node) {
153 workingset_node_pages_inc(node);
154 /*
155 * Don't track node that contains actual pages.
156 *
157 * Avoid acquiring the list_lru lock if already
158 * untracked. The list_empty() test is safe as
159 * node->private_list is protected by
160 * mapping->tree_lock.
161 */
162 if (!list_empty(&node->private_list))
163 list_lru_del(&workingset_shadow_nodes,
164 &node->private_list);
165 }
166 return 0;
167}
168
169static void page_cache_tree_delete(struct address_space *mapping,
170 struct page *page, void *shadow)
171{
172 int i, nr;
173

--- 6 unchanged lines hidden (view full) ---

180
181 for (i = 0; i < nr; i++) {
182 struct radix_tree_node *node;
183 void **slot;
184
185 __radix_tree_lookup(&mapping->page_tree, page->index + i,
186 &node, &slot);
187
148 return 0;
149}
150
151static void page_cache_tree_delete(struct address_space *mapping,
152 struct page *page, void *shadow)
153{
154 int i, nr;
155

--- 6 unchanged lines hidden (view full) ---

162
163 for (i = 0; i < nr; i++) {
164 struct radix_tree_node *node;
165 void **slot;
166
167 __radix_tree_lookup(&mapping->page_tree, page->index + i,
168 &node, &slot);
169
188 radix_tree_clear_tags(&mapping->page_tree, node, slot);
189
190 if (!node) {
191 VM_BUG_ON_PAGE(nr != 1, page);
192 /*
193 * We need a node to properly account shadow
194 * entries. Don't plant any without. XXX
195 */
196 shadow = NULL;
197 }
198
170 if (!node) {
171 VM_BUG_ON_PAGE(nr != 1, page);
172 /*
173 * We need a node to properly account shadow
174 * entries. Don't plant any without. XXX
175 */
176 shadow = NULL;
177 }
178
199 radix_tree_replace_slot(&mapping->page_tree, slot, shadow);
200
201 if (!node)
202 break;
203
204 workingset_node_pages_dec(node);
205 if (shadow)
206 workingset_node_shadows_inc(node);
207 else
208 if (__radix_tree_delete_node(&mapping->page_tree, node))
209 continue;
210
211 /*
212 * Track node that only contains shadow entries. DAX mappings
213 * contain no shadow entries and may contain other exceptional
214 * entries so skip those.
215 *
216 * Avoid acquiring the list_lru lock if already tracked.
217 * The list_empty() test is safe as node->private_list is
218 * protected by mapping->tree_lock.
219 */
220 if (!dax_mapping(mapping) && !workingset_node_pages(node) &&
221 list_empty(&node->private_list)) {
222 node->private_data = mapping;
223 list_lru_add(&workingset_shadow_nodes,
224 &node->private_list);
225 }
179 radix_tree_clear_tags(&mapping->page_tree, node, slot);
180 __radix_tree_replace(&mapping->page_tree, node, slot, shadow,
181 workingset_update_node, mapping);
226 }
227
228 if (shadow) {
229 mapping->nrexceptional += nr;
230 /*
231 * Make sure the nrexceptional update is committed before
232 * the nrpages update so that final truncate racing
233 * with reclaim does not see both counters 0 at the

--- 2695 unchanged lines hidden ---
182 }
183
184 if (shadow) {
185 mapping->nrexceptional += nr;
186 /*
187 * Make sure the nrexceptional update is committed before
188 * the nrpages update so that final truncate racing
189 * with reclaim does not see both counters 0 at the

--- 2695 unchanged lines hidden ---