linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] coda: kill file_count abuse
@ 2007-07-19 21:45 Christoph Hellwig
  2007-07-19 22:16 ` Jan Harkes
  0 siblings, 1 reply; 11+ messages in thread
From: Christoph Hellwig @ 2007-07-19 21:45 UTC (permalink / raw)
  To: akpm, jaharkes; +Cc: linux-fsdevel

->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 <hch@lst.de>

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 *);

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-07-20 14:26 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-19 21:45 [PATCH] coda: kill file_count abuse Christoph Hellwig
2007-07-19 22:16 ` Jan Harkes
2007-07-20  0:45   ` David Chinner
2007-07-20  0:53     ` Al Viro
2007-07-20  2:36       ` David Chinner
2007-07-20  3:16         ` Al Viro
2007-07-20  4:10           ` [PATCH] coda: file count cannot be used to discover last close Jan Harkes
2007-07-20  5:38             ` Al Viro
2007-07-20 14:26               ` Jan Harkes
2007-07-20  6:03           ` [PATCH] coda: kill file_count abuse David Chinner
2007-07-20  2:40       ` Jan Harkes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).