aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fscache/object-list.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fscache/object-list.c')
-rw-r--r--fs/fscache/object-list.c103
1 files changed, 45 insertions, 58 deletions
diff --git a/fs/fscache/object-list.c b/fs/fscache/object-list.c
index f27c89d17885..e1959efad64f 100644
--- a/fs/fscache/object-list.c
+++ b/fs/fscache/object-list.c
@@ -70,13 +70,10 @@ void fscache_objlist_add(struct fscache_object *obj)
70 write_unlock(&fscache_object_list_lock); 70 write_unlock(&fscache_object_list_lock);
71} 71}
72 72
73/** 73/*
74 * fscache_object_destroy - Note that a cache object is about to be destroyed 74 * Remove an object from the object list.
75 * @object: The object to be destroyed
76 *
77 * Note the imminent destruction and deallocation of a cache object record.
78 */ 75 */
79void fscache_object_destroy(struct fscache_object *obj) 76void fscache_objlist_remove(struct fscache_object *obj)
80{ 77{
81 write_lock(&fscache_object_list_lock); 78 write_lock(&fscache_object_list_lock);
82 79
@@ -85,7 +82,6 @@ void fscache_object_destroy(struct fscache_object *obj)
85 82
86 write_unlock(&fscache_object_list_lock); 83 write_unlock(&fscache_object_list_lock);
87} 84}
88EXPORT_SYMBOL(fscache_object_destroy);
89 85
90/* 86/*
91 * find the object in the tree on or after the specified index 87 * find the object in the tree on or after the specified index
@@ -166,15 +162,14 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
166{ 162{
167 struct fscache_objlist_data *data = m->private; 163 struct fscache_objlist_data *data = m->private;
168 struct fscache_object *obj = v; 164 struct fscache_object *obj = v;
165 struct fscache_cookie *cookie;
169 unsigned long config = data->config; 166 unsigned long config = data->config;
170 uint16_t keylen, auxlen;
171 char _type[3], *type; 167 char _type[3], *type;
172 bool no_cookie;
173 u8 *buf = data->buf, *p; 168 u8 *buf = data->buf, *p;
174 169
175 if ((unsigned long) v == 1) { 170 if ((unsigned long) v == 1) {
176 seq_puts(m, "OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS" 171 seq_puts(m, "OBJECT PARENT STAT CHLDN OPS OOP IPR EX READS"
177 " EM EV F S" 172 " EM EV FL S"
178 " | NETFS_COOKIE_DEF TY FL NETFS_DATA"); 173 " | NETFS_COOKIE_DEF TY FL NETFS_DATA");
179 if (config & (FSCACHE_OBJLIST_CONFIG_KEY | 174 if (config & (FSCACHE_OBJLIST_CONFIG_KEY |
180 FSCACHE_OBJLIST_CONFIG_AUX)) 175 FSCACHE_OBJLIST_CONFIG_AUX))
@@ -193,7 +188,7 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
193 188
194 if ((unsigned long) v == 2) { 189 if ((unsigned long) v == 2) {
195 seq_puts(m, "======== ======== ==== ===== === === === == =====" 190 seq_puts(m, "======== ======== ==== ===== === === === == ====="
196 " == == = =" 191 " == == == ="
197 " | ================ == == ================"); 192 " | ================ == == ================");
198 if (config & (FSCACHE_OBJLIST_CONFIG_KEY | 193 if (config & (FSCACHE_OBJLIST_CONFIG_KEY |
199 FSCACHE_OBJLIST_CONFIG_AUX)) 194 FSCACHE_OBJLIST_CONFIG_AUX))
@@ -216,10 +211,11 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
216 } \ 211 } \
217 } while(0) 212 } while(0)
218 213
214 cookie = obj->cookie;
219 if (~config) { 215 if (~config) {
220 FILTER(obj->cookie, 216 FILTER(cookie->def,
221 COOKIE, NOCOOKIE); 217 COOKIE, NOCOOKIE);
222 FILTER(obj->state != FSCACHE_OBJECT_ACTIVE || 218 FILTER(fscache_object_is_active(obj) ||
223 obj->n_ops != 0 || 219 obj->n_ops != 0 ||
224 obj->n_obj_ops != 0 || 220 obj->n_obj_ops != 0 ||
225 obj->flags || 221 obj->flags ||
@@ -235,10 +231,10 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
235 } 231 }
236 232
237 seq_printf(m, 233 seq_printf(m,
238 "%8x %8x %s %5u %3u %3u %3u %2u %5u %2lx %2lx %1lx %1x | ", 234 "%8x %8x %s %5u %3u %3u %3u %2u %5u %2lx %2lx %2lx %1x | ",
239 obj->debug_id, 235 obj->debug_id,
240 obj->parent ? obj->parent->debug_id : -1, 236 obj->parent ? obj->parent->debug_id : -1,
241 fscache_object_states_short[obj->state], 237 obj->state->short_name,
242 obj->n_children, 238 obj->n_children,
243 obj->n_ops, 239 obj->n_ops,
244 obj->n_obj_ops, 240 obj->n_obj_ops,
@@ -250,48 +246,40 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
250 obj->flags, 246 obj->flags,
251 work_busy(&obj->work)); 247 work_busy(&obj->work));
252 248
253 no_cookie = true; 249 if (fscache_use_cookie(obj)) {
254 keylen = auxlen = 0; 250 uint16_t keylen = 0, auxlen = 0;
255 if (obj->cookie) {
256 spin_lock(&obj->lock);
257 if (obj->cookie) {
258 switch (obj->cookie->def->type) {
259 case 0:
260 type = "IX";
261 break;
262 case 1:
263 type = "DT";
264 break;
265 default:
266 sprintf(_type, "%02u",
267 obj->cookie->def->type);
268 type = _type;
269 break;
270 }
271 251
272 seq_printf(m, "%-16s %s %2lx %16p", 252 switch (cookie->def->type) {
273 obj->cookie->def->name, 253 case 0:
274 type, 254 type = "IX";
275 obj->cookie->flags, 255 break;
276 obj->cookie->netfs_data); 256 case 1:
277 257 type = "DT";
278 if (obj->cookie->def->get_key && 258 break;
279 config & FSCACHE_OBJLIST_CONFIG_KEY) 259 default:
280 keylen = obj->cookie->def->get_key( 260 sprintf(_type, "%02u", cookie->def->type);
281 obj->cookie->netfs_data, 261 type = _type;
282 buf, 400); 262 break;
283
284 if (obj->cookie->def->get_aux &&
285 config & FSCACHE_OBJLIST_CONFIG_AUX)
286 auxlen = obj->cookie->def->get_aux(
287 obj->cookie->netfs_data,
288 buf + keylen, 512 - keylen);
289
290 no_cookie = false;
291 } 263 }
292 spin_unlock(&obj->lock);
293 264
294 if (!no_cookie && (keylen > 0 || auxlen > 0)) { 265 seq_printf(m, "%-16s %s %2lx %16p",
266 cookie->def->name,
267 type,
268 cookie->flags,
269 cookie->netfs_data);
270
271 if (cookie->def->get_key &&
272 config & FSCACHE_OBJLIST_CONFIG_KEY)
273 keylen = cookie->def->get_key(cookie->netfs_data,
274 buf, 400);
275
276 if (cookie->def->get_aux &&
277 config & FSCACHE_OBJLIST_CONFIG_AUX)
278 auxlen = cookie->def->get_aux(cookie->netfs_data,
279 buf + keylen, 512 - keylen);
280 fscache_unuse_cookie(obj);
281
282 if (keylen > 0 || auxlen > 0) {
295 seq_printf(m, " "); 283 seq_printf(m, " ");
296 for (p = buf; keylen > 0; keylen--) 284 for (p = buf; keylen > 0; keylen--)
297 seq_printf(m, "%02x", *p++); 285 seq_printf(m, "%02x", *p++);
@@ -302,12 +290,11 @@ static int fscache_objlist_show(struct seq_file *m, void *v)
302 seq_printf(m, "%02x", *p++); 290 seq_printf(m, "%02x", *p++);
303 } 291 }
304 } 292 }
305 }
306 293
307 if (no_cookie)
308 seq_printf(m, "<no_cookie>\n");
309 else
310 seq_printf(m, "\n"); 294 seq_printf(m, "\n");
295 } else {
296 seq_printf(m, "<no_netfs>\n");
297 }
311 return 0; 298 return 0;
312} 299}
313 300