X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Ffile_table.c;h=eb260df6c93788639aace22422dd4f82d5789b05;hb=8e8ece46a861c84343256819eaec77e608ff9217;hp=5d56ec5db141ebfc45be159712853a03cc29d8b2;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/fs/file_table.c b/fs/file_table.c index 5d56ec5db..eb260df6c 100644 --- a/fs/file_table.c +++ b/fs/file_table.c @@ -16,6 +16,8 @@ #include #include #include +#include +#include /* sysctl tunables... */ struct files_stat_struct files_stat = { @@ -24,12 +26,10 @@ struct files_stat_struct files_stat = { EXPORT_SYMBOL(files_stat); /* Needed by unix.o */ -/* public *and* exported. Not pretty! */ -spinlock_t __cacheline_aligned_in_smp files_lock = SPIN_LOCK_UNLOCKED; +/* public. Not pretty! */ + __cacheline_aligned_in_smp DEFINE_SPINLOCK(files_lock); -EXPORT_SYMBOL(files_lock); - -static spinlock_t filp_count_lock = SPIN_LOCK_UNLOCKED; +static DEFINE_SPINLOCK(filp_count_lock); /* slab constructors and destructors are called from arbitrary * context and must be fully threaded - use a local spinlock @@ -84,9 +84,12 @@ static int old_max; atomic_set(&f->f_count, 1); f->f_uid = current->fsuid; f->f_gid = current->fsgid; - f->f_owner.lock = RW_LOCK_UNLOCKED; + rwlock_init(&f->f_owner.lock); /* f->f_version: 0 */ INIT_LIST_HEAD(&f->f_list); + f->f_xid = vx_current_xid(); + vx_files_inc(f); + f->f_maxcount = INT_MAX; return f; } } @@ -106,52 +109,6 @@ fail: EXPORT_SYMBOL(get_empty_filp); -/* - * Clear and initialize a (private) struct file for the given dentry, - * allocate the security structure, and call the open function (if any). - * The file should be released using close_private_file. - */ -int open_private_file(struct file *filp, struct dentry *dentry, int flags) -{ - int error; - memset(filp, 0, sizeof(*filp)); - eventpoll_init_file(filp); - filp->f_flags = flags; - filp->f_mode = (flags+1) & O_ACCMODE; - atomic_set(&filp->f_count, 1); - filp->f_dentry = dentry; - filp->f_mapping = dentry->d_inode->i_mapping; - filp->f_uid = current->fsuid; - filp->f_gid = current->fsgid; - filp->f_op = dentry->d_inode->i_fop; - INIT_LIST_HEAD(&filp->f_list); - error = security_file_alloc(filp); - if (!error) - if (filp->f_op && filp->f_op->open) { - error = filp->f_op->open(dentry->d_inode, filp); - if (error) - security_file_free(filp); - } - return error; -} - -EXPORT_SYMBOL(open_private_file); - -/* - * Release a private file by calling the release function (if any) and - * freeing the security structure. - */ -void close_private_file(struct file *file) -{ - struct inode * inode = file->f_dentry->d_inode; - - if (file->f_op && file->f_op->release) - file->f_op->release(inode, file); - security_file_free(file); -} - -EXPORT_SYMBOL(close_private_file); - void fastcall fput(struct file *file) { if (atomic_dec_and_test(&file->f_count)) @@ -169,6 +126,7 @@ void fastcall __fput(struct file *file) struct vfsmount *mnt = file->f_vfsmnt; struct inode *inode = dentry->d_inode; + might_sleep(); /* * The function eventpoll_release() should be the first called * in the file cleanup chain. @@ -184,6 +142,8 @@ void fastcall __fput(struct file *file) fops_put(file->f_op); if (file->f_mode & FMODE_WRITE) put_write_access(inode); + vx_files_dec(file); + file->f_xid = 0; file_kill(file); file->f_dentry = NULL; file->f_vfsmnt = NULL; @@ -239,13 +199,13 @@ void put_filp(struct file *file) { if (atomic_dec_and_test(&file->f_count)) { security_file_free(file); + vx_files_dec(file); + file->f_xid = 0; file_kill(file); file_free(file); } } -EXPORT_SYMBOL(put_filp); - void file_move(struct file *file, struct list_head *list) { if (!list)