From: Christoph Hellwig <hch@lst.de>
To: akpm@osdl.org, jaharkes@cs.cmu.edu
Cc: linux-fsdevel@vger.kernel.org
Subject: [PATCH] coda: kill file_count abuse
Date: Thu, 19 Jul 2007 23:45:08 +0200 [thread overview]
Message-ID: <20070719214508.GA4482@lst.de> (raw)
->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 *);
next reply other threads:[~2007-07-19 21:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-19 21:45 Christoph Hellwig [this message]
2007-07-19 22:16 ` [PATCH] coda: kill file_count abuse 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070719214508.GA4482@lst.de \
--to=hch@lst.de \
--cc=akpm@osdl.org \
--cc=jaharkes@cs.cmu.edu \
--cc=linux-fsdevel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).