Whamcloud - gitweb
LU-1866 osd: ancillary work for initial OI scrub
[fs/lustre-release.git] / lustre / llite / llite_capa.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
19  *
20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21  * CA 95054 USA or visit www.sun.com if you need additional information or
22  * have any questions.
23  *
24  * GPL HEADER END
25  */
26 /*
27  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
28  * Use is subject to license terms.
29  *
30  * Copyright (c) 2011, 2012, Intel Corporation.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/llite/llite_capa.c
37  *
38  * Author: Lai Siyao <lsy@clusterfs.com>
39  */
40
41 #define DEBUG_SUBSYSTEM S_LLITE
42
43 #include <linux/fs.h>
44 #include <linux/version.h>
45 #include <asm/uaccess.h>
46 #include <linux/file.h>
47 #include <linux/kmod.h>
48
49 #include <lustre_lite.h>
50 #include "llite_internal.h"
51
52 /* for obd_capa.c_list, client capa might stay in three places:
53  * 1. ll_capa_list.
54  * 2. ll_idle_capas.
55  * 3. stand alone: just allocated.
56  */
57
58 /* capas for oss writeback and those failed to renew */
59 static CFS_LIST_HEAD(ll_idle_capas);
60 static struct ptlrpc_thread ll_capa_thread;
61 static cfs_list_t *ll_capa_list = &capa_list[CAPA_SITE_CLIENT];
62
63 /* llite capa renewal timer */
64 struct timer_list ll_capa_timer;
65 /* for debug: indicate whether capa on llite is enabled or not */
66 static cfs_atomic_t ll_capa_debug = CFS_ATOMIC_INIT(0);
67 static unsigned long long ll_capa_renewed = 0;
68 static unsigned long long ll_capa_renewal_noent = 0;
69 static unsigned long long ll_capa_renewal_failed = 0;
70 static unsigned long long ll_capa_renewal_retries = 0;
71
72 static inline void update_capa_timer(struct obd_capa *ocapa, cfs_time_t expiry)
73 {
74         if (cfs_time_before(expiry, ll_capa_timer.expires) ||
75             !timer_pending(&ll_capa_timer)) {
76                 mod_timer(&ll_capa_timer, expiry);
77                 DEBUG_CAPA(D_SEC, &ocapa->c_capa,
78                            "ll_capa_timer update: %lu/%lu by", expiry, jiffies);
79         }
80 }
81
82 static inline cfs_time_t capa_renewal_time(struct obd_capa *ocapa)
83 {
84         return cfs_time_sub(ocapa->c_expiry,
85                             cfs_time_seconds(ocapa->c_capa.lc_timeout) / 2);
86 }
87
88 static inline int capa_is_to_expire(struct obd_capa *ocapa)
89 {
90         return cfs_time_beforeq(capa_renewal_time(ocapa), cfs_time_current());
91 }
92
93 static inline int have_expired_capa(void)
94 {
95         struct obd_capa *ocapa = NULL;
96         int expired = 0;
97
98         /* if ll_capa_list has client capa to expire or ll_idle_capas has
99          * expired capa, return 1.
100          */
101         spin_lock(&capa_lock);
102         if (!cfs_list_empty(ll_capa_list)) {
103                 ocapa = cfs_list_entry(ll_capa_list->next, struct obd_capa,
104                                        c_list);
105                 expired = capa_is_to_expire(ocapa);
106                 if (!expired)
107                         update_capa_timer(ocapa, capa_renewal_time(ocapa));
108         } else if (!cfs_list_empty(&ll_idle_capas)) {
109                 ocapa = cfs_list_entry(ll_idle_capas.next, struct obd_capa,
110                                        c_list);
111                 expired = capa_is_expired(ocapa);
112                 if (!expired)
113                         update_capa_timer(ocapa, ocapa->c_expiry);
114         }
115         spin_unlock(&capa_lock);
116
117         if (expired)
118                 DEBUG_CAPA(D_SEC, &ocapa->c_capa, "expired");
119         return expired;
120 }
121
122 static void sort_add_capa(struct obd_capa *ocapa, cfs_list_t *head)
123 {
124         struct obd_capa *tmp;
125         cfs_list_t *before = NULL;
126
127         /* TODO: client capa is sorted by expiry, this could be optimized */
128         cfs_list_for_each_entry_reverse(tmp, head, c_list) {
129                 if (cfs_time_aftereq(ocapa->c_expiry, tmp->c_expiry)) {
130                         before = &tmp->c_list;
131                         break;
132                 }
133         }
134
135         LASSERT(&ocapa->c_list != before);
136         cfs_list_add(&ocapa->c_list, before ?: head);
137 }
138
139 static inline int obd_capa_open_count(struct obd_capa *oc)
140 {
141         struct ll_inode_info *lli = ll_i2info(oc->u.cli.inode);
142         return cfs_atomic_read(&lli->lli_open_count);
143 }
144
145 static void ll_delete_capa(struct obd_capa *ocapa)
146 {
147         struct ll_inode_info *lli = ll_i2info(ocapa->u.cli.inode);
148
149         if (capa_for_mds(&ocapa->c_capa)) {
150                 LASSERT(lli->lli_mds_capa == ocapa);
151                 lli->lli_mds_capa = NULL;
152         } else if (capa_for_oss(&ocapa->c_capa)) {
153                 cfs_list_del_init(&ocapa->u.cli.lli_list);
154         }
155
156         DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free client");
157         cfs_list_del_init(&ocapa->c_list);
158         capa_count[CAPA_SITE_CLIENT]--;
159         /* release the ref when alloc */
160         capa_put(ocapa);
161 }
162
163 /* three places where client capa is deleted:
164  * 1. capa_thread_main(), main place to delete expired capa.
165  * 2. ll_clear_inode_capas() in ll_clear_inode().
166  * 3. ll_truncate_free_capa() delete truncate capa explicitly in ll_setattr_ost().
167  */
168 static int capa_thread_main(void *unused)
169 {
170         struct obd_capa *ocapa, *tmp, *next;
171         struct inode *inode = NULL;
172         struct l_wait_info lwi = { 0 };
173         int rc;
174         ENTRY;
175
176         cfs_daemonize("ll_capa");
177
178         thread_set_flags(&ll_capa_thread, SVC_RUNNING);
179         cfs_waitq_signal(&ll_capa_thread.t_ctl_waitq);
180
181         while (1) {
182                 l_wait_event(ll_capa_thread.t_ctl_waitq,
183                              !thread_is_running(&ll_capa_thread) ||
184                              have_expired_capa(),
185                              &lwi);
186
187                 if (!thread_is_running(&ll_capa_thread))
188                         break;
189
190                 next = NULL;
191
192                 spin_lock(&capa_lock);
193                 cfs_list_for_each_entry_safe(ocapa, tmp, ll_capa_list, c_list) {
194                         __u64 ibits;
195
196                         LASSERT(ocapa->c_capa.lc_opc != CAPA_OPC_OSS_TRUNC);
197
198                         if (!capa_is_to_expire(ocapa)) {
199                                 next = ocapa;
200                                 break;
201                         }
202
203                         cfs_list_del_init(&ocapa->c_list);
204
205                         /* for MDS capability, only renew those which belong to
206                          * dir, or its inode is opened, or client holds LOOKUP
207                          * lock.
208                          */
209                         /* ibits may be changed by ll_have_md_lock() so we have
210                          * to set it each time */
211                         ibits = MDS_INODELOCK_LOOKUP;
212                         if (capa_for_mds(&ocapa->c_capa) &&
213                             !S_ISDIR(ocapa->u.cli.inode->i_mode) &&
214                             obd_capa_open_count(ocapa) == 0 &&
215                             !ll_have_md_lock(ocapa->u.cli.inode,
216                                              &ibits, LCK_MINMODE)) {
217                                 DEBUG_CAPA(D_SEC, &ocapa->c_capa,
218                                            "skip renewal for");
219                                 sort_add_capa(ocapa, &ll_idle_capas);
220                                 continue;
221                         }
222
223                         /* for OSS capability, only renew those whose inode is
224                          * opened.
225                          */
226                         if (capa_for_oss(&ocapa->c_capa) &&
227                             obd_capa_open_count(ocapa) == 0) {
228                                 /* oss capa with open count == 0 won't renew,
229                                  * move to idle list */
230                                 sort_add_capa(ocapa, &ll_idle_capas);
231                                 continue;
232                         }
233
234                         /* NB iput() is in ll_update_capa() */
235                         inode = igrab(ocapa->u.cli.inode);
236                         if (inode == NULL) {
237                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
238                                            "igrab failed for");
239                                 continue;
240                         }
241
242                         capa_get(ocapa);
243                         ll_capa_renewed++;
244                         spin_unlock(&capa_lock);
245                         rc = md_renew_capa(ll_i2mdexp(inode), ocapa,
246                                            ll_update_capa);
247                         spin_lock(&capa_lock);
248                         if (rc) {
249                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
250                                            "renew failed: %d", rc);
251                                 ll_capa_renewal_failed++;
252                         }
253                 }
254
255                 if (next)
256                         update_capa_timer(next, capa_renewal_time(next));
257
258                 cfs_list_for_each_entry_safe(ocapa, tmp, &ll_idle_capas,
259                                              c_list) {
260                         if (!capa_is_expired(ocapa)) {
261                                 if (!next)
262                                         update_capa_timer(ocapa,
263                                                           ocapa->c_expiry);
264                                 break;
265                         }
266
267                         if (cfs_atomic_read(&ocapa->c_refc) > 1) {
268                                 DEBUG_CAPA(D_SEC, &ocapa->c_capa,
269                                            "expired(c_refc %d), don't release",
270                                            cfs_atomic_read(&ocapa->c_refc));
271                                 /* don't try to renew any more */
272                                 cfs_list_del_init(&ocapa->c_list);
273                                 continue;
274                         }
275
276                         /* expired capa is released. */
277                         DEBUG_CAPA(D_SEC, &ocapa->c_capa, "release expired");
278                         ll_delete_capa(ocapa);
279                 }
280
281                 spin_unlock(&capa_lock);
282         }
283
284         thread_set_flags(&ll_capa_thread, SVC_STOPPED);
285         cfs_waitq_signal(&ll_capa_thread.t_ctl_waitq);
286         RETURN(0);
287 }
288
289 void ll_capa_timer_callback(unsigned long unused)
290 {
291         cfs_waitq_signal(&ll_capa_thread.t_ctl_waitq);
292 }
293
294 int ll_capa_thread_start(void)
295 {
296         int rc;
297         ENTRY;
298
299         cfs_waitq_init(&ll_capa_thread.t_ctl_waitq);
300
301         rc = cfs_create_thread(capa_thread_main, NULL, 0);
302         if (rc < 0) {
303                 CERROR("cannot start expired capa thread: rc %d\n", rc);
304                 RETURN(rc);
305         }
306         cfs_wait_event(ll_capa_thread.t_ctl_waitq,
307                        thread_is_running(&ll_capa_thread));
308
309         RETURN(0);
310 }
311
312 void ll_capa_thread_stop(void)
313 {
314         thread_set_flags(&ll_capa_thread, SVC_STOPPING);
315         cfs_waitq_signal(&ll_capa_thread.t_ctl_waitq);
316         cfs_wait_event(ll_capa_thread.t_ctl_waitq,
317                        thread_is_stopped(&ll_capa_thread));
318 }
319
320 struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc)
321 {
322         struct ll_inode_info *lli = ll_i2info(inode);
323         struct obd_capa *ocapa;
324         int found = 0;
325
326         ENTRY;
327
328         if ((ll_i2sbi(inode)->ll_flags & LL_SBI_OSS_CAPA) == 0)
329                 RETURN(NULL);
330
331         LASSERT(opc == CAPA_OPC_OSS_WRITE || opc == CAPA_OPC_OSS_RW ||
332                 opc == CAPA_OPC_OSS_TRUNC);
333
334         spin_lock(&capa_lock);
335         cfs_list_for_each_entry(ocapa, &lli->lli_oss_capas, u.cli.lli_list) {
336                 if (capa_is_expired(ocapa))
337                         continue;
338                 if ((opc & CAPA_OPC_OSS_WRITE) &&
339                     capa_opc_supported(&ocapa->c_capa, CAPA_OPC_OSS_WRITE)) {
340                         found = 1;
341                         break;
342                 } else if ((opc & CAPA_OPC_OSS_READ) &&
343                            capa_opc_supported(&ocapa->c_capa,
344                                               CAPA_OPC_OSS_READ)) {
345                         found = 1;
346                         break;
347                 } else if ((opc & CAPA_OPC_OSS_TRUNC) &&
348                            capa_opc_supported(&ocapa->c_capa, opc)) {
349                         found = 1;
350                         break;
351                 }
352         }
353
354         if (found) {
355                 LASSERT(lu_fid_eq(capa_fid(&ocapa->c_capa),
356                                   ll_inode2fid(inode)));
357                 LASSERT(ocapa->c_site == CAPA_SITE_CLIENT);
358
359                 capa_get(ocapa);
360
361                 DEBUG_CAPA(D_SEC, &ocapa->c_capa, "found client");
362         } else {
363                 ocapa = NULL;
364
365                 if (cfs_atomic_read(&ll_capa_debug)) {
366                         CERROR("no capability for "DFID" opc "LPX64"\n",
367                                PFID(&lli->lli_fid), opc);
368                         cfs_atomic_set(&ll_capa_debug, 0);
369                 }
370         }
371         spin_unlock(&capa_lock);
372
373         RETURN(ocapa);
374 }
375 EXPORT_SYMBOL(ll_osscapa_get);
376
377 struct obd_capa *ll_mdscapa_get(struct inode *inode)
378 {
379         struct ll_inode_info *lli = ll_i2info(inode);
380         struct obd_capa *ocapa;
381         ENTRY;
382
383         LASSERT(inode != NULL);
384
385         if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0)
386                 RETURN(NULL);
387
388         spin_lock(&capa_lock);
389         ocapa = capa_get(lli->lli_mds_capa);
390         spin_unlock(&capa_lock);
391         if (!ocapa && cfs_atomic_read(&ll_capa_debug)) {
392                 CERROR("no mds capability for "DFID"\n", PFID(&lli->lli_fid));
393                 cfs_atomic_set(&ll_capa_debug, 0);
394         }
395
396         RETURN(ocapa);
397 }
398
399 static struct obd_capa *do_add_mds_capa(struct inode *inode,
400                                         struct obd_capa *ocapa)
401 {
402         struct ll_inode_info *lli = ll_i2info(inode);
403         struct obd_capa *old = lli->lli_mds_capa;
404         struct lustre_capa *capa = &ocapa->c_capa;
405
406         if (!old) {
407                 ocapa->u.cli.inode = inode;
408                 lli->lli_mds_capa = ocapa;
409                 capa_count[CAPA_SITE_CLIENT]++;
410
411                 DEBUG_CAPA(D_SEC, capa, "add MDS");
412         } else {
413                 spin_lock(&old->c_lock);
414                 old->c_capa = *capa;
415                 spin_unlock(&old->c_lock);
416
417                 DEBUG_CAPA(D_SEC, capa, "update MDS");
418
419                 capa_put(ocapa);
420                 ocapa = old;
421         }
422         return ocapa;
423 }
424
425 static struct obd_capa *do_lookup_oss_capa(struct inode *inode, int opc)
426 {
427         struct ll_inode_info *lli = ll_i2info(inode);
428         struct obd_capa *ocapa;
429
430         /* inside capa_lock */
431         cfs_list_for_each_entry(ocapa, &lli->lli_oss_capas, u.cli.lli_list) {
432                 if ((capa_opc(&ocapa->c_capa) & opc) != opc)
433                         continue;
434
435                 LASSERT(lu_fid_eq(capa_fid(&ocapa->c_capa),
436                                   ll_inode2fid(inode)));
437                 LASSERT(ocapa->c_site == CAPA_SITE_CLIENT);
438
439                 DEBUG_CAPA(D_SEC, &ocapa->c_capa, "found client");
440                 return ocapa;
441         }
442
443         return NULL;
444 }
445
446 static inline void inode_add_oss_capa(struct inode *inode,
447                                       struct obd_capa *ocapa)
448 {
449         struct ll_inode_info *lli = ll_i2info(inode);
450         struct obd_capa *tmp;
451         cfs_list_t *next = NULL;
452
453         /* capa is sorted in lli_oss_capas so lookup can always find the
454          * latest one */
455         cfs_list_for_each_entry(tmp, &lli->lli_oss_capas, u.cli.lli_list) {
456                 if (cfs_time_after(ocapa->c_expiry, tmp->c_expiry)) {
457                         next = &tmp->u.cli.lli_list;
458                         break;
459                 }
460         }
461         LASSERT(&ocapa->u.cli.lli_list != next);
462         cfs_list_move_tail(&ocapa->u.cli.lli_list, next ?: &lli->lli_oss_capas);
463 }
464
465 static struct obd_capa *do_add_oss_capa(struct inode *inode,
466                                         struct obd_capa *ocapa)
467 {
468         struct obd_capa *old;
469         struct lustre_capa *capa = &ocapa->c_capa;
470
471         LASSERTF(S_ISREG(inode->i_mode),
472                  "inode has oss capa, but not regular file, mode: %d\n",
473                  inode->i_mode);
474
475         /* FIXME: can't replace it so easily with fine-grained opc */
476         old = do_lookup_oss_capa(inode, capa_opc(capa) & CAPA_OPC_OSS_ONLY);
477         if (!old) {
478                 ocapa->u.cli.inode = inode;
479                 CFS_INIT_LIST_HEAD(&ocapa->u.cli.lli_list);
480                 capa_count[CAPA_SITE_CLIENT]++;
481
482                 DEBUG_CAPA(D_SEC, capa, "add OSS");
483         } else {
484                 spin_lock(&old->c_lock);
485                 old->c_capa = *capa;
486                 spin_unlock(&old->c_lock);
487
488                 DEBUG_CAPA(D_SEC, capa, "update OSS");
489
490                 capa_put(ocapa);
491                 ocapa = old;
492         }
493
494         inode_add_oss_capa(inode, ocapa);
495         return ocapa;
496 }
497
498 struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa)
499 {
500         spin_lock(&capa_lock);
501         ocapa = capa_for_mds(&ocapa->c_capa) ? do_add_mds_capa(inode, ocapa) :
502                                                do_add_oss_capa(inode, ocapa);
503
504         /* truncate capa won't renew */
505         if (ocapa->c_capa.lc_opc != CAPA_OPC_OSS_TRUNC) {
506                 set_capa_expiry(ocapa);
507                 cfs_list_del_init(&ocapa->c_list);
508                 sort_add_capa(ocapa, ll_capa_list);
509
510                 update_capa_timer(ocapa, capa_renewal_time(ocapa));
511         }
512
513         spin_unlock(&capa_lock);
514
515         cfs_atomic_set(&ll_capa_debug, 1);
516         return ocapa;
517 }
518
519 static inline void delay_capa_renew(struct obd_capa *oc, cfs_time_t delay)
520 {
521         /* NB: set a fake expiry for this capa to prevent it renew too soon */
522         oc->c_expiry = cfs_time_add(oc->c_expiry, cfs_time_seconds(delay));
523 }
524
525 int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
526 {
527         struct inode *inode = ocapa->u.cli.inode;
528         int rc = 0;
529         ENTRY;
530
531         LASSERT(ocapa);
532
533         if (IS_ERR(capa)) {
534                 /* set error code */
535                 rc = PTR_ERR(capa);
536                 spin_lock(&capa_lock);
537                 if (rc == -ENOENT) {
538                         DEBUG_CAPA(D_SEC, &ocapa->c_capa,
539                                    "renewal canceled because object removed");
540                         ll_capa_renewal_noent++;
541                 } else {
542                         ll_capa_renewal_failed++;
543
544                         /* failed capa won't be renewed any longer, but if -EIO,
545                          * client might be doing recovery, retry in 2 min. */
546                         if (rc == -EIO && !capa_is_expired(ocapa)) {
547                                 delay_capa_renew(ocapa, 120);
548                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
549                                            "renewal failed: -EIO, "
550                                            "retry in 2 mins");
551                                 ll_capa_renewal_retries++;
552                                 GOTO(retry, rc);
553                         } else {
554                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
555                                            "renewal failed(rc: %d) for", rc);
556                         }
557                 }
558
559                 cfs_list_del_init(&ocapa->c_list);
560                 sort_add_capa(ocapa, &ll_idle_capas);
561                 spin_unlock(&capa_lock);
562
563                 capa_put(ocapa);
564                 iput(inode);
565                 RETURN(rc);
566         }
567
568         spin_lock(&ocapa->c_lock);
569         LASSERT(!memcmp(&ocapa->c_capa, capa,
570                         offsetof(struct lustre_capa, lc_opc)));
571         ocapa->c_capa = *capa;
572         set_capa_expiry(ocapa);
573         spin_unlock(&ocapa->c_lock);
574
575         spin_lock(&capa_lock);
576         if (capa_for_oss(capa))
577                 inode_add_oss_capa(inode, ocapa);
578         DEBUG_CAPA(D_SEC, capa, "renew");
579         EXIT;
580 retry:
581         cfs_list_del_init(&ocapa->c_list);
582         sort_add_capa(ocapa, ll_capa_list);
583         update_capa_timer(ocapa, capa_renewal_time(ocapa));
584         spin_unlock(&capa_lock);
585
586         capa_put(ocapa);
587         iput(inode);
588         return rc;
589 }
590
591 void ll_capa_open(struct inode *inode)
592 {
593         struct ll_inode_info *lli = ll_i2info(inode);
594
595         if ((ll_i2sbi(inode)->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
596             == 0)
597                 return;
598
599         if (!S_ISREG(inode->i_mode))
600                 return;
601
602         cfs_atomic_inc(&lli->lli_open_count);
603 }
604
605 void ll_capa_close(struct inode *inode)
606 {
607         struct ll_inode_info *lli = ll_i2info(inode);
608
609         if ((ll_i2sbi(inode)->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
610             == 0)
611                 return;
612
613         if (!S_ISREG(inode->i_mode))
614                 return;
615
616         cfs_atomic_dec(&lli->lli_open_count);
617 }
618
619 /* delete CAPA_OPC_OSS_TRUNC only */
620 void ll_truncate_free_capa(struct obd_capa *ocapa)
621 {
622         if (!ocapa)
623                 return;
624
625         LASSERT(ocapa->c_capa.lc_opc & CAPA_OPC_OSS_TRUNC);
626         DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free truncate");
627
628         /* release ref when find */
629         capa_put(ocapa);
630         if (likely(ocapa->c_capa.lc_opc == CAPA_OPC_OSS_TRUNC)) {
631                 spin_lock(&capa_lock);
632                 ll_delete_capa(ocapa);
633                 spin_unlock(&capa_lock);
634         }
635 }
636
637 void ll_clear_inode_capas(struct inode *inode)
638 {
639         struct ll_inode_info *lli = ll_i2info(inode);
640         struct obd_capa *ocapa, *tmp;
641
642         spin_lock(&capa_lock);
643         ocapa = lli->lli_mds_capa;
644         if (ocapa)
645                 ll_delete_capa(ocapa);
646
647         cfs_list_for_each_entry_safe(ocapa, tmp, &lli->lli_oss_capas,
648                                      u.cli.lli_list)
649                 ll_delete_capa(ocapa);
650         spin_unlock(&capa_lock);
651 }
652
653 void ll_print_capa_stat(struct ll_sb_info *sbi)
654 {
655         if (sbi->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
656                 LCONSOLE_INFO("Fid capabilities renewed: %llu\n"
657                               "Fid capabilities renewal ENOENT: %llu\n"
658                               "Fid capabilities failed to renew: %llu\n"
659                               "Fid capabilities renewal retries: %llu\n",
660                               ll_capa_renewed, ll_capa_renewal_noent,
661                               ll_capa_renewal_failed, ll_capa_renewal_retries);
662 }