From: ericm Date: Wed, 30 Sep 2009 02:27:15 +0000 (+0000) Subject: branch: HEAD X-Git-Tag: v1_9_280~38 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=e0419ec1b09478d871b1457f787ff1dc92cf6c89;p=fs%2Flustre-release.git branch: HEAD move common client helper function to lclient. b=19688 o=adilger r=tappro r=ericm --- diff --git a/lustre/include/lclient.h b/lustre/include/lclient.h index 4df7c2b..ead82c3 100644 --- a/lustre/include/lclient.h +++ b/lustre/include/lclient.h @@ -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) \ diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 7e1f826..7767097 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -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 */ }; /** diff --git a/lustre/include/lustre_fid.h b/lustre/include/lustre_fid.h index ac91579..6f3a29d 100644 --- a/lustre/include/lustre_fid.h +++ b/lustre/include/lustre_fid.h @@ -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 */ diff --git a/lustre/lclient/lcommon_cl.c b/lustre/lclient/lcommon_cl.c index 9eb6bbb..87d2b91 100644 --- a/lustre/lclient/lcommon_cl.c +++ b/lustre/lclient/lcommon_cl.c @@ -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); +} diff --git a/lustre/liblustre/Makefile.am b/lustre/liblustre/Makefile.am index 91e5f01..d7f8957 100644 --- a/lustre/liblustre/Makefile.am +++ b/lustre/liblustre/Makefile.am @@ -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) diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c index c8e3300..0039f3d 100644 --- a/lustre/liblustre/dir.c +++ b/lustre/liblustre/dir.c @@ -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 index c9135db..0000000 --- a/lustre/liblustre/llite_fid.c +++ /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 -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_XTIO_H -#include -#endif -#include -#include -#include -#include -#ifdef HAVE_FILE_H -#include -#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 /* needed for parse_dump */ - -#include "lutil.h" -#include "llite_lib.h" -#include -#include - -/* 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); -} diff --git a/lustre/llite/Makefile.in b/lustre/llite/Makefile.in index 09689d2..5bb5717 100644 --- a/lustre/llite/Makefile.in +++ b/lustre/llite/Makefile.in @@ -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 diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 33c7963..30e0134 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -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 index eab0e84..0000000 --- a/lustre/llite/llite_fid.c +++ /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 -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#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); -} diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 5f7ac48..c061183 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -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; diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 6de3ecc..11c65e1 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -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); diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index f20bf65..0f72d19 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -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; diff --git a/lustre/mdd/mdd_lov.c b/lustre/mdd/mdd_lov.c index d692736..2abbb65 100644 --- a/lustre/mdd/mdd_lov.c +++ b/lustre/mdd/mdd_lov.c @@ -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) {