Whamcloud - gitweb
LU-6158 mdt: always shrink_capsule in getxattr_all
[fs/lustre-release.git] / lustre / fld / fld_handler.c
index e40b61a..b38f306 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -51,7 +51,6 @@
 #include <obd_support.h>
 #include <lustre_fid.h>
 #include <lustre_fld.h>
-#include <md_object.h>
 #include <lustre_req_layout.h>
 #include <lprocfs_status.h>
 #include "fld_internal.h"
@@ -180,7 +179,10 @@ int fld_update_from_controller(const struct lu_env *env,
                        if (lsra->lsra_lsr[i].lsr_index != index)
                                GOTO(out, rc = -EINVAL);
 
+                       mutex_lock(&fld->lsf_lock);
                        rc1 = fld_insert_entry(env, fld, &lsra->lsra_lsr[i]);
+                       mutex_unlock(&fld->lsf_lock);
+
                        if (rc1 != 0)
                                GOTO(out, rc = rc1);
                }
@@ -201,7 +203,7 @@ EXPORT_SYMBOL(fld_update_from_controller);
  * Lookup sequece in local cache/fldb.
  **/
 int fld_local_lookup(const struct lu_env *env, struct lu_server_fld *fld,
-                    seqno_t seq, struct lu_seq_range *range)
+                    u64 seq, struct lu_seq_range *range)
 {
        struct lu_seq_range *erange;
        struct fld_thread_info *info;
@@ -237,7 +239,7 @@ EXPORT_SYMBOL(fld_local_lookup);
  *  cache fld entries, but this cache is not persistent.
  */
 int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld,
-                     seqno_t seq, struct lu_seq_range *range)
+                     u64 seq, struct lu_seq_range *range)
 {
        __u32 index;
        int rc;
@@ -250,15 +252,13 @@ int fld_server_lookup(const struct lu_env *env, struct lu_server_fld *fld,
        rc = fld_name_to_index(fld->lsf_name, &index);
        if (rc < 0)
                RETURN(rc);
-       else
-               rc = 0;
 
-       if (index == 0) {
+       if (index == 0 && rc == LDD_F_SV_TYPE_MDT) {
                /* On server side, all entries should be in cache.
                 * If we can not find it in cache, just return error */
                CERROR("%s: Cannot find sequence "LPX64": rc = %d\n",
-                      fld->lsf_name, seq, -EIO);
-               RETURN(-EIO);
+                      fld->lsf_name, seq, -ENOENT);
+               RETURN(-ENOENT);
        } else {
                if (fld->lsf_control_exp == NULL) {
                        CERROR("%s: lookup "LPX64", but not connects to MDT0"
@@ -392,19 +392,17 @@ int fid_is_local(const struct lu_env *env,
        }
        return result;
 }
-EXPORT_SYMBOL(fid_is_local);
 
 static void fld_server_proc_fini(struct lu_server_fld *fld);
 
-#ifdef LPROCFS
+#ifdef CONFIG_PROC_FS
 static int fld_server_proc_init(struct lu_server_fld *fld)
 {
         int rc = 0;
         ENTRY;
 
-       fld->lsf_proc_dir = lprocfs_seq_register(fld->lsf_name,
-                                                fld_type_proc_dir,
-                                                fld_server_proc_list, fld);
+       fld->lsf_proc_dir = lprocfs_register(fld->lsf_name, fld_type_proc_dir,
+                                            fld_server_proc_list, fld);
        if (IS_ERR(fld->lsf_proc_dir)) {
                rc = PTR_ERR(fld->lsf_proc_dir);
                RETURN(rc);
@@ -465,7 +463,7 @@ int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld,
                RETURN(rc);
        }
 
-       rc = fld_index_init(env, fld, dt);
+       rc = fld_index_init(env, fld, dt, type);
        if (rc)
                GOTO(out_cache, rc);
 
@@ -474,7 +472,9 @@ int fld_server_init(const struct lu_env *env, struct lu_server_fld *fld,
                GOTO(out_index, rc);
 
        fld->lsf_control_exp = NULL;
+       fld->lsf_seq_lookup = fld_server_lookup;
 
+       fld->lsf_seq_lookup = fld_server_lookup;
        RETURN(0);
 out_index:
        fld_index_fini(env, fld);