diff options
Diffstat (limited to 'libglusterfs/src/inode.h')
| -rw-r--r-- | libglusterfs/src/inode.h | 158 |
1 files changed, 111 insertions, 47 deletions
diff --git a/libglusterfs/src/inode.h b/libglusterfs/src/inode.h index 520df7dbc..a88976265 100644 --- a/libglusterfs/src/inode.h +++ b/libglusterfs/src/inode.h @@ -1,20 +1,11 @@ /* - Copyright (c) 2007-2009 Gluster, Inc. <http://www.gluster.com> - This file is part of GlusterFS. - - GlusterFS is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published - by the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - GlusterFS 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 for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see - <http://www.gnu.org/licenses/>. + Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com> + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. */ #ifndef _INODE_H @@ -28,6 +19,8 @@ #include <stdint.h> #include <sys/types.h> +#define DEFAULT_INODE_MEMPOOL_ENTRIES 32 * 1024 +#define INODE_PATH_FMT "<gfid:%s>" struct _inode_table; typedef struct _inode_table inode_table_t; @@ -39,6 +32,8 @@ typedef struct _dentry dentry_t; #include "list.h" #include "xlator.h" +#include "iatt.h" +#include "uuid.h" struct _inode_table { @@ -58,10 +53,10 @@ struct _inode_table { struct list_head purge; /* list of inodes to be purged soon */ uint32_t purge_size; /* count of inodes in purge list */ - struct list_head attic; /* list of inodes which do not have the latest generation - number. inode_t's @hash is linked with @attic. It is - otherwise linked with @inode_hash */ - uint32_t attic_size; + struct mem_pool *inode_pool; /* memory pool for inodes */ + struct mem_pool *dentry_pool; /* memory pool for dentrys */ + struct mem_pool *fd_mem_pool; /* memory pool for fd_t */ + int ctxcount; /* number of slots in inode->ctx */ }; @@ -78,10 +73,12 @@ struct _inode_ctx { uint64_t key; xlator_t *xl_key; }; + /* if value1 is 0, then field is not set.. */ union { uint64_t value1; void *ptr1; }; + /* if value2 is 0, then field is not set.. */ union { uint64_t value2; void *ptr2; @@ -90,13 +87,12 @@ struct _inode_ctx { struct _inode { inode_table_t *table; /* the table this inode belongs to */ + uuid_t gfid; gf_lock_t lock; uint64_t nlookup; - uint64_t generation; - uint32_t in_attic; /* whether @hash is linked with @inode_hash or @attic */ + uint32_t fd_count; /* Open fd count */ uint32_t ref; /* reference count on this inode */ - ino_t ino; /* inode number in the storage (persistent) */ - mode_t st_mode; /* what kind of file */ + ia_type_t ia_type; /* what kind of file */ struct list_head fd_list; /* list of open files on this inode */ struct list_head dentry_list; /* list of directory entries for this inode */ struct list_head hash; /* hash table pointers */ @@ -106,6 +102,10 @@ struct _inode { }; +#define UUID0_STR "00000000-0000-0000-0000-000000000000" +#define GFID_STR_PFX "<gfid:" UUID0_STR ">" +#define GFID_STR_PFX_LEN (sizeof (GFID_STR_PFX) - 1) + inode_table_t * inode_table_new (size_t lru_limit, xlator_t *xl); @@ -113,17 +113,14 @@ inode_t * inode_new (inode_table_t *table); inode_t * -inode_search (inode_table_t *table, ino_t ino, const char *name); - -inode_t * inode_link (inode_t *inode, inode_t *parent, - const char *name, struct stat *stbuf); + const char *name, struct iatt *stbuf); void inode_unlink (inode_t *inode, inode_t *parent, const char *name); inode_t * -inode_parent (inode_t *inode, ino_t par, const char *name); +inode_parent (inode_t *inode, uuid_t pargfid, const char *name); inode_t * inode_ref (inode_t *inode); @@ -138,50 +135,117 @@ int inode_forget (inode_t *inode, uint64_t nlookup); int +inode_invalidate(inode_t *inode); + +int inode_rename (inode_table_t *table, inode_t *olddir, const char *oldname, inode_t *newdir, const char *newname, - inode_t *inode, struct stat *stbuf); + inode_t *inode, struct iatt *stbuf); inode_t * inode_grep (inode_table_t *table, inode_t *parent, const char *name); +int +inode_grep_for_gfid (inode_table_t *table, inode_t *parent, const char *name, + uuid_t gfid, ia_type_t *type); + inode_t * -inode_get (inode_table_t *table, ino_t ino, uint64_t gen); +inode_find (inode_table_t *table, uuid_t gfid); int inode_path (inode_t *inode, const char *name, char **bufp); +int +__inode_path (inode_t *inode, const char *name, char **bufp); + inode_t * inode_from_path (inode_table_t *table, const char *path); -dentry_t * -dentry_search_for_inode (inode_t *inode, ino_t par, const char *name); +inode_t * +inode_resolve (inode_table_t *table, char *path); + +/* deal with inode ctx's both values */ int -__inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value); +inode_ctx_set2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, + uint64_t *value2); +int +__inode_ctx_set2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, + uint64_t *value2); int -inode_ctx_put (inode_t *inode, xlator_t *xlator, uint64_t value); +inode_ctx_get2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, + uint64_t *value2); +int +__inode_ctx_get2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, + uint64_t *value2); -int -__inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value); +int +inode_ctx_del2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, + uint64_t *value2); -int -inode_ctx_get (inode_t *inode, xlator_t *xlator, uint64_t *value); +int +inode_ctx_reset2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, + uint64_t *value2); -int -inode_ctx_del (inode_t *inode, xlator_t *xlator, uint64_t *value); +/* deal with inode ctx's 1st value */ int -inode_ctx_put2 (inode_t *inode, xlator_t *xlator, uint64_t value1, - uint64_t value2); +inode_ctx_set0 (inode_t *inode, xlator_t *xlator, uint64_t *value1); int -inode_ctx_get2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, - uint64_t *value2); +__inode_ctx_set0 (inode_t *inode, xlator_t *xlator, uint64_t *value1); int -inode_ctx_del2 (inode_t *inode, xlator_t *xlator, uint64_t *value1, - uint64_t *value2); +inode_ctx_get0 (inode_t *inode, xlator_t *xlator, uint64_t *value1); +int +__inode_ctx_get0 (inode_t *inode, xlator_t *xlator, uint64_t *value1); + +int +inode_ctx_reset0 (inode_t *inode, xlator_t *xlator, uint64_t *value1); + +/* deal with inode ctx's 2st value */ + +int +inode_ctx_set1 (inode_t *inode, xlator_t *xlator, uint64_t *value2); + +int +__inode_ctx_set1 (inode_t *inode, xlator_t *xlator, uint64_t *value2); + +int +inode_ctx_get1 (inode_t *inode, xlator_t *xlator, uint64_t *value2); +int +__inode_ctx_get1 (inode_t *inode, xlator_t *xlator, uint64_t *value2); + +int +inode_ctx_reset1 (inode_t *inode, xlator_t *xlator, uint64_t *value2); + + +static inline int +__inode_ctx_put(inode_t *inode, xlator_t *this, uint64_t v) +{ + return __inode_ctx_set0 (inode, this, &v); +} + +static inline int +inode_ctx_put(inode_t *inode, xlator_t *this, uint64_t v) +{ + return inode_ctx_set0 (inode, this, &v); +} + +#define __inode_ctx_set(i,x,v_p) __inode_ctx_set0(i,x,v_p) + +#define inode_ctx_set(i,x,v_p) inode_ctx_set0(i,x,v_p) + +#define inode_ctx_reset(i,x,v) inode_ctx_reset0(i,x,v) + +#define __inode_ctx_get(i,x,v) __inode_ctx_get0(i,x,v) + +#define inode_ctx_get(i,x,v) inode_ctx_get0(i,x,v) + +#define inode_ctx_del(i,x,v) inode_ctx_del2(i,x,v,0) + +gf_boolean_t +__is_root_gfid (uuid_t gfid); #endif /* _INODE_H */ |
