patch-2.3.9 linux/fs/file_table.c
Next file: linux/fs/hfs/dir_cap.c
Previous file: linux/fs/fifo.c
Back to the patch index
Back to the overall index
- Lines: 43
- Date:
Mon Jun 28 11:43:43 1999
- Orig file:
v2.3.8/linux/fs/file_table.c
- Orig date:
Tue Jun 1 23:25:48 1999
diff -u --recursive --new-file v2.3.8/linux/fs/file_table.c linux/fs/file_table.c
@@ -80,7 +80,7 @@
nr_free_files--;
new_one:
memset(f, 0, sizeof(*f));
- f->f_count = 1;
+ atomic_set(&f->f_count, 1);
f->f_version = ++event;
f->f_uid = current->fsuid;
f->f_gid = current->fsgid;
@@ -120,7 +120,7 @@
{
memset(filp, 0, sizeof(*filp));
filp->f_mode = mode;
- filp->f_count = 1;
+ atomic_set(&filp->f_count, 1);
filp->f_dentry = dentry;
filp->f_uid = current->fsuid;
filp->f_gid = current->fsgid;
@@ -133,21 +133,17 @@
void fput(struct file *file)
{
- int count = file->f_count-1;
-
- if (!count) {
+ if (atomic_dec_and_test(&file->f_count)) {
locks_remove_flock(file);
__fput(file);
- file->f_count = 0;
remove_filp(file);
insert_file_free(file);
- } else
- file->f_count = count;
+ }
}
void put_filp(struct file *file)
{
- if(--file->f_count == 0) {
+ if (atomic_dec_and_test(&file->f_count)) {
remove_filp(file);
insert_file_free(file);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)