Whamcloud - gitweb
branch: HEAD
authorericm <ericm>
Wed, 30 Sep 2009 02:27:15 +0000 (02:27 +0000)
committerericm <ericm>
Wed, 30 Sep 2009 02:27:15 +0000 (02:27 +0000)
move common client helper function to lclient.
b=19688
o=adilger
r=tappro
r=ericm

14 files changed:
lustre/include/lclient.h
lustre/include/lu_object.h
lustre/include/lustre_fid.h
lustre/lclient/lcommon_cl.c
lustre/liblustre/Makefile.am
lustre/liblustre/dir.c
lustre/liblustre/llite_fid.c [deleted file]
lustre/llite/Makefile.in
lustre/llite/dir.c
lustre/llite/llite_fid.c [deleted file]
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/llite_nfs.c
lustre/mdd/mdd_lov.c

index 4df7c2b..ead82c3 100644 (file)
@@ -371,6 +371,8 @@ void cl_inode_fini(struct inode *inode);
 int cl_local_size(struct inode *inode);
 
 __u16 ll_dirent_type_get(struct lu_dirent *ent);
+ino_t cl_fid_build_ino(struct lu_fid *fid);
+__u32 cl_fid_build_gen(struct lu_fid *fid);
 
 #ifdef INVARIANT_CHECK
 # define CLOBINVRNT(env, clob, expr)                                    \
index 7e1f826..7767097 100644 (file)
@@ -496,8 +496,8 @@ enum lu_object_header_attr {
         /**
          * UNIX file type is stored in S_IFMT bits.
          */
-        LOHA_FT_START = 1 << 12, /**< S_IFIFO */
-        LOHA_FT_END   = 1 << 15, /**< S_IFREG */
+        LOHA_FT_START = 001 << 12, /**< S_IFIFO */
+        LOHA_FT_END   = 017 << 12, /**< S_IFMT */
 };
 
 /**
index ac91579..6f3a29d 100644 (file)
@@ -87,6 +87,11 @@ enum {
 /** special fid seq: used for .lustre objects. */
 #define LU_DOT_LUSTRE_SEQ       (FID_SEQ_START + 0x02ULL)
 
+/* Note that reserved SEQ numbers below 12 will conflict with ldiskfs
+ * inodes in the IGIF namespace, so these reserved SEQ numbers must be
+ * used sparingly until ldiskfs-based MDT backends and/or IGIF FIDs 
+ * have been completely removed. */
+
 /** special OID for local objects */
 enum {
         /** \see osd_oi_index_create */
index 9eb6bbb..87d2b91 100644 (file)
@@ -1289,3 +1289,43 @@ __u16 ll_dirent_type_get(struct lu_dirent *ent)
         }
         return type;
 }
+
+/**
+ * build inode number from passed @fid */
+ino_t cl_fid_build_ino(struct lu_fid *fid)
+{
+        ino_t ino;
+        ENTRY;
+
+        if (fid_is_igif(fid)) {
+                ino = lu_igif_ino(fid);
+                RETURN(ino);
+        }
+
+        /* Very stupid and having many downsides inode allocation algorithm
+         * based on fid. */
+        ino = fid_flatten(fid) & 0xFFFFFFFF;
+
+        if (unlikely(ino == 0))
+                /* the first result ino is 0xFFC001, so this is rarely used */
+                ino = 0xffbcde;
+        ino = ino | 0x80000000;
+        RETURN(ino);
+}
+
+/**
+ * build inode generation from passed @fid.  If our FID overflows the 32-bit
+ * inode number then return a non-zero generation to distinguish them. */
+__u32 cl_fid_build_gen(struct lu_fid *fid)
+{
+        __u32 gen;
+        ENTRY;
+
+        if (fid_is_igif(fid)) {
+                gen = lu_igif_gen(fid);
+                RETURN(gen);
+        }
+
+        gen = (fid_flatten(fid) >> 32);
+        RETURN(gen);
+}
index 91e5f01..d7f8957 100644 (file)
@@ -58,12 +58,12 @@ else
 install-exec-hook:
 endif
 
-libllite_a_SOURCES = llite_lib.c llite_fid.c super.c namei.c rw.c file.c dir.c \
+libllite_a_SOURCES = llite_lib.c super.c namei.c rw.c file.c dir.c \
                     lutil.c lutil.h llite_lib.h llite_cl.c \
                      ../lclient/lcommon_cl.c ../lclient/glimpse.c ../lclient/lcommon_misc.c
 
 # for make rpms -- need cleanup
