[PVFS2-CVS] commit by neill in pvfs2/src/kernel/linux-2.6: dcache.c
devpvfs2-req.c file.c inode.c namei.c pvfs2-kernel.h pvfs2-utils.c
super.c
CVS commit program
cvs at parl.clemson.edu
Thu May 13 12:01:52 EDT 2004
Update of /projects/cvsroot/pvfs2/src/kernel/linux-2.6
In directory parlweb:/tmp/cvs-serv16864/src/kernel/linux-2.6
Modified Files:
dcache.c devpvfs2-req.c file.c inode.c namei.c pvfs2-kernel.h
pvfs2-utils.c super.c
Log Message:
- properly set the inode address operations on file open as expected
- replace request_semaphore operations with interruptible operations
- added a macro that can fill in the sys_attr objects when creating
objects with default values (doesn't require an inode to copy from)
- fix kernel oops on cancelled object creation (file,dir,symlink)
- return more specific error codes in a few places (using translation)
- fix annoying quicklist compile error added a few days ago
- several comment updates
- kernel debugging output cleanups
Index: dcache.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/dcache.c,v
diff -p -u -r1.15 -r1.16
--- dcache.c 29 Mar 2004 22:11:11 -0000 1.15
+++ dcache.c 13 May 2004 15:01:52 -0000 1.16
@@ -19,7 +19,7 @@ int pvfs2_d_revalidate(
int ret = 0;
struct inode *inode = (dentry ? dentry->d_inode : NULL);
- pvfs2_print("pvfs2: pvfs2_d_revalidate called\n");
+ pvfs2_print("pvfs2_d_revalidate: called on dentry %p\n", dentry);
if (nd && (nd->flags & LOOKUP_FOLLOW) &&
(!nd->flags & LOOKUP_CREATE))
@@ -58,8 +58,8 @@ static int pvfs2_d_compare(
struct qstr *d_name,
struct qstr *name)
{
- pvfs2_print("pvfs2: pvfs2_d_compare called (name1: %s | name2: %s)\n",
- d_name->name, name->name);
+ pvfs2_print("pvfs2_d_compare: called on parent %p\n (name1: %s| "
+ "name2: %s)\n", parent, d_name->name, name->name);
/* if we have a match, return 0 (normally called from __d_lookup) */
return !((d_name->len == name->len) &&
Index: devpvfs2-req.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/devpvfs2-req.c,v
diff -p -u -r1.31 -r1.32
--- devpvfs2-req.c 30 Apr 2004 16:01:22 -0000 1.31
+++ devpvfs2-req.c 13 May 2004 15:01:52 -0000 1.32
@@ -354,6 +354,7 @@ static int pvfs2_devreq_release(
open_access_count--;
device_owner = NULL;
+
module_put(pvfs2_fs_type.owner);
/*
Index: file.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/file.c,v
diff -p -u -r1.65 -r1.66
--- file.c 20 Apr 2004 16:52:30 -0000 1.65
+++ file.c 13 May 2004 15:01:52 -0000 1.66
@@ -39,9 +39,15 @@ int pvfs2_file_open(
struct inode *inode,
struct file *file)
{
+ int ret = -EINVAL;
+
pvfs2_print("pvfs2: pvfs2_file_open called on %s (inode is %d)\n",
file->f_dentry->d_name.name, (int)inode->i_ino);
+ inode->i_mapping->host = inode;
+ inode->i_mapping->a_ops = &pvfs2_address_operations;
+ inode->i_mapping->backing_dev_info = &pvfs2_backing_dev_info;
+
if (S_ISDIR(inode->i_mode))
{
return dcache_dir_open(inode, file);
@@ -54,11 +60,10 @@ int pvfs2_file_open(
*/
if (file->f_flags & O_APPEND)
{
- int ret = -EINVAL;
-
ret = pvfs2_inode_getattr(inode);
if (ret)
{
+ pvfs2_print("pvfs2_file_open getattr error: %d\n", ret);
return ret;
}
file->f_pos = inode->i_size;
@@ -68,7 +73,10 @@ int pvfs2_file_open(
fs/open.c: returns 0 after enforcing large file support if
running on a 32 bit system w/o O_LARGFILE flag
*/
- return generic_file_open(inode, file);
+ ret = generic_file_open(inode, file);
+
+ pvfs2_print("pvfs2_file_open returning normally: %d\n", ret);
+ return ret;
}
ssize_t pvfs2_inode_read(
Index: inode.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/inode.c,v
diff -p -u -r1.37 -r1.38
--- inode.c 16 Apr 2004 21:42:05 -0000 1.37
+++ inode.c 13 May 2004 15:01:52 -0000 1.38
@@ -258,24 +258,29 @@ int pvfs2_setattr(struct dentry *dentry,
int ret = -EINVAL;
struct inode *inode = dentry->d_inode;
- pvfs2_print("pvfs2: pvfs2_setattr called on %s\n",
- dentry->d_name.name);
+ pvfs2_print("pvfs2_setattr: called on %s\n", dentry->d_name.name);
ret = inode_change_ok(inode, iattr);
if (ret == 0)
{
- update_atime(inode);
- ret = pvfs2_inode_setattr(inode, iattr);
- if ((ret == 0) && (S_ISREG(inode->i_mode)))
+ if (S_ISREG(inode->i_mode))
{
- pvfs2_print("calling inode_setattr\n");
- inode_setattr(inode, iattr);
+ ret = inode_setattr(inode, iattr);
+ pvfs2_print("pvfs2_setattr: inode_setattr returned %d\n", ret);
+ }
+
+ if (ret == 0)
+ {
+ ret = pvfs2_inode_setattr(inode, iattr);
}
}
else
{
- pvfs2_error("pvfs2: inode_change_ok failed with %d\n",ret);
+ pvfs2_error("pvfs2_setattr: inode_change_ok failed "
+ "with %d\n", ret);
}
+
+ pvfs2_print("pvfs2_setattr: returning %d\n", ret);
return ret;
}
@@ -287,8 +292,7 @@ int pvfs2_getattr(
int ret = -ENOENT;
struct inode *inode = dentry->d_inode;
- pvfs2_print("pvfs2: pvfs2_getattr called on %s\n",
- dentry->d_name.name);
+ pvfs2_print("pvfs2_getattr: called on %s\n", dentry->d_name.name);
ret = pvfs2_inode_getattr(inode);
if (ret == 0)
@@ -318,9 +322,9 @@ struct inode *pvfs2_get_custom_inode(
struct inode *inode = NULL;
pvfs2_inode_t *pvfs2_inode = NULL;
- pvfs2_print("pvfs2_get_custom_inode: called (sb is %p | "
- "MAJOR(dev)=%u | MINOR(dev)=%u)\n",
- sb, MAJOR(dev), MINOR(dev));
+ pvfs2_print("pvfs2_get_custom_inode: called\n (sb is %p | "
+ "MAJOR(dev)=%u | MINOR(dev)=%u)\n", sb, MAJOR(dev),
+ MINOR(dev));
inode = new_inode(sb);
if (inode)
@@ -337,7 +341,7 @@ struct inode *pvfs2_get_custom_inode(
pvfs2_inode->refn.handle = 0;
pvfs2_inode->refn.fs_id = 0;
}
- pvfs2_print("pvfs2_get_custom_inode: inode %p allocated "
+ pvfs2_print("pvfs2_get_custom_inode: inode %p allocated\n "
"(pvfs2_inode is %p | sb is %p)\n", inode,
pvfs2_inode, inode->i_sb);
@@ -379,7 +383,7 @@ struct inode *pvfs2_get_custom_inode(
}
else
{
- pvfs2_print("pvfs2_get_custom_inode -- unsupported mode\n");
+ pvfs2_print("pvfs2_get_custom_inode: unsupported mode\n");
}
}
return inode;
Index: namei.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/namei.c,v
diff -p -u -r1.49 -r1.50
--- namei.c 12 Apr 2004 18:18:53 -0000 1.49
+++ namei.c 13 May 2004 15:01:52 -0000 1.50
@@ -21,8 +21,8 @@ extern wait_queue_head_t pvfs2_request_l
extern struct dentry_operations pvfs2_dentry_operations;
/*
- called with a negative dentry, so we need to hook
- it up with a newly allocated inode
+ called with a negative dentry, so we need to hook it up with a newly
+ allocated inode
*/
static int pvfs2_create(
struct inode *dir,
@@ -33,11 +33,12 @@ static int pvfs2_create(
int ret = -EINVAL;
struct inode *inode = NULL;
- pvfs2_print("pvfs2: pvfs2_create called\n");
+ pvfs2_print("pvfs2_create: called\n");
inode = pvfs2_create_entry(
dir, dentry, NULL, mode, PVFS2_VFS_OP_CREATE, &ret);
+ pvfs2_print("pvfs2_create: returning %d\n", (inode ? 0 : ret));
return (inode ? 0 : ret);
}
@@ -130,13 +131,12 @@ struct dentry *pvfs2_lookup(
strncpy(new_op->upcall.req.lookup.d_name,
dentry->d_name.name, PVFS2_NAME_LEN);
- pvfs2_print(
- "pvfs2_lookup: doing lookup on %s under %Lu,%d (follow=%s)\n",
- new_op->upcall.req.lookup.d_name,
- new_op->upcall.req.lookup.parent_refn.handle,
- new_op->upcall.req.lookup.parent_refn.fs_id,
- ((new_op->upcall.req.lookup.sym_follow ==
- PVFS2_LOOKUP_LINK_FOLLOW) ? "yes" : "no"));
+ pvfs2_print("pvfs2_lookup: doing lookup on %s\n under %Lu,%d "
+ "(follow=%s)\n", new_op->upcall.req.lookup.d_name,
+ new_op->upcall.req.lookup.parent_refn.handle,
+ new_op->upcall.req.lookup.parent_refn.fs_id,
+ ((new_op->upcall.req.lookup.sym_follow ==
+ PVFS2_LOOKUP_LINK_FOLLOW) ? "yes" : "no"));
service_error_exit_op_with_timeout_retry(
new_op, "pvfs2_lookup", retries, error_exit,
@@ -144,7 +144,7 @@ struct dentry *pvfs2_lookup(
ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
- pvfs2_print("Lookup Got PVFS2 handle %Lu on fsid %d (ret=%d)\n",
+ pvfs2_print("Lookup Got %Lu, fsid %d (ret=%d)\n",
new_op->downcall.resp.lookup.refn.handle,
new_op->downcall.resp.lookup.refn.fs_id, ret);
@@ -188,19 +188,21 @@ struct dentry *pvfs2_lookup(
noticeably break during directory renames.
however, if the operation failed or exited, do not add the
- dentry.
+ dentry (e.g. in the case that a touch is issued on a file that
+ already exists that was interrupted during this lookup -- no
+ need to add another negative dentry for an existing file)
*/
if (!inode && !error_exit)
{
- pvfs2_print("pvfs2_lookup: Adding *negative* dentry for %s\n",
- dentry->d_name.name);
-
/*
- make sure to set the pvfs2 specific dentry operations, even
- for the negative dentry that we're adding now so that a
+ make sure to set the pvfs2 specific dentry operations for
+ the negative dentry that we're adding now so that a
potential future lookup of this cached negative dentry can
- be properly revalidated
+ be properly revalidated.
*/
+ pvfs2_print("pvfs2_lookup: Adding *negative* dentry %p\n "
+ "for %s\n", dentry, dentry->d_name.name);
+
dentry->d_op = &pvfs2_dentry_operations;
d_add(dentry, inode);
}
@@ -377,26 +379,18 @@ static int pvfs2_rename(
new_op, "pvfs2_rename", retries,
get_interruptible_flag(old_dentry->d_inode));
- /*
- nothing's returned; just return the exit status
-
- NOTE: make sure the properly translated error code
- is passed down from above to distinguish between
- different types of rename errors (target dir/file
- exists, other error, etc).
- */
- ret = new_op->downcall.status;
+ ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
pvfs2_print("pvfs2: pvfs2_rename got downcall status %d\n", ret);
if (new_dentry->d_inode)
{
- if (are_directories && simple_empty(new_dentry))
- {
- pvfs2_print("pvfs2: pvfs2_rename target dir not empty\n");
- ret = -ENOTEMPTY;
- goto error_exit;
- }
+/* if (are_directories && simple_empty(new_dentry)) */
+/* { */
+/* pvfs2_print("pvfs2: pvfs2_rename target dir not empty\n"); */
+/* ret = -ENOTEMPTY; */
+/* goto error_exit; */
+/* } */
new_dentry->d_inode->i_ctime = CURRENT_TIME;
if (are_directories)
Index: pvfs2-kernel.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-kernel.h,v
diff -p -u -r1.50 -r1.51
--- pvfs2-kernel.h 16 Apr 2004 19:58:04 -0000 1.50
+++ pvfs2-kernel.h 13 May 2004 15:01:52 -0000 1.51
@@ -362,7 +362,7 @@ do {
do { \
sigset_t orig_sigset; \
if (!intr) mask_blocked_signals(&orig_sigset); \
- down(&request_semaphore); \
+ down_interruptible(&request_semaphore); \
add_op_to_request_list(op); \
up(&request_semaphore); \
ret = wait_for_matching_downcall(new_op); \
@@ -405,7 +405,7 @@ do {
sigset_t orig_sigset; \
if (!intr) mask_blocked_signals(&orig_sigset); \
wait_for_op: \
- down(&request_semaphore); \
+ down_interruptible(&request_semaphore); \
add_op_to_request_list(op); \
up(&request_semaphore); \
ret = wait_for_matching_downcall(op); \
@@ -441,36 +441,36 @@ do {
NOTE: used in namei.c:lookup, file.c:pvfs2_inode_read, and
file.c:pvfs2_file_write
*/
-#define service_error_exit_op_with_timeout_retry(op,meth,num,e, intr)\
-do { \
- sigset_t orig_sigset; \
- if (!intr) mask_blocked_signals(&orig_sigset); \
- wait_for_op: \
- down(&request_semaphore); \
- add_op_to_request_list(op); \
- up(&request_semaphore); \
- ret = wait_for_matching_downcall(op); \
- if (!intr) unmask_blocked_signals(&orig_sigset); \
- if (ret != PVFS2_WAIT_SUCCESS) \
- { \
- if ((ret == PVFS2_WAIT_TIMEOUT_REACHED) && (--num)) \
- { \
- pvfs2_print("pvfs2: %s -- timeout; requeing op\n", \
- meth); \
- goto wait_for_op; \
- } \
- else \
- { \
- if (ret == PVFS2_WAIT_TIMEOUT_REACHED) \
- { \
- pvfs2_error("pvfs2: %s -- wait timed out (%x). " \
- "aborting retry attempts.\n", \
- meth,ret); \
- } \
- e = 1; \
- goto error_exit; \
- } \
- } \
+#define service_error_exit_op_with_timeout_retry(op,meth,num,e,intr)\
+do { \
+ sigset_t orig_sigset; \
+ if (!intr) mask_blocked_signals(&orig_sigset); \
+ wait_for_op: \
+ down_interruptible(&request_semaphore); \
+ add_op_to_request_list(op); \
+ up(&request_semaphore); \
+ ret = wait_for_matching_downcall(op); \
+ if (!intr) unmask_blocked_signals(&orig_sigset); \
+ if (ret != PVFS2_WAIT_SUCCESS) \
+ { \
+ if ((ret == PVFS2_WAIT_TIMEOUT_REACHED) && (--num)) \
+ { \
+ pvfs2_print("pvfs2: %s -- timeout; requeing op\n", \
+ meth); \
+ goto wait_for_op; \
+ } \
+ else \
+ { \
+ if (ret == PVFS2_WAIT_TIMEOUT_REACHED) \
+ { \
+ pvfs2_error("pvfs2: %s -- wait timed out (%x). " \
+ "aborting retry attempts.\n", \
+ meth,ret); \
+ } \
+ e = 1; \
+ goto error_exit; \
+ } \
+ } \
} while(0)
/*
@@ -552,6 +552,22 @@ do {
} \
spin_unlock(&pvfs2_superblocks_lock); \
} while(0)
+
+#define fill_default_sys_attrs(sys_attr,type,mode)\
+do \
+{ \
+ struct timespec tspec = CURRENT_TIME; \
+ sys_attr.owner = current->fsuid; \
+ sys_attr.group = current->fsgid; \
+ sys_attr.atime = (PVFS_time)tspec.tv_sec; \
+ sys_attr.mtime = (PVFS_time)tspec.tv_sec; \
+ sys_attr.ctime = (PVFS_time)tspec.tv_sec; \
+ sys_attr.size = 0; \
+ sys_attr.perms = mode; \
+ sys_attr.objtype = type; \
+ sys_attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; \
+} while(0)
+
#endif /* __PVFS2KERNEL_H */
Index: pvfs2-utils.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/pvfs2-utils.c,v
diff -p -u -r1.66 -r1.67
--- pvfs2-utils.c 12 Apr 2004 18:18:53 -0000 1.66
+++ pvfs2-utils.c 13 May 2004 15:01:52 -0000 1.67
@@ -67,22 +67,18 @@ static inline int copy_attributes_to_ino
pvfs2_inode = PVFS2_I(inode);
/*
- arbitrarily set the inode block size;
- FIXME: we need to resolve the difference
- between the reported inode blocksize and
- the PAGE_CACHE_SIZE, since our block count
- will always be wrong.
-
- For now, we're setting the block count to
- be the proper number assuming the block size
- is 512 bytes, and the size is rounded up
- to the nearest 4K. This is apparently
- required to get proper size reports from
- the 'du' shell utility.
-
- changing the inode->i_blkbits to something
- other than PAGE_CACHE_SHIFT breaks mmap/execution
- as we depend on that.
+ arbitrarily set the inode block size; FIXME: we need to
+ resolve the difference between the reported inode blocksize
+ and the PAGE_CACHE_SIZE, since our block count will always
+ be wrong.
+
+ For now, we're setting the block count to be the proper
+ number assuming the block size is 512 bytes, and the size is
+ rounded up to the nearest 4K. This is apparently required
+ to get proper size reports from the 'du' shell utility.
+
+ changing the inode->i_blkbits to something other than
+ PAGE_CACHE_SHIFT breaks mmap/execution as we depend on that.
*/
inode->i_blksize = pvfs_bufmap_size_query();
inode->i_blkbits = PAGE_CACHE_SHIFT;
@@ -261,9 +257,8 @@ static inline void convert_attribute_mod
}
/*
- NOTE: in kernel land, we never use the
- sys_attr->link_target for anything, so don't bother
- copying it into the sys_attr object here.
+ NOTE: in kernel land, we never use the sys_attr->link_target for
+ anything, so don't bother copying it into the sys_attr object here.
*/
static inline int copy_attributes_from_inode(
struct inode *inode,
@@ -275,9 +270,9 @@ static inline int copy_attributes_from_i
if (inode && attrs)
{
/*
- if we got a non-NULL iattr structure, we need to be
- careful to only copy the attributes out of the iattr
- object that we know are valid
+ if we got a non-NULL iattr structure, we need to be careful
+ to only copy the attributes out of the iattr object that we
+ know are valid
*/
if (iattr && (iattr->ia_valid & ATTR_UID))
attrs->owner = iattr->ia_uid;
@@ -329,10 +324,8 @@ static inline int copy_attributes_from_i
}
/*
- issues a pvfs2 getattr request and fills in the
- appropriate inode attributes if successful.
-
- returns 0 on success; -errno otherwise
+ issues a pvfs2 getattr request and fills in the appropriate inode
+ attributes if successful. returns 0 on success; -errno otherwise
*/
int pvfs2_inode_getattr(
struct inode *inode)
@@ -350,11 +343,11 @@ int pvfs2_inode_getattr(
}
/*
- in the case of being called from s_op->read_inode,
- the pvfs2_inode private data hasn't been initialized
- yet, so we need to use the inode number as the handle
- and query the superblock for the fs_id. Further, we
- assign that private data here.
+ in the case of being called from s_op->read_inode, the
+ pvfs2_inode private data hasn't been initialized yet, so we
+ need to use the inode number as the handle and query the
+ superblock for the fs_id. Further, we assign that private
+ data here.
that call flow looks like:
lookup --> iget --> read_inode --> here
@@ -372,26 +365,20 @@ int pvfs2_inode_getattr(
}
/*
- post a getattr request here;
- make dentry valid if getattr passes
+ post a getattr request here; make dentry valid if getattr
+ passes
*/
new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
if (!new_op)
{
- pvfs2_error("pvfs2: pvfs2_inode_getattr -- "
- "kmem_cache_alloc failed!\n");
+ pvfs2_error("pvfs2_inode_getattr: kmem_cache_alloc "
+ "failed!\n");
ret = -ENOMEM;
return ret;
}
new_op->upcall.type = PVFS2_VFS_OP_GETATTR;
new_op->upcall.req.getattr.refn = pvfs2_inode->refn;
- /* need to check downcall.status value */
- pvfs2_print("Trying Getattr on handle %Lu on fsid %d "
- "(inode ct = %d)\n", pvfs2_inode->refn.handle,
- pvfs2_inode->refn.fs_id,
- (int)atomic_read(&inode->i_count));
-
service_error_exit_op_with_timeout_retry(
new_op, "pvfs2_inode_getattr", retries, error_exit,
get_interruptible_flag(inode));
@@ -403,24 +390,27 @@ int pvfs2_inode_getattr(
(inode, &new_op->downcall.resp.getattr.attributes,
new_op->downcall.resp.getattr.link_target))
{
- pvfs2_error("pvfs2: pvfs2_inode_getattr -- failed "
- "to copy attributes\n");
+ pvfs2_error("pvfs2_inode_getattr: failed to copy "
+ "attributes\n");
}
}
- ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
error_exit:
- pvfs2_print(error_exit ? "*** warning: getattr error_exit\n" : "");
+ ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
+
+ pvfs2_print("Getattr on handle %Lu, fsid %d\n (inode ct = %d) "
+ "returned %d (error_exit = %d)\n",
+ pvfs2_inode->refn.handle, pvfs2_inode->refn.fs_id,
+ (int)atomic_read(&inode->i_count), ret, error_exit);
+
op_release(new_op);
}
return ret;
}
/*
- issues a pvfs2 setattr request to make sure the
- new attribute values take effect if successful.
-
- returns 0 on success; -1 otherwise
+ issues a pvfs2 setattr request to make sure the new attribute values
+ take effect if successful. returns 0 on success; -errno otherwise
*/
int pvfs2_inode_setattr(
struct inode *inode,
@@ -458,11 +448,8 @@ int pvfs2_inode_setattr(
new_op, "pvfs2_inode_setattr", retries,
get_interruptible_flag(inode));
- pvfs2_print("Setattr Got PVFS2 status value of %d\n",
- new_op->downcall.status);
-
error_exit:
- ret = new_op->downcall.status;
+ ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
/* when request is serviced properly, free req op struct */
op_release(new_op);
@@ -476,99 +463,88 @@ static inline struct inode *pvfs2_create
int mode,
int *error_code)
{
- int ret = -1, retries = PVFS2_OP_RETRY_COUNT;
+ int ret = -1, retries = PVFS2_OP_RETRY_COUNT, error_exit = 0;
pvfs2_kernel_op_t *new_op = NULL;
pvfs2_inode_t *parent = PVFS2_I(dir);
pvfs2_inode_t *pvfs2_inode = NULL;
- struct inode *inode =
- pvfs2_get_custom_inode(dir->i_sb, (S_IFREG | mode), 0);
+ struct inode *inode = NULL;
- if (inode)
+ new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
+ if (!new_op)
{
- new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
- if (!new_op)
+ pvfs2_error("pvfs2_create_file: kmem_cache_alloc failed!\n");
+ *error_code = -ENOMEM;
+ return NULL;
+ }
+
+ new_op->upcall.type = PVFS2_VFS_OP_CREATE;
+ if (parent && parent->refn.handle && parent->refn.fs_id)
+ {
+ new_op->upcall.req.create.parent_refn = parent->refn;
+ }
+ else
+ {
+ new_op->upcall.req.create.parent_refn.handle =
+ pvfs2_ino_to_handle(dir->i_ino);
+ new_op->upcall.req.create.parent_refn.fs_id =
+ PVFS2_SB(dir->i_sb)->fs_id;
+ }
+
+ /* macro defined in pvfs2-kernel.h */
+ fill_default_sys_attrs(new_op->upcall.req.create.attributes,
+ PVFS_TYPE_METAFILE, (S_IFREG | mode));
+
+ strncpy(new_op->upcall.req.create.d_name,
+ dentry->d_name.name, PVFS2_NAME_LEN);
+
+ service_error_exit_op_with_timeout_retry(
+ new_op, "pvfs2_create_file", retries, error_exit,
+ get_interruptible_flag(dir));
+
+ pvfs2_print("Create Got PVFS2 handle %Lu on fsid %d\n",
+ new_op->downcall.resp.create.refn.handle,
+ new_op->downcall.resp.create.refn.fs_id);
+
+ if (new_op->downcall.status > -1)
+ {
+ inode = pvfs2_get_custom_inode(dir->i_sb, (S_IFREG | mode), 0);
+ if (!inode)
{
- pvfs2_error("pvfs2: pvfs2_create_file -- "
- "kmem_cache_alloc failed!\n");
- iput(inode);
+ pvfs2_error("*** Failed to allocate pvfs2 file inode\n");
+ op_release(new_op);
*error_code = -ENOMEM;
return NULL;
}
- new_op->upcall.type = PVFS2_VFS_OP_CREATE;
- if (parent && parent->refn.handle && parent->refn.fs_id)
- {
- new_op->upcall.req.create.parent_refn = parent->refn;
- }
- else
- {
- new_op->upcall.req.create.parent_refn.handle =
- pvfs2_ino_to_handle(dir->i_ino);
- new_op->upcall.req.create.parent_refn.fs_id =
- PVFS2_SB(dir->i_sb)->fs_id;
- }
- copy_attributes_from_inode(
- inode, &new_op->upcall.req.create.attributes, NULL);
- strncpy(new_op->upcall.req.create.d_name,
- dentry->d_name.name, PVFS2_NAME_LEN);
- service_operation_with_timeout_retry(
- new_op, "pvfs2_create_file", retries,
- get_interruptible_flag(inode));
+ inode->i_ino = pvfs2_handle_to_ino(
+ new_op->downcall.resp.create.refn.handle);
- pvfs2_print("Create Got PVFS2 handle %Lu on fsid %d\n",
- new_op->downcall.resp.create.refn.handle,
- new_op->downcall.resp.create.refn.fs_id);
+ pvfs2_print("Assigned file inode new number of %d\n",
+ (int)inode->i_ino);
- /*
- set the inode private data here, and set the inode number
- here
- */
- if (new_op->downcall.status > -1)
- {
- inode->i_ino = pvfs2_handle_to_ino(
- new_op->downcall.resp.create.refn.handle);
-
- pvfs2_print("Assigned inode new number of %d\n",
- (int)inode->i_ino);
-
- pvfs2_inode = PVFS2_I(inode);
- pvfs2_inode->refn = new_op->downcall.resp.create.refn;
+ pvfs2_inode = PVFS2_I(inode);
+ pvfs2_inode->refn = new_op->downcall.resp.create.refn;
- /*
- set up the dentry operations to make sure that our
- pvfs2 specific dentry operations take effect.
+ /* finally, add dentry with this new inode to the dcache */
+ pvfs2_print("pvfs2_create_file: Instantiating\n *negative* "
+ "dentry %p for %s\n", dentry,
+ dentry->d_name.name);
- this is exploited by defining a revalidate method to be
- called each time a lookup is done to avoid the natural
- caching effect of the vfs. unfortunately, client side
- caching isn't good for consistency across nodes. this
- is also done in the create_dir and create_symlink
- methods below.
-
- NOTE: when adding negative dentries, we set the pvfs2
- specific dentry operations already, so this is more
- just a sanity re-set.
- */
- dentry->d_op = &pvfs2_dentry_operations;
-
- /* finally, add dentry with this new inode to the dcache */
- pvfs2_print("pvfs2_create_file: Instantiating *negative* "
- "dentry for %s\n", dentry->d_name.name);
- d_instantiate(dentry, inode);
- }
- else
- {
- error_exit:
- pvfs2_print("pvfs2_create_file: An error occurred; "
- "removing created inode\n");
- iput(inode);
- inode = NULL;
+ dentry->d_op = &pvfs2_dentry_operations;
+ d_instantiate(dentry, inode);
+ }
+ else
+ {
+ error_exit:
+ *error_code = (error_exit ? -EINTR :
+ pvfs2_kernel_error_code_convert(
+ new_op->downcall.status));
- *error_code = pvfs2_kernel_error_code_convert(
- new_op->downcall.status);
- }
- op_release(new_op);
+ pvfs2_print("pvfs2_create_file: failed with error code %d\n",
+ *error_code);
}
+
+ op_release(new_op);
return inode;
}
@@ -578,87 +554,88 @@ static inline struct inode *pvfs2_create
int mode,
int *error_code)
{
- int ret = -1, retries = PVFS2_OP_RETRY_COUNT;
+ int ret = -1, retries = PVFS2_OP_RETRY_COUNT, error_exit = 0;
pvfs2_kernel_op_t *new_op = NULL;
pvfs2_inode_t *parent = PVFS2_I(dir);
pvfs2_inode_t *pvfs2_inode = NULL;
- struct inode *inode =
- pvfs2_get_custom_inode(dir->i_sb, (S_IFDIR | mode), 0);
+ struct inode *inode = NULL;
- if (inode)
+ new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
+ if (!new_op)
{
- new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
- if (!new_op)
- {
- pvfs2_error("pvfs2: pvfs2_create_dir -- "
- "kmem_cache_alloc failed!\n");
- iput(inode);
- *error_code = -ENOMEM;
- return NULL;
- }
- new_op->upcall.type = PVFS2_VFS_OP_MKDIR;
- if (parent && parent->refn.handle && parent->refn.fs_id)
- {
- new_op->upcall.req.mkdir.parent_refn = parent->refn;
- }
- else
- {
- new_op->upcall.req.mkdir.parent_refn.handle =
- pvfs2_ino_to_handle(dir->i_ino);
- new_op->upcall.req.mkdir.parent_refn.fs_id =
- PVFS2_SB(dir->i_sb)->fs_id;
- }
- copy_attributes_from_inode(
- inode, &new_op->upcall.req.mkdir.attributes, NULL);
- strncpy(new_op->upcall.req.mkdir.d_name,
- dentry->d_name.name, PVFS2_NAME_LEN);
+ pvfs2_error("pvfs2_create_dir: kmem_cache_alloc failed!\n");
+ *error_code = -ENOMEM;
+ return NULL;
+ }
- pvfs2_print("pvfs2: pvfs2_create_dir op initialized "
- "with type %d\n", new_op->upcall.type);
+ new_op->upcall.type = PVFS2_VFS_OP_MKDIR;
+ if (parent && parent->refn.handle && parent->refn.fs_id)
+ {
+ new_op->upcall.req.mkdir.parent_refn = parent->refn;
+ }
+ else
+ {
+ new_op->upcall.req.mkdir.parent_refn.handle =
+ pvfs2_ino_to_handle(dir->i_ino);
+ new_op->upcall.req.mkdir.parent_refn.fs_id =
+ PVFS2_SB(dir->i_sb)->fs_id;
+ }
- service_operation_with_timeout_retry(
- new_op, "pvfs2_create_dir", retries,
- get_interruptible_flag(inode));
+ /* macro defined in pvfs2-kernel.h */
+ fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes,
+ PVFS_TYPE_DIRECTORY, (S_IFDIR | mode));
- pvfs2_print("Mkdir Got PVFS2 handle %Lu on fsid %d\n",
- new_op->downcall.resp.mkdir.refn.handle,
- new_op->downcall.resp.mkdir.refn.fs_id);
+ strncpy(new_op->upcall.req.mkdir.d_name,
+ dentry->d_name.name, PVFS2_NAME_LEN);
- /*
- set the inode private data here, and set the
- inode number here
- */
- if (new_op->downcall.status > -1)
+ service_error_exit_op_with_timeout_retry(
+ new_op, "pvfs2_create_dir", retries, error_exit,
+ get_interruptible_flag(dir));
+
+ pvfs2_print("Mkdir Got PVFS2 handle %Lu on fsid %d\n",
+ new_op->downcall.resp.mkdir.refn.handle,
+ new_op->downcall.resp.mkdir.refn.fs_id);
+
+ if (new_op->downcall.status > -1)
+ {
+ inode = pvfs2_get_custom_inode(dir->i_sb, (S_IFDIR | mode), 0);
+ if (!inode)
{
- inode->i_ino = pvfs2_handle_to_ino(
- new_op->downcall.resp.mkdir.refn.handle);
+ pvfs2_error("*** Failed to allocate pvfs2 dir inode\n");
+ op_release(new_op);
+ *error_code = -ENOMEM;
+ return NULL;
+ }
- pvfs2_print("Assigned inode new number of %d\n",
- (int) inode->i_ino);
+ inode->i_ino = pvfs2_handle_to_ino(
+ new_op->downcall.resp.mkdir.refn.handle);
- pvfs2_inode = PVFS2_I(inode);
- pvfs2_inode->refn = new_op->downcall.resp.mkdir.refn;
+ pvfs2_print("Assigned dir inode new number of %d\n",
+ (int) inode->i_ino);
- dentry->d_op = &pvfs2_dentry_operations;
+ pvfs2_inode = PVFS2_I(inode);
+ pvfs2_inode->refn = new_op->downcall.resp.mkdir.refn;
- /* finally, add dentry with this new inode to the dcache */
- pvfs2_print("pvfs2_create_dir: Instantiating *negative* "
- "dentry for %s\n", dentry->d_name.name);
- d_instantiate(dentry, inode);
- }
- else
- {
- error_exit:
- pvfs2_error("pvfs2_create_dir: An error occurred; "
- "removing created inode\n");
- iput(inode);
- inode = NULL;
+ /* finally, add dentry with this new inode to the dcache */
+ pvfs2_print("pvfs2_create_dir: Instantiating\n *negative* "
+ "dentry %p for %s\n", dentry,
+ dentry->d_name.name);
- *error_code = pvfs2_kernel_error_code_convert(
- new_op->downcall.status);
- }
- op_release(new_op);
+ dentry->d_op = &pvfs2_dentry_operations;
+ d_instantiate(dentry, inode);
+ }
+ else
+ {
+ error_exit:
+ *error_code = (error_exit ? -EINTR :
+ pvfs2_kernel_error_code_convert(
+ new_op->downcall.status));
+
+ pvfs2_print("pvfs2_create_dir: failed with error code %d\n",
+ *error_code);
}
+
+ op_release(new_op);
return inode;
}
@@ -669,86 +646,89 @@ static inline struct inode *pvfs2_create
int mode,
int *error_code)
{
- int ret = -1, retries = PVFS2_OP_RETRY_COUNT;
+ int ret = -1, retries = PVFS2_OP_RETRY_COUNT, error_exit = 0;
pvfs2_kernel_op_t *new_op = NULL;
pvfs2_inode_t *parent = PVFS2_I(dir);
pvfs2_inode_t *pvfs2_inode = NULL;
- struct inode *inode =
- pvfs2_get_custom_inode(dir->i_sb, (S_IFLNK | mode), 0);
+ struct inode *inode = NULL;
- if (inode)
+ new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
+ if (!new_op)
{
- new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
- if (!new_op)
+ pvfs2_error("pvfs2_create_symlink: kmem_cache_alloc failed!\n");
+ *error_code = -ENOMEM;
+ return NULL;
+ }
+
+ new_op->upcall.type = PVFS2_VFS_OP_SYMLINK;
+ if (parent && parent->refn.handle && parent->refn.fs_id)
+ {
+ new_op->upcall.req.sym.parent_refn = parent->refn;
+ }
+ else
+ {
+ new_op->upcall.req.sym.parent_refn.handle =
+ pvfs2_ino_to_handle(dir->i_ino);
+ new_op->upcall.req.sym.parent_refn.fs_id =
+ PVFS2_SB(dir->i_sb)->fs_id;
+ }
+
+ /* macro defined in pvfs2-kernel.h */
+ fill_default_sys_attrs(new_op->upcall.req.sym.attributes,
+ PVFS_TYPE_SYMLINK, (S_IFLNK | mode));
+
+ strncpy(new_op->upcall.req.sym.entry_name, dentry->d_name.name,
+ PVFS2_NAME_LEN);
+ strncpy(new_op->upcall.req.sym.target, symname, PVFS2_NAME_LEN);
+
+ service_error_exit_op_with_timeout_retry(
+ new_op, "pvfs2_symlink_file", retries, error_exit,
+ get_interruptible_flag(dir));
+
+ pvfs2_print("Symlink Got PVFS2 handle %Lu on fsid %d\n",
+ new_op->downcall.resp.sym.refn.handle,
+ new_op->downcall.resp.sym.refn.fs_id);
+
+ if (new_op->downcall.status > -1)
+ {
+ inode = pvfs2_get_custom_inode(dir->i_sb, (S_IFLNK | mode), 0);
+ if (!inode)
{
- pvfs2_error("pvfs2: pvfs2_create_symlink -- "
- "kmem_cache_alloc failed!\n");
- iput(inode);
+ pvfs2_error("*** Failed to allocate pvfs2 symlink inode\n");
+ op_release(new_op);
*error_code = -ENOMEM;
return NULL;
}
- new_op->upcall.type = PVFS2_VFS_OP_SYMLINK;
- if (parent && parent->refn.handle && parent->refn.fs_id)
- {
- new_op->upcall.req.sym.parent_refn = parent->refn;
- }
- else
- {
- new_op->upcall.req.sym.parent_refn.handle =
- pvfs2_ino_to_handle(dir->i_ino);
- new_op->upcall.req.sym.parent_refn.fs_id =
- PVFS2_SB(dir->i_sb)->fs_id;
- }
- copy_attributes_from_inode(
- inode, &new_op->upcall.req.sym.attributes, NULL);
- strncpy(new_op->upcall.req.sym.entry_name,
- dentry->d_name.name, PVFS2_NAME_LEN);
- strncpy(new_op->upcall.req.sym.target,
- symname, PVFS2_NAME_LEN);
-
- service_operation_with_timeout_retry(
- new_op, "pvfs2_symlink_file", retries,
- get_interruptible_flag(inode));
-
- pvfs2_print("Symlink Got PVFS2 handle %Lu on fsid %d\n",
- new_op->downcall.resp.sym.refn.handle,
- new_op->downcall.resp.sym.refn.fs_id);
- /*
- set the inode private data here, and set the
- inode number here
- */
- if (new_op->downcall.status > -1)
- {
- inode->i_ino = pvfs2_handle_to_ino(
- new_op->downcall.resp.sym.refn.handle);
+ inode->i_ino = pvfs2_handle_to_ino(
+ new_op->downcall.resp.sym.refn.handle);
- pvfs2_print("Assigned inode new number of %d\n",
- (int)inode->i_ino);
+ pvfs2_print("Assigned symlink inode new number of %d\n",
+ (int)inode->i_ino);
- pvfs2_inode = PVFS2_I(inode);
- pvfs2_inode->refn = new_op->downcall.resp.sym.refn;
+ pvfs2_inode = PVFS2_I(inode);
+ pvfs2_inode->refn = new_op->downcall.resp.sym.refn;
- dentry->d_op = &pvfs2_dentry_operations;
+ /* finally, add dentry with this new inode to the dcache */
+ pvfs2_print("pvfs2_create_symlink: Instantiating\n "
+ "*negative* dentry %p for %s\n", dentry,
+ dentry->d_name.name);
- /* finally, add dentry with this new inode to the dcache */
- pvfs2_print("pvfs2_create_symlink: Instantiating *negative* "
- "dentry for %s\n", dentry->d_name.name);
- d_instantiate(dentry, inode);
- }
- else
- {
- error_exit:
- pvfs2_error("pvfs2_symlink_file: An error occurred; "
- "removing created inode\n");
- iput(inode);
- inode = NULL;
+ dentry->d_op = &pvfs2_dentry_operations;
+ d_instantiate(dentry, inode);
+ }
+ else
+ {
+ error_exit:
+ *error_code = (error_exit ? -EINTR :
+ pvfs2_kernel_error_code_convert(
+ new_op->downcall.status));
- *error_code = pvfs2_kernel_error_code_convert(
- new_op->downcall.status);
- }
- op_release(new_op);
+ pvfs2_print("pvfs2_create_symlink: failed with error code %d\n",
+ *error_code);
}
+
+ op_release(new_op);
return inode;
}
@@ -757,7 +737,7 @@ static inline struct inode *pvfs2_create
pointer on success; NULL on failure.
the required error_code value will contain an error code ONLY if an
- error occurs (i.e. NULL is returned) and is unmodified otherwise.
+ error occurs (i.e. NULL is returned) and is set to 0 otherwise.
if op_type is PVFS_VFS_OP_CREATE, a file is created
if op_type is PVFS_VFS_OP_MKDIR, a directory is created
@@ -789,6 +769,11 @@ struct inode *pvfs2_create_entry(
"op_type (%d)\n", op_type);
}
}
+
+ if (error_code)
+ {
+ *error_code = -EINVAL;
+ }
return NULL;
}
@@ -886,7 +871,7 @@ int pvfs2_truncate_inode(
the truncate has no downcall members to retrieve, but
the status value tells us if it went through ok or not
*/
- ret = new_op->downcall.status;
+ ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
pvfs2_print("pvfs2: pvfs2_truncate got return value of %d\n",ret);
@@ -918,7 +903,7 @@ int pvfs2_flush_mmap_racache(struct inod
service_operation(new_op, "pvfs2_flush_mmap_racache",
get_interruptible_flag(inode));
- ret = new_op->downcall.status;
+ ret = pvfs2_kernel_error_code_convert(new_op->downcall.status);
pvfs2_print("pvfs2: pvfs2_flush_mmap_racache got "
"return value of %d\n",ret);
@@ -958,16 +943,7 @@ int pvfs2_unmount_sb(struct super_block
if (ret)
{
sb = ERR_PTR(ret);
- goto error_exit;
}
-
- /*
- the unmount has no downcall members to retrieve, but
- the status value tells us if it went through ok or not
- */
- ret = new_op->downcall.status;
-
- pvfs2_print("pvfs2_unmount got return value of %d\n",ret);
error_exit:
op_release(new_op);
Index: super.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/kernel/linux-2.6/super.c,v
diff -p -u -r1.41 -r1.42
--- super.c 15 Apr 2004 21:24:46 -0000 1.41
+++ super.c 13 May 2004 15:01:52 -0000 1.42
@@ -63,18 +63,17 @@ static int parse_mount_options(
return 0;
}
-static struct inode *pvfs2_alloc_inode(
- struct super_block *sb)
+static struct inode *pvfs2_alloc_inode(struct super_block *sb)
{
struct inode *new_inode = NULL;
pvfs2_inode_t *pvfs2_inode = NULL;
/*
this allocator has an associated constructor that fills in the
- internal vfs inode structure. this initialization is
- extremely important and is required since we're allocating
- the inodes ourselves (rather than letting the system inode
- allocator initialize them for us); see inode.c/inode_init_once()
+ internal vfs inode structure. this initialization is extremely
+ important and is required since we're allocating the inodes
+ ourselves (rather than letting the system inode allocator
+ initialize them for us); see inode.c/inode_init_once()
*/
pvfs2_inode = kmem_cache_alloc(pvfs2_inode_cache,
PVFS2_CACHE_ALLOC_FLAGS);
@@ -85,8 +84,7 @@ static struct inode *pvfs2_alloc_inode(
return new_inode;
}
-static void pvfs2_destroy_inode(
- struct inode *inode)
+static void pvfs2_destroy_inode(struct inode *inode)
{
pvfs2_inode_t *pvfs2_inode = PVFS2_I(inode);
@@ -102,9 +100,8 @@ static void pvfs2_read_inode(
{
pvfs2_inode_t *pvfs2_inode = PVFS2_I(inode);
- pvfs2_print("pvfs2: pvfs2_read_inode called (inode = %lu | "
- "ct = %d)\n", inode->i_ino,
- (int)atomic_read(&inode->i_count));
+ pvfs2_print("pvfs2_read_inode: (inode = %lu | ct = %d)\n",
+ inode->i_ino, (int)atomic_read(&inode->i_count));
/*
at this point we know the private inode data handle/fs_id can't
@@ -135,7 +132,7 @@ static void pvfs2_write_inode(
struct inode *inode,
int do_sync)
{
- pvfs2_print("pvfs2: pvfs2_write_inode called (inode = %d)\n",
+ pvfs2_print("pvfs2_write_inode: called (inode = %d)\n",
(int)inode->i_ino);
}
@@ -143,9 +140,8 @@ static void pvfs2_write_inode(
static void pvfs2_put_inode(
struct inode *inode)
{
- pvfs2_print("pvfs2: pvfs2_put_inode called (ino %d | ct=%d | "
- "nlink=%d)\n", (int) inode->i_ino,
- (int)atomic_read(&inode->i_count),
+ pvfs2_print("pvfs2_put_inode: (%d | ct=%d | nlink=%d)\n",
+ (int)inode->i_ino, (int)atomic_read(&inode->i_count),
(int)inode->i_nlink);
if (atomic_read(&inode->i_count) == 1)
@@ -167,13 +163,13 @@ static int pvfs2_statfs(
pvfs2_kernel_op_t *new_op = NULL;
struct statfs tmp_statfs;
- pvfs2_print("pvfs2_: pvfs2_statfs called on sb %p "
- "(fs_id is %d)\n", sb, (int)(PVFS2_SB(sb)->fs_id));
+ pvfs2_print("pvfs2_statfs: called on sb %p (fs_id is %d)\n",
+ sb, (int)(PVFS2_SB(sb)->fs_id));
new_op = kmem_cache_alloc(op_cache, PVFS2_CACHE_ALLOC_FLAGS);
if (!new_op)
{
- pvfs2_error("pvfs2: pvfs2_statfs -- kmem_cache_alloc failed!\n");
+ pvfs2_error("pvfs2_statfs: kmem_cache_alloc failed!\n");
return ret;
}
new_op->upcall.type = PVFS2_VFS_OP_STATFS;
@@ -185,7 +181,7 @@ static int pvfs2_statfs(
if (new_op->downcall.status > -1)
{
- pvfs2_print("pvfs2_statfs got %ld blocks available | "
+ pvfs2_print("pvfs2_statfs: got %ld blocks available | "
"%ld blocks total\n",
new_op->downcall.resp.statfs.blocks_avail,
new_op->downcall.resp.statfs.blocks_total);
@@ -245,7 +241,7 @@ static int pvfs2_statfs(
error_exit:
op_release(new_op);
- pvfs2_print("pvfs2_statfs returning %d\n", ret);
+ pvfs2_print("pvfs2_statfs: returning %d\n", ret);
return ret;
}
@@ -268,7 +264,7 @@ int pvfs2_remount(
int ret = -EINVAL;
pvfs2_kernel_op_t *new_op = NULL;
- pvfs2_print("pvfs2: pvfs2_remount called\n");
+ pvfs2_print("pvfs2_remount: called\n");
if (sb && PVFS2_SB(sb))
{
@@ -520,7 +516,7 @@ void pvfs2_kill_sb(
/* free the pvfs2 superblock private data */
kfree(PVFS2_SB(sb));
- pvfs2_print("pvfs2_kill_sb returning normally\n");
+ pvfs2_print("pvfs2_kill_sb: returning normally\n");
}
/*
More information about the PVFS2-CVS
mailing list