Whamcloud - gitweb
LU-1305 osd: xattr support for osd-zfs
[fs/lustre-release.git] / lustre / llite / llite_capa.c
index 1fcfacf..57ec818 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +26,8 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -119,11 +119,6 @@ static inline int have_expired_capa(void)
         return expired;
 }
 
-static inline int ll_capa_check_stop(void)
-{
-        return (ll_capa_thread.t_flags & SVC_STOPPING) ? 1: 0;
-}
-
 static void sort_add_capa(struct obd_capa *ocapa, cfs_list_t *head)
 {
         struct obd_capa *tmp;
@@ -180,21 +175,24 @@ static int capa_thread_main(void *unused)
 
         cfs_daemonize("ll_capa");
 
-        ll_capa_thread.t_flags = SVC_RUNNING;
+        thread_set_flags(&ll_capa_thread, SVC_RUNNING);
         cfs_waitq_signal(&ll_capa_thread.t_ctl_waitq);
 
         while (1) {
                 l_wait_event(ll_capa_thread.t_ctl_waitq,
-                             (ll_capa_check_stop() || have_expired_capa()),
+                             !thread_is_running(&ll_capa_thread) ||
+                             have_expired_capa(),
                              &lwi);
 
-                if (ll_capa_check_stop())
+                if (!thread_is_running(&ll_capa_thread))
                         break;
 
                 next = NULL;
 
                 cfs_spin_lock(&capa_lock);
                 cfs_list_for_each_entry_safe(ocapa, tmp, ll_capa_list, c_list) {
+                        __u64 ibits;
+
                         LASSERT(ocapa->c_capa.lc_opc != CAPA_OPC_OSS_TRUNC);
 
                         if (!capa_is_to_expire(ocapa)) {
@@ -208,12 +206,14 @@ static int capa_thread_main(void *unused)
                          * dir, or its inode is opened, or client holds LOOKUP
                          * lock.
                          */
+                        /* ibits may be changed by ll_have_md_lock() so we have
+                         * to set it each time */
+                        ibits = MDS_INODELOCK_LOOKUP;
                         if (capa_for_mds(&ocapa->c_capa) &&
                             !S_ISDIR(ocapa->u.cli.inode->i_mode) &&
                             obd_capa_open_count(ocapa) == 0 &&
                             !ll_have_md_lock(ocapa->u.cli.inode,
-                                             MDS_INODELOCK_LOOKUP,
-                                             LCK_MINMODE)) {
+                                             &ibits, LCK_MINMODE)) {
                                 DEBUG_CAPA(D_SEC, &ocapa->c_capa,
                                            "skip renewal for");
                                 sort_add_capa(ocapa, &ll_idle_capas);
@@ -259,7 +259,8 @@ static int capa_thread_main(void *unused)
                                              c_list) {
                         if (!capa_is_expired(ocapa)) {
                                 if (!next)
-                                        update_capa_timer(ocapa, ocapa->c_expiry);
+                                        update_capa_timer(ocapa,
+                                                          ocapa->c_expiry);
                                 break;
                         }
 
@@ -280,7 +281,7 @@ static int capa_thread_main(void *unused)
                 cfs_spin_unlock(&capa_lock);
         }
 
-        ll_capa_thread.t_flags = SVC_STOPPED;
+        thread_set_flags(&ll_capa_thread, SVC_STOPPED);
         cfs_waitq_signal(&ll_capa_thread.t_ctl_waitq);
         RETURN(0);
 }
@@ -303,17 +304,17 @@ int ll_capa_thread_start(void)
                 RETURN(rc);
         }
         cfs_wait_event(ll_capa_thread.t_ctl_waitq,
-                       ll_capa_thread.t_flags & SVC_RUNNING);
+                       thread_is_running(&ll_capa_thread));
 
         RETURN(0);
 }
 
 void ll_capa_thread_stop(void)
 {
-        ll_capa_thread.t_flags = SVC_STOPPING;
+        thread_set_flags(&ll_capa_thread, SVC_STOPPING);
         cfs_waitq_signal(&ll_capa_thread.t_ctl_waitq);
         cfs_wait_event(ll_capa_thread.t_ctl_waitq,
-                       ll_capa_thread.t_flags & SVC_STOPPED);
+                       thread_is_stopped(&ll_capa_thread));
 }
 
 struct obd_capa *ll_osscapa_get(struct inode *inode, __u64 opc)
@@ -545,7 +546,8 @@ int ll_update_capa(struct obd_capa *ocapa, struct lustre_capa *capa)
                         if (rc == -EIO && !capa_is_expired(ocapa)) {
                                 delay_capa_renew(ocapa, 120);
                                 DEBUG_CAPA(D_ERROR, &ocapa->c_capa,
-                                           "renewal failed: -EIO, retry in 2 mins");
+                                           "renewal failed: -EIO, "
+                                           "retry in 2 mins");
                                 ll_capa_renewal_retries++;
                                 GOTO(retry, rc);
                         } else {