[PVFS2-CVS]
commit by neill in pvfs2-1/src/kernel/linux-2.6: inode.c
pvfs2-kernel.h pvfs2-utils.c super.c
CVS commit program
cvs at parl.clemson.edu
Fri May 21 11:37:14 EDT 2004
Update of /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6
In directory parlweb:/tmp/cvs-serv15334/src/kernel/linux-2.6
Modified Files:
inode.c pvfs2-kernel.h pvfs2-utils.c super.c
Log Message:
- memory leak caught by Murali -- failed to free symlink targets when
used due to a bug
- replaced new_inode with iget after talking with Murali about this. It will
save us a headache in the case that an inode exists in the system with
the same inode number of the object created in pvfs2 and doesn't change
anything in the other case; requires an extra parameter to the pvfs2 inode
allocation function
Index: inode.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/inode.c,v
diff -p -u -r1.38 -r1.39
--- inode.c 13 May 2004 15:01:52 -0000 1.38
+++ inode.c 21 May 2004 14:37:14 -0000 1.39
@@ -317,7 +317,8 @@ struct inode_operations pvfs2_file_inode
struct inode *pvfs2_get_custom_inode(
struct super_block *sb,
int mode,
- dev_t dev)
+ dev_t dev,
+ unsigned long ino)
{
struct inode *inode = NULL;
pvfs2_inode_t *pvfs2_inode = NULL;
@@ -326,7 +327,7 @@ struct inode *pvfs2_get_custom_inode(
"MAJOR(dev)=%u | MINOR(dev)=%u)\n", sb, MAJOR(dev),
MINOR(dev));
- inode = new_inode(sb);
+ inode = iget(sb, ino);
if (inode)
{
/* initialize pvfs2 specific private data */
Index: pvfs2-kernel.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-kernel.h,v
diff -p -u -r1.51 -r1.52
--- pvfs2-kernel.h 13 May 2004 15:01:52 -0000 1.51
+++ pvfs2-kernel.h 21 May 2004 14:37:14 -0000 1.52
@@ -230,9 +230,16 @@ int pvfs2_remount(
/****************************
* defined in inode.c
****************************/
+struct inode *pvfs2_get_custom_inode(
+ struct super_block *sb,
+ int mode,
+ dev_t dev,
+ unsigned long ino);
+
int pvfs2_setattr(
struct dentry *dentry,
struct iattr *iattr);
+
int pvfs2_getattr(
struct vfsmount *mnt,
struct dentry *dentry,
@@ -282,6 +289,9 @@ int pvfs2_kernel_error_code_convert(
int pvfs2_error_code);
void pvfs2_inode_initialize(
+ pvfs2_inode_t *pvfs2_inode);
+
+void pvfs2_inode_finalize(
pvfs2_inode_t *pvfs2_inode);
void pvfs2_op_initialize(
Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -p -u -r1.67 -r1.68
--- pvfs2-utils.c 13 May 2004 15:01:52 -0000 1.67
+++ pvfs2-utils.c 21 May 2004 14:37:14 -0000 1.68
@@ -29,11 +29,6 @@ extern struct inode_operations pvfs2_dir
extern struct file_operations pvfs2_dir_operations;
extern struct dentry_operations pvfs2_dentry_operations;
-extern struct inode *pvfs2_get_custom_inode(
- struct super_block *sb,
- int mode,
- dev_t dev);
-
int pvfs2_gen_credentials(
PVFS_credentials *credentials)
@@ -507,7 +502,9 @@ static inline struct inode *pvfs2_create
if (new_op->downcall.status > -1)
{
- inode = pvfs2_get_custom_inode(dir->i_sb, (S_IFREG | mode), 0);
+ inode = pvfs2_get_custom_inode(
+ dir->i_sb, (S_IFREG | mode), 0, pvfs2_handle_to_ino(
+ new_op->downcall.resp.create.refn.handle));
if (!inode)
{
pvfs2_error("*** Failed to allocate pvfs2 file inode\n");
@@ -516,9 +513,6 @@ static inline struct inode *pvfs2_create
return NULL;
}
- inode->i_ino = pvfs2_handle_to_ino(
- new_op->downcall.resp.create.refn.handle);
-
pvfs2_print("Assigned file inode new number of %d\n",
(int)inode->i_ino);
@@ -598,7 +592,9 @@ static inline struct inode *pvfs2_create
if (new_op->downcall.status > -1)
{
- inode = pvfs2_get_custom_inode(dir->i_sb, (S_IFDIR | mode), 0);
+ inode = pvfs2_get_custom_inode(
+ dir->i_sb, (S_IFDIR | mode), 0, pvfs2_handle_to_ino(
+ new_op->downcall.resp.mkdir.refn.handle));
if (!inode)
{
pvfs2_error("*** Failed to allocate pvfs2 dir inode\n");
@@ -607,9 +603,6 @@ static inline struct inode *pvfs2_create
return NULL;
}
- inode->i_ino = pvfs2_handle_to_ino(
- new_op->downcall.resp.mkdir.refn.handle);
-
pvfs2_print("Assigned dir inode new number of %d\n",
(int) inode->i_ino);
@@ -691,7 +684,9 @@ static inline struct inode *pvfs2_create
if (new_op->downcall.status > -1)
{
- inode = pvfs2_get_custom_inode(dir->i_sb, (S_IFLNK | mode), 0);
+ inode = pvfs2_get_custom_inode(
+ dir->i_sb, (S_IFLNK | mode), 0, pvfs2_handle_to_ino(
+ new_op->downcall.resp.sym.refn.handle));
if (!inode)
{
pvfs2_error("*** Failed to allocate pvfs2 symlink inode\n");
@@ -700,9 +695,6 @@ static inline struct inode *pvfs2_create
return NULL;
}
- inode->i_ino = pvfs2_handle_to_ino(
- new_op->downcall.resp.sym.refn.handle);
-
pvfs2_print("Assigned symlink inode new number of %d\n",
(int)inode->i_ino);
@@ -962,9 +954,21 @@ int pvfs2_kernel_error_code_convert(
void pvfs2_inode_initialize(pvfs2_inode_t *pvfs2_inode)
{
- pvfs2_inode->refn.handle = 0;
- pvfs2_inode->refn.fs_id = 0;
+ pvfs2_inode->refn.handle = PVFS_HANDLE_NULL;
+ pvfs2_inode->refn.fs_id = PVFS_FS_ID_NULL;
+ pvfs2_inode->last_failed_block_index_read = 0;
+ pvfs2_inode->readdir_token_adjustment = 0;
pvfs2_inode->link_target = NULL;
+}
+
+/*
+ this is called from super:pvfs2_destroy_inode.
+ pvfs2_inode_cache_dtor frees the link_target if any
+*/
+void pvfs2_inode_finalize(pvfs2_inode_t *pvfs2_inode)
+{
+ pvfs2_inode->refn.handle = PVFS_HANDLE_NULL;
+ pvfs2_inode->refn.fs_id = PVFS_FS_ID_NULL;
pvfs2_inode->last_failed_block_index_read = 0;
pvfs2_inode->readdir_token_adjustment = 0;
}
Index: super.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/kernel/linux-2.6/super.c,v
diff -p -u -r1.42 -r1.43
--- super.c 13 May 2004 15:01:52 -0000 1.42
+++ super.c 21 May 2004 14:37:14 -0000 1.43
@@ -16,8 +16,6 @@
extern struct file_system_type pvfs2_fs_type;
extern struct dentry_operations pvfs2_dentry_operations;
-extern struct inode *pvfs2_get_custom_inode(
- struct super_block *sb, int mode, dev_t dev);
extern kmem_cache_t *pvfs2_inode_cache;
@@ -91,7 +89,8 @@ static void pvfs2_destroy_inode(struct i
pvfs2_print("pvfs2_destroy_inode: destroying inode %d\n",
(int)inode->i_ino);
- pvfs2_inode_initialize(pvfs2_inode);
+
+ pvfs2_inode_finalize(pvfs2_inode);
kmem_cache_free(pvfs2_inode_cache, pvfs2_inode);
}
@@ -373,12 +372,12 @@ int pvfs2_fill_sb(
sb->s_maxbytes = MAX_LFS_FILESIZE;
/* alloc and initialize our root directory inode */
- root = pvfs2_get_custom_inode(sb, (S_IFDIR | 0755), 0);
+ root = pvfs2_get_custom_inode(sb, (S_IFDIR | 0755),
+ 0, PVFS2_SB(sb)->root_handle);
if (!root)
{
return -ENOMEM;
}
- root->i_ino = (ino_t)PVFS2_SB(sb)->root_handle;
PVFS2_I(root)->refn.handle = PVFS2_SB(sb)->root_handle;
PVFS2_I(root)->refn.fs_id = PVFS2_SB(sb)->fs_id;
More information about the PVFS2-CVS
mailing list