->release is the proper way to detect the last close of a file,
file_count should never be used in filesystems.
Signed-off-by: Christoph Hellwig <[EMAIL PROTECTED]>
Index: linux-2.6/fs/coda/dir.c
===================================================================
--- linux-2.6.orig/fs/coda/dir.c 2007-07-19 22:40:25.000000000 +0200
+++ linux-2.6/fs/coda/dir.c 2007-07-19 22:40:27.000000000 +0200
@@ -86,7 +86,6 @@ const struct file_operations coda_dir_op
.read = generic_read_dir,
.readdir = coda_readdir,
.open = coda_open,
- .flush = coda_flush,
.release = coda_release,
.fsync = coda_fsync,
};
Index: linux-2.6/fs/coda/file.c
===================================================================
--- linux-2.6.orig/fs/coda/file.c 2007-07-19 22:36:38.000000000 +0200
+++ linux-2.6/fs/coda/file.c 2007-07-19 22:40:13.000000000 +0200
@@ -163,58 +163,31 @@ int coda_open(struct inode *coda_inode,
return 0;
}
-int coda_flush(struct file *coda_file, fl_owner_t id)
+int coda_release(struct inode *coda_inode, struct file *coda_file)
{
unsigned short flags = coda_file->f_flags & ~O_EXCL;
unsigned short coda_flags = coda_flags_to_cflags(flags);
- struct coda_file_info *cfi;
- struct inode *coda_inode;
- int err = 0, fcnt;
+ struct coda_file_info *cfi = CODA_FTOC(coda_file);
+ struct coda_inode_info *cii;
+ struct inode *host_inode;
+ int err = 0;
lock_kernel();
- /* last close semantics */
- fcnt = file_count(coda_file);
- if (fcnt > 1)
- goto out;
-
/* No need to make an upcall when we have not made any modifications
* to the file */
- if ((coda_file->f_flags & O_ACCMODE) == O_RDONLY)
- goto out;
-
- if (use_coda_close)
- goto out;
+ if (((coda_file->f_flags & O_ACCMODE) != O_RDONLY) && !use_coda_close) {
+ BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
- cfi = CODA_FTOC(coda_file);
- BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
-
- coda_inode = coda_file->f_path.dentry->d_inode;
-
- err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
- coda_file->f_uid);
+ err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode),
coda_flags,
+ coda_file->f_uid);
- if (err == -EOPNOTSUPP) {
- use_coda_close = 1;
- err = 0;
+ if (err == -EOPNOTSUPP) {
+ use_coda_close = 1;
+ err = 0;
+ }
}
-out:
- unlock_kernel();
- return err;
-}
-
-int coda_release(struct inode *coda_inode, struct file *coda_file)
-{
- unsigned short flags = (coda_file->f_flags) & (~O_EXCL);
- unsigned short coda_flags = coda_flags_to_cflags(flags);
- struct coda_file_info *cfi;
- struct coda_inode_info *cii;
- struct inode *host_inode;
- int err = 0;
-
- lock_kernel();
-
if (!use_coda_close) {
err = venus_release(coda_inode->i_sb, coda_i2f(coda_inode),
coda_flags);
@@ -224,7 +197,6 @@ int coda_release(struct inode *coda_inod
}
}
- cfi = CODA_FTOC(coda_file);
BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
if (use_coda_close)
@@ -288,7 +260,6 @@ const struct file_operations coda_file_o
.write = coda_file_write,
.mmap = coda_file_mmap,
.open = coda_open,
- .flush = coda_flush,
.release = coda_release,
.fsync = coda_fsync,
.splice_read = coda_file_splice_read,
Index: linux-2.6/include/linux/coda_linux.h
===================================================================
--- linux-2.6.orig/include/linux/coda_linux.h 2007-07-19 22:40:33.000000000
+0200
+++ linux-2.6/include/linux/coda_linux.h 2007-07-19 22:40:35.000000000
+0200
@@ -36,7 +36,6 @@ extern const struct file_operations coda
/* operations shared over more than one file */
int coda_open(struct inode *i, struct file *f);
-int coda_flush(struct file *f, fl_owner_t id);
int coda_release(struct inode *i, struct file *f);
int coda_permission(struct inode *inode, int mask, struct nameidata *nd);
int coda_revalidate_inode(struct dentry *);
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html