Whamcloud - gitweb
fid_is_local(): make it non-inline and conservative
authornikita <nikita>
Fri, 30 Jun 2006 13:36:01 +0000 (13:36 +0000)
committernikita <nikita>
Fri, 30 Jun 2006 13:36:01 +0000 (13:36 +0000)
lustre/fld/fld_handler.c
lustre/include/lu_object.h
lustre/include/lustre_fid.h

index 841e664..2067a38 100644 (file)
@@ -60,14 +60,14 @@ static int fld_init(void)
 {
         int rc = 0;
         ENTRY;
-        
+
         fld_cache = fld_cache_init(FLD_HTABLE_SIZE);
         if (IS_ERR(fld_cache))
                 rc = PTR_ERR(fld_cache);
 
         if (rc != 0)
                 fld_cache = NULL;
-        
+
         RETURN(rc);
 }
 
@@ -101,7 +101,7 @@ fld_server_create(struct lu_server_fld *fld,
 {
         int rc;
         ENTRY;
-        
+
         rc = fld_index_create(fld, ctx, seq, mds);
         if (rc == 0) {
                 /* do not return result of calling fld_cache_insert()
@@ -135,7 +135,7 @@ fld_server_lookup(struct lu_server_fld *fld,
         struct fld_cache_entry *flde;
         int rc;
         ENTRY;
-        
+
         /* lookup it in the cache first */
         flde = fld_cache_lookup(fld_cache, seq);
         if (flde != NULL) {
@@ -212,7 +212,7 @@ fld_req_handle0(const struct lu_context *ctx,
         } else {
                 CERROR("cannot unpack FLD operation\n");
         }
-        
+
 out_pill:
         EXIT;
         req_capsule_fini(&pill);
@@ -255,6 +255,30 @@ out:
         return 0;
 }
 
+/*
+ * Returns true, if fid is local to this server node.
+ *
+ * WARNING: this function is *not* guaranteed to return false if fid is
+ * remote: it makes an educated conservative guess only.
+ *
+ * fid_is_local() is supposed to be used in assertion checks only.
+ */
+int fid_is_local(struct lu_site *site, const struct lu_fid *fid)
+{
+        int result;
+
+        result = 1; /* conservatively assume fid is local */
+        if (site->ls_fld != NULL) {
+                struct fld_cache_entry *entry;
+
+                entry = fld_cache_lookup(fld_cache, fid_seq(fid));
+                if (entry != NULL)
+                        result = (entry->fce_mds == site->ls_node_id);
+        }
+        return result;
+}
+EXPORT_SYMBOL(fid_is_local);
+
 #ifdef LPROCFS
 static int
 fld_server_proc_init(struct lu_server_fld *fld)
@@ -338,7 +362,7 @@ fld_server_init(struct lu_server_fld *fld,
 
         snprintf(fld->fld_name, sizeof(fld->fld_name),
                  "%s-%s", LUSTRE_FLD_NAME, uuid);
-        
+
         rc = fld_index_init(fld, ctx);
         if (rc)
                 GOTO(out, rc);
@@ -378,7 +402,7 @@ fld_server_fini(struct lu_server_fld *fld,
 #ifdef LPROCFS
         fld_server_proc_fini(fld);
 #endif
-        
+
         if (fld->fld_service != NULL) {
                 ptlrpc_unregister_service(fld->fld_service);
                 fld->fld_service = NULL;
index e3a8026..14caa28 100644 (file)
@@ -142,7 +142,7 @@ struct lu_device_operations {
                                    struct lu_device *, struct lustre_cfg *);
 
         /*
-         * notify function for metadata stack 
+         * notify function for metadata stack
          */
         int (*ldo_notify)(const struct lu_context *ctx, struct lu_device *d,
                           struct obd_device *watched, enum obd_notify_event ev,
@@ -480,8 +480,10 @@ struct lu_site {
          * Top-level device for this stack.
          */
         struct lu_device     *ls_top_dev;
-        /* current server index */
-        __u32                 ls_node_id;
+        /*
+         * mds number of this site.
+         */
+        mdsno_t               ls_node_id;
         /*
          * Fid location database
          */
@@ -713,7 +715,7 @@ static inline int lu_object_assert_exists(const struct lu_context *ctx,
                 result = 1;
         return result;
 }
+
 static inline int lu_object_assert_not_exists(const struct lu_context *ctx,
                                        const struct lu_object *o)
 {
index 1d0bc27..c42492d 100644 (file)
@@ -91,7 +91,7 @@ struct lu_server_seq {
         /* super-sequence range, all super-sequences for other servers are
          * allocated from it. */
         struct lu_range         seq_super;
-       
+
         /* device for server side seq manager needs (saving sequences to backing
          * store). */
         struct dt_device       *seq_dev;
@@ -147,7 +147,7 @@ int seq_server_init_ctlr(struct lu_server_seq *seq,
 void  seq_server_fini_ctlr(struct lu_server_seq *seq);
 #endif
 
-int seq_client_init(struct lu_client_seq *seq, 
+int seq_client_init(struct lu_client_seq *seq,
                     const char *uuid,
                     struct obd_export *exp);
 
@@ -162,29 +162,7 @@ int seq_client_alloc_fid(struct lu_client_seq *seq,
                          struct lu_fid *fid);
 
 /* Fids common stuff */
-static inline int fid_is_local(const struct lu_context *ctx,
-                               struct lu_site *site,
-                               const struct lu_fid *fid)
-{
-        mdsno_t mds;
-        
-        if (site->ls_fld == NULL)
-                return 1;
-
-        /* XXX: this function checks also on-disk index, so it can't be used
-         * with spinlocks taken.  --umka */
-        rc = fld_server_lookup(site->ls_fld, ctx,
-                               fid_seq(fid), *mds);
-        if (rc) {
-                CERROR("can't lookup FLD for seq "LPU64", rc %d. "
-                       "Considering local fid anyway\n", fid_seq(fid),
-                        rc);
-                return 1;
-        }
-        
-        return (mds == ls_node_id);
-}
-
+int fid_is_local(struct lu_site *site, const struct lu_fid *fid);
 void fid_to_le(struct lu_fid *dst, const struct lu_fid *src);
 
 #endif /* __LINUX_OBD_CLASS_H */