All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Laurent Riffard <laurent.riffard@free.fr>,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	reiserfs-devel@vger.kernel.org
Subject: [RFC][PATCH] make reiserfs stop using 'struct file' for internal xattr operations
Date: Thu, 27 Sep 2007 13:53:39 -0700	[thread overview]
Message-ID: <1190926419.7344.27.camel@localhost> (raw)
In-Reply-To: <20070927202607.GA3812@infradead.org>

On Thu, 2007-09-27 at 21:26 +0100, Christoph Hellwig wrote:
> 
> Dave will probably find a bandaid to work around this, but the
> right fix is to stop using a file struct here entirely.  If you
> look at reiserfs_xattr_set it's not actually used at all except
> for passing it to ->prepare_write and ->commit_write which then
> don't use it at all.  All that crap should be rewritten to just
> pass the dentry around.  Note that all this should not acquire
> writer counts on the vfsmount - we have done this already
> before calling into the xattr methods.

I'm perplexed as to why a 'struct file' is needed, too.  The 'struct
file' doesn't get used for anything _but_ the dentry, and the functions
to which it is passed (reiserfs_prepate/commit_write()) don't use it.
In fact, some other callers just pass NULL.

This is a completely naive implementation, and I've only tested that it
compiles, but does anybody see a reason we can't just do this?

BTW, do reiserfs developers know that you can put function declarations
in header files?  ;)  4 different .c files have this:

int reiserfs_commit_write(struct page *page, unsigned from, unsigned to);
int reiserfs_prepare_write(struct page *page, unsigned from, unsigned to);

---

 lxc-dave/fs/reiserfs/inode.c |   15 ++++------
 lxc-dave/fs/reiserfs/ioctl.c |   10 ++-----
 lxc-dave/fs/reiserfs/xattr.c |   59 +++++++++++++------------------------------
 3 files changed, 28 insertions(+), 56 deletions(-)

diff -puN fs/open.c~fix-reiserfs-oops fs/open.c
diff -puN fs/file_table.c~fix-reiserfs-oops fs/file_table.c
diff -puN include/linux/mount.h~fix-reiserfs-oops include/linux/mount.h
diff -puN fs/reiserfs/xattr.c~fix-reiserfs-oops fs/reiserfs/xattr.c
--- lxc/fs/reiserfs/xattr.c~fix-reiserfs-oops	2007-09-27 13:36:38.000000000 -0700
+++ lxc-dave/fs/reiserfs/xattr.c	2007-09-27 13:49:02.000000000 -0700
@@ -194,27 +194,6 @@ static struct dentry *get_xa_file_dentry
 	return xafile;
 }
 
-/* Opens a file pointer to the attribute associated with inode */
-static struct file *open_xa_file(const struct inode *inode, const char *name,
-				 int flags)
-{
-	struct dentry *xafile;
-	struct file *fp;
-
-	xafile = get_xa_file_dentry(inode, name, flags);
-	if (IS_ERR(xafile))
-		return ERR_PTR(PTR_ERR(xafile));
-	else if (!xafile->d_inode) {
-		dput(xafile);
-		return ERR_PTR(-ENODATA);
-	}
-
-	fp = dentry_open(xafile, NULL, O_RDWR);
-	/* dentry_open dputs the dentry if it fails */
-
-	return fp;
-}
-
 /*
  * this is very similar to fs/reiserfs/dir.c:reiserfs_readdir, but
  * we need to drop the path before calling the filldir struct.  That
@@ -426,10 +405,8 @@ static inline __u32 xattr_hash(const cha
 	return csum_partial(msg, len, 0);
 }
 
-int reiserfs_commit_write(struct file *f, struct page *page,
-			  unsigned from, unsigned to);
-int reiserfs_prepare_write(struct file *f, struct page *page,
-			   unsigned from, unsigned to);
+int reiserfs_commit_write(struct page *page, unsigned from, unsigned to);
+int reiserfs_prepare_write(struct page *page, unsigned from, unsigned to);
 
 
 /* Generic extended attribute operations that can be used by xa plugins */
