update codes

This commit is contained in:
chyyuu
2012-09-14 21:36:57 +08:00
parent c417874aa8
commit 92c553113b
32 changed files with 506 additions and 1809 deletions

View File

@@ -26,8 +26,8 @@ __alloc_inode(int type) {
* */
void
inode_init(struct inode *node, const struct inode_ops *ops, struct fs *fs) {
atomic_set(&(node->ref_count), 0);
atomic_set(&(node->open_count), 0);
node->ref_count = 0;
node->open_count = 0;
node->in_ops = ops, node->in_fs = fs;
vop_ref_inc(node);
}
@@ -49,7 +49,8 @@ inode_kill(struct inode *node) {
* */
int
inode_ref_inc(struct inode *node) {
return atomic_add_return(&(node->ref_count), 1);
node->ref_count += 1;
return node->ref_count;
}
/* *
@@ -61,7 +62,9 @@ int
inode_ref_dec(struct inode *node) {
assert(inode_ref_count(node) > 0);
int ref_count, ret;
if ((ref_count = atomic_sub_return(&(node->ref_count), 1)) == 0) {
node->ref_count-= 1;
ref_count = node->ref_count;
if (ref_count == 0) {
if ((ret = vop_reclaim(node)) != 0 && ret != -E_BUSY) {
cprintf("vfs: warning: vop_reclaim: %e.\n", ret);
}
@@ -75,7 +78,8 @@ inode_ref_dec(struct inode *node) {
* */
int
inode_open_inc(struct inode *node) {
return atomic_add_return(&(node->open_count), 1);
node->open_count += 1;
return node->open_count;
}
/* *
@@ -87,7 +91,9 @@ int
inode_open_dec(struct inode *node) {
assert(inode_open_count(node) > 0);
int open_count, ret;
if ((open_count = atomic_sub_return(&(node->open_count), 1)) == 0) {
node->open_count -= 1;
open_count = node->open_count;
if (open_count == 0) {
if ((ret = vop_close(node)) != 0) {
cprintf("vfs: warning: vop_close: %e.\n", ret);
}

View File

@@ -35,8 +35,8 @@ struct inode {
inode_type_device_info = 0x1234,
inode_type_sfs_inode_info,
} in_type;
atomic_t ref_count;
atomic_t open_count;
int ref_count;
int open_count;
struct fs *in_fs;
const struct inode_ops *in_ops;
};
@@ -236,12 +236,12 @@ void inode_check(struct inode *node, const char *opstr);
static inline int
inode_ref_count(struct inode *node) {
return atomic_read(&(node->ref_count));
return node->ref_count;
}
static inline int
inode_open_count(struct inode *node) {
return atomic_read(&(node->open_count));
return node->open_count;
}
#endif /* !__KERN_FS_VFS_INODE_H__ */