Whamcloud - gitweb
LU-4082 llite: Chk ret of ll_prep_md_op_data in ll_dir_filler
[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) 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         thread_set_flags(&ll_capa_thread, SVC_RUNNING);
177         wake_up(&ll_capa_thread.t_ctl_waitq);
178
179         while (1) {
180                 l_wait_event(ll_capa_thread.t_ctl_waitq,
181                              !thread_is_running(&ll_capa_thread) ||
182                              have_expired_capa(),
183                              &lwi);
184
185                 if (!thread_is_running(&ll_capa_thread))
186                         break;
187
188                 next = NULL;
189
190                 spin_lock(&capa_lock);
191                 cfs_list_for_each_entry_safe(ocapa, tmp, ll_capa_list, c_list) {
192                         __u64 ibits;
193
194                         LASSERT(ocapa->c_capa.lc_opc != CAPA_OPC_OSS_TRUNC);
195
196                         if (!capa_is_to_expire(ocapa)) {
197                                 next = ocapa;
198                                 break;
199                         }
200
201                         cfs_list_del_init(&ocapa->c_list);
202
203                         /* for MDS capability, only renew those which belong to
204                          * dir, or its inode is opened, or client holds LOOKUP
205                          * lock.
206                          */
207                         /* ibits may be changed by ll_have_md_lock() so we have
208                          * to set it each time */
209                         ibits = MDS_INODELOCK_LOOKUP;
210                         if (capa_for_mds(&ocapa->c_capa) &&
211                             !S_ISDIR(ocapa->u.cli.inode->i_mode) &&
212                             obd_capa_open_count(ocapa) == 0 &&
213                             !ll_have_md_lock(ocapa->u.cli.inode,
214                                              &ibits, LCK_MINMODE)) {
215                                 DEBUG_CAPA(D_SEC, &ocapa->c_capa,
216                                            "skip renewal for");
217                                 sort_add_capa(ocapa, &ll_idle_capas);
218                                 continue;
219                         }
220
221                         /* for OSS capability, only renew those whose inode is
222                          * opened.
223                          */
224                         if (capa_for_oss(&ocapa->c_capa) &&
225                             obd_capa_open_count(ocapa) == 0) {
226                                 /* oss capa with open count == 0 won't renew,
227                                  * move to idle list */
228                                 sort_add_capa(ocapa, &ll_idle_capas);
229                                 continue;
230                         }
231
232                         /* NB iput() is in ll_update_capa() */
233                         inode = igrab(ocapa->u.cli.inode);
234                         if (inode == NULL) {
235                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
236                                            "igrab failed for");
237                                 continue;
238                         }
239
240                         capa_get(ocapa);
241                         ll_capa_renewed++;
242                         spin_unlock(&capa_lock);
243                         rc = md_renew_capa(ll_i2mdexp(inode), ocapa,
244                                            ll_update_capa);
245                         spin_lock(&capa_lock);
246                         if (rc) {
247                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
248                                            "renew failed: %d", rc);
249                                 ll_capa_renewal_failed++;
250                         }
251                 }
252
253                 if (next)
254                         update_capa_timer(next, capa_renewal_time(next));
255
256                 cfs_list_for_each_entry_safe(ocapa, tmp, &ll_idle_capas,
257                                              c_list) {
258                         if (!capa_is_expired(ocapa)) {
259                                 if (!next)
260                                         update_capa_timer(ocapa,
261                                                           ocapa->c_expiry);
262                                 break;
263                         }
264
265                         if (cfs_atomic_read(&ocapa->c_refc) > 1) {
266                                 DEBUG_CAPA(D_SEC, &ocapa->c_capa,
267                                            "expired(c_refc %d), don't release",
268                                            cfs_atomic_read(&ocapa->c_refc));
269                                 /* don't try to renew any more */
270                                 cfs_list_del_init(&ocapa->c_list);
271                                 continue;
272                         }
273
274                         /* expired capa is released. */
275                         DEBUG_CAPA(D_SEC, &ocapa->c_capa, "release expired");
276                         ll_delete_capa(ocapa);
277                 }
278
279                 spin_unlock(&capa_lock);
280         }
281
282         thread_set_flags(&ll_capa_thread, SVC_STOPPED);
283         wake_up(&ll_capa_thread.t_ctl_waitq);
284         RETURN(0);
285 }
286
287 void ll_capa_timer_callback(unsigned long unused)
288 {
289         wake_up(&ll_capa_thread.t_ctl_waitq);
290 }
291
292 int ll_capa_thread_start(void)
293 {
294         struct task_struct *task;
295         ENTRY;
296
297         init_waitqueue_head(&ll_capa_thread.t_ctl_waitq);
298
299         task = kthread_run(capa_thread_main, NULL, "ll_capa");
300         if (IS_ERR(task)) {
301                 CERROR("cannot start expired capa thread: rc %ld\n",
302                         PTR_ERR(task));
303                 RETURN(PTR_ERR(task));
304         }
305         wait_event(ll_capa_thread.t_ctl_waitq,
306                        thread_is_running(&ll_capa_thread));
307
308         RETURN(0);
309 }
310
311 void ll_capa_thread_stop(void)
312 {
313         thread_set_flags(&ll_capa_thread, SVC_STOPPING);
314         wake_up(&ll_capa_thread.t_ctl_waitq);
315         wait_event(ll_capa_thread.t_ctl_waitq,
316                        thread_is_stopped(&ll_capa_thread));
317 }
318
319 struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc)
320 {
321         struct ll_inode_info *lli = ll_i2info(inode);
322         struct obd_capa *ocapa;
323         int found = 0;
324
325         ENTRY;
326
327         if ((ll_i2sbi(inode)->ll_flags & LL_SBI_OSS_CAPA) == 0)
328                 RETURN(NULL);
329
330         LASSERT(opc == CAPA_OPC_OSS_WRITE || opc == CAPA_OPC_OSS_RW ||
331                 opc == CAPA_OPC_OSS_TRUNC);
332
333         spin_lock(&capa_lock);
334         cfs_list_for_each_entry(ocapa, &lli->lli_oss_capas, u.cli.lli_list) {
335                 if (capa_is_expired(ocapa))
336                         continue;
337                 if ((opc & CAPA_OPC_OSS_WRITE) &&
338                     capa_opc_supported(&ocapa->c_capa, CAPA_OPC_OSS_WRITE)) {
339                         found = 1;
340                         break;
341                 } else if ((opc & CAPA_OPC_OSS_READ) &&
342                            capa_opc_supported(&ocapa->c_capa,
343                                               CAPA_OPC_OSS_READ)) {
344                         found = 1;
345                         break;
346                 } else if ((opc & CAPA_OPC_OSS_TRUNC) &&
347                            capa_opc_supported(&ocapa->c_capa, opc)) {
348                         found = 1;
349                         break;
350                 }
351         }
352
353         if (found) {
354                 LASSERT(lu_fid_eq(capa_fid(&ocapa->c_capa),
355                                   ll_inode2fid(inode)));
356                 LASSERT(ocapa->c_site == CAPA_SITE_CLIENT);
357
358                 capa_get(ocapa);
359
360                 DEBUG_CAPA(D_SEC, &ocapa->c_capa, "found client");
361         } else {
362                 ocapa = NULL;
363
364                 if (cfs_atomic_read(&ll_capa_debug)) {
365                         CERROR("no capability for "DFID" opc "LPX64"\n",
366                                PFID(&lli->lli_fid), opc);
367                         cfs_atomic_set(&ll_capa_debug, 0);
368                 }
369         }
370         spin_unlock(&capa_lock);
371
372         RETURN(ocapa);
373 }
374 EXPORT_SYMBOL(ll_osscapa_get);
375
376 struct obd_capa *ll_mdscapa_get(struct inode *inode)
377 {
378         struct ll_inode_info *lli = ll_i2info(inode);
379         struct obd_capa *ocapa;
380         ENTRY;
381
382         LASSERT(inode != NULL);
383
384         if ((ll_i2sbi(inode)->ll_flags & LL_SBI_MDS_CAPA) == 0)
385                 RETURN(NULL);
386
387         spin_lock(&capa_lock);
388         ocapa = capa_get(lli->lli_mds_capa);
389         spin_unlock(&capa_lock);
390         if (!ocapa && cfs_atomic_read(&ll_capa_debug)) {
391                 CERROR("no mds capability for "DFID"\n", PFID(&lli->lli_fid));
392                 cfs_atomic_set(&ll_capa_debug, 0);
393         }
394
395         RETURN(ocapa);
396 }
397
398 static struct obd_capa *do_add_mds_capa(struct inode *inode,
399                                         struct obd_capa *ocapa)
400 {
401         struct ll_inode_info *lli = ll_i2info(inode);
402         struct obd_capa *old = lli->lli_mds_capa;
403         struct lustre_capa *capa = &ocapa->c_capa;
404
405         if (!old) {
406                 ocapa->u.cli.inode = inode;
407                 lli->lli_mds_capa = ocapa;
408                 capa_count[CAPA_SITE_CLIENT]++;
409
410                 DEBUG_CAPA(D_SEC, capa, "add MDS");
411         } else {
412                 spin_lock(&old->c_lock);
413                 old->c_capa = *capa;
414                 spin_unlock(&old->c_lock);
415
416                 DEBUG_CAPA(D_SEC, capa, "update MDS");
417
418                 capa_put(ocapa);
419                 ocapa = old;
420         }
421         return ocapa;
422 }
423
424 static struct obd_capa *do_lookup_oss_capa(struct inode *inode, int opc)
425 {
426         struct ll_inode_info *lli = ll_i2info(inode);
427         struct obd_capa *ocapa;
428
429         /* inside capa_lock */
430         cfs_list_for_each_entry(ocapa, &lli->lli_oss_capas, u.cli.lli_list) {
431                 if ((capa_opc(&ocapa->c_capa) & opc) != opc)
432                         continue;
433
434                 LASSERT(lu_fid_eq(capa_fid(&ocapa->c_capa),
435                                   ll_inode2fid(inode)));
436                 LASSERT(ocapa->c_site == CAPA_SITE_CLIENT);
437
438                 DEBUG_CAPA(D_SEC, &ocapa->c_capa, "found client");
439                 return ocapa;
440         }
441
442         return NULL;
443 }
444
445 static inline void inode_add_oss_capa(struct inode *inode,
446                                       struct obd_capa *ocapa)
447 {
448         struct ll_inode_info *lli = ll_i2info(inode);
449         struct obd_capa *tmp;
450         cfs_list_t *next = NULL;
451
452         /* capa is sorted in lli_oss_capas so lookup can always find the
453          * latest one */
454         cfs_list_for_each_entry(tmp, &lli->lli_oss_capas, u.cli.lli_list) {
455                 if (cfs_time_after(ocapa->c_expiry, tmp->c_expiry)) {
456                         next = &tmp->u.cli.lli_list;
457                         break;
458                 }
459         }
460         LASSERT(&ocapa->u.cli.lli_list != next);
461         cfs_list_move_tail(&ocapa->u.cli.lli_list, next ?: &lli->lli_oss_capas);
462 }
463
464 static struct obd_capa *do_add_oss_capa(struct inode *inode,
465                                         struct obd_capa *ocapa)
466 {
467         struct obd_capa *old;
468         struct lustre_capa *capa = &ocapa->c_capa;
469
470         LASSERTF(S_ISREG(inode->i_mode),
471                  "inode has oss capa, but not regular file, mode: %d\n",
472                  inode->i_mode);
473
474         /* FIXME: can't replace it so easily with fine-grained opc */
475         old = do_lookup_oss_capa(inode, capa_opc(capa) & CAPA_OPC_OSS_ONLY);
476         if (!old) {
477                 ocapa->u.cli.inode = inode;
478                 CFS_INIT_LIST_HEAD(&ocapa->u.cli.lli_list);
479                 capa_count[CAPA_SITE_CLIENT]++;
480
481                 DEBUG_CAPA(D_SEC, capa, "add OSS");
482         } else {
483                 spin_lock(&old->c_lock);
484                 old->c_capa = *capa;
485                 spin_unlock(&old->c_lock);
486
487                 DEBUG_CAPA(D_SEC, capa, "update OSS");
488
489                 capa_put(ocapa);
490                 ocapa = old;
491         }
492
493         inode_add_oss_capa(inode, ocapa);
494         return ocapa;
495 }
496
497 struct obd_capa *ll_add_capa(struct inode *inode, struct obd_capa *ocapa)
498 {
499         spin_lock(&capa_lock);
500         ocapa = capa_for_mds(&ocapa->c_capa) ? do_add_mds_capa(inode, ocapa) :
501                                                do_add_oss_capa(inode, ocapa);
502
503         /* truncate capa won't renew */
504         if (ocapa->c_capa.lc_opc != CAPA_OPC_OSS_TRUNC) {
505                 set_capa_expiry(ocapa);
506                 cfs_list_del_init(&ocapa->c_list);
507                 sort_add_capa(ocapa, ll_capa_list);
508
509                 update_capa_timer(ocapa, capa_renewal_time(ocapa));
510         }
511
512         spin_unlock(&capa_lock);
513
514         cfs_atomic_set(&ll_capa_debug, 1);
515         return ocapa;
516 }
517
518 static inline void delay_capa_renew(struct obd_capa *oc, cfs_time_t delay)
519 {
520         /* NB: set a fake expiry for this capa to prevent it renew too soon */
521         oc->c_expiry = cfs_time_add(oc->c_expiry, cfs_time_seconds(delay));
522 }
523
524 int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
525 {
526         struct inode *inode = ocapa->u.cli.inode;
527         int rc = 0;
528         ENTRY;
529
530         LASSERT(ocapa);
531
532         if (IS_ERR(capa)) {
533                 /* set error code */
534                 rc = PTR_ERR(capa);
535                 spin_lock(&capa_lock);
536                 if (rc == -ENOENT) {
537                         DEBUG_CAPA(D_SEC, &ocapa->c_capa,
538                                    "renewal canceled because object removed");
539                         ll_capa_renewal_noent++;
540                 } else {
541                         ll_capa_renewal_failed++;
542
543                         /* failed capa won't be renewed any longer, but if -EIO,
544                          * client might be doing recovery, retry in 2 min. */
545                         if (rc == -EIO && !capa_is_expired(ocapa)) {
546                                 delay_capa_renew(ocapa, 120);
547                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
548                                            "renewal failed: -EIO, "
549                                            "retry in 2 mins");
550                                 ll_capa_renewal_retries++;
551                                 GOTO(retry, rc);
552                         } else {
553                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
554                                            "renewal failed(rc: %d) for", rc);
555                         }
556                 }
557
558                 cfs_list_del_init(&ocapa->c_list);
559                 sort_add_capa(ocapa, &ll_idle_capas);
560                 spin_unlock(&capa_lock);
561
562                 capa_put(ocapa);
563                 iput(inode);
564                 RETURN(rc);
565         }
566
567         spin_lock(&ocapa->c_lock);
568         LASSERT(!memcmp(&ocapa->c_capa, capa,
569                         offsetof(struct lustre_capa, lc_opc)));
570         ocapa->c_capa = *capa;
571         set_capa_expiry(ocapa);
572         spin_unlock(&ocapa->c_lock);
573
574         spin_lock(&capa_lock);
575         if (capa_for_oss(capa))
576                 inode_add_oss_capa(inode, ocapa);
577         DEBUG_CAPA(D_SEC, capa, "renew");
578         EXIT;
579 retry:
580         cfs_list_del_init(&ocapa->c_list);
581         sort_add_capa(ocapa, ll_capa_list);
582         update_capa_timer(ocapa, capa_renewal_time(ocapa));
583         spin_unlock(&capa_lock);
584
585         capa_put(ocapa);
586         iput(inode);
587         return rc;
588 }
589
590 void ll_capa_open(struct inode *inode)
591 {
592         struct ll_inode_info *lli = ll_i2info(inode);
593
594         if ((ll_i2sbi(inode)->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
595             == 0)
596                 return;
597
598         if (!S_ISREG(inode->i_mode))
599                 return;
600
601         cfs_atomic_inc(&lli->lli_open_count);
602 }
603
604 void ll_capa_close(struct inode *inode)
605 {
606         struct ll_inode_info *lli = ll_i2info(inode);
607
608         if ((ll_i2sbi(inode)->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
609             == 0)
610                 return;
611
612         if (!S_ISREG(inode->i_mode))
613                 return;
614
615         cfs_atomic_dec(&lli->lli_open_count);
616 }
617
618 /* delete CAPA_OPC_OSS_TRUNC only */
619 void ll_truncate_free_capa(struct obd_capa *ocapa)
620 {
621         if (!ocapa)
622                 return;
623
624         LASSERT(ocapa->c_capa.lc_opc & CAPA_OPC_OSS_TRUNC);
625         DEBUG_CAPA(D_SEC, &ocapa->c_capa, "free truncate");
626
627         /* release ref when find */
628         capa_put(ocapa);
629         if (likely(ocapa->c_capa.lc_opc == CAPA_OPC_OSS_TRUNC)) {
630                 spin_lock(&capa_lock);
631                 ll_delete_capa(ocapa);
632                 spin_unlock(&capa_lock);
633         }
634 }
635
636 void ll_clear_inode_capas(struct inode *inode)
637 {
638         struct ll_inode_info *lli = ll_i2info(inode);
639         struct obd_capa *ocapa, *tmp;
640
641         spin_lock(&capa_lock);
642         ocapa = lli->lli_mds_capa;
643         if (ocapa)
644                 ll_delete_capa(ocapa);
645
646         cfs_list_for_each_entry_safe(ocapa, tmp, &lli->lli_oss_capas,
647                                      u.cli.lli_list)
648                 ll_delete_capa(ocapa);
649         spin_unlock(&capa_lock);
650 }
651
652 void ll_print_capa_stat(struct ll_sb_info *sbi)
653 {
654         if (sbi->ll_flags & (LL_SBI_MDS_CAPA | LL_SBI_OSS_CAPA))
655                 LCONSOLE_INFO("Fid capabilities renewed: %llu\n"
656                               "Fid capabilities renewal ENOENT: %llu\n"
657                               "Fid capabilities failed to renew: %llu\n"
658                               "Fid capabilities renewal retries: %llu\n",
659                               ll_capa_renewed, ll_capa_renewal_noent,
660                               ll_capa_renewal_failed, ll_capa_renewal_retries);
661 }