@@ -442,7 +419,7 @@ reiserfs_xattr_set(struct inode *inode, 
 		   size_t buffer_size, int flags)
 {
 	int err = 0;
-	struct file *fp;
+	struct dentry *dentry;
 	struct page *page;
 	char *data;
 	struct address_space *mapping;
@@ -460,18 +437,18 @@ reiserfs_xattr_set(struct inode *inode, 
 		xahash = xattr_hash(buffer, buffer_size);
 
       open_file:
-	fp = open_xa_file(inode, name, flags);
-	if (IS_ERR(fp)) {
-		err = PTR_ERR(fp);
+	dentry = get_xa_file_dentry(inode, name, flags);
+	if (IS_ERR(dentry)) {
+		err = PTR_ERR(dentry);
 		goto out;
 	}
 
-	xinode = fp->f_path.dentry->d_inode;
+	xinode = dentry->d_inode;
 	REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
 
 	/* we need to copy it off.. */
 	if (xinode->i_nlink > 1) {
-		fput(fp);
+		dput(dentry);
 		err = reiserfs_xattr_del(inode, name);
 		if (err < 0)
 			goto out;
@@ -485,7 +462,7 @@ reiserfs_xattr_set(struct inode *inode, 
 	newattrs.ia_size = buffer_size;
 	newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
 	mutex_lock(&xinode->i_mutex);
-	err = notify_change(fp->f_path.dentry, &newattrs);
+	err = notify_change(dentry, &newattrs);
 	if (err)
 		goto out_filp;
 
@@ -518,13 +495,13 @@ reiserfs_xattr_set(struct inode *inode, 
 			rxh->h_hash = cpu_to_le32(xahash);
 		}
 
-		err = reiserfs_prepare_write(fp, page, page_offset,
+		err = reiserfs_prepare_write(page, page_offset,
 					    page_offset + chunk + skip);
 		if (!err) {
 			if (buffer)
 				memcpy(data + skip, buffer + buffer_pos, chunk);
 			err =
-			    reiserfs_commit_write(fp, page, page_offset,
+			    reiserfs_commit_write(page, page_offset,
 						  page_offset + chunk +
 						  skip);
 		}
@@ -548,7 +525,7 @@ reiserfs_xattr_set(struct inode *inode, 
 
       out_filp:
 	mutex_unlock(&xinode->i_mutex);
-	fput(fp);
+	dput(dentry);
 
       out:
 	return err;
@@ -562,7 +539,7 @@ reiserfs_xattr_get(const struct inode *i
 		   size_t buffer_size)
 {
 	ssize_t err = 0;
-	struct file *fp;
+	struct dentry *dentry;
 	size_t isize;
 	size_t file_pos = 0;
 	size_t buffer_pos = 0;
@@ -578,13 +555,13 @@ reiserfs_xattr_get(const struct inode *i
 	if (get_inode_sd_version(inode) == STAT_DATA_V1)
 		return -EOPNOTSUPP;
 
-	fp = open_xa_file(inode, name, FL_READONLY);
-	if (IS_ERR(fp)) {
-		err = PTR_ERR(fp);
+	dentry = get_xa_file_dentry(inode, name, FL_READONLY);
+	if (IS_ERR(dentry)) {
+		err = PTR_ERR(dentry);
 		goto out;
 	}
 
-	xinode = fp->f_path.dentry->d_inode;
+	xinode = dentry->d_inode;
 	isize = xinode->i_size;
 	REISERFS_I(inode)->i_flags |= i_has_xattr_dir;
 
@@ -652,7 +629,7 @@ reiserfs_xattr_get(const struct inode *i
 	}
 
       out_dput:
-	fput(fp);
+	dput(dentry);
 
       out:
 	return err;
diff -puN fs/reiserfs/inode.c~fix-reiserfs-oops fs/reiserfs/inode.c
--- lxc/fs/reiserfs/inode.c~fix-reiserfs-oops	2007-09-27 13:39:47.000000000 -0700
+++ lxc-dave/fs/reiserfs/inode.c	2007-09-27 13:45:03.000000000 -0700
@@ -19,10 +19,8 @@
 #include <linux/quotaops.h>
 #include <linux/swap.h>
 
-int reiserfs_commit_write(struct file *f, struct page *page,
-			  unsigned from, unsigned to);
-int reiserfs_prepare_write(struct file *f, struct page *page,
-			   unsigned from, unsigned to);
+int reiserfs_commit_write(struct page *page,  unsigned from, unsigned to);
+int reiserfs_prepare_write(struct page *page, unsigned from, unsigned to);
 
 void reiserfs_delete_inode(struct inode *inode)
 {
@@ -550,14 +548,14 @@ static int convert_tail_for_hole(struct 
 	 ** won't trigger a get_block in this case.
 	 */
 	fix_tail_page_for_writing(tail_page);
-	retval = reiserfs_prepare_write(NULL, tail_page, tail_start, tail_end);
+	retval = reiserfs_prepare_write(tail_page, tail_start, tail_end);
 	if (retval)
 		goto unlock;
 
 	/* tail conversion might change the data in the page */
 	flush_dcache_page(tail_page);
 
-	retval = reiserfs_commit_write(NULL, tail_page, tail_start, tail_end);
+	retval = reiserfs_commit_write(tail_page, tail_start, tail_end);
 
       unlock:
 	if (tail_page != hole_page) {
@@ -2613,8 +2611,7 @@ static int reiserfs_write_begin(struct f
 	return ret;
 }
 
-int reiserfs_prepare_write(struct file *f, struct page *page,
-			   unsigned from, unsigned to)
+int reiserfs_prepare_write(struct page *page, unsigned from, unsigned to)
 {
 	struct inode *inode = page->mapping->host;
 	int ret;
@@ -2761,7 +2758,7 @@ static int reiserfs_write_end(struct fil
 	goto out;
 }
 
-int reiserfs_commit_write(struct file *f, struct page *page,
+int reiserfs_commit_write(struct page *page,
 			  unsigned from, unsigned to)
 {
 	struct inode *inode = page->mapping->host;
diff -puN fs/reiserfs/ioctl.c~fix-reiserfs-oops fs/reiserfs/ioctl.c
--- lxc/fs/reiserfs/ioctl.c~fix-reiserfs-oops	2007-09-27 13:42:07.000000000 -0700
+++ lxc-dave/fs/reiserfs/ioctl.c	2007-09-27 13:45:17.000000000 -0700
@@ -143,10 +143,8 @@ long reiserfs_compat_ioctl(struct file *
 }
 #endif
 
-int reiserfs_commit_write(struct file *f, struct page *page,
-			  unsigned from, unsigned to);
-int reiserfs_prepare_write(struct file *f, struct page *page,
-			   unsigned from, unsigned to);
+int reiserfs_commit_write(struct page *page, unsigned from, unsigned to);
+int reiserfs_prepare_write(struct page *page, unsigned from, unsigned to);
 /*
 ** reiserfs_unpack
 ** Function try to convert tail from direct item into indirect.
@@ -194,13 +192,13 @@ static int reiserfs_unpack(struct inode 
 	if (!page) {
 		goto out;
 	}
-	retval = reiserfs_prepare_write(NULL, page, write_from, write_from);
+	retval = reiserfs_prepare_write(page, write_from, write_from);
 	if (retval)
 		goto out_unlock;
 
 	/* conversion can change page contents, must flush */
 	flush_dcache_page(page);
-	retval = reiserfs_commit_write(NULL, page, write_from, write_from);
+	retval = reiserfs_commit_write(page, write_from, write_from);
 	REISERFS_I(inode)->i_flags |= i_nopack_mask;
 
       out_unlock:
_


-- Dave


  reply	other threads:[~2007-09-27 20:53 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-27  9:22 2.6.23-rc8-mm2 Andrew Morton
2007-09-27 10:52 ` 2.6.23-rc8-mm2 - drivers/net/ibm_newemac/mal - broken Kamalesh Babulal
2007-09-27 15:19 ` 2.6.23-rc8-mm2: problems on HP nx6325 Rafael J. Wysocki
2007-09-27 15:59   ` Rafael J. Wysocki
2007-09-27 15:49     ` Thomas Gleixner
2007-09-28 21:31       ` Rafael J. Wysocki
2007-09-27 16:53     ` Sam Ravnborg
2007-09-27 17:33       ` Randy Dunlap
2007-09-27 19:19         ` Sam Ravnborg
2007-09-27 19:48           ` Rafael J. Wysocki
2007-09-27 19:37             ` Randy Dunlap
2007-09-27 20:01               ` Rafael J. Wysocki
2007-09-27 19:18 ` 2.6.23-rc8-mm2: BUG near reiserfs_xattr_set Laurent Riffard
2007-09-27 19:48   ` Andrew Morton
2007-09-27 19:48     ` Andrew Morton
2007-09-27 20:05     ` Dave Hansen
2007-09-27 20:26     ` Christoph Hellwig
2007-09-27 20:53       ` Dave Hansen [this message]
2007-09-27 21:04         ` [RFC][PATCH] make reiserfs stop using 'struct file' for internal xattr operations Christoph Hellwig
2007-09-27 21:27           ` Dave Hansen
2007-09-27 21:51             ` Andrew Morton
2007-09-27 21:54               ` Andrew Morton
2007-09-27 22:02               ` Peter Zijlstra
2007-09-28  7:16               ` Christoph Hellwig
2007-09-28  7:29                 ` [RFC][PATCH] stop abusing filp_open in reiserfs journal code Christoph Hellwig
2007-09-28  7:29                   ` Christoph Hellwig
2007-09-28  7:29                 ` Christoph Hellwig
2007-09-28  2:40 ` WARNING: at arch/x86_64/kernel/smp.c:397 smp_call_function_mask() Fengguang Wu
2007-09-28  2:40   ` Fengguang Wu
2007-09-28  8:52     ` Laurent Vivier
2007-09-28  9:09       ` Andrew Morton
2007-09-28  9:18         ` Laurent Vivier
2007-09-28  9:34           ` Andrew Morton
2007-09-28 12:07             ` Laurent Vivier
2007-09-29  6:59               ` Fengguang Wu
2007-09-29  6:59                 ` Fengguang Wu
2007-09-29  8:15               ` Fengguang Wu
2007-09-29  8:15                 ` Fengguang Wu
2007-10-02  9:11                 ` [PATCH][RESEND] call free_init_pages() with irqs enabled in alternative_instructions() Fengguang Wu
2007-10-02  9:11                   ` Fengguang Wu
2007-09-28 15:42 ` 2.6.23-rc8-mm2 - tcp_fastretrans_alert() WARNING Cedric Le Goater
2007-09-28 19:10   ` Ilpo Järvinen
2007-09-29 12:44     ` Ilpo Järvinen
2007-09-29 14:55       ` Cedric Le Goater
2007-09-29 20:49         ` Ilpo Järvinen
2007-10-01  9:26           ` Cedric Le Goater
2007-10-02 10:26             ` Ilpo Järvinen
2007-10-02 20:06               ` Ilpo Järvinen
2007-10-02 21:48                 ` Ilpo Järvinen
2007-09-28 16:30 ` /proc/net/ bad hard links count [Was: 2.6.23-rc8-mm2] Jiri Slaby
2007-09-28 17:03   ` Eric W. Biederman
2007-09-29  9:37 ` 2.6.23-rc8-mm2 Dave Young
2007-09-29 15:19   ` 2.6.23-rc8-mm2 Greg KH
2007-09-30  1:29     ` 2.6.23-rc8-mm2 Dave Young
2007-09-30  5:18     ` 2.6.23-rc8-mm2 thunder7
2007-10-08  6:43     ` 2.6.23-rc8-mm2 Dave Young
2007-09-30  2:26 ` 2.6.23-rc8-mm2 Valdis.Kletnieks
2007-09-30  8:50   ` 2.6.23-rc8-mm2 Andrew Morton
2007-09-30 20:01     ` 2.6.23-rc8-mm2 Rafael J. Wysocki
2007-10-01 17:12       ` 2.6.23-rc8-mm2 Valdis.Kletnieks
2007-10-01 16:12     ` 2.6.23-rc8-mm2 Valdis.Kletnieks
2007-09-30  4:10 ` 2.6.23-rc8-mm2 - PowerPC link failure at arch/powerpc/kernel/head_64.o Kamalesh Babulal
2007-09-30  9:37   ` Kamalesh Babulal
2007-09-30  9:37     ` Kamalesh Babulal
2007-10-09 17:49 ` 2.6.23-rc8-mm2 Matt Mackall

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=1190926419.7344.27.camel@localhost \
    --to=haveblue@us.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=hch@infradead.org \
    --cc=laurent.riffard@free.fr \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.