-liblustre_a_SOURCES = llite_lib.c llite_fid.c super.c namei.c rw.c file.c dir.c \
+liblustre_a_SOURCES = llite_lib.c super.c namei.c rw.c file.c dir.c \
                     llite_lib.h llite_cl.c
 
 liblustre.a : $(LUSTRE_LIBS) $(LND_LIBS) $(LNET_LIBS) $(SYSIO_LIBS) $(QUOTA_LIBS)
index c8e3300..0039f3d 100644 (file)
@@ -272,7 +272,7 @@ ssize_t llu_iop_filldirentries(struct inode *dir, _SYSIO_OFF_T *basep,
                                 fid  = ent->lde_fid;
                                 name = ent->lde_name;
                                 fid_le_to_cpu(&fid, &fid);
-                                ino  = llu_fid_build_ino(llu_i2sbi(dir), &fid);
+                                ino  = cl_fid_build_ino(&fid);
                                 type = ll_dirent_type_get(ent);
                                 done = filldir(buf, nbytes, name, namelen,
                                                (loff_t)hash, ino, type,
diff --git a/lustre/liblustre/llite_fid.c b/lustre/liblustre/llite_fid.c
deleted file mode 100644 (file)
index c9135db..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* -*- 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.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/liblustre/llite_fid.c
- *
- * Lustre Light Super operations
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/queue.h>
-
-#ifdef HAVE_XTIO_H
-#include <xtio.h>
-#endif
-#include <sysio.h>
-#include <fs.h>
-#include <mount.h>
-#include <inode.h>
-#ifdef HAVE_FILE_H
-#include <file.h>
-#endif
-
-/* both sys/queue.h (libsysio require it) and portals/lists.h have definition
- * of 'LIST_HEAD'. undef it to suppress warnings
- */
-#undef LIST_HEAD
-#include <lnet/lnetctl.h>     /* needed for parse_dump */
-
-#include "lutil.h"
-#include "llite_lib.h"
-#include <lustre_ver.h>
-#include <lustre_fid.h>
-
-/* build inode number on passed @fid */
-unsigned long llu_fid_build_ino(struct llu_sb_info *sbi,
-                                struct lu_fid *fid)
-{
-        unsigned long ino;
-        ENTRY;
-
-        if (fid_is_igif(fid)) {
-                ino = lu_igif_ino(fid);
-                RETURN(ino);
-        }
-
-        ino = fid_flatten(fid);
-
-        if (unlikely(ino == 0))
-                /* the first result ino is 0xFFC001, so this is rarely used */
-                ino = 0xffbcde;
-        ino = ino | 0x80000000;
-        RETURN(ino);
-}
index 09689d2..5bb5717 100644 (file)
@@ -1,6 +1,6 @@
 MODULES := lustre llite_lloop
 lustre-objs := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o
-lustre-objs += llite_fid.o rw.o lproc_llite.o namei.o symlink.o llite_mmap.o
+lustre-objs += rw.o lproc_llite.o namei.o symlink.o llite_mmap.o
 lustre-objs += xattr.o remote_perm.o llite_rmtacl.o llite_capa.o
 lustre-objs += rw26.o super25.o statahead.o
 lustre-objs += ../lclient/glimpse.o ../lclient/lcommon_cl.o ../lclient/lcommon_misc.o
index 33c7963..30e0134 100644 (file)
@@ -388,7 +388,6 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
 {
         struct inode         *inode = filp->f_dentry->d_inode;
         struct ll_inode_info *info  = ll_i2info(inode);
-        struct ll_sb_info    *sbi   = ll_i2sbi(inode);
         __u64                 pos   = filp->f_pos;
         struct page          *page;
         struct ll_dir_chain   chain;
@@ -458,7 +457,7 @@ int ll_readdir(struct file *filp, void *cookie, filldir_t filldir)
                                 fid  = ent->lde_fid;
                                 name = ent->lde_name;
                                 fid_le_to_cpu(&fid, &fid);
-                                ino  = ll_fid_build_ino(sbi, &fid);
+                                ino  = cl_fid_build_ino(&fid);
                                 type = ll_dirent_type_get(ent);
                                 done = filldir(cookie, name, namelen,
                                                (loff_t)hash, ino, type);
diff --git a/lustre/llite/llite_fid.c b/lustre/llite/llite_fid.c
deleted file mode 100644 (file)
index eab0e84..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* -*- 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.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright  2008 Sun Microsystems, Inc. All rights reserved
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/llite/llite_fid.c
- *
- * Lustre Light Super operations
- */
-
-#define DEBUG_SUBSYSTEM S_LLITE
-
-#include <linux/module.h>
-#include <linux/types.h>
-#include <linux/random.h>
-#include <linux/version.h>
-
-#include <lustre_fid.h>
-#include <lustre_lite.h>
-#include <lustre_ha.h>
-#include <lustre_ver.h>
-#include <lustre_dlm.h>
-#include <lustre_disk.h>
-#include "llite_internal.h"
-
-/* Build inode number on passed @fid */
-ino_t ll_fid_build_ino(struct ll_sb_info *sbi,
-                       struct lu_fid *fid)
-{
-        ino_t ino;
-        ENTRY;
-
-        if (fid_is_igif(fid)) {
-                ino = lu_igif_ino(fid);
-                RETURN(ino);
-        }
-
-        /*
-         * Very stupid and having many downsides inode allocation algorithm
-         * based on fid.
-         */
-        ino = fid_flatten(fid) & 0xFFFFFFFF;
-
-        if (unlikely(ino == 0))
-                /* the first result ino is 0xFFC001, so this is rarely used */
-                ino = 0xffbcde; 
-        ino = ino | 0x80000000;
-        RETURN(ino);
-}
-
-__u32 ll_fid_build_gen(struct ll_sb_info *sbi,
-                       struct lu_fid *fid)
-{
-        __u32 gen = 0;
-        ENTRY;
-
-        if (fid_is_igif(fid)) {
-                gen = lu_igif_gen(fid);
-        }
-        RETURN(gen);
-}
index 5f7ac48..c061183 100644 (file)
@@ -947,10 +947,6 @@ void free_rmtperm_hash(struct hlist_head *hash);
 int ll_update_remote_perm(struct inode *inode, struct mdt_remote_perm *perm);
 int lustre_check_remote_perm(struct inode *inode, int mask);
 
-/* llite/llite_fid.c */
-ino_t ll_fid_build_ino(struct ll_sb_info *sbi, struct lu_fid *fid);
-__u32 ll_fid_build_gen(struct ll_sb_info *sbi, struct lu_fid *fid);
-
 /* llite/llite_capa.c */
 extern cfs_timer_t ll_capa_timer;
 
index 6de3ecc..11c65e1 100644 (file)
@@ -437,7 +437,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
         }
 
         LASSERT(fid_is_sane(&sbi->ll_root_fid));
-        root = ll_iget(sb, ll_fid_build_ino(sbi, &sbi->ll_root_fid), &lmd);
+        root = ll_iget(sb, cl_fid_build_ino(&sbi->ll_root_fid), &lmd);
         md_free_lustre_md(sbi->ll_md_exp, &lmd);
         ptlrpc_req_finished(request);
 
@@ -1586,8 +1586,8 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
                 spin_unlock(&lli->lli_lock);
         }
 #endif
-        inode->i_ino = ll_fid_build_ino(sbi, &body->fid1);
-        inode->i_generation = ll_fid_build_gen(sbi, &body->fid1);
+        inode->i_ino = cl_fid_build_ino(&body->fid1);
+        inode->i_generation = cl_fid_build_gen(&body->fid1);
 
         if (body->valid & OBD_MD_FLATIME &&
             body->atime > LTIME_S(inode->i_atime))
@@ -2006,7 +2006,7 @@ int ll_prep_inode(struct inode **inode,
                  */
                 LASSERT(fid_is_sane(&md.body->fid1));
 
-                *inode = ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1),&md);
+                *inode = ll_iget(sb, cl_fid_build_ino(&md.body->fid1), &md);
                 if (*inode == NULL || IS_ERR(*inode)) {
                         if (md.lsm)
                                 obd_free_memmd(sbi->ll_dt_exp, &md.lsm);
index f20bf65..0f72d19 100644 (file)
@@ -75,7 +75,7 @@ static struct inode *search_inode_for_lustre(struct super_block *sb,
         struct inode          *inode = NULL;
         unsigned long         valid = 0;
         int                   eadatalen = 0;
-        ino_t                 ino = ll_fid_build_ino(sbi, fid);
+        ino_t                 ino = cl_fid_build_ino(fid);
         int                   rc;
         ENTRY;
 
index d692736..2abbb65 100644 (file)
@@ -357,7 +357,7 @@ int mdd_lov_set_md(const struct lu_env *env, struct mdd_object *pobj,
 /*
  * XXX: this is for create lsm object id, which should identify the lsm object
  * unique in the whole mds, as I see. But it seems, we still not need it
- * now. Right? So just borrow the ll_fid_build_ino().
+ * now. Right? So just borrow the cl_fid_build_ino().
  */
 static obd_id mdd_lov_create_id(const struct lu_fid *fid)
 {